Use VN_AS wherever possible and obvious. No functional change.
This commit is contained in:
parent
aa1a0b0f13
commit
dae9fa5053
|
|
@ -355,7 +355,7 @@ private:
|
|||
} else if (m_check == CT_LATCH) {
|
||||
// Suppress. Shouldn't matter that the interior of the latch races
|
||||
} else if (!(VN_IS(nodep->lhsp(), VarRef)
|
||||
&& VN_CAST(nodep->lhsp(), VarRef)->varp()->isLatched())) {
|
||||
&& VN_AS(nodep->lhsp(), VarRef)->varp()->isLatched())) {
|
||||
nodep->v3warn(COMBDLY, "Delayed assignments (<=) in non-clocked"
|
||||
" (non flop or latch) block\n"
|
||||
<< nodep->warnMore()
|
||||
|
|
@ -490,7 +490,7 @@ private:
|
|||
void visitAlways(AstNode* nodep, AstSenTree* oldsensesp, VAlwaysKwd kwd) {
|
||||
// Move always to appropriate ACTIVE based on its sense list
|
||||
if (oldsensesp && oldsensesp->sensesp() && VN_IS(oldsensesp->sensesp(), SenItem)
|
||||
&& VN_CAST(oldsensesp->sensesp(), SenItem)->isNever()) {
|
||||
&& VN_AS(oldsensesp->sensesp(), SenItem)->isNever()) {
|
||||
// Never executing. Kill it.
|
||||
UASSERT_OBJ(!oldsensesp->sensesp()->nextp(), nodep,
|
||||
"Never senitem should be alone, else the never should be eliminated.");
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ private:
|
|||
AstSenTree* sensesp = nodep->sensesp();
|
||||
UASSERT_OBJ(sensesp, nodep, "nullptr");
|
||||
if (sensesp->sensesp() && VN_IS(sensesp->sensesp(), SenItem)
|
||||
&& VN_CAST(sensesp->sensesp(), SenItem)->isNever()) {
|
||||
&& VN_AS(sensesp->sensesp(), SenItem)->isNever()) {
|
||||
// Never executing. Kill it.
|
||||
UASSERT_OBJ(!sensesp->sensesp()->nextp(), nodep,
|
||||
"Never senitem should be alone, else the never should be eliminated.");
|
||||
|
|
|
|||
|
|
@ -147,7 +147,7 @@ private:
|
|||
selfDestruct = true;
|
||||
} else {
|
||||
// V3Coverage assigned us a bucket to increment.
|
||||
AstCoverInc* covincp = VN_CAST(snodep->coverincp(), CoverInc);
|
||||
AstCoverInc* covincp = VN_AS(snodep->coverincp(), CoverInc);
|
||||
UASSERT_OBJ(covincp, snodep, "Missing AstCoverInc under assertion");
|
||||
covincp->unlinkFrBackWithNext(); // next() might have AstAssign for trace
|
||||
if (message != "") covincp->declp()->comment(message);
|
||||
|
|
@ -258,7 +258,7 @@ private:
|
|||
if (!nodep->user1SetOnce()) {
|
||||
bool has_default = false;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (itemp->isDefault()) has_default = true;
|
||||
}
|
||||
if (nodep->fullPragma() || nodep->priorityPragma()) {
|
||||
|
|
@ -279,7 +279,7 @@ private:
|
|||
} else {
|
||||
AstNode* propp = nullptr;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) {
|
||||
AstNode* onep;
|
||||
if (AstInsideRange* rcondp = VN_CAST(icondp, InsideRange)) {
|
||||
|
|
@ -329,7 +329,7 @@ private:
|
|||
if (nodep->ticksp()) {
|
||||
UASSERT_OBJ(VN_IS(nodep->ticksp(), Const), nodep,
|
||||
"Expected constant ticks, checked in V3Width");
|
||||
ticks = VN_CAST(nodep->ticksp(), Const)->toUInt();
|
||||
ticks = VN_AS(nodep->ticksp(), Const)->toUInt();
|
||||
}
|
||||
UASSERT_OBJ(ticks >= 1, nodep, "0 tick should have been checked in V3Width");
|
||||
AstNode* inp = nodep->exprp()->unlinkFrBack();
|
||||
|
|
|
|||
24
src/V3Ast.h
24
src/V3Ast.h
|
|
@ -2166,7 +2166,7 @@ public:
|
|||
AstNode* fromp() const { return op1p(); }
|
||||
AstNode* rhsp() const { return op2p(); }
|
||||
AstNode* thsp() const { return op3p(); }
|
||||
AstAttrOf* attrp() const { return VN_CAST(op4p(), AttrOf); }
|
||||
AstAttrOf* attrp() const { return VN_AS(op4p(), AttrOf); }
|
||||
void fromp(AstNode* nodep) { return setOp1p(nodep); }
|
||||
void rhsp(AstNode* nodep) { return setOp2p(nodep); }
|
||||
void thsp(AstNode* nodep) { return setOp3p(nodep); }
|
||||
|
|
@ -2304,7 +2304,7 @@ public:
|
|||
virtual int instrCount() const override { return INSTR_COUNT_BRANCH; }
|
||||
AstNode* exprp() const { return op1p(); } // op1 = case condition <expression>
|
||||
AstCaseItem* itemsp() const {
|
||||
return VN_CAST(op2p(), CaseItem);
|
||||
return VN_AS(op2p(), CaseItem);
|
||||
} // op2 = list of case expressions
|
||||
AstNode* notParallelp() const { return op3p(); } // op3 = assertion code for non-full case's
|
||||
void addItemsp(AstNode* nodep) { addOp2p(nodep); }
|
||||
|
|
@ -2518,10 +2518,10 @@ public:
|
|||
// For basicp() we reuse the size to indicate a "fake" basic type of same size
|
||||
virtual AstBasicDType* basicp() const override {
|
||||
return (isFourstate()
|
||||
? VN_CAST(findLogicRangeDType(VNumRange{width() - 1, 0}, width(), numeric()),
|
||||
BasicDType)
|
||||
: VN_CAST(findBitRangeDType(VNumRange{width() - 1, 0}, width(), numeric()),
|
||||
BasicDType));
|
||||
? VN_AS(findLogicRangeDType(VNumRange{width() - 1, 0}, width(), numeric()),
|
||||
BasicDType)
|
||||
: VN_AS(findBitRangeDType(VNumRange{width() - 1, 0}, width(), numeric()),
|
||||
BasicDType));
|
||||
}
|
||||
virtual AstNodeDType* skipRefp() const override { return (AstNodeDType*)this; }
|
||||
virtual AstNodeDType* skipRefToConstp() const override { return (AstNodeDType*)this; }
|
||||
|
|
@ -2537,7 +2537,7 @@ public:
|
|||
virtual string name() const override { return m_name; }
|
||||
virtual void name(const string& flag) override { m_name = flag; }
|
||||
AstMemberDType* membersp() const {
|
||||
return VN_CAST(op1p(), MemberDType);
|
||||
return VN_AS(op1p(), MemberDType);
|
||||
} // op1 = AstMember list
|
||||
void addMembersp(AstNode* nodep) { addNOp1p(nodep); }
|
||||
bool packed() const { return m_packed; }
|
||||
|
|
@ -2591,7 +2591,7 @@ public:
|
|||
&& subDTypep()->skipRefp()->similarDType(asamep->subDTypep()->skipRefp()));
|
||||
}
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -2599,7 +2599,7 @@ public:
|
|||
void refDTypep(AstNodeDType* nodep) { m_refDTypep = nodep; }
|
||||
virtual AstNodeDType* virtRefDTypep() const override { return m_refDTypep; }
|
||||
virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); }
|
||||
AstRange* rangep() const { return VN_CAST(op2p(), Range); } // op2 = Array(s) of variable
|
||||
AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Array(s) of variable
|
||||
void rangep(AstRange* nodep);
|
||||
// METHODS
|
||||
virtual AstBasicDType* basicp() const override {
|
||||
|
|
@ -2762,7 +2762,7 @@ public:
|
|||
AstNode* stmtsp() const { return op3p(); } // op3 = List of statements
|
||||
void addStmtsp(AstNode* nodep) { addNOp3p(nodep); }
|
||||
// op4 = scope name
|
||||
AstScopeName* scopeNamep() const { return VN_CAST(op4p(), ScopeName); }
|
||||
AstScopeName* scopeNamep() const { return VN_AS(op4p(), ScopeName); }
|
||||
// MORE ACCESSORS
|
||||
void dpiOpenParentInc() { ++m_dpiOpenParent; }
|
||||
void dpiOpenParentClear() { m_dpiOpenParent = 0; }
|
||||
|
|
@ -2860,7 +2860,7 @@ public:
|
|||
AstNode* pinsp() const { return op3p(); }
|
||||
void addPinsp(AstNode* nodep) { addOp3p(nodep); }
|
||||
// op4 = scope tracking
|
||||
AstScopeName* scopeNamep() const { return VN_CAST(op4p(), ScopeName); }
|
||||
AstScopeName* scopeNamep() const { return VN_AS(op4p(), ScopeName); }
|
||||
void scopeNamep(AstNode* nodep) { setNOp4p(nodep); }
|
||||
};
|
||||
|
||||
|
|
@ -2906,7 +2906,7 @@ public:
|
|||
virtual string name() const override { return m_name; }
|
||||
virtual bool timescaleMatters() const = 0;
|
||||
AstNode* stmtsp() const { return op2p(); } // op2 = List of statements
|
||||
AstActive* activesp() const { return VN_CAST(op3p(), Active); } // op3 = List of i/sblocks
|
||||
AstActive* activesp() const { return VN_AS(op3p(), Active); } // op3 = List of i/sblocks
|
||||
// METHODS
|
||||
void addInlinesp(AstNode* nodep) { addOp1p(nodep); }
|
||||
void addStmtp(AstNode* nodep) { addNOp2p(nodep); }
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ inline int AstNode::widthInstrs() const {
|
|||
return (!dtypep() ? 1 : (dtypep()->isWide() ? dtypep()->widthWords() : 1));
|
||||
}
|
||||
inline bool AstNode::isDouble() const {
|
||||
return dtypep() && VN_IS(dtypep(), BasicDType) && VN_CAST(dtypep(), BasicDType)->isDouble();
|
||||
return dtypep() && VN_IS(dtypep(), BasicDType) && VN_AS(dtypep(), BasicDType)->isDouble();
|
||||
}
|
||||
inline bool AstNode::isString() const {
|
||||
return dtypep() && dtypep()->basicp() && dtypep()->basicp()->isString();
|
||||
|
|
@ -42,19 +42,19 @@ inline bool AstNode::isString() const {
|
|||
inline bool AstNode::isSigned() const { return dtypep() && dtypep()->isSigned(); }
|
||||
|
||||
inline bool AstNode::isZero() const {
|
||||
return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->num().isEqZero());
|
||||
return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isEqZero());
|
||||
}
|
||||
inline bool AstNode::isNeqZero() const {
|
||||
return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->num().isNeqZero());
|
||||
return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isNeqZero());
|
||||
}
|
||||
inline bool AstNode::isOne() const {
|
||||
return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->num().isEqOne());
|
||||
return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->num().isEqOne());
|
||||
}
|
||||
inline bool AstNode::isAllOnes() const {
|
||||
return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->isEqAllOnes());
|
||||
return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->isEqAllOnes());
|
||||
}
|
||||
inline bool AstNode::isAllOnesV() const {
|
||||
return (VN_IS(this, Const) && VN_CAST_CONST(this, Const)->isEqAllOnesV());
|
||||
return (VN_IS(this, Const) && VN_AS_CONST(this, Const)->isEqAllOnesV());
|
||||
}
|
||||
inline bool AstNode::sameTree(const AstNode* node2p) const {
|
||||
return sameTreeIter(this, node2p, true, false);
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ const char* AstIfaceRefDType::broken() const {
|
|||
}
|
||||
|
||||
AstIface* AstIfaceRefDType::ifaceViaCellp() const {
|
||||
return ((m_cellp && m_cellp->modp()) ? VN_CAST(m_cellp->modp(), Iface) : m_ifacep);
|
||||
return ((m_cellp && m_cellp->modp()) ? VN_AS(m_cellp->modp(), Iface) : m_ifacep);
|
||||
}
|
||||
|
||||
const char* AstNodeVarRef::broken() const {
|
||||
|
|
@ -73,13 +73,13 @@ const char* AstAddrOfCFunc::broken() const {
|
|||
}
|
||||
|
||||
int AstNodeSel::bitConst() const {
|
||||
AstConst* constp = VN_CAST(bitp(), Const);
|
||||
AstConst* constp = VN_AS(bitp(), Const);
|
||||
return (constp ? constp->toSInt() : 0);
|
||||
}
|
||||
|
||||
void AstNodeUOrStructDType::repairMemberCache() {
|
||||
clearCache();
|
||||
for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_CAST(itemp->nextp(), MemberDType)) {
|
||||
for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_AS(itemp->nextp(), MemberDType)) {
|
||||
if (m_members.find(itemp->name()) != m_members.end()) {
|
||||
itemp->v3error("Duplicate declaration of member name: " << itemp->prettyNameQ());
|
||||
} else {
|
||||
|
|
@ -90,7 +90,7 @@ void AstNodeUOrStructDType::repairMemberCache() {
|
|||
|
||||
const char* AstNodeUOrStructDType::broken() const {
|
||||
std::unordered_set<AstMemberDType*> exists;
|
||||
for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_CAST(itemp->nextp(), MemberDType)) {
|
||||
for (AstMemberDType* itemp = membersp(); itemp; itemp = VN_AS(itemp->nextp(), MemberDType)) {
|
||||
exists.insert(itemp);
|
||||
}
|
||||
for (MemberNameMap::const_iterator it = m_members.begin(); it != m_members.end(); ++it) {
|
||||
|
|
@ -614,8 +614,8 @@ AstVar* AstVar::scVarRecurse(AstNode* nodep) {
|
|||
return nullptr;
|
||||
}
|
||||
} else if (VN_IS(nodep, VarRef)) {
|
||||
if (VN_CAST(nodep, VarRef)->varp()->isSc()) {
|
||||
return VN_CAST(nodep, VarRef)->varp();
|
||||
if (VN_AS(nodep, VarRef)->varp()->isSc()) {
|
||||
return VN_AS(nodep, VarRef)->varp();
|
||||
} else {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
@ -795,25 +795,25 @@ AstNode* AstArraySel::baseFromp(AstNode* nodep, bool overMembers) {
|
|||
// Else AstArraySel etc; search for the base
|
||||
while (nodep) {
|
||||
if (VN_IS(nodep, ArraySel)) {
|
||||
nodep = VN_CAST(nodep, ArraySel)->fromp();
|
||||
nodep = VN_AS(nodep, ArraySel)->fromp();
|
||||
continue;
|
||||
} else if (VN_IS(nodep, Sel)) {
|
||||
nodep = VN_CAST(nodep, Sel)->fromp();
|
||||
nodep = VN_AS(nodep, Sel)->fromp();
|
||||
continue;
|
||||
} else if (overMembers && VN_IS(nodep, MemberSel)) {
|
||||
nodep = VN_CAST(nodep, MemberSel)->fromp();
|
||||
nodep = VN_AS(nodep, MemberSel)->fromp();
|
||||
continue;
|
||||
}
|
||||
// AstNodeSelPre stashes the associated variable under an ATTROF
|
||||
// of AstAttrType::VAR_BASE/MEMBER_BASE so it isn't constified
|
||||
else if (VN_IS(nodep, AttrOf)) {
|
||||
nodep = VN_CAST(nodep, AttrOf)->fromp();
|
||||
nodep = VN_AS(nodep, AttrOf)->fromp();
|
||||
continue;
|
||||
} else if (VN_IS(nodep, NodePreSel)) {
|
||||
if (VN_CAST(nodep, NodePreSel)->attrp()) {
|
||||
nodep = VN_CAST(nodep, NodePreSel)->attrp();
|
||||
if (VN_AS(nodep, NodePreSel)->attrp()) {
|
||||
nodep = VN_AS(nodep, NodePreSel)->attrp();
|
||||
} else {
|
||||
nodep = VN_CAST(nodep, NodePreSel)->fromp();
|
||||
nodep = VN_AS(nodep, NodePreSel)->fromp();
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
|
|
@ -854,7 +854,7 @@ string AstScope::nameDotless() const {
|
|||
|
||||
string AstScopeName::scopePrettyNameFormatter(AstText* scopeTextp) const {
|
||||
string out;
|
||||
for (AstText* textp = scopeTextp; textp; textp = VN_CAST(textp->nextp(), Text)) {
|
||||
for (AstText* textp = scopeTextp; textp; textp = VN_AS(textp->nextp(), Text)) {
|
||||
out += textp->text();
|
||||
}
|
||||
// TOP will be replaced by top->name()
|
||||
|
|
@ -865,7 +865,7 @@ string AstScopeName::scopePrettyNameFormatter(AstText* scopeTextp) const {
|
|||
}
|
||||
string AstScopeName::scopeNameFormatter(AstText* scopeTextp) const {
|
||||
string out;
|
||||
for (AstText* textp = scopeTextp; textp; textp = VN_CAST(textp->nextp(), Text)) {
|
||||
for (AstText* textp = scopeTextp; textp; textp = VN_AS(textp->nextp(), Text)) {
|
||||
out += textp->text();
|
||||
}
|
||||
if (out.substr(0, 10) == "__DOT__TOP") out.replace(0, 10, "");
|
||||
|
|
@ -879,28 +879,28 @@ string AstScopeName::scopeNameFormatter(AstText* scopeTextp) const {
|
|||
|
||||
bool AstSenTree::hasClocked() const {
|
||||
UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it");
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
if (senp->isClocked()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool AstSenTree::hasSettle() const {
|
||||
UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it");
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
if (senp->isSettle()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool AstSenTree::hasInitial() const {
|
||||
UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it");
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
if (senp->isInitial()) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
bool AstSenTree::hasCombo() const {
|
||||
UASSERT_OBJ(sensesp(), this, "SENTREE without any SENITEMs under it");
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = sensesp(); senp; senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
if (senp->isCombo()) return true;
|
||||
}
|
||||
return false;
|
||||
|
|
@ -1041,10 +1041,8 @@ static bool sameInit(const AstInitArray* ap, const AstInitArray* bp) {
|
|||
// - the default/inititem children might be in different order yet still yield the same table
|
||||
// See note in AstInitArray::same about the same. This function instead compares by initializer
|
||||
// value, rather than by tree structure.
|
||||
const AstUnpackArrayDType* const aDTypep = VN_CAST(ap->dtypep(), UnpackArrayDType);
|
||||
const AstUnpackArrayDType* const bDTypep = VN_CAST(bp->dtypep(), UnpackArrayDType);
|
||||
UASSERT_STATIC(aDTypep, "Bad type in array initializer");
|
||||
UASSERT_STATIC(bDTypep, "Bad type in array initializer");
|
||||
const AstUnpackArrayDType* const aDTypep = VN_AS(ap->dtypep(), UnpackArrayDType);
|
||||
const AstUnpackArrayDType* const bDTypep = VN_AS(bp->dtypep(), UnpackArrayDType);
|
||||
if (!aDTypep->subDTypep()->sameTree(bDTypep->subDTypep())) { // Element types differ
|
||||
return false;
|
||||
}
|
||||
|
|
@ -1070,7 +1068,7 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) {
|
|||
UASSERT_OBJ(!defaultp || VN_IS(defaultp, Const), initp,
|
||||
"Const pool table default must be Const");
|
||||
for (AstNode* nodep = initp->initsp(); nodep; nodep = nodep->nextp()) {
|
||||
AstNode* const valuep = VN_CAST(nodep, InitItem)->valuep();
|
||||
AstNode* const valuep = VN_AS(nodep, InitItem)->valuep();
|
||||
UASSERT_OBJ(VN_IS(valuep, Const), valuep, "Const pool table entry must be Const");
|
||||
}
|
||||
// Try to find an existing table with the same content
|
||||
|
|
@ -1078,7 +1076,7 @@ AstVarScope* AstConstPool::findTable(AstInitArray* initp) {
|
|||
const auto& er = m_tables.equal_range(hash.value());
|
||||
for (auto it = er.first; it != er.second; ++it) {
|
||||
AstVarScope* const varScopep = it->second;
|
||||
const AstInitArray* const init2p = VN_CAST(varScopep->varp()->valuep(), InitArray);
|
||||
const AstInitArray* const init2p = VN_AS(varScopep->varp()->valuep(), InitArray);
|
||||
if (sameInit(initp, init2p)) {
|
||||
return varScopep; // Found identical table
|
||||
}
|
||||
|
|
@ -1107,7 +1105,7 @@ AstVarScope* AstConstPool::findConst(AstConst* initp, bool mergeDType) {
|
|||
const auto& er = m_consts.equal_range(hash.value());
|
||||
for (auto it = er.first; it != er.second; ++it) {
|
||||
AstVarScope* const varScopep = it->second;
|
||||
const AstConst* const init2p = VN_CAST(varScopep->varp()->valuep(), Const);
|
||||
const AstConst* const init2p = VN_AS(varScopep->varp()->valuep(), Const);
|
||||
if (sameInit(initp, init2p)
|
||||
&& (mergeDType || varScopep->dtypep()->sameTree(initp->dtypep()))) {
|
||||
return varScopep; // Found identical constant
|
||||
|
|
@ -1284,9 +1282,8 @@ const char* AstClassPackage::broken() const {
|
|||
return nullptr;
|
||||
}
|
||||
void AstClass::insertCache(AstNode* nodep) {
|
||||
const bool doit
|
||||
= (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef)
|
||||
|| (VN_IS(nodep, NodeFTask) && !VN_CAST(nodep, NodeFTask)->isExternProto()));
|
||||
const bool doit = (VN_IS(nodep, Var) || VN_IS(nodep, EnumItemRef)
|
||||
|| (VN_IS(nodep, NodeFTask) && !VN_AS(nodep, NodeFTask)->isExternProto()));
|
||||
if (doit) {
|
||||
if (m_members.find(nodep->name()) != m_members.end()) {
|
||||
nodep->v3error("Duplicate declaration of member name: " << nodep->prettyNameQ());
|
||||
|
|
@ -1314,7 +1311,7 @@ void AstClass::dump(std::ostream& str) const {
|
|||
AstClass* AstClassExtends::classp() const {
|
||||
AstClassRefDType* refp = VN_CAST(dtypep(), ClassRefDType);
|
||||
if (VL_UNLIKELY(!refp)) { // LinkDot uses this for 'super.'
|
||||
refp = VN_CAST(childDTypep(), ClassRefDType);
|
||||
refp = VN_AS(childDTypep(), ClassRefDType);
|
||||
}
|
||||
UASSERT_OBJ(refp, this, "class extends non-ref");
|
||||
return refp->classp();
|
||||
|
|
|
|||
141
src/V3AstNodes.h
141
src/V3AstNodes.h
|
|
@ -282,7 +282,7 @@ public:
|
|||
virtual string emitC() override { V3ERROR_NA_RETURN(""); }
|
||||
virtual bool cleanOut() const override { return true; }
|
||||
AstNode* exprp() const { return op1p(); } // op1 = Pin expression
|
||||
AstRange* rangep() const { return VN_CAST(op2p(), Range); } // op2 = Range of pin
|
||||
AstRange* rangep() const { return VN_AS(op2p(), Range); } // op2 = Range of pin
|
||||
};
|
||||
|
||||
//######################################################################
|
||||
|
|
@ -334,7 +334,7 @@ public:
|
|||
insertCache(nodep);
|
||||
addStmtp(nodep);
|
||||
}
|
||||
AstClassExtends* extendsp() const { return VN_CAST(op4p(), ClassExtends); }
|
||||
AstClassExtends* extendsp() const { return VN_AS(op4p(), ClassExtends); }
|
||||
void extendsp(AstNode* nodep) { addNOp4p(nodep); }
|
||||
void clearCache() { m_members.clear(); }
|
||||
void repairCache();
|
||||
|
|
@ -362,7 +362,7 @@ public:
|
|||
ASTNODE_NODE_FUNCS(ClassExtends)
|
||||
virtual bool hasDType() const override { return true; }
|
||||
virtual string verilogKwd() const override { return "extends"; }
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
AstNode* classOrPkgsp() const { return op2p(); }
|
||||
void classOrPkgsp(AstNode* nodep) { setOp2p(nodep); }
|
||||
|
|
@ -390,7 +390,7 @@ public:
|
|||
ASTNODE_NODE_FUNCS(ParamTypeDType)
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Type assigning to
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return dtypep() ? dtypep() : childDTypep();
|
||||
|
|
@ -441,7 +441,7 @@ public:
|
|||
virtual void dump(std::ostream& str) const override;
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Type assigning to
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
|
||||
void addAttrsp(AstNode* nodep) { addNOp4p(nodep); }
|
||||
|
|
@ -503,7 +503,7 @@ public:
|
|||
}
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return dtypep() ? dtypep() : childDTypep();
|
||||
|
|
@ -567,7 +567,7 @@ public:
|
|||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
virtual AstNodeDType* getChild2DTypep() const override { return keyChildDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -581,7 +581,7 @@ public:
|
|||
AstNodeDType* keyDTypep() const { return m_keyDTypep ? m_keyDTypep : keyChildDTypep(); }
|
||||
void keyDTypep(AstNodeDType* nodep) { m_keyDTypep = nodep; }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* keyChildDTypep() const { return VN_CAST(op2p(), NodeDType); }
|
||||
AstNodeDType* keyChildDTypep() const { return VN_AS(op2p(), NodeDType); }
|
||||
void keyChildDTypep(AstNodeDType* nodep) { setOp2p(nodep); }
|
||||
// METHODS
|
||||
virtual AstBasicDType* basicp() const override { return nullptr; }
|
||||
|
|
@ -607,7 +607,7 @@ public:
|
|||
ASTNODE_NODE_FUNCS(BracketArrayDType)
|
||||
virtual bool similarDType(AstNodeDType* samep) const override { V3ERROR_NA_RETURN(false); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
virtual AstNodeDType* subDTypep() const override { return childDTypep(); }
|
||||
// op2 = Range of variable
|
||||
AstNode* elementsp() const { return op2p(); }
|
||||
|
|
@ -664,7 +664,7 @@ public:
|
|||
virtual void dumpSmall(std::ostream& str) const override;
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -780,7 +780,7 @@ public:
|
|||
virtual void dumpSmall(std::ostream& str) const override;
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -889,7 +889,7 @@ public:
|
|||
BROKEN_RTN(dtypep() != this);
|
||||
return nullptr;
|
||||
}
|
||||
AstRange* rangep() const { return VN_CAST(op1p(), Range); } // op1 = Range of variable
|
||||
AstRange* rangep() const { return VN_AS(op1p(), Range); } // op1 = Range of variable
|
||||
void rangep(AstRange* nodep) { setNOp1p(nodep); }
|
||||
void setSignedState(const VSigning& signst) {
|
||||
// Note NOSIGN does NOT change the state; this is required by the parser
|
||||
|
|
@ -983,7 +983,7 @@ public:
|
|||
}
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -1049,7 +1049,7 @@ public:
|
|||
void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; }
|
||||
AstClass* classp() const { return m_classp; }
|
||||
void classp(AstClass* nodep) { m_classp = nodep; }
|
||||
AstPin* paramsp() const { return VN_CAST(op4p(), Pin); }
|
||||
AstPin* paramsp() const { return VN_AS(op4p(), Pin); }
|
||||
virtual bool isCompound() const override { return true; }
|
||||
};
|
||||
|
||||
|
|
@ -1150,7 +1150,7 @@ public:
|
|||
virtual string prettyDTypeName() const override;
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -1272,7 +1272,7 @@ public:
|
|||
void classOrPackagep(AstNodeModule* nodep) { m_classOrPackagep = nodep; }
|
||||
AstNode* typeofp() const { return op2p(); }
|
||||
AstNode* classOrPackageOpp() const { return op3p(); }
|
||||
AstPin* paramsp() const { return VN_CAST(op4p(), Pin); }
|
||||
AstPin* paramsp() const { return VN_AS(op4p(), Pin); }
|
||||
virtual bool isCompound() const override {
|
||||
v3fatalSrc("call isCompound on subdata type, not reference");
|
||||
return false;
|
||||
|
|
@ -1329,7 +1329,7 @@ public:
|
|||
virtual bool maybePointedTo() const override { return true; }
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
return m_refDTypep ? m_refDTypep : childDTypep();
|
||||
|
|
@ -1436,8 +1436,8 @@ public:
|
|||
virtual bool maybePointedTo() const override { return true; }
|
||||
virtual bool hasDType() const override { return true; }
|
||||
virtual void name(const string& flag) override { m_name = flag; }
|
||||
AstRange* rangep() const { return VN_CAST(op1p(), Range); } // op1 = Range for name appending
|
||||
void rangep(AstNode* nodep) { addOp1p(nodep); }
|
||||
AstRange* rangep() const { return VN_AS(op1p(), Range); } // op1 = Range for name appending
|
||||
void rangep(AstRange* nodep) { addOp1p(nodep); }
|
||||
AstNode* valuep() const { return op2p(); } // op2 = Value
|
||||
void valuep(AstNode* nodep) { addOp2p(nodep); }
|
||||
};
|
||||
|
|
@ -1462,7 +1462,7 @@ public:
|
|||
}
|
||||
virtual int instrCount() const override { return 0; }
|
||||
virtual void cloneRelink() override {
|
||||
if (m_itemp->clonep()) m_itemp = VN_CAST(m_itemp->clonep(), EnumItem);
|
||||
if (m_itemp->clonep()) m_itemp = VN_AS(m_itemp->clonep(), EnumItem);
|
||||
}
|
||||
virtual bool same(const AstNode* samep) const override {
|
||||
const AstEnumItemRef* sp = static_cast<const AstEnumItemRef*>(samep);
|
||||
|
|
@ -1510,7 +1510,7 @@ public:
|
|||
}
|
||||
virtual bool similarDType(AstNodeDType* samep) const override { return this == samep; }
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); } // op1 = Data type
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); } // op1 = Data type
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
// op1 = Range of variable
|
||||
virtual AstNodeDType* subDTypep() const override {
|
||||
|
|
@ -1521,8 +1521,7 @@ public:
|
|||
virtual void virtRefDTypep(AstNodeDType* nodep) override { refDTypep(nodep); }
|
||||
virtual string name() const override { return m_name; }
|
||||
virtual void name(const string& flag) override { m_name = flag; }
|
||||
AstEnumItem* itemsp() const { return VN_CAST(op2p(), EnumItem); } // op2 = AstEnumItem's
|
||||
void addValuesp(AstNode* nodep) { addOp2p(nodep); }
|
||||
AstEnumItem* itemsp() const { return VN_AS(op2p(), EnumItem); } // op2 = AstEnumItem's
|
||||
// METHODS
|
||||
virtual AstBasicDType* basicp() const override { return subDTypep()->basicp(); }
|
||||
virtual AstNodeDType* skipRefp() const override { return subDTypep()->skipRefp(); }
|
||||
|
|
@ -1575,7 +1574,7 @@ private:
|
|||
void init(AstNode* fromp) {
|
||||
if (fromp && VN_IS(fromp->dtypep()->skipRefp(), NodeArrayDType)) {
|
||||
// Strip off array to find what array references
|
||||
dtypeFrom(VN_CAST(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep());
|
||||
dtypeFrom(VN_AS(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1620,7 +1619,7 @@ private:
|
|||
void init(AstNode* fromp) {
|
||||
if (fromp && VN_IS(fromp->dtypep()->skipRefp(), AssocArrayDType)) {
|
||||
// Strip off array to find what array references
|
||||
dtypeFrom(VN_CAST(fromp->dtypep()->skipRefp(), AssocArrayDType)->subDTypep());
|
||||
dtypeFrom(VN_AS(fromp->dtypep()->skipRefp(), AssocArrayDType)->subDTypep());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1752,7 +1751,7 @@ public:
|
|||
: ASTGEN_SUPER_Sel(fl, fromp, lsbp, widthp)
|
||||
, m_declElWidth{1} {
|
||||
if (VN_IS(widthp, Const)) {
|
||||
dtypeSetLogicSized(VN_CAST(widthp, Const)->toUInt(), VSigning::UNSIGNED);
|
||||
dtypeSetLogicSized(VN_AS(widthp, Const)->toUInt(), VSigning::UNSIGNED);
|
||||
}
|
||||
}
|
||||
AstSel(FileLine* fl, AstNode* fromp, int lsb, int bitwidth)
|
||||
|
|
@ -1787,8 +1786,8 @@ public:
|
|||
} // op1 = Extracting what (nullptr=TBD during parsing)
|
||||
AstNode* lsbp() const { return op2p(); } // op2 = Msb selection expression
|
||||
AstNode* widthp() const { return op3p(); } // op3 = Width
|
||||
int widthConst() const { return VN_CAST(widthp(), Const)->toSInt(); }
|
||||
int lsbConst() const { return VN_CAST(lsbp(), Const)->toSInt(); }
|
||||
int widthConst() const { return VN_AS(widthp(), Const)->toSInt(); }
|
||||
int lsbConst() const { return VN_AS(lsbp(), Const)->toSInt(); }
|
||||
int msbConst() const { return lsbConst() + widthConst() - 1; }
|
||||
VNumRange& declRange() { return m_declRange; }
|
||||
const VNumRange& declRange() const { return m_declRange; }
|
||||
|
|
@ -2100,7 +2099,7 @@ public:
|
|||
void combineType(AstVarType type);
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
// op1 = Range of variable
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
AstNodeDType* dtypeSkipRefp() const { return subDTypep()->skipRefp(); }
|
||||
// (Slow) recurse down to find basic data type (Note don't need virtual -
|
||||
// AstVar isn't a NodeDType)
|
||||
|
|
@ -2350,7 +2349,7 @@ public:
|
|||
ASTNODE_NODE_FUNCS(TopScope)
|
||||
AstNode* stmtsp() const { return op1p(); }
|
||||
void addStmtsp(AstNode* nodep) { addOp1p(nodep); }
|
||||
AstScope* scopep() const { return VN_CAST(op2p(), Scope); } // op1 = AstVarScope's
|
||||
AstScope* scopep() const { return VN_AS(op2p(), Scope); } // op1 = AstVarScope's
|
||||
};
|
||||
|
||||
class AstVarScope final : public AstNode {
|
||||
|
|
@ -2860,13 +2859,13 @@ public:
|
|||
string modName() const { return m_modName; } // * = Instance name
|
||||
void modName(const string& name) { m_modName = name; }
|
||||
FileLine* modNameFileline() const { return m_modNameFileline; }
|
||||
AstPin* pinsp() const { return VN_CAST(op1p(), Pin); } // op1 = List of cell ports
|
||||
AstPin* pinsp() const { return VN_AS(op1p(), Pin); } // op1 = List of cell ports
|
||||
// op2 = List of parameter #(##) values
|
||||
AstPin* paramsp() const { return VN_CAST(op2p(), Pin); }
|
||||
AstPin* paramsp() const { return VN_AS(op2p(), Pin); }
|
||||
// op3 = Range of arrayed instants (nullptr=not ranged)
|
||||
AstRange* rangep() const { return VN_CAST(op3p(), Range); }
|
||||
AstRange* rangep() const { return VN_AS(op3p(), Range); }
|
||||
// op4 = List of interface references
|
||||
AstIntfRef* intfRefp() const { return VN_CAST(op4p(), IntfRef); }
|
||||
AstIntfRef* intfRefp() const { return VN_AS(op4p(), IntfRef); }
|
||||
AstNodeModule* modp() const { return m_modp; } // [AfterLink] = Pointer to module instantiated
|
||||
void addPinsp(AstPin* nodep) { addOp1p(nodep); }
|
||||
void addParamsp(AstPin* nodep) { addOp2p(nodep); }
|
||||
|
|
@ -3070,10 +3069,10 @@ public:
|
|||
virtual string name() const override { return m_name; } // * = Var name
|
||||
AstNode* classOrPackageNodep() const { return m_classOrPackageNodep; }
|
||||
void classOrPackageNodep(AstNode* nodep) { m_classOrPackageNodep = nodep; }
|
||||
AstNodeModule* classOrPackagep() const { return VN_CAST(m_classOrPackageNodep, NodeModule); }
|
||||
AstPackage* packagep() const { return VN_CAST(classOrPackageNodep(), Package); }
|
||||
AstNodeModule* classOrPackagep() const { return VN_AS(m_classOrPackageNodep, NodeModule); }
|
||||
AstPackage* packagep() const { return VN_AS(classOrPackageNodep(), Package); }
|
||||
void classOrPackagep(AstNodeModule* nodep) { m_classOrPackageNodep = nodep; }
|
||||
AstPin* paramsp() const { return VN_CAST(op4p(), Pin); }
|
||||
AstPin* paramsp() const { return VN_AS(op4p(), Pin); }
|
||||
};
|
||||
|
||||
class AstDot final : public AstNode {
|
||||
|
|
@ -3244,8 +3243,8 @@ public:
|
|||
return nullptr;
|
||||
}
|
||||
//
|
||||
AstLambdaArgRef* indexArgRefp() const { return VN_CAST(op1p(), LambdaArgRef); }
|
||||
AstLambdaArgRef* valueArgRefp() const { return VN_CAST(op2p(), LambdaArgRef); }
|
||||
AstLambdaArgRef* indexArgRefp() const { return VN_AS(op1p(), LambdaArgRef); }
|
||||
AstLambdaArgRef* valueArgRefp() const { return VN_AS(op2p(), LambdaArgRef); }
|
||||
AstNode* exprp() const { return op3p(); }
|
||||
};
|
||||
|
||||
|
|
@ -3322,7 +3321,7 @@ public:
|
|||
virtual bool maybePointedTo() const override { return true; }
|
||||
bool isMulti() const { return m_multi; }
|
||||
// op1 = Sensitivity list
|
||||
AstSenItem* sensesp() const { return VN_CAST(op1p(), SenItem); }
|
||||
AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); }
|
||||
void addSensesp(AstSenItem* nodep) { addOp1p(nodep); }
|
||||
void multi(bool flag) { m_multi = true; }
|
||||
// METHODS
|
||||
|
|
@ -3358,7 +3357,7 @@ public:
|
|||
ASTNODE_NODE_FUNCS(Always)
|
||||
//
|
||||
virtual void dump(std::ostream& str) const override;
|
||||
AstSenTree* sensesp() const { return VN_CAST(op1p(), SenTree); } // op1 = Sensitivity list
|
||||
AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } // op1 = Sensitivity list
|
||||
void sensesp(AstSenTree* nodep) { setOp1p(nodep); }
|
||||
VAlwaysKwd keyword() const { return m_keyword; }
|
||||
};
|
||||
|
|
@ -3394,7 +3393,7 @@ public:
|
|||
ASTNODE_NODE_FUNCS(AlwaysPublic)
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
//
|
||||
AstSenTree* sensesp() const { return VN_CAST(op1p(), SenTree); } // op1 = Sensitivity list
|
||||
AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); } // op1 = Sensitivity list
|
||||
AstNode* bodysp() const { return op2p(); } // op2 = Statements to evaluate
|
||||
void addStmtp(AstNode* nodep) { addOp2p(nodep); }
|
||||
// Special accessors
|
||||
|
|
@ -3525,7 +3524,7 @@ public:
|
|||
addOp1p(new AstVarRef{fl, varScopep, VAccess::WRITE});
|
||||
}
|
||||
ASTNODE_NODE_FUNCS(DpiExportUpdated)
|
||||
AstVarScope* varScopep() const { return VN_CAST(op1p(), VarRef)->varScopep(); }
|
||||
AstVarScope* varScopep() const { return VN_AS(op1p(), VarRef)->varScopep(); }
|
||||
};
|
||||
|
||||
class AstExprStmt final : public AstNodeMath {
|
||||
|
|
@ -3707,7 +3706,7 @@ public:
|
|||
return false; // Though the AstCoverInc under this is an outputter
|
||||
}
|
||||
// but isPure() true
|
||||
AstCoverInc* incp() const { return VN_CAST(op1p(), CoverInc); }
|
||||
AstCoverInc* incp() const { return VN_AS(op1p(), CoverInc); }
|
||||
void incp(AstCoverInc* nodep) { setOp1p(nodep); }
|
||||
AstNode* origp() const { return op2p(); }
|
||||
AstNode* changep() const { return op3p(); }
|
||||
|
|
@ -3846,7 +3845,7 @@ public:
|
|||
AstNode* exprsp() const { return op1p(); } // op1 = Expressions to output
|
||||
string text() const { return m_text; } // * = Text to display
|
||||
void text(const string& text) { m_text = text; }
|
||||
AstScopeName* scopeNamep() const { return VN_CAST(op2p(), ScopeName); }
|
||||
AstScopeName* scopeNamep() const { return VN_AS(op2p(), ScopeName); }
|
||||
void scopeNamep(AstNode* nodep) { setNOp2p(nodep); }
|
||||
bool formatScopeTracking() const { // Track scopeNamep(); Ok if false positive
|
||||
return (name().find("%m") != string::npos || name().find("%M") != string::npos);
|
||||
|
|
@ -3907,7 +3906,7 @@ public:
|
|||
// * = Add a newline for $display
|
||||
bool addNewline() const { return displayType().addNewline(); }
|
||||
void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter
|
||||
AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); }
|
||||
AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); }
|
||||
AstNode* filep() const { return op3p(); }
|
||||
void filep(AstNodeVarRef* nodep) { setNOp3p(nodep); }
|
||||
};
|
||||
|
|
@ -3969,7 +3968,7 @@ public:
|
|||
AstDisplayType displayType() const { return m_displayType; }
|
||||
void displayType(AstDisplayType type) { m_displayType = type; }
|
||||
void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter
|
||||
AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); }
|
||||
AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); }
|
||||
};
|
||||
|
||||
class AstSFormat final : public AstNodeStmt {
|
||||
|
|
@ -4002,7 +4001,7 @@ public:
|
|||
virtual int instrCount() const override { return INSTR_COUNT_PLI; }
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
void fmtp(AstSFormatF* nodep) { addOp1p(nodep); } // op1 = To-String formatter
|
||||
AstSFormatF* fmtp() const { return VN_CAST(op1p(), SFormatF); }
|
||||
AstSFormatF* fmtp() const { return VN_AS(op1p(), SFormatF); }
|
||||
AstNode* lhsp() const { return op3p(); }
|
||||
void lhsp(AstNode* nodep) { setOp3p(nodep); }
|
||||
};
|
||||
|
|
@ -5193,7 +5192,7 @@ public:
|
|||
virtual bool isPure() const override { return false; }
|
||||
virtual bool isOutputter() const override { return false; }
|
||||
virtual int instrCount() const override { return 0; }
|
||||
AstSenTree* sensesp() const { return VN_CAST(op1p(), SenTree); }
|
||||
AstSenTree* sensesp() const { return VN_AS(op1p(), SenTree); }
|
||||
AstNode* stmtsp() const { return op2p(); }
|
||||
};
|
||||
|
||||
|
|
@ -5355,7 +5354,7 @@ public:
|
|||
AstSenTree* sensesp() const { return m_sensesp; }
|
||||
// op1 = Sensitivity tree, if a clocked block in early stages
|
||||
void sensesStorep(AstSenTree* nodep) { addOp1p(nodep); }
|
||||
AstSenTree* sensesStorep() const { return VN_CAST(op1p(), SenTree); }
|
||||
AstSenTree* sensesStorep() const { return VN_AS(op1p(), SenTree); }
|
||||
// op2 = Combo logic
|
||||
AstNode* stmtsp() const { return op2p(); }
|
||||
void addStmtsp(AstNode* nodep) { addOp2p(nodep); }
|
||||
|
|
@ -5405,9 +5404,9 @@ public:
|
|||
virtual string emitVerilog() override { return ""; }
|
||||
virtual string emitC() override { V3ERROR_NA_RETURN(""); }
|
||||
virtual bool cleanOut() const override { return true; }
|
||||
AstText* scopeAttrp() const { return VN_CAST(op1p(), Text); }
|
||||
AstText* scopeAttrp() const { return VN_AS(op1p(), Text); }
|
||||
void scopeAttrp(AstNode* nodep) { addOp1p(nodep); }
|
||||
AstText* scopeEntrp() const { return VN_CAST(op2p(), Text); }
|
||||
AstText* scopeEntrp() const { return VN_AS(op2p(), Text); }
|
||||
void scopeEntrp(AstNode* nodep) { addOp2p(nodep); }
|
||||
string scopeSymName() const { // Name for __Vscope variable including children
|
||||
return scopeNameFormatter(scopeAttrp());
|
||||
|
|
@ -5433,7 +5432,7 @@ public:
|
|||
}
|
||||
ASTNODE_NODE_FUNCS(UdpTable)
|
||||
// op1 = List of UdpTableLines
|
||||
AstUdpTableLine* bodysp() const { return VN_CAST(op1p(), UdpTableLine); }
|
||||
AstUdpTableLine* bodysp() const { return VN_AS(op1p(), UdpTableLine); }
|
||||
};
|
||||
|
||||
class AstUdpTableLine final : public AstNode {
|
||||
|
|
@ -6041,7 +6040,7 @@ public:
|
|||
AstNode* fromp() const { return lhsp(); }
|
||||
void lhsp(AstNode* nodep) { setOp1p(nodep); }
|
||||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op2p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op2p(), NodeDType); }
|
||||
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
|
||||
};
|
||||
|
||||
|
|
@ -8316,7 +8315,7 @@ public:
|
|||
virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); }
|
||||
virtual int instrCount() const override { return widthInstrs(); }
|
||||
AstNode* exprp() const { return op1p(); } // op1 = expression
|
||||
AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain
|
||||
AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain
|
||||
void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
};
|
||||
|
|
@ -8339,7 +8338,7 @@ public:
|
|||
virtual int instrCount() const override { return widthInstrs(); }
|
||||
AstNode* exprp() const { return op1p(); } // op1 = expression
|
||||
AstNode* ticksp() const { return op2p(); } // op2 = ticks or nullptr means 1
|
||||
AstSenTree* sentreep() const { return VN_CAST(op4p(), SenTree); } // op4 = clock domain
|
||||
AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain
|
||||
void sentreep(AstSenTree* sentreep) { addOp4p(sentreep); } // op4 = clock domain
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
};
|
||||
|
|
@ -8360,7 +8359,7 @@ public:
|
|||
virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); }
|
||||
virtual int instrCount() const override { return widthInstrs(); }
|
||||
AstNode* exprp() const { return op1p(); } // op1 = expression
|
||||
AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain
|
||||
AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain
|
||||
void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
};
|
||||
|
|
@ -8400,7 +8399,7 @@ public:
|
|||
virtual bool cleanOut() const override { V3ERROR_NA_RETURN(""); }
|
||||
virtual int instrCount() const override { return widthInstrs(); }
|
||||
AstNode* exprp() const { return op1p(); } // op1 = expression
|
||||
AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain
|
||||
AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain
|
||||
void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
};
|
||||
|
|
@ -8423,7 +8422,7 @@ public:
|
|||
virtual AstNodeDType* getChildDTypep() const override { return childDTypep(); }
|
||||
virtual AstNodeDType* subDTypep() const { return dtypep() ? dtypep() : childDTypep(); }
|
||||
// op1 = Type assigning to
|
||||
AstNodeDType* childDTypep() const { return VN_CAST(op1p(), NodeDType); }
|
||||
AstNodeDType* childDTypep() const { return VN_AS(op1p(), NodeDType); }
|
||||
void childDTypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||
AstNode* itemsp() const { return op2p(); } // op2 = AstPatReplicate, AstPatMember, etc
|
||||
};
|
||||
|
|
@ -8474,7 +8473,7 @@ public:
|
|||
AstNode* rhsp() const { return op2p(); }
|
||||
void lhsp(AstNode* nodep) { return setOp1p(nodep); }
|
||||
void rhsp(AstNode* nodep) { return setOp2p(nodep); }
|
||||
AstSenTree* sentreep() const { return VN_CAST(op4p(), SenTree); } // op4 = clock domain
|
||||
AstSenTree* sentreep() const { return VN_AS(op4p(), SenTree); } // op4 = clock domain
|
||||
void sentreep(AstSenTree* sentreep) { addOp4p(sentreep); } // op4 = clock domain
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
};
|
||||
|
|
@ -8494,7 +8493,7 @@ public:
|
|||
}
|
||||
ASTNODE_NODE_FUNCS(Clocking)
|
||||
// op1 = Sensitivity list
|
||||
AstSenItem* sensesp() const { return VN_CAST(op1p(), SenItem); }
|
||||
AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); }
|
||||
AstNode* bodysp() const { return op2p(); } // op2 = Body
|
||||
};
|
||||
|
||||
|
|
@ -8516,7 +8515,7 @@ public:
|
|||
virtual bool hasDType() const override {
|
||||
return true;
|
||||
} // Used under Cover, which expects a bool child
|
||||
AstSenItem* sensesp() const { return VN_CAST(op1p(), SenItem); } // op1 = Sensitivity list
|
||||
AstSenItem* sensesp() const { return VN_AS(op1p(), SenItem); } // op1 = Sensitivity list
|
||||
AstNode* disablep() const { return op2p(); } // op2 = disable
|
||||
AstNode* propp() const { return op3p(); } // op3 = property
|
||||
};
|
||||
|
|
@ -8543,7 +8542,7 @@ public:
|
|||
virtual void name(const string& name) override { m_name = name; }
|
||||
virtual void dump(std::ostream& str = std::cout) const override;
|
||||
AstNode* propp() const { return op1p(); } // op1 = property
|
||||
AstSenTree* sentreep() const { return VN_CAST(op2p(), SenTree); } // op2 = clock domain
|
||||
AstSenTree* sentreep() const { return VN_AS(op2p(), SenTree); } // op2 = clock domain
|
||||
void sentreep(AstSenTree* sentreep) { addOp2p(sentreep); } // op2 = clock domain
|
||||
AstNode* passsp() const { return op4p(); } // op4 = statements (assert/cover passes)
|
||||
bool immediate() const { return m_immediate; }
|
||||
|
|
@ -8719,7 +8718,7 @@ public:
|
|||
virtual string name() const override { return m_name; }
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
void tblockp(AstTextBlock* tblockp) { setOp1p(tblockp); }
|
||||
AstTextBlock* tblockp() { return VN_CAST(op1p(), TextBlock); }
|
||||
AstTextBlock* tblockp() { return VN_AS(op1p(), TextBlock); }
|
||||
};
|
||||
|
||||
//======================================================================
|
||||
|
|
@ -9019,7 +9018,7 @@ public:
|
|||
class AstCReset final : public AstNodeStmt {
|
||||
// Reset variable at startup
|
||||
public:
|
||||
AstCReset(FileLine* fl, AstNode* exprsp)
|
||||
AstCReset(FileLine* fl, AstVarRef* exprsp)
|
||||
: ASTGEN_SUPER_CReset(fl) {
|
||||
addNOp1p(exprsp);
|
||||
}
|
||||
|
|
@ -9027,7 +9026,7 @@ public:
|
|||
virtual bool isGateOptimizable() const override { return false; }
|
||||
virtual bool isPredictOptimizable() const override { return false; }
|
||||
virtual bool same(const AstNode* samep) const override { return true; }
|
||||
AstVarRef* varrefp() const { return VN_CAST(op1p(), VarRef); } // op1 = varref to reset
|
||||
AstVarRef* varrefp() const { return VN_AS(op1p(), VarRef); } // op1 = varref to reset
|
||||
};
|
||||
|
||||
class AstCStmt final : public AstNodeStmt {
|
||||
|
|
@ -9138,7 +9137,7 @@ class AstTypeTable final : public AstNode {
|
|||
public:
|
||||
explicit AstTypeTable(FileLine* fl);
|
||||
ASTNODE_NODE_FUNCS(TypeTable)
|
||||
AstNodeDType* typesp() const { return VN_CAST(op1p(), NodeDType); } // op1 = List of dtypes
|
||||
AstNodeDType* typesp() const { return VN_AS(op1p(), NodeDType); } // op1 = List of dtypes
|
||||
void addTypesp(AstNodeDType* nodep) { addOp1p(nodep); }
|
||||
AstBasicDType* findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd);
|
||||
AstBasicDType* findLogicBitDType(FileLine* fl, AstBasicDTypeKwd kwd, int width, int widthMin,
|
||||
|
|
@ -9212,13 +9211,13 @@ public:
|
|||
virtual string name() const override { return "$root"; }
|
||||
virtual void dump(std::ostream& str) const override;
|
||||
AstNodeModule* modulesp() const { // op1 = List of modules
|
||||
return VN_CAST(op1p(), NodeModule);
|
||||
return VN_AS(op1p(), NodeModule);
|
||||
}
|
||||
AstNodeModule* topModulep() const { // * = Top module in hierarchy (first one added, for now)
|
||||
return VN_CAST(op1p(), NodeModule);
|
||||
AstNodeModule* topModulep() const { // Top module in hierarchy
|
||||
return modulesp(); // First one in the list, for now
|
||||
}
|
||||
void addModulep(AstNodeModule* modulep) { addOp1p(modulep); }
|
||||
AstNodeFile* filesp() const { return VN_CAST(op2p(), NodeFile); } // op2 = List of files
|
||||
AstNodeFile* filesp() const { return VN_AS(op2p(), NodeFile); } // op2 = List of files
|
||||
void addFilesp(AstNodeFile* filep) { addOp2p(filep); }
|
||||
AstNode* miscsp() const { return op3p(); } // op3 = List of dtypes etc
|
||||
void addMiscsp(AstNode* nodep) { addOp3p(nodep); }
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ private:
|
|||
processAndIterate(nodep);
|
||||
UASSERT_OBJ(!(v3Global.assertDTypesResolved() && nodep->brokeLhsMustBeLvalue()
|
||||
&& VN_IS(nodep->lhsp(), NodeVarRef)
|
||||
&& !VN_CAST(nodep->lhsp(), NodeVarRef)->access().isWriteOrRW()),
|
||||
&& !VN_AS(nodep->lhsp(), NodeVarRef)->access().isWriteOrRW()),
|
||||
nodep, "Assignment LHS is not an lvalue");
|
||||
}
|
||||
virtual void visit(AstScope* nodep) override {
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ void V3CCtors::cctorsAll() {
|
|||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
evalAsserts();
|
||||
for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
// Process each module in turn
|
||||
{
|
||||
V3CCtorsBuilder var_reset{modp, "_ctor_var_reset",
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ void V3CUse::cUseAll() {
|
|||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
// Call visitor separately for each module, so visitor state is cleared
|
||||
for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
// Insert under this module; someday we should e.g. make Ast
|
||||
// for each output file and put under that
|
||||
CUseVisitor{modp};
|
||||
|
|
|
|||
|
|
@ -59,13 +59,13 @@ private:
|
|||
VL_DEBUG_FUNC; // Declare debug()
|
||||
|
||||
virtual void visit(AstNodeCase* nodep) override {
|
||||
if (VN_IS(nodep, Case) && VN_CAST(nodep, Case)->casex()) {
|
||||
if (VN_IS(nodep, Case) && VN_AS(nodep, Case)->casex()) {
|
||||
nodep->v3warn(CASEX, "Suggest casez (with ?'s) in place of casex (with X's)");
|
||||
}
|
||||
// Detect multiple defaults
|
||||
bool hitDefault = false;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (itemp->isDefault()) {
|
||||
if (hitDefault) {
|
||||
itemp->v3error("Multiple default statements in case statement.");
|
||||
|
|
@ -79,7 +79,7 @@ private:
|
|||
m_caseExprp = nodep;
|
||||
iterate(nodep->exprp());
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
iterateAndNextNull(itemp->condsp());
|
||||
}
|
||||
m_caseExprp = nullptr;
|
||||
|
|
@ -91,11 +91,11 @@ private:
|
|||
if (VN_IS(m_caseExprp, GenCase)) {
|
||||
nodep->v3error("Use of x/? constant in generate case statement, "
|
||||
"(no such thing as 'generate casez')");
|
||||
} else if (VN_IS(m_caseExprp, Case) && VN_CAST(m_caseExprp, Case)->casex()) {
|
||||
} else if (VN_IS(m_caseExprp, Case) && VN_AS(m_caseExprp, Case)->casex()) {
|
||||
// Don't sweat it, we already complained about casex in general
|
||||
} else if (VN_IS(m_caseExprp, Case)
|
||||
&& (VN_CAST(m_caseExprp, Case)->casez()
|
||||
|| VN_CAST(m_caseExprp, Case)->caseInside())) {
|
||||
&& (VN_AS(m_caseExprp, Case)->casez()
|
||||
|| VN_AS(m_caseExprp, Case)->caseInside())) {
|
||||
if (nodep->num().isAnyX()) {
|
||||
nodep->v3warn(CASEWITHX, "Use of x constant in casez statement, "
|
||||
"(perhaps intended ?/z in constant)");
|
||||
|
|
@ -145,7 +145,7 @@ private:
|
|||
m_caseItems = 0;
|
||||
m_caseNoOverlapsAllCovered = true;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) {
|
||||
if (icondp->width() > width) width = icondp->width();
|
||||
if (icondp->isDouble()) opaque = true;
|
||||
|
|
@ -167,10 +167,10 @@ private:
|
|||
bool reportedOverlap = false;
|
||||
bool reportedSubcase = false;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
for (AstNode* icondp = itemp->condsp(); icondp; icondp = icondp->nextp()) {
|
||||
// if (debug() >= 9) icondp->dumpTree(cout, " caseitem: ");
|
||||
AstConst* iconstp = VN_CAST(icondp, Const);
|
||||
AstConst* iconstp = VN_AS(icondp, Const);
|
||||
UASSERT_OBJ(iconstp, nodep, "above 'can't parse' should have caught this");
|
||||
if (neverItem(nodep, iconstp)) {
|
||||
// X in casez can't ever be executed
|
||||
|
|
@ -244,7 +244,7 @@ private:
|
|||
// Convert valueItem from AstCaseItem* to the expression
|
||||
// Not done earlier, as we may now have a nullptr because it's just a ";" NOP branch
|
||||
for (uint32_t i = 0; i < numCases; ++i) {
|
||||
m_valueItem[i] = VN_CAST(m_valueItem[i], CaseItem)->bodysp();
|
||||
m_valueItem[i] = VN_AS(m_valueItem[i], CaseItem)->bodysp();
|
||||
}
|
||||
return true; // All is fine
|
||||
}
|
||||
|
|
@ -341,7 +341,7 @@ private:
|
|||
if (debug() >= 9) nodep->dumpTree(cout, " _comp_IN: ");
|
||||
bool hadDefault = false;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (!itemp->condsp()) {
|
||||
// Default clause. Just make true, we'll optimize it away later
|
||||
itemp->condsp(new AstConst(itemp->fileline(), AstConst::BitTrue()));
|
||||
|
|
@ -416,7 +416,7 @@ private:
|
|||
AstIf* groupnextp = nullptr;
|
||||
AstIf* itemnextp = nullptr;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
AstNode* istmtsp = itemp->bodysp(); // Maybe null -- no action.
|
||||
if (istmtsp) istmtsp->unlinkFrBackWithNext();
|
||||
// Expressioned clause
|
||||
|
|
|
|||
|
|
@ -599,7 +599,7 @@ private:
|
|||
}
|
||||
}
|
||||
// If multiple domains need to do complicated optimizations
|
||||
if (senedited) senoutp = VN_CAST(V3Const::constifyExpensiveEdit(senoutp), SenTree);
|
||||
if (senedited) senoutp = VN_AS(V3Const::constifyExpensiveEdit(senoutp), SenTree);
|
||||
if (traceDests) {
|
||||
vertexp->dstDomainSet(true); // Note it's set - domainp may be null, so can't use that
|
||||
vertexp->dstDomainp(senoutp);
|
||||
|
|
|
|||
|
|
@ -94,7 +94,7 @@ public:
|
|||
if (!m_tlChgFuncp->stmtsp()) {
|
||||
m_tlChgFuncp->addStmtsp(new AstCReturn{m_scopetopp->fileline(), callp});
|
||||
} else {
|
||||
AstCReturn* const returnp = VN_CAST(m_tlChgFuncp->stmtsp(), CReturn);
|
||||
AstCReturn* const returnp = VN_AS(m_tlChgFuncp->stmtsp(), CReturn);
|
||||
UASSERT_OBJ(returnp, m_scopetopp, "Lost CReturn in top change function");
|
||||
// This is currently using AstLogOr which will shortcut the
|
||||
// evaluation if any function returns true. This is likely what
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ public:
|
|||
if (VN_IS(moved.first, NodeFTask)) {
|
||||
moved.second->addActivep(moved.first->unlinkFrBack());
|
||||
} else if (VN_IS(moved.first, Var)) {
|
||||
AstVarScope* scopep = VN_CAST(moved.first->user1p(), VarScope);
|
||||
AstVarScope* scopep = VN_AS(moved.first->user1p(), VarScope);
|
||||
moved.second->addVarp(scopep->unlinkFrBack());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ private:
|
|||
AstNode* createSenseEquation(AstSenItem* nodesp) {
|
||||
// Nodep may be a list of elements; we need to walk it
|
||||
AstNode* senEqnp = nullptr;
|
||||
for (AstSenItem* senp = nodesp; senp; senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = nodesp; senp; senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
AstNode* const senOnep = createSenItemEquation(senp);
|
||||
if (senEqnp) {
|
||||
// Add new OR to the sensitivity list equation
|
||||
|
|
@ -412,8 +412,8 @@ private:
|
|||
}
|
||||
}
|
||||
virtual void visit(AstExecGraph* nodep) override {
|
||||
for (m_mtaskBodyp = VN_CAST(nodep->op1p(), MTaskBody); m_mtaskBodyp;
|
||||
m_mtaskBodyp = VN_CAST(m_mtaskBodyp->nextp(), MTaskBody)) {
|
||||
for (m_mtaskBodyp = VN_AS(nodep->op1p(), MTaskBody); m_mtaskBodyp;
|
||||
m_mtaskBodyp = VN_AS(m_mtaskBodyp->nextp(), MTaskBody)) {
|
||||
clearLastSen();
|
||||
iterate(m_mtaskBodyp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ private:
|
|||
// METHODS
|
||||
void walkEmptyFuncs() {
|
||||
for (const auto& itr : m_dupFinder) {
|
||||
AstCFunc* const oldfuncp = VN_CAST(itr.second, CFunc);
|
||||
AstCFunc* const oldfuncp = VN_AS(itr.second, CFunc);
|
||||
UASSERT_OBJ(oldfuncp, itr.second, "Not a CFunc in hash");
|
||||
if (!oldfuncp->emptyBody()) continue;
|
||||
UASSERT_OBJ(!oldfuncp->dontCombine(), oldfuncp,
|
||||
|
|
@ -152,14 +152,14 @@ private:
|
|||
// Do non-slow first as then favors naming functions based on fast name
|
||||
for (const bool slow : {false, true}) {
|
||||
for (auto newIt = m_dupFinder.begin(); newIt != m_dupFinder.end(); ++newIt) {
|
||||
AstCFunc* const newfuncp = VN_CAST(newIt->second, CFunc);
|
||||
AstCFunc* const newfuncp = VN_AS(newIt->second, CFunc);
|
||||
UASSERT_OBJ(newfuncp, newIt->second, "Not a CFunc in hash");
|
||||
if (newfuncp->user3()) continue; // Already replaced
|
||||
if (newfuncp->slow() != slow) continue;
|
||||
auto oldIt = newIt;
|
||||
++oldIt; // Skip over current position
|
||||
for (; oldIt != m_dupFinder.end(); ++oldIt) {
|
||||
AstCFunc* const oldfuncp = VN_CAST(oldIt->second, CFunc);
|
||||
AstCFunc* const oldfuncp = VN_AS(oldIt->second, CFunc);
|
||||
UASSERT_OBJ(oldfuncp, oldIt->second, "Not a CFunc in hash");
|
||||
UASSERT_OBJ(newfuncp != oldfuncp, newfuncp,
|
||||
"Same function hashed multiple times");
|
||||
|
|
|
|||
273
src/V3Const.cpp
273
src/V3Const.cpp
|
|
@ -902,7 +902,7 @@ private:
|
|||
// Remove And with constant one inserted by V3Clean
|
||||
// 1 & (a == b) -> (IData)(a == b)
|
||||
// When bool is casted to int, the value is either 0 or 1
|
||||
AstConst* constp = VN_CAST(andp->lhsp(), Const);
|
||||
AstConst* constp = VN_AS(andp->lhsp(), Const);
|
||||
UASSERT_OBJ(constp && constp->isOne(), andp->lhsp(), "TRREEOPC must meet this condition");
|
||||
AstNode* rhsp = andp->rhsp();
|
||||
AstCCast* ccastp = nullptr;
|
||||
|
|
@ -945,20 +945,20 @@ private:
|
|||
AstNode* ap;
|
||||
AstNodeBiop* andp;
|
||||
if (VN_IS(nodep->lhsp(), And)) {
|
||||
andp = VN_CAST(nodep->lhsp(), And);
|
||||
andp = VN_AS(nodep->lhsp(), And);
|
||||
ap = nodep->rhsp();
|
||||
} else if (VN_IS(nodep->rhsp(), And)) {
|
||||
andp = VN_CAST(nodep->rhsp(), And);
|
||||
andp = VN_AS(nodep->rhsp(), And);
|
||||
ap = nodep->lhsp();
|
||||
} else
|
||||
return false;
|
||||
AstNodeUniop* notp;
|
||||
AstNode* cp;
|
||||
if (VN_IS(andp->lhsp(), Not)) {
|
||||
notp = VN_CAST(andp->lhsp(), Not);
|
||||
notp = VN_AS(andp->lhsp(), Not);
|
||||
cp = andp->rhsp();
|
||||
} else if (VN_IS(andp->rhsp(), Not)) {
|
||||
notp = VN_CAST(andp->rhsp(), Not);
|
||||
notp = VN_AS(andp->rhsp(), Not);
|
||||
cp = andp->lhsp();
|
||||
} else
|
||||
return false;
|
||||
|
|
@ -1007,10 +1007,10 @@ private:
|
|||
// 0xff & (a << 8 | b >> 24) --> 0xff & (b >> 24)
|
||||
|
||||
// Compute how many significant bits are in the mask
|
||||
const AstConst* const constp = VN_CAST(nodep->lhsp(), Const);
|
||||
const AstConst* const constp = VN_AS(nodep->lhsp(), Const);
|
||||
const uint32_t significantBits = constp->num().widthMin();
|
||||
|
||||
AstOr* const orp = VN_CAST(nodep->rhsp(), Or);
|
||||
AstOr* const orp = VN_AS(nodep->rhsp(), Or);
|
||||
|
||||
// Predicate for checking whether the bottom 'significantBits' bits of the given expression
|
||||
// are all zeroes.
|
||||
|
|
@ -1049,7 +1049,7 @@ private:
|
|||
// drop redundant masking of left shift result. E.g.: 0xff000000 & ((uint32_t)a << 24).
|
||||
|
||||
const auto checkMask = [=](const V3Number& mask) -> bool {
|
||||
const AstConst* const constp = VN_CAST(nodep->lhsp(), Const);
|
||||
const AstConst* const constp = VN_AS(nodep->lhsp(), Const);
|
||||
if (constp->num().isCaseEq(mask)) {
|
||||
AstNode* const rhsp = nodep->rhsp();
|
||||
rhsp->unlinkFrBack();
|
||||
|
|
@ -1121,7 +1121,7 @@ private:
|
|||
return newp;
|
||||
}
|
||||
static bool operandShiftSame(const AstNode* nodep) {
|
||||
const AstNodeBiop* np = VN_CAST_CONST(nodep, NodeBiop);
|
||||
const AstNodeBiop* np = VN_AS_CONST(nodep, NodeBiop);
|
||||
{
|
||||
const AstShiftL* lp = VN_CAST_CONST(np->lhsp(), ShiftL);
|
||||
const AstShiftL* rp = VN_CAST_CONST(np->rhsp(), ShiftL);
|
||||
|
|
@ -1142,28 +1142,28 @@ private:
|
|||
}
|
||||
bool operandHugeShiftL(const AstNodeBiop* nodep) {
|
||||
return (VN_IS(nodep->rhsp(), Const)
|
||||
&& !VN_CAST_CONST(nodep->rhsp(), Const)->num().isFourState()
|
||||
&& (VN_CAST_CONST(nodep->rhsp(), Const)->toUInt()
|
||||
&& !VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState()
|
||||
&& (VN_AS_CONST(nodep->rhsp(), Const)->toUInt()
|
||||
>= static_cast<uint32_t>(nodep->width()))
|
||||
&& isTPure(nodep->lhsp()));
|
||||
}
|
||||
bool operandHugeShiftR(const AstNodeBiop* nodep) {
|
||||
return (VN_IS(nodep->rhsp(), Const)
|
||||
&& !VN_CAST_CONST(nodep->rhsp(), Const)->num().isFourState()
|
||||
&& (VN_CAST_CONST(nodep->rhsp(), Const)->toUInt()
|
||||
&& !VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState()
|
||||
&& (VN_AS_CONST(nodep->rhsp(), Const)->toUInt()
|
||||
>= static_cast<uint32_t>(nodep->lhsp()->width()))
|
||||
&& isTPure(nodep->lhsp()));
|
||||
}
|
||||
bool operandIsTwo(const AstNode* nodep) {
|
||||
return (VN_IS(nodep, Const) && !VN_CAST_CONST(nodep, Const)->num().isFourState()
|
||||
&& nodep->width() <= VL_QUADSIZE && VN_CAST_CONST(nodep, Const)->toUQuad() == 2);
|
||||
return (VN_IS(nodep, Const) && !VN_AS_CONST(nodep, Const)->num().isFourState()
|
||||
&& nodep->width() <= VL_QUADSIZE && VN_AS_CONST(nodep, Const)->toUQuad() == 2);
|
||||
}
|
||||
bool operandIsTwostate(const AstNode* nodep) {
|
||||
return (VN_IS(nodep, Const) && !VN_CAST_CONST(nodep, Const)->num().isFourState());
|
||||
return (VN_IS(nodep, Const) && !VN_AS_CONST(nodep, Const)->num().isFourState());
|
||||
}
|
||||
bool operandIsPowTwo(const AstNode* nodep) {
|
||||
if (!operandIsTwostate(nodep)) return false;
|
||||
return (1 == VN_CAST_CONST(nodep, Const)->num().countOnes());
|
||||
return (1 == VN_AS_CONST(nodep, Const)->num().countOnes());
|
||||
}
|
||||
bool operandShiftOp(const AstNodeBiop* nodep) {
|
||||
if (!VN_IS(nodep->rhsp(), Const)) return false;
|
||||
|
|
@ -1181,8 +1181,8 @@ private:
|
|||
// We can only get rid of a<<b>>c or a<<b<<c, with constant b & c
|
||||
// because bits may be masked in that process, or (b+c) may exceed the word width.
|
||||
if (!(VN_IS(nodep->rhsp(), Const) && VN_IS(lhsp->rhsp(), Const))) return false;
|
||||
if (VN_CAST_CONST(nodep->rhsp(), Const)->num().isFourState()
|
||||
|| VN_CAST_CONST(lhsp->rhsp(), Const)->num().isFourState())
|
||||
if (VN_AS_CONST(nodep->rhsp(), Const)->num().isFourState()
|
||||
|| VN_AS_CONST(lhsp->rhsp(), Const)->num().isFourState())
|
||||
return false;
|
||||
if (nodep->width() != lhsp->width()) return false;
|
||||
if (nodep->width() != lhsp->lhsp()->width()) return false;
|
||||
|
|
@ -1193,9 +1193,9 @@ private:
|
|||
// It was an expression, then got constified. In reality, the WordSel
|
||||
// must be wrapped in a Cond, that will be false.
|
||||
return (VN_IS(nodep->rhsp(), Const) && VN_IS(nodep->fromp(), NodeVarRef)
|
||||
&& VN_CAST_CONST(nodep->fromp(), NodeVarRef)->access().isReadOnly()
|
||||
&& (static_cast<int>(VN_CAST_CONST(nodep->rhsp(), Const)->toUInt())
|
||||
>= VN_CAST(nodep->fromp(), NodeVarRef)->varp()->widthWords()));
|
||||
&& VN_AS_CONST(nodep->fromp(), NodeVarRef)->access().isReadOnly()
|
||||
&& (static_cast<int>(VN_AS_CONST(nodep->rhsp(), Const)->toUInt())
|
||||
>= VN_AS(nodep->fromp(), NodeVarRef)->varp()->widthWords()));
|
||||
}
|
||||
bool operandSelFull(const AstSel* nodep) {
|
||||
return (VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const)
|
||||
|
|
@ -1240,8 +1240,8 @@ private:
|
|||
return false;
|
||||
}
|
||||
AstNode* ap = shiftp->lhsp();
|
||||
AstConst* bp = VN_CAST(shiftp->rhsp(), Const);
|
||||
AstConst* lp = VN_CAST(nodep->lsbp(), Const);
|
||||
AstConst* bp = VN_AS(shiftp->rhsp(), Const);
|
||||
AstConst* lp = VN_AS(nodep->lsbp(), Const);
|
||||
if (bp->isWide() || bp->num().isFourState() || bp->num().isNegative() || lp->isWide()
|
||||
|| lp->num().isFourState() || lp->num().isNegative()) {
|
||||
return false;
|
||||
|
|
@ -1336,8 +1336,8 @@ private:
|
|||
if (m_warn && VN_IS(nodep->lsbp(), Const) && VN_IS(nodep->widthp(), Const) && doit) {
|
||||
const int maxDeclBit = nodep->declRange().hiMaxSelect() * nodep->declElWidth()
|
||||
+ (nodep->declElWidth() - 1);
|
||||
if (VN_CAST(nodep->lsbp(), Const)->num().isFourState()
|
||||
|| VN_CAST(nodep->widthp(), Const)->num().isFourState()) {
|
||||
if (VN_AS(nodep->lsbp(), Const)->num().isFourState()
|
||||
|| VN_AS(nodep->widthp(), Const)->num().isFourState()) {
|
||||
nodep->v3error("Selection index is constantly unknown or tristated: "
|
||||
"lsb="
|
||||
<< nodep->lsbp()->name() << " width=" << nodep->widthp()->name());
|
||||
|
|
@ -1491,7 +1491,7 @@ private:
|
|||
void replaceNum(AstNode* oldp, const V3Number& num) {
|
||||
// Replace oldp node with a constant set to specified value
|
||||
UASSERT(oldp, "Null old");
|
||||
UASSERT_OBJ(!(VN_IS(oldp, Const) && !VN_CAST(oldp, Const)->num().isFourState()), oldp,
|
||||
UASSERT_OBJ(!(VN_IS(oldp, Const) && !VN_AS(oldp, Const)->num().isFourState()), oldp,
|
||||
"Already constant??");
|
||||
AstNode* newp = new AstConst(oldp->fileline(), num);
|
||||
newp->dtypeFrom(oldp);
|
||||
|
|
@ -1539,30 +1539,30 @@ private:
|
|||
}
|
||||
void replaceConst(AstNodeUniop* nodep) {
|
||||
V3Number num(nodep, nodep->width());
|
||||
nodep->numberOperate(num, VN_CAST(nodep->lhsp(), Const)->num());
|
||||
nodep->numberOperate(num, VN_AS(nodep->lhsp(), Const)->num());
|
||||
UINFO(4, "UNICONST -> " << num << endl);
|
||||
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
|
||||
}
|
||||
void replaceConst(AstNodeBiop* nodep) {
|
||||
V3Number num(nodep, nodep->width());
|
||||
nodep->numberOperate(num, VN_CAST(nodep->lhsp(), Const)->num(),
|
||||
VN_CAST(nodep->rhsp(), Const)->num());
|
||||
nodep->numberOperate(num, VN_AS(nodep->lhsp(), Const)->num(),
|
||||
VN_AS(nodep->rhsp(), Const)->num());
|
||||
UINFO(4, "BICONST -> " << num << endl);
|
||||
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
|
||||
}
|
||||
void replaceConst(AstNodeTriop* nodep) {
|
||||
V3Number num(nodep, nodep->width());
|
||||
nodep->numberOperate(num, VN_CAST(nodep->lhsp(), Const)->num(),
|
||||
VN_CAST(nodep->rhsp(), Const)->num(),
|
||||
VN_CAST(nodep->thsp(), Const)->num());
|
||||
nodep->numberOperate(num, VN_AS(nodep->lhsp(), Const)->num(),
|
||||
VN_AS(nodep->rhsp(), Const)->num(),
|
||||
VN_AS(nodep->thsp(), Const)->num());
|
||||
UINFO(4, "TRICONST -> " << num << endl);
|
||||
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
|
||||
}
|
||||
void replaceConst(AstNodeQuadop* nodep) {
|
||||
V3Number num(nodep, nodep->width());
|
||||
nodep->numberOperate(
|
||||
num, VN_CAST(nodep->lhsp(), Const)->num(), VN_CAST(nodep->rhsp(), Const)->num(),
|
||||
VN_CAST(nodep->thsp(), Const)->num(), VN_CAST(nodep->fhsp(), Const)->num());
|
||||
num, VN_AS(nodep->lhsp(), Const)->num(), VN_AS(nodep->rhsp(), Const)->num(),
|
||||
VN_AS(nodep->thsp(), Const)->num(), VN_AS(nodep->fhsp(), Const)->num());
|
||||
UINFO(4, "QUADCONST -> " << num << endl);
|
||||
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
|
||||
}
|
||||
|
|
@ -1620,7 +1620,7 @@ private:
|
|||
// BIASV(SAMEa, BIASV(SAMEb, c)) -> BIASV( BIASV(SAMEa,SAMEb), c)
|
||||
// nodep->dumpTree(cout, " repAsvConst_old: ");
|
||||
AstNode* ap = nodep->lhsp();
|
||||
AstNodeBiop* rp = VN_CAST(nodep->rhsp(), NodeBiop);
|
||||
AstNodeBiop* rp = VN_AS(nodep->rhsp(), NodeBiop);
|
||||
AstNode* bp = rp->lhsp();
|
||||
AstNode* cp = rp->rhsp();
|
||||
ap->unlinkFrBack();
|
||||
|
|
@ -1636,7 +1636,7 @@ private:
|
|||
}
|
||||
void replaceAsvLUp(AstNodeBiop* nodep) {
|
||||
// BIASV(BIASV(CONSTll,lr),r) -> BIASV(CONSTll,BIASV(lr,r))
|
||||
AstNodeBiop* lp = VN_CAST(nodep->lhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNode* llp = lp->lhsp()->unlinkFrBack();
|
||||
AstNode* lrp = lp->rhsp()->unlinkFrBack();
|
||||
AstNode* rp = nodep->rhsp()->unlinkFrBack();
|
||||
|
|
@ -1649,7 +1649,7 @@ private:
|
|||
void replaceAsvRUp(AstNodeBiop* nodep) {
|
||||
// BIASV(l,BIASV(CONSTrl,rr)) -> BIASV(CONSTrl,BIASV(l,rr))
|
||||
AstNode* lp = nodep->lhsp()->unlinkFrBack();
|
||||
AstNodeBiop* rp = VN_CAST(nodep->rhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNode* rlp = rp->lhsp()->unlinkFrBack();
|
||||
AstNode* rrp = rp->rhsp()->unlinkFrBack();
|
||||
nodep->lhsp(rlp);
|
||||
|
|
@ -1663,10 +1663,10 @@ private:
|
|||
// OR (AND (CONSTll,lr), AND(CONSTrl, rr=lr)) -> AND (OR(ll,rl), rr)
|
||||
// nodep ^lp ^llp ^lrp ^rp ^rlp ^rrp
|
||||
// (Or/And may also be reversed)
|
||||
AstNodeBiop* lp = VN_CAST(nodep->lhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNode* llp = lp->lhsp()->unlinkFrBack();
|
||||
AstNode* lrp = lp->rhsp()->unlinkFrBack();
|
||||
AstNodeBiop* rp = VN_CAST(nodep->rhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNode* rlp = rp->lhsp()->unlinkFrBack();
|
||||
AstNode* rrp = rp->rhsp()->unlinkFrBack();
|
||||
nodep->replaceWith(lp);
|
||||
|
|
@ -1692,10 +1692,10 @@ private:
|
|||
void replaceShiftSame(AstNodeBiop* nodep) {
|
||||
// Or(Shift(ll,CONSTlr),Shift(rl,CONSTrr==lr)) -> Shift(Or(ll,rl),CONSTlr)
|
||||
// (Or/And may also be reversed)
|
||||
AstNodeBiop* lp = VN_CAST(nodep->lhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* lp = VN_AS(nodep->lhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNode* llp = lp->lhsp()->unlinkFrBack();
|
||||
AstNode* lrp = lp->rhsp()->unlinkFrBack();
|
||||
AstNodeBiop* rp = VN_CAST(nodep->rhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* rp = VN_AS(nodep->rhsp()->unlinkFrBack(), NodeBiop);
|
||||
AstNode* rlp = rp->lhsp()->unlinkFrBack();
|
||||
AstNode* rrp = rp->rhsp()->unlinkFrBack();
|
||||
nodep->replaceWith(lp);
|
||||
|
|
@ -1709,8 +1709,8 @@ private:
|
|||
}
|
||||
void replaceConcatSel(AstConcat* nodep) {
|
||||
// {a[1], a[0]} -> a[1:0]
|
||||
AstSel* lselp = VN_CAST(nodep->lhsp()->unlinkFrBack(), Sel);
|
||||
AstSel* rselp = VN_CAST(nodep->rhsp()->unlinkFrBack(), Sel);
|
||||
AstSel* lselp = VN_AS(nodep->lhsp()->unlinkFrBack(), Sel);
|
||||
AstSel* rselp = VN_AS(nodep->rhsp()->unlinkFrBack(), Sel);
|
||||
const int lstart = lselp->lsbConst();
|
||||
const int lwidth = lselp->widthConst();
|
||||
const int rstart = rselp->lsbConst();
|
||||
|
|
@ -1729,8 +1729,8 @@ private:
|
|||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
}
|
||||
void replaceConcatMerge(AstConcat* nodep) {
|
||||
AstNodeBiop* lp = VN_CAST(nodep->lhsp(), NodeBiop);
|
||||
AstNodeBiop* rp = VN_CAST(nodep->rhsp(), NodeBiop);
|
||||
AstNodeBiop* lp = VN_AS(nodep->lhsp(), NodeBiop);
|
||||
AstNodeBiop* rp = VN_AS(nodep->rhsp(), NodeBiop);
|
||||
AstNode* llp = lp->lhsp()->cloneTree(false);
|
||||
AstNode* lrp = lp->rhsp()->cloneTree(false);
|
||||
AstNode* rlp = rp->lhsp()->cloneTree(false);
|
||||
|
|
@ -1776,7 +1776,7 @@ private:
|
|||
}
|
||||
void replaceMulShift(AstMul* nodep) { // Mul, but not MulS as not simple shift
|
||||
UINFO(5, "MUL(2^n,b)->SHIFTL(b,n) " << nodep << endl);
|
||||
const int amount = VN_CAST(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
const int amount = VN_AS(nodep->lhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
AstNode* opp = nodep->rhsp()->unlinkFrBack();
|
||||
AstShiftL* newp
|
||||
= new AstShiftL(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount));
|
||||
|
|
@ -1786,7 +1786,7 @@ private:
|
|||
}
|
||||
void replaceDivShift(AstDiv* nodep) { // Mul, but not MulS as not simple shift
|
||||
UINFO(5, "DIV(b,2^n)->SHIFTR(b,n) " << nodep << endl);
|
||||
const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
const int amount = VN_AS(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
AstNode* opp = nodep->lhsp()->unlinkFrBack();
|
||||
AstShiftR* newp
|
||||
= new AstShiftR(nodep->fileline(), opp, new AstConst(nodep->fileline(), amount));
|
||||
|
|
@ -1796,7 +1796,7 @@ private:
|
|||
}
|
||||
void replaceModAnd(AstModDiv* nodep) { // Mod, but not ModS as not simple shift
|
||||
UINFO(5, "MOD(b,2^n)->AND(b,2^n-1) " << nodep << endl);
|
||||
const int amount = VN_CAST(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
const int amount = VN_AS(nodep->rhsp(), Const)->num().mostSetBitP1() - 1; // 2^n->n+1
|
||||
V3Number mask(nodep, nodep->width());
|
||||
mask.setMask(amount);
|
||||
AstNode* opp = nodep->lhsp()->unlinkFrBack();
|
||||
|
|
@ -1809,7 +1809,7 @@ private:
|
|||
UINFO(5, "SHIFT(AND(a,b),CONST)->AND(SHIFT(a,CONST),SHIFT(b,CONST)) " << nodep << endl);
|
||||
AstNRelinker handle;
|
||||
nodep->unlinkFrBack(&handle);
|
||||
AstNodeBiop* lhsp = VN_CAST(nodep->lhsp(), NodeBiop);
|
||||
AstNodeBiop* lhsp = VN_AS(nodep->lhsp(), NodeBiop);
|
||||
lhsp->unlinkFrBack();
|
||||
AstNode* shiftp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* ap = lhsp->lhsp()->unlinkFrBack();
|
||||
|
|
@ -1829,7 +1829,7 @@ private:
|
|||
void replaceShiftShift(AstNodeBiop* nodep) {
|
||||
UINFO(4, "SHIFT(SHIFT(a,s1),s2)->SHIFT(a,ADD(s1,s2)) " << nodep << endl);
|
||||
if (debug() >= 9) nodep->dumpTree(cout, " repShiftShift_old: ");
|
||||
AstNodeBiop* lhsp = VN_CAST(nodep->lhsp(), NodeBiop);
|
||||
AstNodeBiop* lhsp = VN_AS(nodep->lhsp(), NodeBiop);
|
||||
lhsp->unlinkFrBack();
|
||||
AstNode* ap = lhsp->lhsp()->unlinkFrBack();
|
||||
AstNode* shift1p = lhsp->rhsp()->unlinkFrBack();
|
||||
|
|
@ -1837,8 +1837,8 @@ private:
|
|||
// Shift1p and shift2p may have different sizes, both are
|
||||
// self-determined so sum with infinite width
|
||||
if (nodep->type() == lhsp->type()) {
|
||||
int shift1 = VN_CAST(shift1p, Const)->toUInt();
|
||||
int shift2 = VN_CAST(shift2p, Const)->toUInt();
|
||||
int shift1 = VN_AS(shift1p, Const)->toUInt();
|
||||
int shift2 = VN_AS(shift2p, Const)->toUInt();
|
||||
const int newshift = shift1 + shift2;
|
||||
VL_DO_DANGLING(shift1p->deleteTree(), shift1p);
|
||||
VL_DO_DANGLING(shift2p->deleteTree(), shift2p);
|
||||
|
|
@ -1847,9 +1847,9 @@ private:
|
|||
iterate(nodep); // Further reduce, either node may have more reductions.
|
||||
} else {
|
||||
// We know shift amounts are constant, but might be a mixed left/right shift
|
||||
int shift1 = VN_CAST(shift1p, Const)->toUInt();
|
||||
int shift1 = VN_AS(shift1p, Const)->toUInt();
|
||||
if (VN_IS(lhsp, ShiftR)) shift1 = -shift1;
|
||||
int shift2 = VN_CAST(shift2p, Const)->toUInt();
|
||||
int shift2 = VN_AS(shift2p, Const)->toUInt();
|
||||
if (VN_IS(nodep, ShiftR)) shift2 = -shift2;
|
||||
const int newshift = shift1 + shift2;
|
||||
VL_DO_DANGLING(shift1p->deleteTree(), shift1p);
|
||||
|
|
@ -1949,7 +1949,7 @@ private:
|
|||
if (!nodep) return true;
|
||||
if (level > 2) return false;
|
||||
if (!nodep->isPure()) return false; // For example a $fgetc can't be reordered
|
||||
if (VN_IS(nodep, NodeVarRef) && VN_CAST(nodep, NodeVarRef)->varp() == varp) return false;
|
||||
if (VN_IS(nodep, NodeVarRef) && VN_AS(nodep, NodeVarRef)->varp() == varp) return false;
|
||||
return (varNotReferenced(nodep->nextp(), varp, level + 1)
|
||||
&& varNotReferenced(nodep->op1p(), varp, level + 1)
|
||||
&& varNotReferenced(nodep->op2p(), varp, level + 1)
|
||||
|
|
@ -1959,7 +1959,7 @@ private:
|
|||
|
||||
bool replaceNodeAssign(AstNodeAssign* nodep) {
|
||||
if (VN_IS(nodep->lhsp(), VarRef) && VN_IS(nodep->rhsp(), VarRef)
|
||||
&& VN_CAST(nodep->lhsp(), VarRef)->sameNoLvalue(VN_CAST(nodep->rhsp(), VarRef))
|
||||
&& VN_AS(nodep->lhsp(), VarRef)->sameNoLvalue(VN_AS(nodep->rhsp(), VarRef))
|
||||
&& !VN_IS(nodep, AssignDly)) {
|
||||
// X = X. Quite pointless, though X <= X may override another earlier assignment
|
||||
if (VN_IS(nodep, AssignW)) {
|
||||
|
|
@ -1994,9 +1994,9 @@ private:
|
|||
}
|
||||
if (debug() >= 9) nodep->dumpTree(cout, " Ass_old: ");
|
||||
// Unlink the stuff
|
||||
AstNode* lc1p = VN_CAST(nodep->lhsp(), Concat)->lhsp()->unlinkFrBack();
|
||||
AstNode* lc2p = VN_CAST(nodep->lhsp(), Concat)->rhsp()->unlinkFrBack();
|
||||
AstNode* conp = VN_CAST(nodep->lhsp(), Concat)->unlinkFrBack();
|
||||
AstNode* lc1p = VN_AS(nodep->lhsp(), Concat)->lhsp()->unlinkFrBack();
|
||||
AstNode* lc2p = VN_AS(nodep->lhsp(), Concat)->rhsp()->unlinkFrBack();
|
||||
AstNode* conp = VN_AS(nodep->lhsp(), Concat)->unlinkFrBack();
|
||||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* rhs2p = rhsp->cloneTree(false);
|
||||
// Calc widths
|
||||
|
|
@ -2012,8 +2012,8 @@ private:
|
|||
//*** Not cloneTree; just one node.
|
||||
AstNode* newp = nullptr;
|
||||
if (!need_temp) {
|
||||
AstNodeAssign* asn1ap = VN_CAST(nodep->cloneType(lc1p, sel1p), NodeAssign);
|
||||
AstNodeAssign* asn2ap = VN_CAST(nodep->cloneType(lc2p, sel2p), NodeAssign);
|
||||
AstNodeAssign* asn1ap = VN_AS(nodep->cloneType(lc1p, sel1p), NodeAssign);
|
||||
AstNodeAssign* asn2ap = VN_AS(nodep->cloneType(lc2p, sel2p), NodeAssign);
|
||||
asn1ap->dtypeFrom(sel1p);
|
||||
asn2ap->dtypeFrom(sel2p);
|
||||
newp = AstNode::addNext(newp, asn1ap);
|
||||
|
|
@ -2033,21 +2033,21 @@ private:
|
|||
m_modp->addStmtp(temp1p);
|
||||
m_modp->addStmtp(temp2p);
|
||||
AstNodeAssign* asn1ap
|
||||
= VN_CAST(nodep->cloneType(
|
||||
new AstVarRef(sel1p->fileline(), temp1p, VAccess::WRITE), sel1p),
|
||||
NodeAssign);
|
||||
= VN_AS(nodep->cloneType(
|
||||
new AstVarRef(sel1p->fileline(), temp1p, VAccess::WRITE), sel1p),
|
||||
NodeAssign);
|
||||
AstNodeAssign* asn2ap
|
||||
= VN_CAST(nodep->cloneType(
|
||||
new AstVarRef(sel2p->fileline(), temp2p, VAccess::WRITE), sel2p),
|
||||
NodeAssign);
|
||||
= VN_AS(nodep->cloneType(
|
||||
new AstVarRef(sel2p->fileline(), temp2p, VAccess::WRITE), sel2p),
|
||||
NodeAssign);
|
||||
AstNodeAssign* asn1bp
|
||||
= VN_CAST(nodep->cloneType(
|
||||
lc1p, new AstVarRef(sel1p->fileline(), temp1p, VAccess::READ)),
|
||||
NodeAssign);
|
||||
= VN_AS(nodep->cloneType(
|
||||
lc1p, new AstVarRef(sel1p->fileline(), temp1p, VAccess::READ)),
|
||||
NodeAssign);
|
||||
AstNodeAssign* asn2bp
|
||||
= VN_CAST(nodep->cloneType(
|
||||
lc2p, new AstVarRef(sel2p->fileline(), temp2p, VAccess::READ)),
|
||||
NodeAssign);
|
||||
= VN_AS(nodep->cloneType(
|
||||
lc2p, new AstVarRef(sel2p->fileline(), temp2p, VAccess::READ)),
|
||||
NodeAssign);
|
||||
asn1ap->dtypeFrom(temp1p);
|
||||
asn1bp->dtypeFrom(temp1p);
|
||||
asn2ap->dtypeFrom(temp2p);
|
||||
|
|
@ -2069,9 +2069,9 @@ private:
|
|||
// The right-streaming operator on rhs of assignment does not
|
||||
// change the order of bits. Eliminate stream but keep its lhsp
|
||||
// Unlink the stuff
|
||||
AstNode* srcp = VN_CAST(nodep->rhsp(), StreamR)->lhsp()->unlinkFrBack();
|
||||
AstNode* sizep = VN_CAST(nodep->rhsp(), StreamR)->rhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_CAST(nodep->rhsp(), StreamR)->unlinkFrBack();
|
||||
AstNode* srcp = VN_AS(nodep->rhsp(), StreamR)->lhsp()->unlinkFrBack();
|
||||
AstNode* sizep = VN_AS(nodep->rhsp(), StreamR)->rhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_AS(nodep->rhsp(), StreamR)->unlinkFrBack();
|
||||
nodep->rhsp(srcp);
|
||||
// Cleanup
|
||||
VL_DO_DANGLING(sizep->deleteTree(), sizep);
|
||||
|
|
@ -2080,14 +2080,14 @@ private:
|
|||
return true;
|
||||
} else if (m_doV && VN_IS(nodep->lhsp(), StreamL)) {
|
||||
// Push the stream operator to the rhs of the assignment statement
|
||||
const int dWidth = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->width();
|
||||
const int dWidth = VN_AS(nodep->lhsp(), StreamL)->lhsp()->width();
|
||||
const int sWidth = nodep->rhsp()->width();
|
||||
// Unlink the stuff
|
||||
AstNode* dstp = VN_CAST(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_CAST(nodep->lhsp(), StreamL)->unlinkFrBack();
|
||||
AstNode* dstp = VN_AS(nodep->lhsp(), StreamL)->lhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_AS(nodep->lhsp(), StreamL)->unlinkFrBack();
|
||||
AstNode* srcp = nodep->rhsp()->unlinkFrBack();
|
||||
// Connect the rhs to the stream operator and update its width
|
||||
VN_CAST(streamp, StreamL)->lhsp(srcp);
|
||||
VN_AS(streamp, StreamL)->lhsp(srcp);
|
||||
streamp->dtypeSetLogicUnsized(srcp->width(), srcp->widthMin(), VSigning::UNSIGNED);
|
||||
// Shrink the RHS if necessary
|
||||
if (sWidth > dWidth) {
|
||||
|
|
@ -2101,12 +2101,12 @@ private:
|
|||
// The right stream operator on lhs of assignment statement does
|
||||
// not reorder bits. However, if the rhs is wider than the lhs,
|
||||
// then we select bits from the left-most, not the right-most.
|
||||
const int dWidth = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->width();
|
||||
const int dWidth = VN_AS(nodep->lhsp(), StreamR)->lhsp()->width();
|
||||
const int sWidth = nodep->rhsp()->width();
|
||||
// Unlink the stuff
|
||||
AstNode* dstp = VN_CAST(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack();
|
||||
AstNode* sizep = VN_CAST(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_CAST(nodep->lhsp(), StreamR)->unlinkFrBack();
|
||||
AstNode* dstp = VN_AS(nodep->lhsp(), StreamR)->lhsp()->unlinkFrBack();
|
||||
AstNode* sizep = VN_AS(nodep->lhsp(), StreamR)->rhsp()->unlinkFrBack();
|
||||
AstNode* streamp = VN_AS(nodep->lhsp(), StreamR)->unlinkFrBack();
|
||||
AstNode* srcp = nodep->rhsp()->unlinkFrBack();
|
||||
if (sWidth > dWidth) {
|
||||
srcp = new AstSel(streamp->fileline(), srcp, sWidth - dWidth, dWidth);
|
||||
|
|
@ -2128,22 +2128,21 @@ private:
|
|||
bool operandBoolShift(const AstNode* nodep) {
|
||||
// boolean test of AND(const,SHIFTR(x,const)) -> test of AND(SHIFTL(x,const), x)
|
||||
if (!VN_IS(nodep, And)) return false;
|
||||
if (!VN_IS(VN_CAST_CONST(nodep, And)->lhsp(), Const)) return false;
|
||||
if (!VN_IS(VN_CAST_CONST(nodep, And)->rhsp(), ShiftR)) return false;
|
||||
const AstShiftR* shiftp = VN_CAST(VN_CAST_CONST(nodep, And)->rhsp(), ShiftR);
|
||||
if (!VN_IS(VN_AS_CONST(nodep, And)->lhsp(), Const)) return false;
|
||||
if (!VN_IS(VN_AS_CONST(nodep, And)->rhsp(), ShiftR)) return false;
|
||||
const AstShiftR* shiftp = VN_AS(VN_AS_CONST(nodep, And)->rhsp(), ShiftR);
|
||||
if (!VN_IS(shiftp->rhsp(), Const)) return false;
|
||||
if (static_cast<uint32_t>(nodep->width())
|
||||
<= VN_CAST_CONST(shiftp->rhsp(), Const)->toUInt()) {
|
||||
<= VN_AS_CONST(shiftp->rhsp(), Const)->toUInt()) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
void replaceBoolShift(AstNode* nodep) {
|
||||
if (debug() >= 9) nodep->dumpTree(cout, " bshft_old: ");
|
||||
AstConst* andConstp = VN_CAST(VN_CAST(nodep, And)->lhsp(), Const);
|
||||
AstNode* fromp = VN_CAST(VN_CAST(nodep, And)->rhsp(), ShiftR)->lhsp()->unlinkFrBack();
|
||||
AstConst* shiftConstp
|
||||
= VN_CAST(VN_CAST(VN_CAST(nodep, And)->rhsp(), ShiftR)->rhsp(), Const);
|
||||
AstConst* andConstp = VN_AS(VN_AS(nodep, And)->lhsp(), Const);
|
||||
AstNode* fromp = VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->lhsp()->unlinkFrBack();
|
||||
AstConst* shiftConstp = VN_AS(VN_AS(VN_AS(nodep, And)->rhsp(), ShiftR)->rhsp(), Const);
|
||||
V3Number val(andConstp, andConstp->width());
|
||||
val.opShiftL(andConstp->num(), shiftConstp->num());
|
||||
AstAnd* newp = new AstAnd(nodep->fileline(), new AstConst(nodep->fileline(), val), fromp);
|
||||
|
|
@ -2252,7 +2251,7 @@ private:
|
|||
UINFO(4, "Move concat: " << nodep << endl);
|
||||
if (operandConcatMove(nodep) > 1) {
|
||||
AstNode* ap = nodep->lhsp()->unlinkFrBack();
|
||||
AstConcat* bcConcp = VN_CAST(nodep->rhsp(), Concat);
|
||||
AstConcat* bcConcp = VN_AS(nodep->rhsp(), Concat);
|
||||
bcConcp->unlinkFrBack();
|
||||
AstNode* bp = bcConcp->lhsp()->unlinkFrBack();
|
||||
AstNode* cp = bcConcp->rhsp()->unlinkFrBack();
|
||||
|
|
@ -2264,7 +2263,7 @@ private:
|
|||
if (operandConcatMove(abConcp)) moveConcat(abConcp);
|
||||
VL_DO_DANGLING(bcConcp->deleteTree(), bcConcp);
|
||||
} else {
|
||||
AstConcat* abConcp = VN_CAST(nodep->lhsp(), Concat);
|
||||
AstConcat* abConcp = VN_AS(nodep->lhsp(), Concat);
|
||||
abConcp->unlinkFrBack();
|
||||
AstNode* ap = abConcp->lhsp()->unlinkFrBack();
|
||||
AstNode* bp = abConcp->rhsp()->unlinkFrBack();
|
||||
|
|
@ -2307,7 +2306,7 @@ private:
|
|||
|
||||
void replaceSelSel(AstSel* nodep) {
|
||||
// SEL(SEL({x},a,b),c,d) => SEL({x},a+c,d)
|
||||
AstSel* belowp = VN_CAST(nodep->fromp(), Sel);
|
||||
AstSel* belowp = VN_AS(nodep->fromp(), Sel);
|
||||
AstNode* fromp = belowp->fromp()->unlinkFrBack();
|
||||
AstNode* widthp = nodep->widthp()->unlinkFrBack();
|
||||
AstNode* lsb1p = nodep->lsbp()->unlinkFrBack();
|
||||
|
|
@ -2316,8 +2315,8 @@ private:
|
|||
UINFO(4, "Elim Lower range: " << nodep << endl);
|
||||
AstNode* newlsbp;
|
||||
if (VN_IS(lsb1p, Const) && VN_IS(lsb2p, Const)) {
|
||||
newlsbp = new AstConst(lsb1p->fileline(), VN_CAST(lsb1p, Const)->toUInt()
|
||||
+ VN_CAST(lsb2p, Const)->toUInt());
|
||||
newlsbp = new AstConst(lsb1p->fileline(),
|
||||
VN_AS(lsb1p, Const)->toUInt() + VN_AS(lsb2p, Const)->toUInt());
|
||||
VL_DO_DANGLING(lsb1p->deleteTree(), lsb1p);
|
||||
VL_DO_DANGLING(lsb2p->deleteTree(), lsb2p);
|
||||
} else {
|
||||
|
|
@ -2326,7 +2325,7 @@ private:
|
|||
newlsbp
|
||||
= new AstAdd(lsb1p->fileline(), lsb2p, new AstExtend(lsb1p->fileline(), lsb1p));
|
||||
newlsbp->dtypeFrom(lsb2p); // Unsigned
|
||||
VN_CAST(newlsbp, Add)->rhsp()->dtypeFrom(lsb2p);
|
||||
VN_AS(newlsbp, Add)->rhsp()->dtypeFrom(lsb2p);
|
||||
}
|
||||
AstSel* newp = new AstSel(nodep->fileline(), fromp, newlsbp, widthp);
|
||||
nodep->replaceWith(newp);
|
||||
|
|
@ -2335,7 +2334,7 @@ private:
|
|||
|
||||
void replaceSelConcat(AstSel* nodep) {
|
||||
// SEL(CONCAT(a,b),c,d) => SEL(a or b, . .)
|
||||
AstConcat* conp = VN_CAST(nodep->fromp(), Concat);
|
||||
AstConcat* conp = VN_AS(nodep->fromp(), Concat);
|
||||
AstNode* conLhsp = conp->lhsp();
|
||||
AstNode* conRhsp = conp->rhsp();
|
||||
if (static_cast<int>(nodep->lsbConst()) >= conRhsp->width()) {
|
||||
|
|
@ -2365,7 +2364,7 @@ private:
|
|||
bool operandSelReplicate(AstSel* nodep) {
|
||||
// SEL(REPLICATE(from,rep),lsb,width) => SEL(from,0,width) as long
|
||||
// as SEL's width <= b's width
|
||||
AstReplicate* repp = VN_CAST(nodep->fromp(), Replicate);
|
||||
AstReplicate* repp = VN_AS(nodep->fromp(), Replicate);
|
||||
AstNode* fromp = repp->lhsp();
|
||||
AstConst* lsbp = VN_CAST(nodep->lsbp(), Const);
|
||||
if (!lsbp) return false;
|
||||
|
|
@ -2389,7 +2388,7 @@ private:
|
|||
}
|
||||
bool operandRepRep(AstReplicate* nodep) {
|
||||
// REPLICATE(REPLICATE2(from2,cnt2),cnt1) => REPLICATE(from2,(cnt1+cnt2))
|
||||
AstReplicate* rep2p = VN_CAST(nodep->lhsp(), Replicate);
|
||||
AstReplicate* rep2p = VN_AS(nodep->lhsp(), Replicate);
|
||||
AstNode* from2p = rep2p->lhsp();
|
||||
AstConst* cnt1p = VN_CAST(nodep->rhsp(), Const);
|
||||
if (!cnt1p) return false;
|
||||
|
|
@ -2418,13 +2417,13 @@ private:
|
|||
if (VN_IS(from1p, Replicate)) {
|
||||
AstConst* cnt1p = VN_CAST(VN_CAST(from1p, Replicate)->rhsp(), Const);
|
||||
if (!cnt1p) return false;
|
||||
from1p = VN_CAST(from1p, Replicate)->lhsp();
|
||||
from1p = VN_AS(from1p, Replicate)->lhsp();
|
||||
cnt1 = cnt1p->toUInt();
|
||||
}
|
||||
if (VN_IS(from2p, Replicate)) {
|
||||
AstConst* cnt2p = VN_CAST(VN_CAST(from2p, Replicate)->rhsp(), Const);
|
||||
if (!cnt2p) return false;
|
||||
from2p = VN_CAST(from2p, Replicate)->lhsp();
|
||||
from2p = VN_AS(from2p, Replicate)->lhsp();
|
||||
cnt2 = cnt2p->toUInt();
|
||||
}
|
||||
if (!operandsSame(from1p, from2p)) return false;
|
||||
|
|
@ -2438,7 +2437,7 @@ private:
|
|||
}
|
||||
void replaceSelIntoBiop(AstSel* nodep) {
|
||||
// SEL(BUFIF1(a,b),1,bit) => BUFIF1(SEL(a,1,bit),SEL(b,1,bit))
|
||||
AstNodeBiop* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), NodeBiop);
|
||||
AstNodeBiop* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeBiop);
|
||||
UASSERT_OBJ(fromp, nodep, "Called on non biop");
|
||||
AstNode* lsbp = nodep->lsbp()->unlinkFrBack();
|
||||
AstNode* widthp = nodep->widthp()->unlinkFrBack();
|
||||
|
|
@ -2455,7 +2454,7 @@ private:
|
|||
}
|
||||
void replaceSelIntoUniop(AstSel* nodep) {
|
||||
// SEL(NOT(a),1,bit) => NOT(SEL(a,bit))
|
||||
AstNodeUniop* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), NodeUniop);
|
||||
AstNodeUniop* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), NodeUniop);
|
||||
UASSERT_OBJ(fromp, nodep, "Called on non biop");
|
||||
AstNode* lsbp = nodep->lsbp()->unlinkFrBack();
|
||||
AstNode* widthp = nodep->widthp()->unlinkFrBack();
|
||||
|
|
@ -2481,8 +2480,8 @@ private:
|
|||
if (VN_IS(nodep->bitp(), Const)
|
||||
&& VN_IS(nodep->fromp(), VarRef)
|
||||
// Need to make sure it's an array object so don't mis-allow a constant (bug509.)
|
||||
&& VN_CAST(nodep->fromp(), VarRef)->varp()
|
||||
&& VN_IS(VN_CAST(nodep->fromp(), VarRef)->varp()->valuep(), InitArray)) {
|
||||
&& VN_AS(nodep->fromp(), VarRef)->varp()
|
||||
&& VN_IS(VN_AS(nodep->fromp(), VarRef)->varp()->valuep(), InitArray)) {
|
||||
m_selp = nodep; // Ask visit(AstVarRef) to replace varref with const
|
||||
}
|
||||
iterateAndNextNull(nodep->fromp());
|
||||
|
|
@ -2495,7 +2494,7 @@ private:
|
|||
if (VN_IS(fromp->dtypep()->skipRefp(), NodeArrayDType)) {
|
||||
// Strip off array to find what array references
|
||||
fromp->dtypeFrom(
|
||||
VN_CAST(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep());
|
||||
VN_AS(fromp->dtypep()->skipRefp(), NodeArrayDType)->subDTypep());
|
||||
}
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
}
|
||||
|
|
@ -2520,16 +2519,16 @@ private:
|
|||
&& !nodep->varp()->noSubst() && !nodep->varp()->isSigPublic())
|
||||
|| nodep->varp()->isParam())) {
|
||||
if (operandConst(valuep)) {
|
||||
const V3Number& num = VN_CAST(valuep, Const)->num();
|
||||
const V3Number& num = VN_AS(valuep, Const)->num();
|
||||
// UINFO(2,"constVisit "<<cvtToHex(valuep)<<" "<<num<<endl);
|
||||
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
|
||||
did = true;
|
||||
} else if (m_selp && VN_IS(valuep, InitArray)) {
|
||||
AstInitArray* initarp = VN_CAST(valuep, InitArray);
|
||||
AstInitArray* initarp = VN_AS(valuep, InitArray);
|
||||
uint32_t bit = m_selp->bitConst();
|
||||
AstNode* itemp = initarp->getIndexDefaultedValuep(bit);
|
||||
if (VN_IS(itemp, Const)) {
|
||||
const V3Number& num = VN_CAST(itemp, Const)->num();
|
||||
const V3Number& num = VN_AS(itemp, Const)->num();
|
||||
// UINFO(2,"constVisit "<<cvtToHex(valuep)<<" "<<num<<endl);
|
||||
VL_DO_DANGLING(replaceNum(nodep, num), nodep);
|
||||
did = true;
|
||||
|
|
@ -2612,12 +2611,12 @@ private:
|
|||
AstNode* lastSensp = sensp;
|
||||
bool invert = false;
|
||||
while (VN_IS(lastSensp, Not)) {
|
||||
lastSensp = VN_CAST(lastSensp, Not)->lhsp();
|
||||
lastSensp = VN_AS(lastSensp, Not)->lhsp();
|
||||
invert = !invert;
|
||||
}
|
||||
UINFO(8, "senItem(NOT...) " << nodep << " " << invert << endl);
|
||||
if (invert) nodep->edgeType(nodep->edgeType().invert());
|
||||
AstNodeVarRef* senvarp = VN_CAST(lastSensp->unlinkFrBack(), NodeVarRef);
|
||||
AstNodeVarRef* senvarp = VN_AS(lastSensp->unlinkFrBack(), NodeVarRef);
|
||||
UASSERT_OBJ(senvarp, sensp, "Non-varref sensitivity variable");
|
||||
sensp->replaceWith(senvarp);
|
||||
VL_DO_DANGLING(sensp->deleteTree(), sensp);
|
||||
|
|
@ -2672,8 +2671,8 @@ private:
|
|||
{
|
||||
AstUser4InUse m_inuse4;
|
||||
// Mark x in SENITEM(x)
|
||||
for (AstSenItem* senp = VN_CAST(nodep->sensesp(), SenItem); senp;
|
||||
senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = VN_AS(nodep->sensesp(), SenItem); senp;
|
||||
senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
if (senp->varrefp() && senp->varrefp()->varScopep()) {
|
||||
senp->varrefp()->varScopep()->user4(1);
|
||||
}
|
||||
|
|
@ -2683,17 +2682,16 @@ private:
|
|||
// Sort the sensitivity names so "posedge a or b" and "posedge b or a" end up together.
|
||||
// Also, remove duplicate assignments, and fold POS&NEGs into ANYEDGEs
|
||||
// Make things a little faster; check first if we need a sort
|
||||
for (AstSenItem *nextp, *senp = VN_CAST(nodep->sensesp(), SenItem); senp;
|
||||
senp = nextp) {
|
||||
nextp = VN_CAST(senp->nextp(), SenItem);
|
||||
for (AstSenItem *nextp, *senp = VN_AS(nodep->sensesp(), SenItem); senp; senp = nextp) {
|
||||
nextp = VN_AS(senp->nextp(), SenItem);
|
||||
// cppcheck-suppress unassignedVariable // cppcheck bug
|
||||
SenItemCmp cmp;
|
||||
if (nextp && !cmp(senp, nextp)) {
|
||||
// Something's out of order, sort it
|
||||
senp = nullptr;
|
||||
std::vector<AstSenItem*> vec;
|
||||
for (AstSenItem* senp = VN_CAST(nodep->sensesp(), SenItem); senp;
|
||||
senp = VN_CAST(senp->nextp(), SenItem)) {
|
||||
for (AstSenItem* senp = VN_AS(nodep->sensesp(), SenItem); senp;
|
||||
senp = VN_AS(senp->nextp(), SenItem)) {
|
||||
vec.push_back(senp);
|
||||
}
|
||||
stable_sort(vec.begin(), vec.end(), SenItemCmp());
|
||||
|
|
@ -2704,9 +2702,8 @@ private:
|
|||
}
|
||||
|
||||
// Pass2, remove dup edges
|
||||
for (AstSenItem *nextp, *senp = VN_CAST(nodep->sensesp(), SenItem); senp;
|
||||
senp = nextp) {
|
||||
nextp = VN_CAST(senp->nextp(), SenItem);
|
||||
for (AstSenItem *nextp, *senp = VN_AS(nodep->sensesp(), SenItem); senp; senp = nextp) {
|
||||
nextp = VN_AS(senp->nextp(), SenItem);
|
||||
AstSenItem* const litemp = senp;
|
||||
AstSenItem* const ritemp = nextp;
|
||||
if (ritemp) {
|
||||
|
|
@ -2759,7 +2756,7 @@ private:
|
|||
nodep->lhsp(),
|
||||
VarRef); // Not VarXRef, as different refs may set different values to each hierarchy
|
||||
if (m_wremove && !m_params && m_doNConst && m_modp && operandConst(nodep->rhsp())
|
||||
&& !VN_CAST(nodep->rhsp(), Const)->num().isFourState()
|
||||
&& !VN_AS(nodep->rhsp(), Const)->num().isFourState()
|
||||
&& varrefp // Don't do messes with BITREFs/ARRAYREFs
|
||||
&& !varrefp->varp()->valuep() // Not already constified
|
||||
&& !varrefp->varScopep()) { // Not scoped (or each scope may have different initial
|
||||
|
|
@ -2825,8 +2822,7 @@ private:
|
|||
|| VN_IS(nodep->condp(), LogNot))
|
||||
&& nodep->ifsp() && nodep->elsesp()) {
|
||||
UINFO(4, "IF(NOT {x}) => IF(x) swapped if/else" << nodep << endl);
|
||||
AstNode* condp
|
||||
= VN_CAST(nodep->condp(), NodeUniop)->lhsp()->unlinkFrBackWithNext();
|
||||
AstNode* condp = VN_AS(nodep->condp(), NodeUniop)->lhsp()->unlinkFrBackWithNext();
|
||||
AstNode* ifsp = nodep->ifsp()->unlinkFrBackWithNext();
|
||||
AstNode* elsesp = nodep->elsesp()->unlinkFrBackWithNext();
|
||||
AstIf* ifp = new AstIf(nodep->fileline(), condp, elsesp, ifsp);
|
||||
|
|
@ -2837,8 +2833,8 @@ private:
|
|||
UINFO(
|
||||
4,
|
||||
"IF({a}) ASSIGN({b},{c}) else ASSIGN({b},{d}) => ASSIGN({b}, {a}?{c}:{d})\n");
|
||||
AstNodeAssign* ifp = VN_CAST(nodep->ifsp(), NodeAssign);
|
||||
AstNodeAssign* elsep = VN_CAST(nodep->elsesp(), NodeAssign);
|
||||
AstNodeAssign* ifp = VN_AS(nodep->ifsp(), NodeAssign);
|
||||
AstNodeAssign* elsep = VN_AS(nodep->elsesp(), NodeAssign);
|
||||
ifp->unlinkFrBack();
|
||||
AstNode* condp = nodep->condp()->unlinkFrBack();
|
||||
AstNode* truep = ifp->rhsp()->unlinkFrBack();
|
||||
|
|
@ -2850,7 +2846,7 @@ private:
|
|||
// without due to short-circuiting
|
||||
&& operandIfIf(nodep)) {
|
||||
UINFO(9, "IF({a}) IF({b}) => IF({a} && {b})" << endl);
|
||||
AstNodeIf* lowerIfp = VN_CAST(nodep->ifsp(), NodeIf);
|
||||
AstNodeIf* lowerIfp = VN_AS(nodep->ifsp(), NodeIf);
|
||||
AstNode* condp = nodep->condp()->unlinkFrBack();
|
||||
AstNode* lowerIfsp = lowerIfp->ifsp()->unlinkFrBackWithNext();
|
||||
AstNode* lowerCondp = lowerIfp->condp()->unlinkFrBackWithNext();
|
||||
|
|
@ -2957,8 +2953,7 @@ private:
|
|||
if (argp) {
|
||||
AstNode* nextp = argp->nextp();
|
||||
if (VN_IS(argp, Const)) { // Convert it
|
||||
const string out
|
||||
= VN_CAST(argp, Const)->num().displayed(nodep, fmt);
|
||||
const string out = VN_AS(argp, Const)->num().displayed(nodep, fmt);
|
||||
UINFO(9, " DispConst: " << fmt << " -> " << out << " for "
|
||||
<< argp << endl);
|
||||
// fmt = out w/ replace % with %% as it must be literal.
|
||||
|
|
@ -3237,7 +3232,7 @@ private:
|
|||
TREEOP1("AstLt {$lhsp.isAllOnes, $rhsp, $lhsp->width()==$rhsp->width()}", "replaceNumLimited(nodep,0)");
|
||||
TREEOP1("AstGte {$lhsp.isAllOnes, $rhsp, $lhsp->width()==$rhsp->width()}", "replaceNumLimited(nodep,1)");
|
||||
// Two level bubble pushing
|
||||
TREEOP ("AstNot {$lhsp.castNot, $lhsp->width()==VN_CAST($lhsp,,Not)->lhsp()->width()}", "replaceWChild(nodep, $lhsp->op1p())"); // NOT(NOT(x))->x
|
||||
TREEOP ("AstNot {$lhsp.castNot, $lhsp->width()==VN_AS($lhsp,,Not)->lhsp()->width()}", "replaceWChild(nodep, $lhsp->op1p())"); // NOT(NOT(x))->x
|
||||
TREEOP ("AstLogNot{$lhsp.castLogNot}", "replaceWChild(nodep, $lhsp->op1p())"); // LOGNOT(LOGNOT(x))->x
|
||||
TREEOPV("AstNot {$lhsp.castEqCase, $lhsp.width1}","AstNeqCase{$lhsp->op1p(),$lhsp->op2p()}");
|
||||
TREEOP ("AstLogNot{$lhsp.castEqCase}", "AstNeqCase{$lhsp->op1p(),$lhsp->op2p()}");
|
||||
|
|
@ -3349,10 +3344,10 @@ private:
|
|||
TREEOPV("AstRedAnd{$lhsp.castConcat}", "AstAnd{AstRedAnd{$lhsp->castConcat()->lhsp()}, AstRedAnd{$lhsp->castConcat()->rhsp()}}"); // &{a,b} => {&a}&{&b}
|
||||
TREEOPV("AstRedOr {$lhsp.castConcat}", "AstOr {AstRedOr {$lhsp->castConcat()->lhsp()}, AstRedOr {$lhsp->castConcat()->rhsp()}}"); // |{a,b} => {|a}|{|b}
|
||||
TREEOPV("AstRedXor{$lhsp.castConcat}", "AstXor{AstRedXor{$lhsp->castConcat()->lhsp()}, AstRedXor{$lhsp->castConcat()->rhsp()}}"); // ^{a,b} => {^a}^{^b}
|
||||
TREEOPV("AstRedAnd{$lhsp.castExtend, $lhsp->width() > VN_CAST($lhsp,,Extend)->lhsp()->width()}", "replaceZero(nodep)"); // &{0,...} => 0 Prevents compiler limited range error
|
||||
TREEOPV("AstRedAnd{$lhsp.castExtend, $lhsp->width() > VN_AS($lhsp,,Extend)->lhsp()->width()}", "replaceZero(nodep)"); // &{0,...} => 0 Prevents compiler limited range error
|
||||
TREEOPV("AstRedOr {$lhsp.castExtend}", "AstRedOr {$lhsp->castExtend()->lhsp()}");
|
||||
TREEOPV("AstRedXor{$lhsp.castExtend}", "AstRedXor{$lhsp->castExtend()->lhsp()}");
|
||||
TREEOP ("AstRedXor{$lhsp.castXor, VN_IS(VN_CAST($lhsp,,Xor)->lhsp(),,Const)}", "AstXor{AstRedXor{$lhsp->castXor()->lhsp()}, AstRedXor{$lhsp->castXor()->rhsp()}}"); // ^(const ^ a) => (^const)^(^a)
|
||||
TREEOP ("AstRedXor{$lhsp.castXor, VN_IS(VN_AS($lhsp,,Xor)->lhsp(),,Const)}", "AstXor{AstRedXor{$lhsp->castXor()->lhsp()}, AstRedXor{$lhsp->castXor()->rhsp()}}"); // ^(const ^ a) => (^const)^(^a)
|
||||
TREEOPC("AstAnd {$lhsp.castConst, $rhsp.castRedXor, matchBitOpTree(nodep)}", "DONE");
|
||||
TREEOPV("AstOneHot{$lhsp.width1}", "replaceWLhs(nodep)");
|
||||
TREEOPV("AstOneHot0{$lhsp.width1}", "replaceNum(nodep,1)");
|
||||
|
|
@ -3365,7 +3360,7 @@ private:
|
|||
TREEOPV("AstConcat{operandConcatMove(nodep)}", "moveConcat(nodep)");
|
||||
TREEOPV("AstConcat{$lhsp.isZero, $rhsp}", "replaceExtend(nodep, nodep->rhsp())");
|
||||
// CONCAT(a[1],a[0]) -> a[1:0]
|
||||
TREEOPV("AstConcat{$lhsp.castSel, $rhsp.castSel, ifAdjacentSel(VN_CAST($lhsp,,Sel),,VN_CAST($rhsp,,Sel))}", "replaceConcatSel(nodep)");
|
||||
TREEOPV("AstConcat{$lhsp.castSel, $rhsp.castSel, ifAdjacentSel(VN_AS($lhsp,,Sel),,VN_AS($rhsp,,Sel))}", "replaceConcatSel(nodep)");
|
||||
TREEOPV("AstConcat{ifConcatMergeableBiop($lhsp), concatMergeable($lhsp,,$rhsp)}", "replaceConcatMerge(nodep)");
|
||||
// Common two-level operations that can be simplified
|
||||
TREEOP ("AstAnd {$lhsp.castConst,matchAndCond(nodep)}", "DONE");
|
||||
|
|
@ -3382,8 +3377,8 @@ private:
|
|||
TREEOPC("AstXor {matchBitOpTree(nodep)}", "DONE");
|
||||
// Note can't simplify a extend{extends}, extends{extend}, as the sign
|
||||
// bits end up in the wrong places
|
||||
TREEOPV("AstExtend {$lhsp.castExtend}", "replaceExtend(nodep, VN_CAST(nodep->lhsp(), Extend)->lhsp())");
|
||||
TREEOPV("AstExtendS{$lhsp.castExtendS}", "replaceExtend(nodep, VN_CAST(nodep->lhsp(), ExtendS)->lhsp())");
|
||||
TREEOPV("AstExtend {$lhsp.castExtend}", "replaceExtend(nodep, VN_AS(nodep->lhsp(), Extend)->lhsp())");
|
||||
TREEOPV("AstExtendS{$lhsp.castExtendS}", "replaceExtend(nodep, VN_AS(nodep->lhsp(), ExtendS)->lhsp())");
|
||||
TREEOPV("AstReplicate{$lhsp, $rhsp.isOne, $lhsp->width()==nodep->width()}", "replaceWLhs(nodep)"); // {1{lhs}}->lhs
|
||||
TREEOPV("AstReplicateN{$lhsp, $rhsp.isOne, $lhsp->width()==nodep->width()}", "replaceWLhs(nodep)"); // {1{lhs}}->lhs
|
||||
TREEOPV("AstReplicate{$lhsp.castReplicate, operandRepRep(nodep)}", "DONE"); // {2{3{lhs}}}->{6{lhs}}
|
||||
|
|
@ -3417,7 +3412,7 @@ private:
|
|||
// Strings
|
||||
TREEOPA("AstPutcN{$lhsp.castConst, $rhsp.castConst, $thsp.castConst}", "replaceConst(nodep)");
|
||||
TREEOPA("AstSubstrN{$lhsp.castConst, $rhsp.castConst, $thsp.castConst}", "replaceConst(nodep)");
|
||||
TREEOPA("AstCvtPackString{$lhsp.castConst}", "replaceConstString(nodep, VN_CAST(nodep->lhsp(), Const)->num().toString())");
|
||||
TREEOPA("AstCvtPackString{$lhsp.castConst}", "replaceConstString(nodep, VN_AS(nodep->lhsp(), Const)->num().toString())");
|
||||
// Custom
|
||||
// Implied by AstIsUnbounded::numberOperate: V("AstIsUnbounded{$lhsp.castConst}", "replaceNum(nodep, 0)");
|
||||
TREEOPV("AstIsUnbounded{$lhsp.castUnbounded}", "replaceNum(nodep, 1)");
|
||||
|
|
|
|||
|
|
@ -352,7 +352,7 @@ private:
|
|||
} else if (AstStructDType* adtypep = VN_CAST(dtypep, StructDType)) {
|
||||
// For now it's packed, so similar to array
|
||||
for (AstMemberDType* itemp = adtypep->membersp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), MemberDType)) {
|
||||
itemp = VN_AS(itemp->nextp(), MemberDType)) {
|
||||
AstNodeDType* subtypep = itemp->subDTypep()->skipRefp();
|
||||
const int index_code = itemp->lsb();
|
||||
ToggleEnt newent(above.m_comment + string(".") + itemp->name(),
|
||||
|
|
@ -387,7 +387,7 @@ private:
|
|||
// An else-if. When we iterate the if, use "elsif" marking
|
||||
const bool elsif
|
||||
= nodep->ifsp() && VN_IS(nodep->elsesp(), If) && !nodep->elsesp()->nextp();
|
||||
if (elsif) VN_CAST(nodep->elsesp(), If)->user1(true);
|
||||
if (elsif) VN_AS(nodep->elsesp(), If)->user1(true);
|
||||
const bool first_elsif = !nodep->user1() && elsif;
|
||||
const bool cont_elsif = nodep->user1() && elsif;
|
||||
const bool final_elsif = nodep->user1() && !elsif && nodep->elsesp();
|
||||
|
|
|
|||
|
|
@ -64,7 +64,7 @@ private:
|
|||
// Note hashed will point to the original variable (what's
|
||||
// duplicated), not the covertoggle, but we need to get back to the
|
||||
// covertoggle which is immediately above, so:
|
||||
AstCoverToggle* removep = VN_CAST(duporigp->backp(), CoverToggle);
|
||||
AstCoverToggle* removep = VN_AS(duporigp->backp(), CoverToggle);
|
||||
UASSERT_OBJ(removep, nodep, "CoverageJoin duplicate of wrong type");
|
||||
UINFO(8, " Orig " << nodep << " -->> " << nodep->incp()->declp() << endl);
|
||||
UINFO(8, " dup " << removep << " -->> " << removep->incp()->declp() << endl);
|
||||
|
|
|
|||
|
|
@ -310,7 +310,7 @@ private:
|
|||
retry = false;
|
||||
AstNodeModule* nextmodp;
|
||||
for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp = nextmodp) {
|
||||
nextmodp = VN_CAST(modp->nextp(), NodeModule);
|
||||
nextmodp = VN_AS(modp->nextp(), NodeModule);
|
||||
if (modp->dead()
|
||||
|| (modp->level() > 2 && modp->user1() == 0 && !modp->internal())) {
|
||||
// > 2 because L1 is the wrapper, L2 is the top user module
|
||||
|
|
@ -418,7 +418,7 @@ private:
|
|||
if ((classp = VN_CAST((*it), NodeUOrStructDType))) {
|
||||
bool cont = true;
|
||||
for (AstMemberDType* memberp = classp->membersp(); memberp;
|
||||
memberp = VN_CAST(memberp->nextp(), MemberDType)) {
|
||||
memberp = VN_AS(memberp->nextp(), MemberDType)) {
|
||||
if (memberp->user1() != 0) {
|
||||
cont = false;
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -206,10 +206,10 @@ private:
|
|||
AstSel* bitselp = nullptr;
|
||||
AstArraySel* arrayselp = nullptr;
|
||||
if (VN_IS(lhsp, Sel)) {
|
||||
bitselp = VN_CAST(lhsp, Sel);
|
||||
arrayselp = VN_CAST(bitselp->fromp(), ArraySel);
|
||||
bitselp = VN_AS(lhsp, Sel);
|
||||
arrayselp = VN_AS(bitselp->fromp(), ArraySel);
|
||||
} else {
|
||||
arrayselp = VN_CAST(lhsp, ArraySel);
|
||||
arrayselp = VN_AS(lhsp, ArraySel);
|
||||
}
|
||||
UASSERT_OBJ(arrayselp, nodep, "No arraysel under bitsel?");
|
||||
UASSERT_OBJ(!VN_IS(arrayselp->dtypep()->skipRefp(), UnpackArrayDType), nodep,
|
||||
|
|
@ -219,11 +219,11 @@ private:
|
|||
//=== Dimensions: __Vdlyvdim__
|
||||
std::deque<AstNode*> dimvalp; // Assignment value for each dimension of assignment
|
||||
AstNode* dimselp = arrayselp;
|
||||
for (; VN_IS(dimselp, ArraySel); dimselp = VN_CAST(dimselp, ArraySel)->fromp()) {
|
||||
AstNode* valp = VN_CAST(dimselp, ArraySel)->bitp()->unlinkFrBack();
|
||||
for (; VN_IS(dimselp, ArraySel); dimselp = VN_AS(dimselp, ArraySel)->fromp()) {
|
||||
AstNode* valp = VN_AS(dimselp, ArraySel)->bitp()->unlinkFrBack();
|
||||
dimvalp.push_front(valp);
|
||||
}
|
||||
AstVarRef* varrefp = VN_CAST(dimselp, VarRef);
|
||||
AstVarRef* varrefp = VN_AS(dimselp, VarRef);
|
||||
UASSERT_OBJ(varrefp, nodep, "No var underneath arraysels");
|
||||
UASSERT_OBJ(varrefp->varScopep(), varrefp, "Var didn't get varscoped in V3Scope.cpp");
|
||||
varrefp->unlinkFrBack();
|
||||
|
|
@ -291,7 +291,7 @@ private:
|
|||
// then we told this nodep->user3 we can use its Vdlyvset rather than making a new one.
|
||||
// This is good for code like:
|
||||
// for (i=0; i<5; i++) vector[i] <= something;
|
||||
setvscp = VN_CAST(nodep->user3p(), VarScope);
|
||||
setvscp = VN_AS(nodep->user3p(), VarScope);
|
||||
++m_statSharedSet;
|
||||
} else { // Create new one
|
||||
string setvarname
|
||||
|
|
@ -325,9 +325,9 @@ private:
|
|||
// Build "IF (changeit) ...
|
||||
UINFO(9, " For " << setvscp << endl);
|
||||
UINFO(9, " & " << varrefp << endl);
|
||||
AstAlwaysPost* finalp = VN_CAST(varrefp->varScopep()->user4p(), AlwaysPost);
|
||||
AstAlwaysPost* finalp = VN_AS(varrefp->varScopep()->user4p(), AlwaysPost);
|
||||
if (finalp) {
|
||||
AstActive* oldactivep = VN_CAST(finalp->user2p(), Active);
|
||||
AstActive* oldactivep = VN_AS(finalp->user2p(), Active);
|
||||
checkActivePost(varrefp, oldactivep);
|
||||
if (setinitp) oldactivep->addStmtsp(setinitp);
|
||||
} else { // first time we've dealt with this memory
|
||||
|
|
@ -343,7 +343,7 @@ private:
|
|||
if (finalp->user3p() == setvscp) {
|
||||
// Optimize as above; if sharing Vdlyvset *ON SAME VARIABLE*,
|
||||
// we can share the IF statement too
|
||||
postLogicp = VN_CAST(finalp->user4p(), If);
|
||||
postLogicp = VN_AS(finalp->user4p(), If);
|
||||
UASSERT_OBJ(postLogicp, nodep,
|
||||
"Delayed assignment misoptimized; prev var found w/o associated IF");
|
||||
} else {
|
||||
|
|
@ -397,7 +397,7 @@ private:
|
|||
}
|
||||
if (VN_IS(nodep->lhsp(), ArraySel)
|
||||
|| (VN_IS(nodep->lhsp(), Sel)
|
||||
&& VN_IS(VN_CAST(nodep->lhsp(), Sel)->fromp(), ArraySel))) {
|
||||
&& VN_IS(VN_AS(nodep->lhsp(), Sel)->fromp(), ArraySel))) {
|
||||
AstNode* lhsp = nodep->lhsp()->unlinkFrBack();
|
||||
AstNode* newlhsp = createDlyArray(nodep, lhsp);
|
||||
if (m_inLoop) {
|
||||
|
|
@ -434,9 +434,9 @@ private:
|
|||
}
|
||||
AstVarScope* oldvscp = nodep->varScopep();
|
||||
UASSERT_OBJ(oldvscp, nodep, "Var didn't get varscoped in V3Scope.cpp");
|
||||
AstVarScope* dlyvscp = VN_CAST(oldvscp->user1p(), VarScope);
|
||||
AstVarScope* dlyvscp = VN_AS(oldvscp->user1p(), VarScope);
|
||||
if (dlyvscp) { // Multiple use of delayed variable
|
||||
AstActive* oldactivep = VN_CAST(dlyvscp->user2p(), Active);
|
||||
AstActive* oldactivep = VN_AS(dlyvscp->user2p(), Active);
|
||||
checkActivePost(nodep, oldactivep);
|
||||
}
|
||||
if (!dlyvscp) { // First use of this delayed variable
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ EmitCParentModule::EmitCParentModule() {
|
|||
}
|
||||
};
|
||||
for (AstNode* modp = v3Global.rootp()->modulesp(); modp; modp = modp->nextp()) {
|
||||
setAll(VN_CAST(modp, NodeModule));
|
||||
setAll(VN_AS(modp, NodeModule));
|
||||
}
|
||||
setAll(v3Global.rootp()->constPoolp()->modp());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
VL_UNCOPYABLE(EmitCParentModule);
|
||||
|
||||
static const AstNodeModule* get(const AstNode* nodep) {
|
||||
return VN_CAST_CONST(nodep->user4p(), NodeModule);
|
||||
return VN_AS_CONST(nodep->user4p(), NodeModule);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ protected:
|
|||
// VISITORS
|
||||
virtual void visit(AstInitArray* nodep) override {
|
||||
const AstUnpackArrayDType* const dtypep
|
||||
= VN_CAST(nodep->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
= VN_AS(nodep->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
UASSERT_OBJ(dtypep, nodep, "Array initializer has non-array dtype");
|
||||
const uint32_t size = dtypep->elementsConst();
|
||||
const uint32_t elemBytes = dtypep->subDTypep()->widthTotalBytes();
|
||||
|
|
|
|||
|
|
@ -629,15 +629,14 @@ void EmitCFunc::emitVarReset(AstVar* varp) {
|
|||
if (initarp->defaultp()) {
|
||||
puts("for (int __Vi=0; __Vi<" + cvtToStr(adtypep->elementsConst()));
|
||||
puts("; ++__Vi) {\n");
|
||||
emitSetVarConstant(varNameProtected + "[__Vi]",
|
||||
VN_CAST(initarp->defaultp(), Const));
|
||||
emitSetVarConstant(varNameProtected + "[__Vi]", VN_AS(initarp->defaultp(), Const));
|
||||
puts("}\n");
|
||||
}
|
||||
const AstInitArray::KeyItemMap& mapr = initarp->map();
|
||||
for (const auto& itr : mapr) {
|
||||
AstNode* valuep = itr.second->valuep();
|
||||
emitSetVarConstant(varNameProtected + "[" + cvtToStr(itr.first) + "]",
|
||||
VN_CAST(valuep, Const));
|
||||
VN_AS(valuep, Const));
|
||||
}
|
||||
} else {
|
||||
varp->v3fatalSrc("InitArray under non-arrayed var");
|
||||
|
|
@ -692,7 +691,7 @@ string EmitCFunc::emitVarResetRecurse(const AstVar* varp, const string& varNameP
|
|||
if (dtypep->isWide()) { // Handle unpacked; not basicp->isWide
|
||||
string out;
|
||||
if (varp->valuep()) {
|
||||
AstConst* const constp = VN_CAST(varp->valuep(), Const);
|
||||
AstConst* const constp = VN_AS(varp->valuep(), Const);
|
||||
if (!constp) varp->v3fatalSrc("non-const initializer for variable");
|
||||
for (int w = 0; w < varp->widthWords(); ++w) {
|
||||
out += varNameProtected + suffix + "[" + cvtToStr(w) + "] = ";
|
||||
|
|
@ -792,7 +791,7 @@ void EmitCFunc::emitChangeDet() {
|
|||
doubleOrDetect(nodep, gotOneIgnore);
|
||||
string varname;
|
||||
if (VN_IS(nodep->lhsp(), VarRef)) {
|
||||
varname = ": " + VN_CAST(nodep->lhsp(), VarRef)->varp()->prettyName();
|
||||
varname = ": " + VN_AS(nodep->lhsp(), VarRef)->varp()->prettyName();
|
||||
}
|
||||
puts(")) VL_DBG_MSGF(\" CHANGE: ");
|
||||
puts(protect(nodep->fileline()->filename()));
|
||||
|
|
|
|||
|
|
@ -323,7 +323,7 @@ public:
|
|||
&& !VN_IS(nodep->rhsp(), AssocSel) //
|
||||
&& !VN_IS(nodep->rhsp(), ArraySel)) {
|
||||
// Wide functions assign into the array directly, don't need separate assign statement
|
||||
m_wideTempRefp = VN_CAST(nodep->lhsp(), VarRef);
|
||||
m_wideTempRefp = VN_AS(nodep->lhsp(), VarRef);
|
||||
paren = false;
|
||||
} else if (nodep->isWide()) {
|
||||
putbs("VL_ASSIGN_W(");
|
||||
|
|
@ -348,7 +348,7 @@ public:
|
|||
virtual void visit(AstAssocSel* nodep) override {
|
||||
iterateAndNextNull(nodep->fromp());
|
||||
putbs(".at(");
|
||||
AstAssocArrayDType* adtypep = VN_CAST(nodep->fromp()->dtypep(), AssocArrayDType);
|
||||
AstAssocArrayDType* 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());
|
||||
|
|
@ -898,7 +898,7 @@ public:
|
|||
}
|
||||
}
|
||||
virtual void visit(AstTextBlock* nodep) override {
|
||||
visit(VN_CAST(nodep, NodeSimpleText));
|
||||
visit(VN_AS(nodep, NodeSimpleText));
|
||||
for (AstNode* childp = nodep->nodesp(); childp; childp = childp->nextp()) {
|
||||
iterate(childp);
|
||||
if (nodep->commas() && childp->nextp()) puts(", ");
|
||||
|
|
@ -978,7 +978,7 @@ public:
|
|||
}
|
||||
virtual void visit(AstRedXor* nodep) override {
|
||||
if (nodep->lhsp()->isWide()) {
|
||||
visit(VN_CAST(nodep, NodeUniop));
|
||||
visit(VN_AS(nodep, NodeUniop));
|
||||
} else {
|
||||
AstVarRef* const vrefp = VN_CAST(nodep->lhsp(), VarRef);
|
||||
const int widthPow2 = vrefp ? vrefp->varp()->dtypep()->widthPow2()
|
||||
|
|
@ -1042,7 +1042,7 @@ public:
|
|||
}
|
||||
virtual void visit(AstReplicate* nodep) override {
|
||||
if (nodep->lhsp()->widthMin() == 1 && !nodep->isWide()) {
|
||||
UASSERT_OBJ((static_cast<int>(VN_CAST(nodep->rhsp(), Const)->toUInt())
|
||||
UASSERT_OBJ((static_cast<int>(VN_AS(nodep->rhsp(), Const)->toUInt())
|
||||
* nodep->lhsp()->widthMin())
|
||||
== nodep->widthMin(),
|
||||
nodep, "Replicate non-constant or width miscomputed");
|
||||
|
|
@ -1064,8 +1064,8 @@ public:
|
|||
virtual void visit(AstStreamL* nodep) override {
|
||||
// Attempt to use a "fast" stream function for slice size = power of 2
|
||||
if (!nodep->isWide()) {
|
||||
uint32_t isPow2 = VN_CAST(nodep->rhsp(), Const)->num().countOnes() == 1;
|
||||
uint32_t sliceSize = VN_CAST(nodep->rhsp(), Const)->toUInt();
|
||||
uint32_t isPow2 = VN_AS(nodep->rhsp(), Const)->num().countOnes() == 1;
|
||||
uint32_t sliceSize = VN_AS(nodep->rhsp(), Const)->toUInt();
|
||||
if (isPow2 && sliceSize <= (nodep->isQuad() ? sizeof(uint64_t) : sizeof(uint32_t))) {
|
||||
puts("VL_STREAML_FAST_");
|
||||
emitIQW(nodep);
|
||||
|
|
@ -1077,7 +1077,7 @@ public:
|
|||
puts(",");
|
||||
iterateAndNextNull(nodep->lhsp());
|
||||
puts(", ");
|
||||
uint32_t rd_log2 = V3Number::log2b(VN_CAST(nodep->rhsp(), Const)->toUInt());
|
||||
uint32_t rd_log2 = V3Number::log2b(VN_AS(nodep->rhsp(), Const)->toUInt());
|
||||
puts(cvtToStr(rd_log2) + ")");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -191,7 +191,7 @@ class EmitCHeader final : public EmitCConstInit {
|
|||
} else {
|
||||
puts("enum " + tdefp->name() + " {\n");
|
||||
for (const AstEnumItem* itemp = edtypep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), EnumItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), EnumItem)) {
|
||||
puts(itemp->nameProtect());
|
||||
puts(" = ");
|
||||
iterate(itemp->valuep());
|
||||
|
|
@ -335,6 +335,6 @@ void V3EmitC::emitcHeaders() {
|
|||
// Process each module in turn
|
||||
for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) {
|
||||
if (VN_IS(nodep, Class)) continue; // Declared with the ClassPackage
|
||||
EmitCHeader::main(VN_CAST_CONST(nodep, NodeModule));
|
||||
EmitCHeader::main(VN_AS_CONST(nodep, NodeModule));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -446,7 +446,7 @@ class EmitCImp final : EmitCFunc {
|
|||
}
|
||||
void emitCommonImp(const AstNodeModule* modp) {
|
||||
const AstClass* const classp
|
||||
= VN_IS(modp, ClassPackage) ? VN_CAST_CONST(modp, ClassPackage)->classp() : nullptr;
|
||||
= VN_IS(modp, ClassPackage) ? VN_AS_CONST(modp, ClassPackage)->classp() : nullptr;
|
||||
|
||||
if (hasCommonImp(modp) || hasCommonImp(classp)) {
|
||||
std::set<string> headers;
|
||||
|
|
@ -724,7 +724,7 @@ class EmitCTrace final : EmitCFunc {
|
|||
puts("const char* " + protect("__VenumItemNames") + "[]\n");
|
||||
puts("= {");
|
||||
for (AstEnumItem* itemp = enump->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), EnumItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), EnumItem)) {
|
||||
if (++nvals > 1) puts(", ");
|
||||
putbs("\"" + itemp->prettyName() + "\"");
|
||||
}
|
||||
|
|
@ -733,8 +733,8 @@ class EmitCTrace final : EmitCFunc {
|
|||
puts("const char* " + protect("__VenumItemValues") + "[]\n");
|
||||
puts("= {");
|
||||
for (AstEnumItem* itemp = enump->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), EnumItem)) {
|
||||
AstConst* constp = VN_CAST(itemp->valuep(), Const);
|
||||
itemp = VN_AS(itemp->nextp(), EnumItem)) {
|
||||
AstConst* constp = VN_AS(itemp->valuep(), Const);
|
||||
if (++nvals > 1) puts(", ");
|
||||
putbs("\"" + constp->num().displayed(nodep, "%0b") + "\"");
|
||||
}
|
||||
|
|
@ -887,7 +887,7 @@ void V3EmitC::emitcImp() {
|
|||
// Process each module in turn
|
||||
for (const AstNode* nodep = v3Global.rootp()->modulesp(); nodep; nodep = nodep->nextp()) {
|
||||
if (VN_IS(nodep, Class)) continue; // Imped with ClassPackage
|
||||
const AstNodeModule* const modp = VN_CAST_CONST(nodep, NodeModule);
|
||||
const AstNodeModule* const modp = VN_AS_CONST(nodep, NodeModule);
|
||||
EmitCImp::main(modp, /* slow: */ true);
|
||||
EmitCImp::main(modp, /* slow: */ false);
|
||||
}
|
||||
|
|
@ -902,7 +902,7 @@ void V3EmitC::emitcImp() {
|
|||
void V3EmitC::emitcFiles() {
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
for (AstNodeFile* filep = v3Global.rootp()->filesp(); filep;
|
||||
filep = VN_CAST(filep->nextp(), NodeFile)) {
|
||||
filep = VN_AS(filep->nextp(), NodeFile)) {
|
||||
AstCFile* cfilep = VN_CAST(filep, CFile);
|
||||
if (cfilep && cfilep->tblockp()) {
|
||||
V3OutCFile of(cfilep->name());
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ class CMakeEmitter final {
|
|||
std::vector<string> support_slow;
|
||||
std::vector<string> global;
|
||||
for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep;
|
||||
nodep = VN_CAST(nodep->nextp(), NodeFile)) {
|
||||
nodep = VN_AS(nodep->nextp(), NodeFile)) {
|
||||
AstCFile* cfilep = VN_CAST(nodep, CFile);
|
||||
if (cfilep && cfilep->source()) {
|
||||
if (cfilep->support()) {
|
||||
|
|
|
|||
|
|
@ -124,8 +124,8 @@ class EmitCSyms final : EmitCBaseVisitor {
|
|||
// Prevent GCC compile time error; name check all things that reach C++ code
|
||||
if (nodep->name() != ""
|
||||
&& !(VN_IS(nodep, CFunc)
|
||||
&& (VN_CAST(nodep, CFunc)->isConstructor()
|
||||
|| VN_CAST(nodep, CFunc)->isDestructor()))) {
|
||||
&& (VN_AS(nodep, CFunc)->isConstructor()
|
||||
|| VN_AS(nodep, CFunc)->isDestructor()))) {
|
||||
const string rsvd = V3LanguageWords::isKeyword(nodep->name());
|
||||
if (rsvd != "") {
|
||||
// Generally V3Name should find all of these and throw SYMRSVDWORD.
|
||||
|
|
@ -402,7 +402,7 @@ void EmitCSyms::emitSymHdr() {
|
|||
|
||||
puts("\n// INCLUDE MODULE CLASSES\n");
|
||||
for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep;
|
||||
nodep = VN_CAST(nodep->nextp(), NodeModule)) {
|
||||
nodep = VN_AS(nodep->nextp(), NodeModule)) {
|
||||
if (VN_IS(nodep, Class)) continue; // Class included earlier
|
||||
puts("#include \"" + prefixNameProtect(nodep) + ".h\"\n");
|
||||
}
|
||||
|
|
@ -584,7 +584,7 @@ void EmitCSyms::emitSymImpPreamble() {
|
|||
puts("#include \"" + symClassName() + ".h\"\n");
|
||||
puts("#include \"" + topClassName() + ".h\"\n");
|
||||
for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep;
|
||||
nodep = VN_CAST(nodep->nextp(), NodeModule)) {
|
||||
nodep = VN_AS(nodep->nextp(), NodeModule)) {
|
||||
if (VN_IS(nodep, Class)) continue; // Class included earlier
|
||||
puts("#include \"" + prefixNameProtect(nodep) + ".h\"\n");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ public:
|
|||
} else if (support == 2 && slow) {
|
||||
} else {
|
||||
for (AstNodeFile* nodep = v3Global.rootp()->filesp(); nodep;
|
||||
nodep = VN_CAST(nodep->nextp(), NodeFile)) {
|
||||
nodep = VN_AS(nodep->nextp(), NodeFile)) {
|
||||
AstCFile* cfilep = VN_CAST(nodep, CFile);
|
||||
if (cfilep && cfilep->source() && cfilep->slow() == (slow != 0)
|
||||
&& cfilep->support() == (support != 0)) {
|
||||
|
|
|
|||
|
|
@ -382,7 +382,7 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||
}
|
||||
}
|
||||
virtual void visit(AstTextBlock* nodep) override {
|
||||
visit(VN_CAST(nodep, NodeSimpleText));
|
||||
visit(VN_AS(nodep, NodeSimpleText));
|
||||
{
|
||||
VL_RESTORER(m_suppressSemi);
|
||||
m_suppressVarSemi = nodep->commas();
|
||||
|
|
@ -538,15 +538,15 @@ class EmitVBaseVisitor VL_NOT_FINAL : public EmitCBaseVisitor {
|
|||
if (VN_IS(nodep->lsbp(), Const)) {
|
||||
if (nodep->widthp()->isOne()) {
|
||||
if (VN_IS(nodep->lsbp(), Const)) {
|
||||
puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt()));
|
||||
puts(cvtToStr(VN_AS(nodep->lsbp(), Const)->toSInt()));
|
||||
} else {
|
||||
iterateAndNextNull(nodep->lsbp());
|
||||
}
|
||||
} else {
|
||||
puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt()
|
||||
+ VN_CAST(nodep->widthp(), Const)->toSInt() - 1));
|
||||
puts(cvtToStr(VN_AS(nodep->lsbp(), Const)->toSInt()
|
||||
+ VN_AS(nodep->widthp(), Const)->toSInt() - 1));
|
||||
puts(":");
|
||||
puts(cvtToStr(VN_CAST(nodep->lsbp(), Const)->toSInt()));
|
||||
puts(cvtToStr(VN_AS(nodep->lsbp(), Const)->toSInt()));
|
||||
}
|
||||
} else {
|
||||
iterateAndNextNull(nodep->lsbp());
|
||||
|
|
@ -837,7 +837,7 @@ void V3EmitV::verilogPrefixedTree(AstNode* nodep, std::ostream& os, const string
|
|||
void V3EmitV::emitvFiles() {
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
for (AstNodeFile* filep = v3Global.rootp()->filesp(); filep;
|
||||
filep = VN_CAST(filep->nextp(), NodeFile)) {
|
||||
filep = VN_AS(filep->nextp(), NodeFile)) {
|
||||
AstVFile* vfilep = VN_CAST(filep, VFile);
|
||||
if (vfilep && vfilep->tblockp()) {
|
||||
V3OutVFile of(vfilep->name());
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ private:
|
|||
static void fixCloneLvalue(AstNode* nodep) {
|
||||
// In AstSel transforms, we call clone() on VarRefs that were lvalues,
|
||||
// but are now being used on the RHS of the assignment
|
||||
if (VN_IS(nodep, VarRef)) VN_CAST(nodep, VarRef)->access(VAccess::READ);
|
||||
if (VN_IS(nodep, VarRef)) VN_AS(nodep, VarRef)->access(VAccess::READ);
|
||||
// Iterate
|
||||
if (nodep->op1p()) fixCloneLvalue(nodep->op1p());
|
||||
if (nodep->op2p()) fixCloneLvalue(nodep->op2p());
|
||||
|
|
@ -183,8 +183,7 @@ private:
|
|||
AstNode* wordp;
|
||||
FileLine* const lfl = lsbp->fileline();
|
||||
if (VN_IS(lsbp, Const)) {
|
||||
wordp
|
||||
= new AstConst{lfl, wordOffset + VL_BITWORD_E(VN_CAST(lsbp, Const)->toUInt())};
|
||||
wordp = new AstConst{lfl, wordOffset + VL_BITWORD_E(VN_AS(lsbp, Const)->toUInt())};
|
||||
} else {
|
||||
wordp = new AstShiftR{lfl, lsbp->cloneTree(true),
|
||||
new AstConst{lfl, VL_EDATASIZE_LOG2}, VL_EDATASIZE};
|
||||
|
|
@ -202,8 +201,8 @@ private:
|
|||
// If there's a CONDBOUND safety to keep arrays in bounds,
|
||||
// we're going to AND it to a value that always fits inside a
|
||||
// word, so we don't need it.
|
||||
// if (VN_IS(nodep, CondBound) && VN_IS(VN_CAST(nodep, CondBound)->lhsp(), Lte)) {
|
||||
// nodep = VN_CAST(nodep, CondBound)->rhsp();
|
||||
// if (VN_IS(nodep, CondBound) && VN_IS(VN_AS(nodep, CondBound)->lhsp(), Lte)) {
|
||||
// nodep = VN_AS(nodep, CondBound)->rhsp();
|
||||
//}
|
||||
return nodep;
|
||||
}
|
||||
|
|
@ -212,7 +211,7 @@ private:
|
|||
// Return equation to get the VL_BITBIT of a constant or non-constant
|
||||
FileLine* const fl = lsbp->fileline();
|
||||
if (VN_IS(lsbp, Const)) {
|
||||
return new AstConst{fl, VL_BITBIT_E(VN_CAST(lsbp, Const)->toUInt())};
|
||||
return new AstConst{fl, VL_BITBIT_E(VN_AS(lsbp, Const)->toUInt())};
|
||||
} else {
|
||||
return new AstAnd{fl, new AstConst{fl, VL_EDATASIZE - 1},
|
||||
dropCondBound(lsbp)->cloneTree(true)};
|
||||
|
|
@ -346,7 +345,7 @@ private:
|
|||
// Remember, Sel's may have non-integer rhs, so need to optimize for that!
|
||||
UASSERT_OBJ(nodep->widthMin() == nodep->widthConst(), nodep, "Width mismatch");
|
||||
if (VN_IS(nodep->backp(), NodeAssign)
|
||||
&& nodep == VN_CAST(nodep->backp(), NodeAssign)->lhsp()) {
|
||||
&& nodep == VN_AS(nodep->backp(), NodeAssign)->lhsp()) {
|
||||
// Sel is an LHS assignment select
|
||||
} else if (nodep->isWide()) {
|
||||
// See under ASSIGN(WIDE)
|
||||
|
|
@ -679,7 +678,7 @@ private:
|
|||
newp = new AstNegate{fl, lhsp};
|
||||
} else {
|
||||
UINFO(8, " REPLICATE " << nodep << endl);
|
||||
const AstConst* constp = VN_CAST(nodep->rhsp(), Const);
|
||||
const AstConst* constp = VN_AS(nodep->rhsp(), Const);
|
||||
UASSERT_OBJ(constp, nodep,
|
||||
"Replication value isn't a constant. Checked earlier!");
|
||||
uint32_t times = constp->toUInt();
|
||||
|
|
@ -707,7 +706,7 @@ private:
|
|||
FileLine* const fl = nodep->fileline();
|
||||
AstNode* const lhsp = rhsp->lhsp();
|
||||
const int lhswidth = lhsp->widthMin();
|
||||
const AstConst* const constp = VN_CAST(rhsp->rhsp(), Const);
|
||||
const AstConst* const constp = VN_AS(rhsp->rhsp(), Const);
|
||||
UASSERT_OBJ(constp, rhsp, "Replication value isn't a constant. Checked earlier!");
|
||||
const uint32_t times = constp->toUInt();
|
||||
for (int w = 0; w < rhsp->widthWords(); ++w) {
|
||||
|
|
|
|||
|
|
@ -249,14 +249,12 @@ private:
|
|||
// This avoids a mess in computing what exactly a POSEDGE is
|
||||
// V3Const cleans up any NOTs by flipping the edges for us
|
||||
if (m_buffersOnly
|
||||
&& !(VN_IS(nodep->rhsp(), VarRef)
|
||||
// Avoid making non-clocked logic into clocked,
|
||||
// as it slows down the verilator_sim_benchmark
|
||||
|| (VN_IS(nodep->rhsp(), Not)
|
||||
&& VN_IS(VN_CAST(nodep->rhsp(), Not)->lhsp(), VarRef)
|
||||
&& VN_CAST(VN_CAST(nodep->rhsp(), Not)->lhsp(), VarRef)
|
||||
->varp()
|
||||
->isUsedClock()))) {
|
||||
&& !(
|
||||
VN_IS(nodep->rhsp(), VarRef)
|
||||
// Avoid making non-clocked logic into clocked,
|
||||
// as it slows down the verilator_sim_benchmark
|
||||
|| (VN_IS(nodep->rhsp(), Not) && VN_IS(VN_AS(nodep->rhsp(), Not)->lhsp(), VarRef)
|
||||
&& VN_AS(VN_AS(nodep->rhsp(), Not)->lhsp(), VarRef)->varp()->isUsedClock()))) {
|
||||
clearSimple("Not a buffer (goes to a clock)");
|
||||
}
|
||||
}
|
||||
|
|
@ -512,7 +510,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstConcat* nodep) override {
|
||||
UASSERT_OBJ(!(VN_IS(nodep->backp(), NodeAssign)
|
||||
&& VN_CAST(nodep->backp(), NodeAssign)->lhsp() == nodep),
|
||||
&& VN_AS(nodep->backp(), NodeAssign)->lhsp() == nodep),
|
||||
nodep, "Concat on LHS of assignment; V3Const should have deleted it");
|
||||
iterateChildren(nodep);
|
||||
}
|
||||
|
|
@ -996,7 +994,7 @@ public:
|
|||
// So dupit is either a different, duplicate rhsp, or the end of the hash.
|
||||
if (dupit != m_dupFinder.end()) {
|
||||
m_dupFinder.erase(inserted);
|
||||
return VN_CAST(dupit->second->user2p(), NodeAssign);
|
||||
return VN_AS(dupit->second->user2p(), NodeAssign);
|
||||
}
|
||||
// Retain new inserted information
|
||||
return nullptr;
|
||||
|
|
@ -1285,8 +1283,8 @@ private:
|
|||
if (AstNodeAssign* assignp = VN_CAST(lvertexp->nodep(), NodeAssign)) {
|
||||
// if (lvertexp->outSize1() && VN_IS(assignp->lhsp(), Sel)) {
|
||||
if (VN_IS(assignp->lhsp(), Sel) && lvertexp->outSize1()) {
|
||||
UINFO(9, "assing to the nodep["
|
||||
<< VN_CAST(assignp->lhsp(), Sel)->lsbConst() << "]" << endl);
|
||||
UINFO(9, "assing to the nodep[" << VN_AS(assignp->lhsp(), Sel)->lsbConst()
|
||||
<< "]" << endl);
|
||||
// first assign with Sel-lhs
|
||||
if (!m_activep) m_activep = lvertexp->activep();
|
||||
if (!m_logicvp) m_logicvp = lvertexp;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ private:
|
|||
// METHODS
|
||||
AstVarScope* genInpClk(AstVarScope* vscp) {
|
||||
if (vscp->user2p()) {
|
||||
return VN_CAST(vscp->user2p(), VarScope);
|
||||
return VN_AS(vscp->user2p(), VarScope);
|
||||
} else {
|
||||
// In order to create a __VinpClk* for a signal, it needs to be marked circular.
|
||||
// The DPI export trigger is never marked circular by V3Order (see comments in
|
||||
|
|
|
|||
|
|
@ -359,7 +359,7 @@ private:
|
|||
// Each inlined cell that contain an interface variable need to
|
||||
// copy the IfaceRefDType and point it to the newly cloned
|
||||
// interface cell.
|
||||
AstIfaceRefDType* newdp = VN_CAST(ifacerefp->cloneTree(false), IfaceRefDType);
|
||||
AstIfaceRefDType* newdp = VN_AS(ifacerefp->cloneTree(false), IfaceRefDType);
|
||||
nodep->dtypep(newdp);
|
||||
ifacerefp->addNextHere(newdp);
|
||||
// Relink to point to newly cloned cell
|
||||
|
|
@ -536,7 +536,7 @@ private:
|
|||
// Better off before, as if module has multiple instantiations
|
||||
// we'll save work, and we can't call pinReconnectSimple in
|
||||
// this loop as it clone()s itself.
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
V3Inst::pinReconnectSimple(pinp, nodep, false);
|
||||
}
|
||||
|
||||
|
|
@ -555,7 +555,7 @@ private:
|
|||
nodep->modp()->timeunit());
|
||||
m_modp->addInlinesp(inlinep); // Must be parsed before any AstCells
|
||||
// Create assignments to the pins
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (!pinp->exprp()) continue;
|
||||
UINFO(6, " Pin change from " << pinp->modVarp() << endl);
|
||||
// Make new signal; even though we'll optimize the interconnect, we
|
||||
|
|
@ -574,7 +574,7 @@ private:
|
|||
// Propagate any attributes across the interconnect
|
||||
pinNewVarp->propagateAttrFrom(pinOldVarp);
|
||||
if (VN_IS(connectRefp, VarRef)) {
|
||||
VN_CAST(connectRefp, VarRef)->varp()->propagateAttrFrom(pinOldVarp);
|
||||
VN_AS(connectRefp, VarRef)->varp()->propagateAttrFrom(pinOldVarp);
|
||||
}
|
||||
|
||||
// One to one interconnect won't make a temporary variable.
|
||||
|
|
@ -648,7 +648,7 @@ private:
|
|||
|
||||
if (AstModule* modp = VN_CAST(nodep->modp(), Module)) {
|
||||
// Pass Cell pointers down to the next module
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
AstVar* varp = pinp->modVarp();
|
||||
AstVarRef* varrefp = VN_CAST(pinp->exprp(), VarRef);
|
||||
if (!varrefp) continue;
|
||||
|
|
@ -720,7 +720,7 @@ void V3Inline::inlineAll(AstNetlist* nodep) {
|
|||
// idea to avoid dumping the hugely exploded tree.
|
||||
AstNodeModule* nextmodp;
|
||||
for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp; modp = nextmodp) {
|
||||
nextmodp = VN_CAST(modp->nextp(), NodeModule);
|
||||
nextmodp = VN_AS(modp->nextp(), NodeModule);
|
||||
if (modp->user1()) { // Was inlined
|
||||
VL_DO_DANGLING(modp->unlinkFrBack()->deleteTree(), modp);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -91,9 +91,9 @@ private:
|
|||
if (debug() >= 9) assp->dumpTree(cout, " _new: ");
|
||||
} else if (nodep->modVarp()->isIfaceRef()
|
||||
|| (VN_IS(nodep->modVarp()->subDTypep(), UnpackArrayDType)
|
||||
&& VN_IS(VN_CAST(nodep->modVarp()->subDTypep(), UnpackArrayDType)
|
||||
->subDTypep(),
|
||||
IfaceRefDType))) {
|
||||
&& VN_IS(
|
||||
VN_AS(nodep->modVarp()->subDTypep(), UnpackArrayDType)->subDTypep(),
|
||||
IfaceRefDType))) {
|
||||
// Create an AstAssignVarScope for Vars to Cells so we can
|
||||
// link with their scope later
|
||||
AstNode* lhsp = new AstVarXRef(exprp->fileline(), nodep->modVarp(),
|
||||
|
|
@ -202,16 +202,16 @@ private:
|
|||
// VISITORS
|
||||
virtual void visit(AstVar* nodep) override {
|
||||
if (VN_IS(nodep->dtypep(), UnpackArrayDType)
|
||||
&& VN_IS(VN_CAST(nodep->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType)) {
|
||||
&& VN_IS(VN_AS(nodep->dtypep(), UnpackArrayDType)->subDTypep(), IfaceRefDType)) {
|
||||
UINFO(8, " dv-vec-VAR " << nodep << endl);
|
||||
AstUnpackArrayDType* arrdtype = VN_CAST(nodep->dtypep(), UnpackArrayDType);
|
||||
AstUnpackArrayDType* arrdtype = VN_AS(nodep->dtypep(), UnpackArrayDType);
|
||||
AstNode* prevp = nullptr;
|
||||
for (int i = arrdtype->lo(); i <= arrdtype->hi(); ++i) {
|
||||
const string varNewName = nodep->name() + "__BRA__" + cvtToStr(i) + "__KET__";
|
||||
UINFO(8, "VAR name insert " << varNewName << " " << nodep << endl);
|
||||
if (!m_deModVars.find(varNewName)) {
|
||||
AstIfaceRefDType* ifaceRefp
|
||||
= VN_CAST(arrdtype->subDTypep(), IfaceRefDType)->cloneTree(false);
|
||||
= VN_AS(arrdtype->subDTypep(), IfaceRefDType)->cloneTree(false);
|
||||
arrdtype->addNextHere(ifaceRefp);
|
||||
ifaceRefp->cellp(nullptr);
|
||||
|
||||
|
|
@ -248,7 +248,7 @@ private:
|
|||
AstVar* ifaceVarp = VN_CAST(nodep->nextp(), Var);
|
||||
const bool isIface
|
||||
= ifaceVarp && VN_IS(ifaceVarp->dtypep(), UnpackArrayDType)
|
||||
&& VN_IS(VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(),
|
||||
&& VN_IS(VN_AS(ifaceVarp->dtypep(), UnpackArrayDType)->subDTypep(),
|
||||
IfaceRefDType);
|
||||
|
||||
// Make all of the required clones
|
||||
|
|
@ -271,9 +271,8 @@ private:
|
|||
// If this AstCell is actually an interface instantiation, also clone the IfaceRef
|
||||
// within the same parent module as the cell
|
||||
if (isIface) {
|
||||
AstUnpackArrayDType* arrdtype = VN_CAST(ifaceVarp->dtypep(), UnpackArrayDType);
|
||||
AstIfaceRefDType* origIfaceRefp
|
||||
= VN_CAST(arrdtype->subDTypep(), IfaceRefDType);
|
||||
AstUnpackArrayDType* arrdtype = VN_AS(ifaceVarp->dtypep(), UnpackArrayDType);
|
||||
AstIfaceRefDType* origIfaceRefp = VN_AS(arrdtype->subDTypep(), IfaceRefDType);
|
||||
origIfaceRefp->cellp(nullptr);
|
||||
AstVar* varNewp = ifaceVarp->cloneTree(false);
|
||||
AstIfaceRefDType* ifaceRefp = origIfaceRefp->cloneTree(false);
|
||||
|
|
@ -328,7 +327,7 @@ private:
|
|||
<< pinDim.second << endl);
|
||||
if (expDim.first == pinDim.first && expDim.second == pinDim.second + 1) {
|
||||
// Connection to array, where array dimensions match the instant dimension
|
||||
AstRange* rangep = VN_CAST(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep();
|
||||
AstRange* rangep = VN_AS(nodep->exprp()->dtypep(), UnpackArrayDType)->rangep();
|
||||
const int arraySelNum = rangep->littleEndian()
|
||||
? (rangep->elementsConst() - 1 - m_instSelNum)
|
||||
: m_instSelNum;
|
||||
|
|
@ -405,7 +404,7 @@ private:
|
|||
if (!pinVarp->backp()) {
|
||||
varNewp = m_deModVars.find(varNewName);
|
||||
} else {
|
||||
AstIfaceRefDType* ifaceRefp = VN_CAST(pinArrp->subDTypep(), IfaceRefDType);
|
||||
AstIfaceRefDType* ifaceRefp = VN_AS(pinArrp->subDTypep(), IfaceRefDType);
|
||||
ifaceRefp->cellp(nullptr);
|
||||
varNewp = pinVarp->cloneTree(false);
|
||||
varNewp->name(varNewName);
|
||||
|
|
@ -433,11 +432,11 @@ private:
|
|||
const AstVarRef* varrefp = VN_CAST(newp->exprp(), VarRef); // Maybe null
|
||||
int expr_i = i;
|
||||
if (AstSliceSel* slicep = VN_CAST(newp->exprp(), SliceSel)) {
|
||||
varrefp = VN_CAST(slicep->fromp(), VarRef);
|
||||
varrefp = VN_AS(slicep->fromp(), VarRef);
|
||||
UASSERT(VN_IS(slicep->rhsp(), Const), "Slices should be constant");
|
||||
int slice_index
|
||||
= slicep->declRange().left() + in * slicep->declRange().leftToRightInc();
|
||||
auto* exprArrp = VN_CAST(varrefp->dtypep(), UnpackArrayDType);
|
||||
auto* exprArrp = VN_AS(varrefp->dtypep(), UnpackArrayDType);
|
||||
UASSERT_OBJ(exprArrp, slicep, "Slice of non-array");
|
||||
expr_i = slice_index + exprArrp->lo();
|
||||
} else if (!varrefp) {
|
||||
|
|
@ -597,7 +596,7 @@ void V3Inst::checkOutputShort(AstPin* nodep) {
|
|||
if (nodep->modVarp()->direction() == VDirection::OUTPUT) {
|
||||
if (VN_IS(nodep->exprp(), Const) || VN_IS(nodep->exprp(), Extend)
|
||||
|| (VN_IS(nodep->exprp(), Concat)
|
||||
&& (VN_IS(VN_CAST(nodep->exprp(), Concat)->lhsp(), Const)))) {
|
||||
&& (VN_IS(VN_AS(nodep->exprp(), Concat)->lhsp(), Const)))) {
|
||||
// Uses v3warn for error, as might be found multiple times
|
||||
nodep->v3warn(E_PORTSHORT, "Output port is connected to a constant pin,"
|
||||
" electrical short");
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ public:
|
|||
m_assignp = assp;
|
||||
m_constp = nullptr;
|
||||
m_everSet = true;
|
||||
if (VN_IS(assp->rhsp(), Const)) m_constp = VN_CAST(assp->rhsp(), Const);
|
||||
if (VN_IS(assp->rhsp(), Const)) m_constp = VN_AS(assp->rhsp(), Const);
|
||||
}
|
||||
inline void complexAssign() { // A[x]=... or some complicated assignment
|
||||
m_assignp = nullptr;
|
||||
|
|
@ -313,7 +313,7 @@ private:
|
|||
}
|
||||
// Has to be direct assignment without any EXTRACTing.
|
||||
if (VN_IS(nodep->lhsp(), VarRef) && !m_sideEffect && !m_noopt) {
|
||||
AstVarScope* vscp = VN_CAST(nodep->lhsp(), VarRef)->varScopep();
|
||||
AstVarScope* vscp = VN_AS(nodep->lhsp(), VarRef)->varScopep();
|
||||
UASSERT_OBJ(vscp, nodep, "Scope lost on variable");
|
||||
m_lifep->simpleAssign(vscp, nodep);
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -187,8 +187,8 @@ private:
|
|||
void squashAssignposts() {
|
||||
for (auto& itr : m_assignposts) {
|
||||
LifePostLocation* app = &itr.second;
|
||||
AstVarRef* lhsp = VN_CAST(app->nodep->lhsp(), VarRef); // original var
|
||||
AstVarRef* rhsp = VN_CAST(app->nodep->rhsp(), VarRef); // dly var
|
||||
AstVarRef* lhsp = VN_AS(app->nodep->lhsp(), VarRef); // original var
|
||||
AstVarRef* rhsp = VN_AS(app->nodep->rhsp(), VarRef); // dly var
|
||||
AstVarScope* dlyVarp = rhsp->varScopep();
|
||||
AstVarScope* origVarp = lhsp->varScopep();
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ private:
|
|||
if (!foundp) {
|
||||
return nullptr;
|
||||
} else {
|
||||
return VN_CAST(foundp->nodep(), NodeModule);
|
||||
return VN_AS(foundp->nodep(), NodeModule);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -233,7 +233,7 @@ private:
|
|||
if (VN_IS(modp, Iface)) {
|
||||
// Track module depths, so can sort list from parent down to children
|
||||
new V3GraphEdge(&m_graph, vertex(m_modp), vertex(modp), 1, false);
|
||||
if (!nodep->cellp()) nodep->ifacep(VN_CAST(modp, Iface));
|
||||
if (!nodep->cellp()) nodep->ifacep(VN_AS(modp, Iface));
|
||||
} else if (VN_IS(modp, NotFoundModule)) { // Will error out later
|
||||
} else {
|
||||
nodep->v3error("Non-interface used as an interface: " << nodep->prettyNameQ());
|
||||
|
|
@ -349,7 +349,7 @@ private:
|
|||
// Convert .* to list of pins
|
||||
bool pinStar = false;
|
||||
for (AstPin *nextp, *pinp = nodep->pinsp(); pinp; pinp = nextp) {
|
||||
nextp = VN_CAST(pinp->nextp(), Pin);
|
||||
nextp = VN_AS(pinp->nextp(), Pin);
|
||||
if (pinp->dotStar()) {
|
||||
if (pinStar) pinp->v3error("Duplicate .* in an instance");
|
||||
pinStar = true;
|
||||
|
|
@ -358,10 +358,10 @@ private:
|
|||
}
|
||||
}
|
||||
// Convert unnamed pins to pin number based assignments
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (pinp->name() == "") pinp->name("__pinNumber" + cvtToStr(pinp->pinNum()));
|
||||
}
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
pinp->param(true);
|
||||
if (pinp->name() == "") pinp->name("__paramNumber" + cvtToStr(pinp->pinNum()));
|
||||
}
|
||||
|
|
@ -369,7 +369,7 @@ private:
|
|||
nodep->modName(nodep->modp()->name());
|
||||
// Note what pins exist
|
||||
std::unordered_set<string> ports; // Symbol table of all connected port names
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (pinp->name() == "")
|
||||
pinp->v3error("Connect by position is illegal in .* connected instances");
|
||||
if (!pinp->exprp()) {
|
||||
|
|
@ -449,7 +449,7 @@ private:
|
|||
}
|
||||
|
||||
virtual void visit(AstRefDType* nodep) override {
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
pinp->param(true);
|
||||
if (pinp->name() == "") pinp->name("__paramNumber" + cvtToStr(pinp->pinNum()));
|
||||
}
|
||||
|
|
@ -469,7 +469,7 @@ private:
|
|||
"information of the top module must exist if --hierarchical-child is set");
|
||||
// Look at all modules, and store pointers to all module names
|
||||
for (AstNodeModule *nextp, *nodep = v3Global.rootp()->modulesp(); nodep; nodep = nextp) {
|
||||
nextp = VN_CAST(nodep->nextp(), NodeModule);
|
||||
nextp = VN_AS(nodep->nextp(), NodeModule);
|
||||
if (v3Global.opt.hierChild() && nodep->name() == hierIt->second.origName()) {
|
||||
nodep->name(hierIt->first); // Change name of this module to be mangled name
|
||||
// considering parameter
|
||||
|
|
|
|||
|
|
@ -259,7 +259,7 @@ public:
|
|||
// We don't throw VARHIDDEN as if the import is later the symbol
|
||||
// table's import wouldn't warn
|
||||
} else if (VN_IS(nodep, Begin) && VN_IS(fnodep, Begin)
|
||||
&& VN_CAST(nodep, Begin)->generate()) {
|
||||
&& VN_AS(nodep, Begin)->generate()) {
|
||||
// Begin: ... blocks often replicate under genif/genfor, so simply
|
||||
// suppress duplicate checks. See t_gen_forif.v for an example.
|
||||
} else {
|
||||
|
|
@ -441,7 +441,7 @@ public:
|
|||
}
|
||||
void computeIfaceVarSyms() {
|
||||
for (VSymEnt* varSymp : m_ifaceVarSyms) {
|
||||
AstVar* varp = varSymp ? VN_CAST(varSymp->nodep(), Var) : nullptr;
|
||||
AstVar* varp = varSymp ? VN_AS(varSymp->nodep(), Var) : nullptr;
|
||||
UINFO(9, " insAllIface se" << cvtToHex(varSymp) << " " << varp << endl);
|
||||
AstIfaceRefDType* ifacerefp = ifaceRefFromArray(varp->subDTypep());
|
||||
UASSERT_OBJ(ifacerefp, varp, "Non-ifacerefs on list!");
|
||||
|
|
@ -497,7 +497,7 @@ public:
|
|||
// Typically lhsp=VAR w/dtype IFACEREF, rhsp=IFACE cell
|
||||
UINFO(9, " insertScopeAlias se" << cvtToHex(lhsp) << " se" << cvtToHex(rhsp) << endl);
|
||||
UASSERT_OBJ(
|
||||
!(VN_IS(rhsp->nodep(), Cell) && !VN_IS(VN_CAST(rhsp->nodep(), Cell)->modp(), Iface)),
|
||||
!(VN_IS(rhsp->nodep(), Cell) && !VN_IS(VN_AS(rhsp->nodep(), Cell)->modp(), Iface)),
|
||||
rhsp->nodep(), "Got a non-IFACE alias RHS");
|
||||
m_scopeAliasMap[samn].emplace(lhsp, rhsp);
|
||||
}
|
||||
|
|
@ -742,7 +742,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
// Process $unit or other packages
|
||||
// Not needed - dotted references not allowed from inside packages
|
||||
// for (AstNodeModule* nodep = v3Global.rootp()->modulesp();
|
||||
// nodep; nodep=VN_CAST(nodep->nextp(), NodeModule)) {
|
||||
// nodep; nodep=VN_AS(nodep->nextp(), NodeModule)) {
|
||||
// if (VN_IS(nodep, Package)) {}}
|
||||
|
||||
m_statep->insertDUnit(nodep);
|
||||
|
|
@ -757,7 +757,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
// wrapTop may have not been created yet.
|
||||
if (!nodep->modulesp()) nodep->v3error("No top level module found");
|
||||
for (AstNodeModule* modp = nodep->modulesp(); modp && modp->level() <= 2;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
UINFO(8, "Top Module: " << modp << endl);
|
||||
m_scope = "TOP";
|
||||
m_curSymp = m_modSymp = m_statep->insertTopCell(modp, m_scope);
|
||||
|
|
@ -999,7 +999,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
}
|
||||
// Set the class as package for iteration
|
||||
if (VN_IS(m_curSymp->nodep(), Class)) {
|
||||
m_classOrPackagep = VN_CAST(m_curSymp->nodep(), Class);
|
||||
m_classOrPackagep = VN_AS(m_curSymp->nodep(), Class);
|
||||
}
|
||||
// Create symbol table for the task's vars
|
||||
const string name = string{nodep->isExternProto() ? "extern " : ""} + nodep->name();
|
||||
|
|
@ -1197,7 +1197,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
if (!foundp && m_modSymp && nodep->name() == m_modSymp->nodep()->name()) {
|
||||
foundp = m_modSymp; // Conflicts with modname?
|
||||
}
|
||||
AstEnumItem* findvarp = foundp ? VN_CAST(foundp->nodep(), EnumItem) : nullptr;
|
||||
AstEnumItem* findvarp = foundp ? VN_AS(foundp->nodep(), EnumItem) : nullptr;
|
||||
bool ins = false;
|
||||
if (!foundp) {
|
||||
ins = true;
|
||||
|
|
@ -1267,7 +1267,7 @@ class LinkDotFindVisitor final : public AstNVisitor {
|
|||
}
|
||||
virtual void visit(AstWithParse* nodep) override {
|
||||
// Change WITHPARSE(FUNCREF, equation) to FUNCREF(WITH(equation))
|
||||
const auto funcrefp = VN_CAST(nodep->funcrefp(), NodeFTaskRef);
|
||||
const auto funcrefp = VN_AS(nodep->funcrefp(), NodeFTaskRef);
|
||||
UASSERT_OBJ(funcrefp, nodep, "'with' only can operate on a function/task");
|
||||
string name = "item";
|
||||
FileLine* argFl = nodep->fileline();
|
||||
|
|
@ -1398,7 +1398,7 @@ private:
|
|||
<< "... Suggest use instantiation with #(."
|
||||
<< nodep->prettyName() << "(...etc...))");
|
||||
VSymEnt* foundp = m_statep->getNodeSym(nodep)->findIdFallback(nodep->path());
|
||||
AstCell* cellp = foundp ? VN_CAST(foundp->nodep(), Cell) : nullptr;
|
||||
AstCell* cellp = foundp ? VN_AS(foundp->nodep(), Cell) : nullptr;
|
||||
if (!cellp) {
|
||||
nodep->v3error("In defparam, instance " << nodep->path() << " never declared");
|
||||
} else {
|
||||
|
|
@ -1418,7 +1418,7 @@ private:
|
|||
// Need to set pin numbers after varnames are created
|
||||
// But before we do the final resolution based on names
|
||||
VSymEnt* foundp = m_statep->getNodeSym(m_modp)->findIdFlat(nodep->name());
|
||||
AstVar* refp = foundp ? VN_CAST(foundp->nodep(), Var) : nullptr;
|
||||
AstVar* refp = foundp ? VN_AS(foundp->nodep(), Var) : nullptr;
|
||||
if (!refp) {
|
||||
nodep->v3error(
|
||||
"Input/output/inout declaration not found for port: " << nodep->prettyNameQ());
|
||||
|
|
@ -1472,10 +1472,10 @@ private:
|
|||
// Relink forward definitions to the "real" definition
|
||||
VSymEnt* foundp = m_statep->getNodeSym(fwdp)->findIdFallback(fwdp->name());
|
||||
if (foundp && (VN_IS(foundp->nodep(), Class) || VN_IS(foundp->nodep(), Package))) {
|
||||
nodep->classOrPackagep(VN_CAST(foundp->nodep(), NodeModule));
|
||||
nodep->classOrPackagep(VN_AS(foundp->nodep(), NodeModule));
|
||||
} else if (foundp && VN_IS(foundp->nodep(), ParamTypeDType)) {
|
||||
UASSERT(m_statep->forPrimary(), "Param types should have been resolved");
|
||||
nodep->classOrPackageNodep(foundp->nodep());
|
||||
nodep->classOrPackageNodep(VN_AS(foundp->nodep(), ParamTypeDType));
|
||||
} else {
|
||||
if (foundp) UINFO(1, "found nodep = " << foundp->nodep() << endl);
|
||||
nodep->v3error(
|
||||
|
|
@ -1597,8 +1597,8 @@ class LinkDotScopeVisitor final : public AstNVisitor {
|
|||
// Track aliases created by V3Inline; if we get a VARXREF(aliased_from)
|
||||
// we'll need to replace it with a VARXREF(aliased_to)
|
||||
if (debug() >= 9) nodep->dumpTree(cout, "- alias: ");
|
||||
AstVarScope* fromVscp = VN_CAST(nodep->lhsp(), VarRef)->varScopep();
|
||||
AstVarScope* toVscp = VN_CAST(nodep->rhsp(), VarRef)->varScopep();
|
||||
AstVarScope* fromVscp = VN_AS(nodep->lhsp(), VarRef)->varScopep();
|
||||
AstVarScope* toVscp = VN_AS(nodep->rhsp(), VarRef)->varScopep();
|
||||
UASSERT_OBJ(fromVscp && toVscp, nodep, "Bad alias scopes");
|
||||
fromVscp->user2p(toVscp);
|
||||
iterateChildren(nodep);
|
||||
|
|
@ -1878,9 +1878,9 @@ private:
|
|||
if (!symp) {
|
||||
return nullptr;
|
||||
} else if (VN_IS(symp->nodep(), Var)) {
|
||||
return VN_CAST(symp->nodep(), Var);
|
||||
return VN_AS(symp->nodep(), Var);
|
||||
} else if (VN_IS(symp->nodep(), ModportVarRef)) {
|
||||
AstModportVarRef* snodep = VN_CAST(symp->nodep(), ModportVarRef);
|
||||
AstModportVarRef* snodep = VN_AS(symp->nodep(), ModportVarRef);
|
||||
AstVar* varp = snodep->varp();
|
||||
if (access.isWriteOrRW() && snodep->direction().isReadOnly()) {
|
||||
nodep->v3error("Attempt to drive input-only modport: " << nodep->prettyNameQ());
|
||||
|
|
@ -1907,7 +1907,7 @@ private:
|
|||
AstVar* findIfaceTopVarp(AstNode* nodep, VSymEnt* parentEntp, const string& name) {
|
||||
const string findName = name + "__Viftop";
|
||||
VSymEnt* ifaceSymp = parentEntp->findIdFallback(findName);
|
||||
AstVar* ifaceTopVarp = ifaceSymp ? VN_CAST(ifaceSymp->nodep(), Var) : nullptr;
|
||||
AstVar* ifaceTopVarp = ifaceSymp ? VN_AS(ifaceSymp->nodep(), Var) : nullptr;
|
||||
UASSERT_OBJ(ifaceTopVarp, nodep, "Can't find interface var ref: " << findName);
|
||||
return ifaceTopVarp;
|
||||
}
|
||||
|
|
@ -2088,12 +2088,12 @@ private:
|
|||
nodep->v3error("'super' used outside class (IEEE 1800-2017 8.15)");
|
||||
m_ds.m_dotErr = true;
|
||||
} else {
|
||||
const auto classp = VN_CAST(classSymp->nodep(), Class);
|
||||
const auto classp = VN_AS(classSymp->nodep(), Class);
|
||||
if (!classp->extendsp()) {
|
||||
nodep->v3error("'super' used on non-extended class (IEEE 1800-2017 8.15)");
|
||||
m_ds.m_dotErr = true;
|
||||
} else {
|
||||
const auto cextp = VN_CAST(classp->extendsp(), ClassExtends);
|
||||
const auto cextp = VN_AS(classp->extendsp(), ClassExtends);
|
||||
UASSERT_OBJ(cextp, nodep, "Bad super extends link");
|
||||
const auto sclassp = cextp->classp();
|
||||
UASSERT_OBJ(sclassp, nodep, "Bad superclass");
|
||||
|
|
@ -2204,8 +2204,7 @@ private:
|
|||
allowVar = true;
|
||||
UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(),
|
||||
"Bad package link");
|
||||
AstClassOrPackageRef* cpackagerefp
|
||||
= VN_CAST(m_ds.m_dotp->lhsp(), ClassOrPackageRef);
|
||||
AstClassOrPackageRef* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef);
|
||||
classOrPackagep = cpackagerefp->classOrPackagep();
|
||||
UASSERT_OBJ(classOrPackagep, m_ds.m_dotp->lhsp(), "Bad package link");
|
||||
m_ds.m_dotSymp = m_statep->getNodeSym(classOrPackagep);
|
||||
|
|
@ -2250,7 +2249,7 @@ private:
|
|||
m_ds.m_dotPos = DP_SCOPE;
|
||||
// Upper AstDot visitor will handle it from here
|
||||
} else if (VN_IS(foundp->nodep(), Cell) && allowVar && m_cellp) {
|
||||
AstCell* cellp = VN_CAST(foundp->nodep(), Cell);
|
||||
AstCell* cellp = VN_AS(foundp->nodep(), Cell);
|
||||
if (VN_IS(cellp->modp(), Iface)) {
|
||||
// Interfaces can be referenced like a variable for interconnect
|
||||
VSymEnt* cellEntp = m_statep->getNodeSym(cellp);
|
||||
|
|
@ -2312,8 +2311,8 @@ private:
|
|||
refp->dotted(dotted.substr(0, pos));
|
||||
newp = refp;
|
||||
} else {
|
||||
newp = new AstUnlinkedRef(nodep->fileline(),
|
||||
VN_CAST(refp, VarXRef), refp->name(),
|
||||
newp = new AstUnlinkedRef(nodep->fileline(), VN_AS(refp, VarXRef),
|
||||
refp->name(),
|
||||
m_ds.m_unlinkedScopep->unlinkFrBack());
|
||||
m_ds.m_unlinkedScopep = nullptr;
|
||||
m_ds.m_unresolved = false;
|
||||
|
|
@ -2342,16 +2341,16 @@ private:
|
|||
UINFO(9, "dotSymp " << m_ds.m_dotSymp << " " << m_ds.m_dotSymp->nodep() << endl);
|
||||
// Iface was the previously dotted component
|
||||
if (!m_ds.m_dotSymp || !VN_IS(m_ds.m_dotSymp->nodep(), Cell)
|
||||
|| !VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp()
|
||||
|| !VN_IS(VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) {
|
||||
|| !VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp()
|
||||
|| !VN_IS(VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) {
|
||||
nodep->v3error("Modport not referenced as <interface>."
|
||||
<< modportp->prettyNameQ());
|
||||
} else if (!VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp()
|
||||
|| !VN_IS(VN_CAST(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) {
|
||||
} else if (!VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp()
|
||||
|| !VN_IS(VN_AS(m_ds.m_dotSymp->nodep(), Cell)->modp(), Iface)) {
|
||||
nodep->v3error("Modport not referenced from underneath an interface: "
|
||||
<< modportp->prettyNameQ());
|
||||
} else {
|
||||
AstCell* cellp = VN_CAST(m_ds.m_dotSymp->nodep(), Cell);
|
||||
AstCell* cellp = VN_AS(m_ds.m_dotSymp->nodep(), Cell);
|
||||
UASSERT_OBJ(cellp, nodep, "Modport not referenced from an instance");
|
||||
VSymEnt* cellEntp = m_statep->getNodeSym(cellp);
|
||||
UASSERT_OBJ(cellEntp, nodep, "No interface sym entry");
|
||||
|
|
@ -2519,7 +2518,7 @@ private:
|
|||
}
|
||||
} else {
|
||||
VSymEnt* foundp = m_statep->findSymPrefixed(dotSymp, nodep->name(), baddot);
|
||||
AstVarScope* vscp = foundp ? VN_CAST(foundp->nodep(), VarScope) : nullptr;
|
||||
AstVarScope* vscp = foundp ? VN_AS(foundp->nodep(), VarScope) : nullptr;
|
||||
if (!vscp) {
|
||||
nodep->v3error("Can't find varpin scope of "
|
||||
<< AstNode::prettyNameQ(baddot) << " in dotted signal: '"
|
||||
|
|
@ -2529,7 +2528,7 @@ private:
|
|||
while (vscp->user2p()) { // If V3Inline aliased it, pick up the new signal
|
||||
UINFO(7, " Resolved pre-alias " << vscp
|
||||
<< endl); // Also prints taskp
|
||||
vscp = VN_CAST(vscp->user2p(), VarScope);
|
||||
vscp = VN_AS(vscp->user2p(), VarScope);
|
||||
}
|
||||
// Convert the VarXRef to a VarRef, so we don't need
|
||||
// later optimizations to deal with VarXRef.
|
||||
|
|
@ -2578,7 +2577,7 @@ private:
|
|||
if (m_ds.m_dotp && m_ds.m_dotPos == DP_PACKAGE) {
|
||||
UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(),
|
||||
"Bad package link");
|
||||
AstClassOrPackageRef* cpackagerefp = VN_CAST(m_ds.m_dotp->lhsp(), ClassOrPackageRef);
|
||||
AstClassOrPackageRef* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef);
|
||||
if (cpackagerefp->name() == "process" || cpackagerefp->name() == "local") {
|
||||
nodep->v3warn(E_UNSUPPORTED,
|
||||
"Unsupported: " << AstNode::prettyNameQ(cpackagerefp->name()));
|
||||
|
|
@ -2864,7 +2863,7 @@ private:
|
|||
cextp->v3error("Attempting to extend class "
|
||||
<< nodep->prettyNameQ() << " from itself");
|
||||
} else {
|
||||
AstNode* paramsp = cpackagerefp->paramsp();
|
||||
AstPin* paramsp = cpackagerefp->paramsp();
|
||||
if (paramsp) paramsp = paramsp->cloneTree(true);
|
||||
const auto newp
|
||||
= new AstClassRefDType{nodep->fileline(), classp, paramsp};
|
||||
|
|
@ -2933,7 +2932,7 @@ private:
|
|||
if (m_ds.m_dotp && m_ds.m_dotPos == DP_PACKAGE) {
|
||||
UASSERT_OBJ(VN_IS(m_ds.m_dotp->lhsp(), ClassOrPackageRef), m_ds.m_dotp->lhsp(),
|
||||
"Bad package link");
|
||||
auto* cpackagerefp = VN_CAST(m_ds.m_dotp->lhsp(), ClassOrPackageRef);
|
||||
auto* cpackagerefp = VN_AS(m_ds.m_dotp->lhsp(), ClassOrPackageRef);
|
||||
UASSERT_OBJ(cpackagerefp->classOrPackagep(), m_ds.m_dotp->lhsp(), "Bad package link");
|
||||
nodep->classOrPackagep(cpackagerefp->classOrPackagep());
|
||||
m_ds.m_dotPos = DP_SCOPE;
|
||||
|
|
@ -2956,7 +2955,7 @@ private:
|
|||
= foundp ? VN_CAST(foundp->nodep(), ParamTypeDType) : nullptr) {
|
||||
nodep->refDTypep(defp);
|
||||
nodep->classOrPackagep(foundp->classOrPackagep());
|
||||
} else if (AstClass* defp = foundp ? VN_CAST(foundp->nodep(), Class) : nullptr) {
|
||||
} else if (AstClass* defp = foundp ? VN_AS(foundp->nodep(), Class) : nullptr) {
|
||||
AstNode* paramsp = nodep->paramsp();
|
||||
if (paramsp) paramsp->unlinkFrBackWithNext();
|
||||
AstClassRefDType* newp = new AstClassRefDType{nodep->fileline(), defp, paramsp};
|
||||
|
|
@ -2976,7 +2975,7 @@ private:
|
|||
iterateChildren(nodep);
|
||||
checkNoDot(nodep);
|
||||
VSymEnt* foundp = m_curSymp->findIdFallback(nodep->name());
|
||||
AstNodeFTask* taskp = foundp ? VN_CAST(foundp->nodep(), NodeFTask) : nullptr;
|
||||
AstNodeFTask* taskp = foundp ? VN_AS(foundp->nodep(), NodeFTask) : nullptr;
|
||||
if (!taskp) {
|
||||
nodep->v3error(
|
||||
"Can't find definition of exported task/function: " << nodep->prettyNameQ());
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ private:
|
|||
} else if (m_insMode == IM_AFTER) {
|
||||
m_insStmtp->addNextHere(newp);
|
||||
} else if (m_insMode == IM_WHILE_PRECOND) {
|
||||
AstWhile* whilep = VN_CAST(m_insStmtp, While);
|
||||
AstWhile* whilep = VN_AS(m_insStmtp, While);
|
||||
UASSERT_OBJ(whilep, nodep, "Insert should be under WHILE");
|
||||
whilep->addPrecondsp(newp);
|
||||
} else {
|
||||
|
|
@ -151,7 +151,7 @@ private:
|
|||
void prepost_non_stmt_visit(AstNodeTriop* nodep) {
|
||||
iterateChildren(nodep);
|
||||
|
||||
AstConst* constp = VN_CAST(nodep->lhsp(), Const);
|
||||
AstConst* constp = VN_AS(nodep->lhsp(), Const);
|
||||
UASSERT_OBJ(nodep, constp, "Expecting CONST");
|
||||
AstConst* newconstp = constp->cloneTree(true);
|
||||
|
||||
|
|
@ -181,7 +181,7 @@ private:
|
|||
return;
|
||||
}
|
||||
|
||||
AstConst* constp = VN_CAST(nodep->lhsp(), Const);
|
||||
AstConst* constp = VN_AS(nodep->lhsp(), Const);
|
||||
UASSERT_OBJ(nodep, constp, "Expecting CONST");
|
||||
AstNode* backp = nodep->backp();
|
||||
AstConst* newconstp = constp->cloneTree(true);
|
||||
|
|
|
|||
|
|
@ -58,19 +58,19 @@ private:
|
|||
AstJumpLabel* findAddLabel(AstNode* nodep, bool endOfIter) {
|
||||
// Put label under given node, and if WHILE optionally at end of iteration
|
||||
UINFO(4, "Create label for " << nodep << endl);
|
||||
if (VN_IS(nodep, JumpLabel)) return VN_CAST(nodep, JumpLabel); // Done
|
||||
if (VN_IS(nodep, JumpLabel)) return VN_AS(nodep, JumpLabel); // Done
|
||||
|
||||
AstNode* underp = nullptr;
|
||||
bool under_and_next = true;
|
||||
if (VN_IS(nodep, NodeBlock)) {
|
||||
underp = VN_CAST(nodep, NodeBlock)->stmtsp();
|
||||
underp = VN_AS(nodep, NodeBlock)->stmtsp();
|
||||
} else if (VN_IS(nodep, NodeFTask)) {
|
||||
underp = VN_CAST(nodep, NodeFTask)->stmtsp();
|
||||
underp = VN_AS(nodep, NodeFTask)->stmtsp();
|
||||
} else if (VN_IS(nodep, While)) {
|
||||
if (endOfIter) {
|
||||
// Note we jump to end of bodysp; a FOR loop has its
|
||||
// increment under incsp() which we don't skip
|
||||
underp = VN_CAST(nodep, While)->bodysp();
|
||||
underp = VN_AS(nodep, While)->bodysp();
|
||||
} else {
|
||||
underp = nodep;
|
||||
under_and_next = false; // IE we skip the entire while
|
||||
|
|
@ -87,7 +87,7 @@ private:
|
|||
UINFO(5, " Underpoint is " << underp << endl);
|
||||
|
||||
if (VN_IS(underp, JumpLabel)) {
|
||||
return VN_CAST(underp, JumpLabel);
|
||||
return VN_AS(underp, JumpLabel);
|
||||
} else { // Move underp stuff to be under a new label
|
||||
AstJumpBlock* blockp = new AstJumpBlock(nodep->fileline(), nullptr);
|
||||
AstJumpLabel* labelp = new AstJumpLabel(nodep->fileline(), blockp);
|
||||
|
|
@ -210,7 +210,7 @@ private:
|
|||
// Set output variable to return value
|
||||
nodep->addPrev(new AstAssign(
|
||||
nodep->fileline(),
|
||||
new AstVarRef(nodep->fileline(), VN_CAST(funcp->fvarp(), Var), VAccess::WRITE),
|
||||
new AstVarRef(nodep->fileline(), VN_AS(funcp->fvarp(), Var), VAccess::WRITE),
|
||||
nodep->lhsp()->unlinkFrBackWithNext()));
|
||||
}
|
||||
// Jump to the end of the function call
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ void V3LinkLevel::modSortByLevel() {
|
|||
ModVec mods; // Modules
|
||||
ModVec tops; // Top level modules
|
||||
for (AstNodeModule* nodep = v3Global.rootp()->modulesp(); nodep;
|
||||
nodep = VN_CAST(nodep->nextp(), NodeModule)) {
|
||||
nodep = VN_AS(nodep->nextp(), NodeModule)) {
|
||||
if (nodep->level() <= 2) tops.push_back(nodep);
|
||||
mods.push_back(nodep);
|
||||
}
|
||||
|
|
@ -165,8 +165,7 @@ void V3LinkLevel::wrapTop(AstNetlist* rootp) {
|
|||
|
||||
// Instantiate all packages under the top wrapper
|
||||
// This way all later SCOPE based optimizations can ignore packages
|
||||
for (AstNodeModule* modp = rootp->modulesp(); modp;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
for (AstNodeModule* modp = rootp->modulesp(); modp; modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
if (VN_IS(modp, Package)) {
|
||||
AstCell* cellp = new AstCell(modp->fileline(), modp->fileline(),
|
||||
// Could add __03a__03a="::" to prevent conflict
|
||||
|
|
@ -189,8 +188,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
|
|||
NameSet ioNames;
|
||||
NameSet dupNames;
|
||||
// For all modules, skipping over new top
|
||||
for (AstNodeModule* oldmodp = VN_CAST(rootp->modulesp()->nextp(), NodeModule);
|
||||
oldmodp && oldmodp->level() <= 2; oldmodp = VN_CAST(oldmodp->nextp(), NodeModule)) {
|
||||
for (AstNodeModule* oldmodp = VN_AS(rootp->modulesp()->nextp(), NodeModule);
|
||||
oldmodp && oldmodp->level() <= 2; oldmodp = VN_AS(oldmodp->nextp(), NodeModule)) {
|
||||
for (AstNode* subnodep = oldmodp->stmtsp(); subnodep; subnodep = subnodep->nextp()) {
|
||||
if (AstVar* oldvarp = VN_CAST(subnodep, Var)) {
|
||||
if (oldvarp->isIO()) {
|
||||
|
|
@ -206,8 +205,8 @@ void V3LinkLevel::wrapTopCell(AstNetlist* rootp) {
|
|||
}
|
||||
|
||||
// For all modules, skipping over new top
|
||||
for (AstNodeModule* oldmodp = VN_CAST(rootp->modulesp()->nextp(), NodeModule);
|
||||
oldmodp && oldmodp->level() <= 2; oldmodp = VN_CAST(oldmodp->nextp(), NodeModule)) {
|
||||
for (AstNodeModule* oldmodp = VN_AS(rootp->modulesp()->nextp(), NodeModule);
|
||||
oldmodp && oldmodp->level() <= 2; oldmodp = VN_AS(oldmodp->nextp(), NodeModule)) {
|
||||
if (VN_IS(oldmodp, Package)) continue;
|
||||
// Add instance
|
||||
UINFO(5, "LOOP " << oldmodp << endl);
|
||||
|
|
|
|||
|
|
@ -280,7 +280,7 @@ private:
|
|||
cleanFileline(nodep);
|
||||
iterateChildren(nodep);
|
||||
if (nodep->attrType() == AstAttrType::DT_PUBLIC) {
|
||||
AstTypedef* typep = VN_CAST(nodep->backp(), Typedef);
|
||||
AstTypedef* typep = VN_AS(nodep->backp(), Typedef);
|
||||
UASSERT_OBJ(typep, nodep, "Attribute not attached to typedef");
|
||||
typep->attrPublic(true);
|
||||
VL_DO_DANGLING(nodep->unlinkFrBack()->deleteTree(), nodep);
|
||||
|
|
|
|||
|
|
@ -449,8 +449,8 @@ private:
|
|||
UASSERT_OBJ(nodep->text() == "", nodep,
|
||||
"Non-format $sformatf should have \"\" format");
|
||||
if (VN_IS(nodep->exprsp(), Const)
|
||||
&& VN_CAST(nodep->exprsp(), Const)->num().isFromString()) {
|
||||
AstConst* fmtp = VN_CAST(nodep->exprsp()->unlinkFrBack(), Const);
|
||||
&& VN_AS(nodep->exprsp(), Const)->num().isFromString()) {
|
||||
AstConst* fmtp = VN_AS(nodep->exprsp()->unlinkFrBack(), Const);
|
||||
nodep->text(fmtp->num().toString());
|
||||
VL_DO_DANGLING(pushDeletep(fmtp), fmtp);
|
||||
}
|
||||
|
|
@ -459,7 +459,7 @@ private:
|
|||
const string newFormat = expectFormat(nodep, nodep->text(), nodep->exprsp(), false);
|
||||
nodep->text(newFormat);
|
||||
if ((VN_IS(nodep->backp(), Display)
|
||||
&& VN_CAST(nodep->backp(), Display)->displayType().needScopeTracking())
|
||||
&& VN_AS(nodep->backp(), Display)->displayType().needScopeTracking())
|
||||
|| nodep->formatScopeTracking()) {
|
||||
nodep->scopeNamep(new AstScopeName(nodep->fileline()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -313,7 +313,7 @@ private:
|
|||
// Cleanup
|
||||
VL_DO_DANGLING(rhsp->deleteTree(), rhsp);
|
||||
} else {
|
||||
AstNodeIf* const ifp = VN_CAST(currp, NodeIf);
|
||||
AstNodeIf* const ifp = VN_AS(currp, NodeIf);
|
||||
UASSERT_OBJ(ifp, currp, "Must be AstNodeIf");
|
||||
// Move branch contents under new if
|
||||
if (AstNode* const listp = ifp->ifsp()) {
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ private:
|
|||
const string newname = string("__PVT__") + nodep->name();
|
||||
nodep->name(newname);
|
||||
nodep->editCountInc();
|
||||
} else if (VN_IS(nodep, CFunc) && VN_CAST(nodep, CFunc)->isConstructor()) {
|
||||
} else if (VN_IS(nodep, CFunc) && VN_AS(nodep, CFunc)->isConstructor()) {
|
||||
} else {
|
||||
const string rsvd = V3LanguageWords::isKeyword(nodep->name());
|
||||
if (rsvd != "") {
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ private:
|
|||
if (m_inAss) {
|
||||
iterateChildren(nodep);
|
||||
if (VN_IS(nodep->rhsp(), Const)) {
|
||||
m_childClkWidth = m_childClkWidth * VN_CAST(nodep->rhsp(), Const)->toUInt();
|
||||
m_childClkWidth = m_childClkWidth * VN_AS(nodep->rhsp(), Const)->toUInt();
|
||||
} else {
|
||||
m_childClkWidth = nodep->width(); // can not check in this case.
|
||||
}
|
||||
|
|
@ -1262,8 +1262,8 @@ static bool domainsExclusive(const AstSenTree* fromp, const AstSenTree* top) {
|
|||
const bool fromInitial = fromp->hasInitial() || fromp->hasSettle();
|
||||
if (toInitial != fromInitial) return true;
|
||||
|
||||
const AstSenItem* fromSenListp = VN_CAST(fromp->sensesp(), SenItem);
|
||||
const AstSenItem* toSenListp = VN_CAST(top->sensesp(), SenItem);
|
||||
const AstSenItem* fromSenListp = VN_AS(fromp->sensesp(), SenItem);
|
||||
const AstSenItem* toSenListp = VN_AS(top->sensesp(), SenItem);
|
||||
|
||||
UASSERT_OBJ(fromSenListp, fromp, "sensitivity list item is not an AstSenItem");
|
||||
UASSERT_OBJ(toSenListp, top, "sensitivity list item is not an AstSenItem");
|
||||
|
|
@ -1728,7 +1728,7 @@ AstActive* OrderVisitor::processMoveOneLogic(const OrderLogicVertex* lvertexp,
|
|||
AstScope* const scopep = lvertexp->scopep();
|
||||
AstSenTree* const domainp = lvertexp->domainp();
|
||||
AstNode* nodep = lvertexp->nodep();
|
||||
AstNodeModule* const modp = VN_CAST(scopep->user1p(), NodeModule); // Stashed by visitor func
|
||||
AstNodeModule* const modp = VN_AS(scopep->user1p(), NodeModule); // Stashed by visitor func
|
||||
UASSERT(modp, "nullptr");
|
||||
if (VN_IS(nodep, SenTree)) {
|
||||
// Just ignore sensitivities, we'll deal with them when we move statements that need them
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ public:
|
|||
m_modParams.insert({hierOpt.second.origName(), {}});
|
||||
}
|
||||
for (AstNodeModule* modp = nodep->modulesp(); modp;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
if (hierOpts.find(modp->prettyName()) != hierOpts.end()) {
|
||||
m_hierBlockMod.emplace(modp->name(), modp);
|
||||
}
|
||||
|
|
@ -138,12 +138,12 @@ public:
|
|||
size_t paramIdx = 0;
|
||||
const ParamConstMap& params = m_hierParams[hierIt->second];
|
||||
UASSERT(params.size() == hierIt->second->params().size(), "not match");
|
||||
for (AstPin* pinp = firstPinp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = firstPinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (!pinp->exprp()) continue;
|
||||
UASSERT_OBJ(!pinp->modPTypep(), pinp,
|
||||
"module with type parameter must not be a hierarchical block");
|
||||
if (AstVar* modvarp = pinp->modVarp()) {
|
||||
AstConst* constp = VN_CAST(pinp->exprp(), Const);
|
||||
AstConst* constp = VN_AS(pinp->exprp(), Const);
|
||||
UASSERT_OBJ(constp, pinp,
|
||||
"parameter for a hierarchical block must have been constified");
|
||||
const auto paramIt = paramsIt->second.find(modvarp->name());
|
||||
|
|
@ -402,19 +402,19 @@ class ParamProcessor final {
|
|||
}
|
||||
}
|
||||
void relinkPins(const CloneMap* clonemapp, AstPin* startpinp) {
|
||||
for (AstPin* pinp = startpinp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = startpinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (pinp->modVarp()) {
|
||||
// Find it in the clone structure
|
||||
// UINFO(8,"Clone find 0x"<<hex<<(uint32_t)pinp->modVarp()<<endl);
|
||||
const auto cloneiter = clonemapp->find(pinp->modVarp());
|
||||
UASSERT_OBJ(cloneiter != clonemapp->end(), pinp,
|
||||
"Couldn't find pin in clone list");
|
||||
pinp->modVarp(VN_CAST(cloneiter->second, Var));
|
||||
pinp->modVarp(VN_AS(cloneiter->second, Var));
|
||||
} else if (pinp->modPTypep()) {
|
||||
const auto cloneiter = clonemapp->find(pinp->modPTypep());
|
||||
UASSERT_OBJ(cloneiter != clonemapp->end(), pinp,
|
||||
"Couldn't find pin in clone list");
|
||||
pinp->modPTypep(VN_CAST(cloneiter->second, ParamTypeDType));
|
||||
pinp->modPTypep(VN_AS(cloneiter->second, ParamTypeDType));
|
||||
} else {
|
||||
pinp->v3fatalSrc("Not linked?");
|
||||
}
|
||||
|
|
@ -429,7 +429,7 @@ class ParamProcessor final {
|
|||
}
|
||||
}
|
||||
}
|
||||
for (AstPin* pinp = startpinp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = startpinp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (AstVar* varp = pinp->modVarp()) {
|
||||
const auto varIt = vlstd::as_const(nameToPin).find(varp->name());
|
||||
UASSERT_OBJ(varIt != nameToPin.end(), varp,
|
||||
|
|
@ -471,7 +471,7 @@ class ParamProcessor final {
|
|||
UASSERT_OBJ(modp->hierBlock(), modp, "should be used for hierarchical block");
|
||||
|
||||
std::map<string, AstConst*> pins;
|
||||
for (AstPin* pinp = paramPinsp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = paramPinsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
checkSupportedParam(modp, pinp);
|
||||
if (AstVar* varp = pinp->modVarp()) {
|
||||
if (!pinp->exprp()) continue;
|
||||
|
|
@ -558,8 +558,8 @@ class ParamProcessor final {
|
|||
// Keep tree sorted by level
|
||||
AstNodeModule* insertp = srcModp;
|
||||
while (VN_IS(insertp->nextp(), NodeModule)
|
||||
&& VN_CAST(insertp->nextp(), NodeModule)->level() < newmodp->level()) {
|
||||
insertp = VN_CAST(insertp->nextp(), NodeModule);
|
||||
&& VN_AS(insertp->nextp(), NodeModule)->level() < newmodp->level()) {
|
||||
insertp = VN_AS(insertp->nextp(), NodeModule);
|
||||
}
|
||||
insertp->addNextHere(newmodp);
|
||||
|
||||
|
|
@ -588,7 +588,7 @@ class ParamProcessor final {
|
|||
}
|
||||
// Assign parameters to the constants specified
|
||||
// DOES clone() so must be finished with module clonep() before here
|
||||
for (AstPin* pinp = paramsp; pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = paramsp; pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
if (pinp->exprp()) {
|
||||
if (AstVar* modvarp = pinp->modVarp()) {
|
||||
AstNode* newp = pinp->exprp(); // Const or InitArray
|
||||
|
|
@ -603,7 +603,7 @@ class ParamProcessor final {
|
|||
modvarp->valuep(newp->cloneTree(false));
|
||||
modvarp->overriddenParam(overridden);
|
||||
} else if (AstParamTypeDType* modptp = pinp->modPTypep()) {
|
||||
AstNodeDType* dtypep = VN_CAST(pinp->exprp(), NodeDType);
|
||||
AstNodeDType* dtypep = VN_AS(pinp->exprp(), NodeDType);
|
||||
UASSERT_OBJ(dtypep, pinp, "unlinked param dtype");
|
||||
if (modptp->childDTypep()) modptp->childDTypep()->unlinkFrBack()->deleteTree();
|
||||
// Set this parameter to value requested by cell
|
||||
|
|
@ -694,7 +694,7 @@ class ParamProcessor final {
|
|||
|
||||
void cellInterfaceCleanup(AstCell* nodep, AstNodeModule* srcModp, string& longnamer,
|
||||
bool& any_overridesr, IfaceRefRefs& ifaceRefRefs) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->pinsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
AstVar* modvarp = pinp->modVarp();
|
||||
if (modvarp->isIfaceRef()) {
|
||||
AstIfaceRefDType* portIrefp = VN_CAST(modvarp->subDTypep(), IfaceRefDType);
|
||||
|
|
@ -704,9 +704,9 @@ class ParamProcessor final {
|
|||
AstIfaceRefDType* pinIrefp = nullptr;
|
||||
AstNode* exprp = pinp->exprp();
|
||||
AstVar* varp
|
||||
= (exprp && VN_IS(exprp, VarRef)) ? VN_CAST(exprp, VarRef)->varp() : nullptr;
|
||||
= (exprp && VN_IS(exprp, VarRef)) ? VN_AS(exprp, VarRef)->varp() : nullptr;
|
||||
if (varp && varp->subDTypep() && VN_IS(varp->subDTypep(), IfaceRefDType)) {
|
||||
pinIrefp = VN_CAST(varp->subDTypep(), IfaceRefDType);
|
||||
pinIrefp = VN_AS(varp->subDTypep(), IfaceRefDType);
|
||||
} else if (varp && varp->subDTypep() && arraySubDTypep(varp->subDTypep())
|
||||
&& VN_CAST(arraySubDTypep(varp->subDTypep()), IfaceRefDType)) {
|
||||
pinIrefp = VN_CAST(arraySubDTypep(varp->subDTypep()), IfaceRefDType);
|
||||
|
|
@ -717,9 +717,9 @@ class ParamProcessor final {
|
|||
&& VN_CAST(
|
||||
arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType)) {
|
||||
pinIrefp = VN_CAST(
|
||||
arraySubDTypep(VN_CAST(exprp->op1p(), VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType);
|
||||
pinIrefp
|
||||
= VN_AS(arraySubDTypep(VN_AS(exprp->op1p(), VarRef)->varp()->subDTypep()),
|
||||
IfaceRefDType);
|
||||
}
|
||||
|
||||
UINFO(9, " portIfaceRef " << portIrefp << endl);
|
||||
|
|
@ -781,7 +781,7 @@ public:
|
|||
longname = parameterizedHierBlockName(srcModp, nodep->paramsp());
|
||||
any_overrides = longname != srcModp->name();
|
||||
} else {
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_CAST(pinp->nextp(), Pin)) {
|
||||
for (AstPin* pinp = nodep->paramsp(); pinp; pinp = VN_AS(pinp->nextp(), Pin)) {
|
||||
cellPinCleanup(nodep, pinp, srcModp, longname /*ref*/, any_overrides /*ref*/);
|
||||
}
|
||||
}
|
||||
|
|
@ -824,7 +824,7 @@ public:
|
|||
explicit ParamProcessor(AstNetlist* nodep)
|
||||
: m_hierBlocks{v3Global.opt.hierBlocks(), nodep} {
|
||||
for (AstNodeModule* modp = nodep->modulesp(); modp;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
m_allModuleNames.insert(modp->name());
|
||||
}
|
||||
}
|
||||
|
|
@ -995,8 +995,8 @@ class ParamVisitor final : public AstNVisitor {
|
|||
UINFO(9, "Hit module boundary, done looking for interface" << endl);
|
||||
break;
|
||||
}
|
||||
if (VN_IS(backp, Var) && VN_CAST(backp, Var)->isIfaceRef()
|
||||
&& VN_CAST(backp, Var)->childDTypep()
|
||||
if (VN_IS(backp, Var) && VN_AS(backp, Var)->isIfaceRef()
|
||||
&& VN_AS(backp, Var)->childDTypep()
|
||||
&& (VN_CAST(VN_CAST(backp, Var)->childDTypep(), IfaceRefDType)
|
||||
|| (VN_CAST(VN_CAST(backp, Var)->childDTypep(), UnpackArrayDType)
|
||||
&& VN_CAST(VN_CAST(backp, Var)->childDTypep()->getChildDTypep(),
|
||||
|
|
@ -1101,7 +1101,7 @@ class ParamVisitor final : public AstNVisitor {
|
|||
//! move to more generic constant expressions, such code will be needed here.
|
||||
virtual void visit(AstBegin* nodep) override {
|
||||
if (nodep->genforp()) {
|
||||
AstGenFor* forp = VN_CAST(nodep->genforp(), GenFor);
|
||||
AstGenFor* forp = VN_AS(nodep->genforp(), GenFor);
|
||||
UASSERT_OBJ(forp, nodep, "Non-GENFOR under generate-for BEGIN");
|
||||
// We should have a GENFOR under here. We will be replacing the begin,
|
||||
// so process here rather than at the generate to avoid iteration problems
|
||||
|
|
@ -1142,10 +1142,10 @@ class ParamVisitor final : public AstNVisitor {
|
|||
V3Width::widthParamsEdit(nodep); // Param typed widthing will NOT recurse the body,
|
||||
// don't trigger errors yet.
|
||||
V3Const::constifyParamsEdit(nodep->exprp()); // exprp may change
|
||||
AstConst* exprp = VN_CAST(nodep->exprp(), Const);
|
||||
AstConst* exprp = VN_AS(nodep->exprp(), Const);
|
||||
// Constify
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
for (AstNode* ep = itemp->condsp(); ep;) {
|
||||
AstNode* nextp = ep->nextp(); // May edit list
|
||||
iterateAndNextNull(ep);
|
||||
|
|
@ -1155,7 +1155,7 @@ class ParamVisitor final : public AstNVisitor {
|
|||
}
|
||||
// Item match
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (!itemp->isDefault()) {
|
||||
for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) {
|
||||
if (const AstConst* ccondp = VN_CAST(ep, Const)) {
|
||||
|
|
@ -1170,7 +1170,7 @@ class ParamVisitor final : public AstNVisitor {
|
|||
}
|
||||
// Else default match
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (itemp->isDefault()) {
|
||||
if (!keepp) keepp = itemp->bodysp();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ AstNode* V3ParseGrammar::createSupplyExpr(FileLine* fileline, const string& name
|
|||
AstRange* V3ParseGrammar::scrubRange(AstNodeRange* nrangep) {
|
||||
// Remove any UnsizedRange's from list
|
||||
for (AstNodeRange *nodep = nrangep, *nextp; nodep; nodep = nextp) {
|
||||
nextp = VN_CAST(nodep->nextp(), NodeRange);
|
||||
nextp = VN_AS(nodep->nextp(), NodeRange);
|
||||
if (!VN_IS(nodep, Range)) {
|
||||
nodep->v3error(
|
||||
"Unsupported or syntax error: Unsized range in instance or other declaration");
|
||||
|
|
@ -115,9 +115,9 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra
|
|||
// into ARRAYDTYPE0(ARRAYDTYPE1(ARRAYDTYPE2(BASICTYPE3), RANGE), RANGE)
|
||||
AstNodeDType* arrayp = basep;
|
||||
if (nrangep) { // Maybe no range - return unmodified base type
|
||||
while (nrangep->nextp()) nrangep = VN_CAST(nrangep->nextp(), NodeRange);
|
||||
while (nrangep->nextp()) nrangep = VN_AS(nrangep->nextp(), NodeRange);
|
||||
while (nrangep) {
|
||||
AstNodeRange* prevp = VN_CAST(nrangep->backp(), NodeRange);
|
||||
AstNodeRange* prevp = VN_AS(nrangep->backp(), NodeRange);
|
||||
if (prevp) nrangep->unlinkFrBack();
|
||||
AstRange* rangep = VN_CAST(nrangep, Range);
|
||||
if (rangep && isPacked) {
|
||||
|
|
@ -134,7 +134,7 @@ AstNodeDType* V3ParseGrammar::createArray(AstNodeDType* basep, AstNodeRange* nra
|
|||
} else if (VN_IS(nrangep, UnsizedRange)) {
|
||||
arrayp = new AstUnsizedArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp);
|
||||
} else if (VN_IS(nrangep, BracketRange)) {
|
||||
AstBracketRange* arangep = VN_CAST(nrangep, BracketRange);
|
||||
AstBracketRange* arangep = VN_AS(nrangep, BracketRange);
|
||||
AstNode* keyp = arangep->elementsp()->unlinkFrBack();
|
||||
arrayp = new AstBracketArrayDType(nrangep->fileline(), VFlagChildDType(), arrayp,
|
||||
keyp);
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ struct VMemberQualifiers {
|
|||
return q;
|
||||
}
|
||||
void applyToNodes(AstNodeFTask* nodesp) const {
|
||||
for (AstNodeFTask* nodep = nodesp; nodep; nodep = VN_CAST(nodep->nextp(), NodeFTask)) {
|
||||
for (AstNodeFTask* nodep = nodesp; nodep; nodep = VN_AS(nodep->nextp(), NodeFTask)) {
|
||||
if (m_local) nodep->isHideLocal(true);
|
||||
if (m_protected) nodep->isHideProtected(true);
|
||||
if (m_virtual) nodep->isVirtual(true);
|
||||
|
|
@ -82,7 +82,7 @@ struct VMemberQualifiers {
|
|||
}
|
||||
}
|
||||
void applyToNodes(AstVar* nodesp) const {
|
||||
for (AstVar* nodep = nodesp; nodep; nodep = VN_CAST(nodep->nextp(), Var)) {
|
||||
for (AstVar* nodep = nodesp; nodep; nodep = VN_AS(nodep->nextp(), Var)) {
|
||||
if (m_randc) {
|
||||
nodep->v3warn(RANDC, "Unsupported: Converting 'randc' to 'rand'");
|
||||
nodep->isRand(true);
|
||||
|
|
@ -309,7 +309,7 @@ public:
|
|||
pkgp = parsep()->rootp()->dollarUnitPkgAddp();
|
||||
symp()->reinsert(pkgp, symp()->symRootp()); // Don't push/pop scope as they're global
|
||||
} else {
|
||||
pkgp = VN_CAST(rootSymp->nodep(), Package);
|
||||
pkgp = VN_AS(rootSymp->nodep(), Package);
|
||||
}
|
||||
return pkgp;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,10 +128,10 @@ private:
|
|||
if (nodep->isWide()) {
|
||||
if (m_assignLhs) {
|
||||
} else if (nodep->firstAbovep() && VN_IS(nodep->firstAbovep(), NodeAssign)
|
||||
&& assignNoTemp(VN_CAST(nodep->firstAbovep(), NodeAssign))) {
|
||||
&& assignNoTemp(VN_AS(nodep->firstAbovep(), NodeAssign))) {
|
||||
// Not much point if it's just a direct assignment to a constant
|
||||
} else if (VN_IS(nodep->backp(), Sel)
|
||||
&& VN_CAST(nodep->backp(), Sel)->widthp() == nodep) {
|
||||
&& VN_AS(nodep->backp(), Sel)->widthp() == nodep) {
|
||||
// AstSel::width must remain a constant
|
||||
} else if ((nodep->firstAbovep() && VN_IS(nodep->firstAbovep(), ArraySel))
|
||||
|| ((VN_IS(m_stmtp, CCall) || VN_IS(m_stmtp, CStmt))
|
||||
|
|
@ -384,7 +384,7 @@ private:
|
|||
AstNode* searchp = nodep->nextp();
|
||||
while (searchp && VN_IS(searchp, Comment)) searchp = searchp->nextp();
|
||||
if (searchp && VN_IS(searchp, Display)
|
||||
&& nodep->filep()->sameGateTree(VN_CAST(searchp, Display)->filep())) {
|
||||
&& nodep->filep()->sameGateTree(VN_AS(searchp, Display)->filep())) {
|
||||
// There's another display next; we can just wait to flush
|
||||
} else {
|
||||
UINFO(4, "Autoflush " << nodep << endl);
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ private:
|
|||
classp = classp->extendsp() ? classp->extendsp()->classp() : nullptr) {
|
||||
for (auto* memberp = classp->stmtsp(); memberp; memberp = memberp->nextp()) {
|
||||
// If member is rand and of class type, mark its class
|
||||
if (VN_IS(memberp, Var) && VN_CAST(memberp, Var)->isRand()) {
|
||||
if (VN_IS(memberp, Var) && VN_AS(memberp, Var)->isRand()) {
|
||||
if (auto* classRefp = VN_CAST(memberp->dtypep(), ClassRefDType)) {
|
||||
auto* rclassp = classRefp->classp();
|
||||
markMembers(rclassp);
|
||||
|
|
@ -127,7 +127,7 @@ private:
|
|||
VL_DEBUG_FUNC;
|
||||
|
||||
AstVar* enumValueTabp(AstEnumDType* nodep) {
|
||||
if (nodep->user2p()) return VN_CAST(nodep->user2p(), Var);
|
||||
if (nodep->user2p()) return VN_AS(nodep->user2p(), Var);
|
||||
UINFO(9, "Construct Venumvaltab " << nodep << endl);
|
||||
AstNodeArrayDType* vardtypep
|
||||
= new AstUnpackArrayDType(nodep->fileline(), nodep->dtypep(),
|
||||
|
|
@ -143,8 +143,8 @@ private:
|
|||
v3Global.rootp()->dollarUnitPkgAddp()->addStmtp(varp);
|
||||
UASSERT_OBJ(nodep->itemsp(), nodep, "Enum without items");
|
||||
for (AstEnumItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), EnumItem)) {
|
||||
AstConst* vconstp = VN_CAST(itemp->valuep(), Const);
|
||||
itemp = VN_AS(itemp->nextp(), EnumItem)) {
|
||||
AstConst* vconstp = VN_AS(itemp->valuep(), Const);
|
||||
UASSERT_OBJ(vconstp, nodep, "Enum item without constified value");
|
||||
initp->addValuep(vconstp->cloneTree(false));
|
||||
}
|
||||
|
|
@ -159,7 +159,7 @@ private:
|
|||
AstNodeStmt* stmtsp = nullptr;
|
||||
offset += memberp ? memberp->lsb() : 0;
|
||||
for (auto* smemberp = structDtp->membersp(); smemberp;
|
||||
smemberp = VN_CAST(smemberp->nextp(), MemberDType)) {
|
||||
smemberp = VN_AS(smemberp->nextp(), MemberDType)) {
|
||||
auto* randp = newRandStmtsp(fl, stmtsp ? varrefp->cloneTree(false) : varrefp,
|
||||
offset, smemberp);
|
||||
if (stmtsp) {
|
||||
|
|
@ -198,7 +198,7 @@ private:
|
|||
if (!nodep->user1()) return; // Doesn't need randomize, or already processed
|
||||
UINFO(9, "Define randomize() for " << nodep << endl);
|
||||
auto* funcp = V3Randomize::newRandomizeFunc(nodep);
|
||||
auto* fvarp = VN_CAST(funcp->fvarp(), Var);
|
||||
auto* fvarp = VN_AS(funcp->fvarp(), Var);
|
||||
funcp->addStmtsp(new AstAssign(
|
||||
nodep->fileline(), new AstVarRef(nodep->fileline(), fvarp, VAccess::WRITE),
|
||||
new AstConst(nodep->fileline(), AstConst::WidthedValue(), 32, 1)));
|
||||
|
|
@ -253,7 +253,7 @@ void V3Randomize::randomizeNetlist(AstNetlist* nodep) {
|
|||
}
|
||||
|
||||
AstFunc* V3Randomize::newRandomizeFunc(AstClass* nodep) {
|
||||
auto* funcp = VN_CAST(nodep->findMember("randomize"), Func);
|
||||
auto* funcp = VN_AS(nodep->findMember("randomize"), Func);
|
||||
if (!funcp) {
|
||||
auto* dtypep
|
||||
= nodep->findBitDType(32, 32, VSigning::SIGNED); // IEEE says int return of 0/1
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ private:
|
|||
VL_DEBUG_FUNC; // Declare debug()
|
||||
|
||||
AstVar* findCreateVarTemp(FileLine* fl, AstCFunc* cfuncp) {
|
||||
AstVar* varp = VN_CAST(cfuncp->user1p(), Var);
|
||||
AstVar* varp = VN_AS(cfuncp->user1p(), Var);
|
||||
if (!varp) {
|
||||
const string newvarname = string("__Vilp");
|
||||
varp = new AstVar(fl, AstVarType::STMTTEMP, newvarname, VFlagLogicPacked(), 32);
|
||||
|
|
|
|||
|
|
@ -370,7 +370,7 @@ private:
|
|||
if (nodep->classOrPackagep()) {
|
||||
// Point to the clone
|
||||
UASSERT_OBJ(nodep->taskp(), nodep, "Unlinked");
|
||||
AstNodeFTask* newp = VN_CAST(nodep->taskp()->user2p(), NodeFTask);
|
||||
AstNodeFTask* newp = VN_AS(nodep->taskp()->user2p(), NodeFTask);
|
||||
UASSERT_OBJ(newp, nodep, "No clone for package function");
|
||||
nodep->taskp(newp);
|
||||
UINFO(9, " New pkg-taskref " << nodep << endl);
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ private:
|
|||
std::ostringstream out;
|
||||
out << "'{";
|
||||
for (AstMemberDType* itemp = stp->membersp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), MemberDType)) {
|
||||
itemp = VN_AS(itemp->nextp(), MemberDType)) {
|
||||
const int width = itemp->width();
|
||||
const int lsb = itemp->lsb();
|
||||
const int msb = lsb + width - 1;
|
||||
|
|
@ -661,7 +661,7 @@ private:
|
|||
clearOptimizable(nodep, "Array select LHS isn't simple variable");
|
||||
return;
|
||||
}
|
||||
AstUnpackArrayDType* arrayp = VN_CAST(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType);
|
||||
AstUnpackArrayDType* arrayp = VN_AS(varrefp->varp()->dtypeSkipRefp(), UnpackArrayDType);
|
||||
UASSERT_OBJ(arrayp, nodep, "Array select of non-array dtype");
|
||||
AstBasicDType* basicp = VN_CAST(arrayp->subDTypep()->skipRefp(), BasicDType);
|
||||
if (!basicp) {
|
||||
|
|
@ -815,7 +815,7 @@ private:
|
|||
iterateAndNextNull(nodep->exprp());
|
||||
bool hit = false;
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (!itemp->isDefault()) {
|
||||
for (AstNode* ep = itemp->condsp(); ep; ep = ep->nextp()) {
|
||||
if (hit) break;
|
||||
|
|
@ -833,7 +833,7 @@ private:
|
|||
}
|
||||
// Else default match
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
if (hit) break;
|
||||
if (!hit && itemp->isDefault()) {
|
||||
iterateAndNextNull(itemp->bodysp());
|
||||
|
|
@ -966,11 +966,11 @@ private:
|
|||
badNodeType(nodep);
|
||||
return;
|
||||
}
|
||||
AstNodeFTask* funcp = VN_CAST(nodep->taskp(), NodeFTask);
|
||||
AstNodeFTask* funcp = VN_AS(nodep->taskp(), NodeFTask);
|
||||
UASSERT_OBJ(funcp, nodep, "Not linked");
|
||||
if (m_params) V3Width::widthParamsEdit(funcp);
|
||||
VL_DANGLING(funcp); // Make sure we've sized the function
|
||||
funcp = VN_CAST(nodep->taskp(), NodeFTask);
|
||||
funcp = VN_AS(nodep->taskp(), NodeFTask);
|
||||
UASSERT_OBJ(funcp, nodep, "Not linked");
|
||||
// Apply function call values to function
|
||||
V3TaskConnects tconnects = V3Task::taskConnects(nodep, nodep->taskp()->stmtsp());
|
||||
|
|
|
|||
|
|
@ -185,12 +185,12 @@ class SliceVisitor final : public AstNVisitor {
|
|||
for (int index = 0; index < adtypep->rangep()->elementsConst(); ++index) {
|
||||
// EQ(a,b) -> LOGAND(EQ(ARRAYSEL(a,0), ARRAYSEL(b,0)), ...[1])
|
||||
AstNodeBiop* clonep
|
||||
= VN_CAST(nodep->cloneType(
|
||||
new AstArraySel(nodep->fileline(),
|
||||
nodep->lhsp()->cloneTree(false), index),
|
||||
new AstArraySel(nodep->fileline(),
|
||||
nodep->rhsp()->cloneTree(false), index)),
|
||||
NodeBiop);
|
||||
= VN_AS(nodep->cloneType(
|
||||
new AstArraySel(nodep->fileline(),
|
||||
nodep->lhsp()->cloneTree(false), index),
|
||||
new AstArraySel(nodep->fileline(),
|
||||
nodep->rhsp()->cloneTree(false), index)),
|
||||
NodeBiop);
|
||||
if (!logp) {
|
||||
logp = clonep;
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -416,7 +416,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
|
|||
}
|
||||
static int outerMostSizeOfUnpackedArray(const AstVar* nodep) {
|
||||
const AstUnpackArrayDType* const dtypep
|
||||
= VN_CAST_CONST(nodep->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
= VN_AS_CONST(nodep->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
UASSERT_OBJ(dtypep, nodep, "Must be unapcked array");
|
||||
return dtypep->elementsConst();
|
||||
}
|
||||
|
|
@ -585,7 +585,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
|
|||
virtual void visit(AstSliceSel* nodep) override {
|
||||
if (AstVarRef* const refp = isTargetVref(nodep->fromp())) {
|
||||
const AstUnpackArrayDType* const dtypep
|
||||
= VN_CAST(refp->varp()->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
= VN_AS(refp->varp()->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
// declRange() of AstSliceSel is shifted by dtypep->declRange().lo() in V3WidthSel.cpp
|
||||
// restore the original decl range here.
|
||||
const VNumRange selRange{nodep->declRange().hi() + dtypep->declRange().lo(),
|
||||
|
|
@ -690,7 +690,7 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
|
|||
AstVar* const varp = pair.first;
|
||||
AstNode* insertp = varp;
|
||||
const AstUnpackArrayDType* const dtypep
|
||||
= VN_CAST(varp->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
= VN_AS(varp->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
AstNodeDType* const subTypep = dtypep->subDTypep();
|
||||
const bool needNext = VN_IS(subTypep, UnpackArrayDType); // Still unpacked array.
|
||||
std::vector<AstVar*> vars;
|
||||
|
|
@ -719,13 +719,13 @@ class SplitUnpackedVarVisitor final : public AstNVisitor, public SplitVarImpl {
|
|||
AstUnpackArrayDType* adtypep;
|
||||
int lsb = 0;
|
||||
if (refp) {
|
||||
adtypep = VN_CAST(refp->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
adtypep = VN_AS(refp->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
} else {
|
||||
AstSliceSel* selp = VN_CAST(ref.nodep(), SliceSel);
|
||||
AstSliceSel* selp = VN_AS(ref.nodep(), SliceSel);
|
||||
UASSERT_OBJ(selp, ref.nodep(), "Unexpected op is registered");
|
||||
refp = VN_CAST(selp->fromp(), VarRef);
|
||||
refp = VN_AS(selp->fromp(), VarRef);
|
||||
UASSERT_OBJ(refp, selp, "Unexpected op is registered");
|
||||
adtypep = VN_CAST(selp->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
adtypep = VN_AS(selp->dtypep()->skipRefp(), UnpackArrayDType);
|
||||
lsb = adtypep->lo();
|
||||
}
|
||||
AstVarRef* const newrefp
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ private:
|
|||
} else if (AstWordSel* wordp = VN_CAST(nodep->lhsp(), WordSel)) {
|
||||
if (AstVarRef* varrefp = VN_CAST(wordp->lhsp(), VarRef)) {
|
||||
if (VN_IS(wordp->rhsp(), Const) && isSubstVar(varrefp->varp())) {
|
||||
const int word = VN_CAST(wordp->rhsp(), Const)->toUInt();
|
||||
const int word = VN_AS(wordp->rhsp(), Const)->toUInt();
|
||||
SubstVarEntry* entryp = getEntryp(varrefp);
|
||||
hit = true;
|
||||
if (m_ops > SUBST_MAX_OPS_SUBST) {
|
||||
|
|
|
|||
|
|
@ -262,7 +262,7 @@ public:
|
|||
string scopes;
|
||||
for (IdNameMap::iterator it = m_idNameMap.begin(); it != m_idNameMap.end(); ++it) {
|
||||
AstNode* itemp = it->second->nodep();
|
||||
if (VN_IS(itemp, Cell) || (VN_IS(itemp, Module) && VN_CAST(itemp, Module)->isTop())) {
|
||||
if (VN_IS(itemp, Cell) || (VN_IS(itemp, Module) && VN_AS(itemp, Module)->isTop())) {
|
||||
if (scopes != "") scopes += ", ";
|
||||
scopes += AstNode::prettyName(it->first);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ private:
|
|||
public:
|
||||
// METHODS
|
||||
AstScope* getScope(AstNodeFTask* nodep) {
|
||||
AstScope* scopep = VN_CAST(nodep->user3p(), Scope);
|
||||
AstScope* scopep = VN_AS(nodep->user3p(), Scope);
|
||||
UASSERT_OBJ(scopep, nodep, "No scope for function");
|
||||
return scopep;
|
||||
}
|
||||
|
|
@ -300,7 +300,7 @@ private:
|
|||
if (nodep->varp()->user2p()) { // It's being converted to an alias.
|
||||
UINFO(9,
|
||||
" relinkVar " << cvtToHex(nodep->varp()->user2p()) << " " << nodep << endl);
|
||||
AstVarScope* newvscp = VN_CAST(nodep->varp()->user2p(), VarScope);
|
||||
AstVarScope* newvscp = VN_AS(nodep->varp()->user2p(), VarScope);
|
||||
UASSERT_OBJ(newvscp, nodep, "not linked");
|
||||
nodep->varScopep(newvscp);
|
||||
nodep->varp(nodep->varScopep()->varp());
|
||||
|
|
@ -454,7 +454,7 @@ private:
|
|||
AstVarScope* createVarScope(AstVar* invarp, const string& name) {
|
||||
if (invarp->isParam() && VN_IS(invarp->valuep(), InitArray)) {
|
||||
// Move array params in functions into constant pool
|
||||
return v3Global.rootp()->constPoolp()->findTable(VN_CAST(invarp->valuep(), InitArray));
|
||||
return v3Global.rootp()->constPoolp()->findTable(VN_AS(invarp->valuep(), InitArray));
|
||||
} else {
|
||||
// We could create under either the ref's scope or the ftask's scope.
|
||||
// It shouldn't matter, as they are only local variables.
|
||||
|
|
@ -686,7 +686,7 @@ private:
|
|||
for (AstNode* pinp = refp->pinsp(); pinp; pinp = nextpinp) {
|
||||
nextpinp = pinp->nextp();
|
||||
// Move pin to the CCall, removing all Arg's
|
||||
AstNode* exprp = VN_CAST(pinp, Arg)->exprp();
|
||||
AstNode* exprp = VN_AS(pinp, Arg)->exprp();
|
||||
exprp->unlinkFrBack();
|
||||
ccallp->addArgsp(exprp);
|
||||
}
|
||||
|
|
@ -1015,7 +1015,7 @@ private:
|
|||
for (AstNode* stmtp = cfuncp->argsp(); stmtp; stmtp = stmtp->nextp()) {
|
||||
if (AstVar* portp = VN_CAST(stmtp, Var)) {
|
||||
AstVarScope* portvscp
|
||||
= VN_CAST(portp->user2p(), VarScope); // Remembered when we created it earlier
|
||||
= VN_AS(portp->user2p(), VarScope); // Remembered when we created it earlier
|
||||
if (portp->isIO() && !portp->isFuncReturn() && portvscp != rtnvscp
|
||||
&& portp->name() != "__Vscopep" // Passed to dpiContext, not callee
|
||||
&& portp->name() != "__Vfilenamep" && portp->name() != "__Vlineno") {
|
||||
|
|
@ -1088,7 +1088,7 @@ private:
|
|||
portp->protect(false); // No additional exposure - already part of shown proto
|
||||
if (portp->isIO() && (portp->isWritable() || portp->isFuncReturn())
|
||||
&& !portp->isDpiOpenArray()) {
|
||||
AstVarScope* portvscp = VN_CAST(
|
||||
AstVarScope* portvscp = VN_AS(
|
||||
portp->user2p(), VarScope); // Remembered when we created it earlier
|
||||
cfuncp->addStmtsp(
|
||||
createAssignDpiToInternal(portvscp, portp->name() + tmpSuffixp));
|
||||
|
|
@ -1120,7 +1120,7 @@ private:
|
|||
AstNode::user2ClearTree();
|
||||
AstVar* rtnvarp = nullptr;
|
||||
if (nodep->isFunction()) {
|
||||
AstVar* portp = VN_CAST(nodep->fvarp(), Var);
|
||||
AstVar* portp = VN_AS(nodep->fvarp(), Var);
|
||||
UASSERT_OBJ(portp, nodep, "function without function output variable");
|
||||
if (!portp->isFuncReturn()) nodep->v3error("Not marked as function return var");
|
||||
if (nodep->dpiImport() || nodep->dpiExport()) {
|
||||
|
|
@ -1254,7 +1254,7 @@ private:
|
|||
portp->unlinkFrBack();
|
||||
pushDeletep(portp);
|
||||
AstNode* const tablep = v3Global.rootp()->constPoolp()->findTable(
|
||||
VN_CAST(portp->valuep(), InitArray));
|
||||
VN_AS(portp->valuep(), InitArray));
|
||||
portp->user2p(tablep);
|
||||
} else {
|
||||
if (portp->isIO()) {
|
||||
|
|
@ -1369,7 +1369,7 @@ private:
|
|||
m_insStmtp->addNextHere(newp);
|
||||
} else if (m_insMode == IM_WHILE_PRECOND) {
|
||||
UINFO(5, " IM_While_Precond " << m_insStmtp << endl);
|
||||
AstWhile* whilep = VN_CAST(m_insStmtp, While);
|
||||
AstWhile* whilep = VN_AS(m_insStmtp, While);
|
||||
UASSERT_OBJ(whilep, nodep, "Insert should be under WHILE");
|
||||
whilep->addPrecondsp(newp);
|
||||
visitp = newp;
|
||||
|
|
@ -1416,7 +1416,7 @@ private:
|
|||
if (nodep->taskp()->isFunction()) {
|
||||
// Not that it's a FUNCREF, but that we're calling a function (perhaps as a task)
|
||||
outvscp
|
||||
= createVarScope(VN_CAST(nodep->taskp()->fvarp(), Var), namePrefix + "__Vfuncout");
|
||||
= createVarScope(VN_AS(nodep->taskp()->fvarp(), Var), namePrefix + "__Vfuncout");
|
||||
}
|
||||
// Create cloned statements
|
||||
AstNode* beginp;
|
||||
|
|
@ -1605,7 +1605,7 @@ V3TaskConnects V3Task::taskConnects(AstNodeFTaskRef* nodep, AstNode* taskStmtsp)
|
|||
bool reorganize = false;
|
||||
for (AstNode *nextp, *pinp = nodep->pinsp(); pinp; pinp = nextp) {
|
||||
nextp = pinp->nextp();
|
||||
AstArg* argp = VN_CAST(pinp, Arg);
|
||||
AstArg* argp = VN_AS(pinp, Arg);
|
||||
UASSERT_OBJ(argp, pinp, "Non-arg under ftask reference");
|
||||
if (argp->name() != "") {
|
||||
// By name
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ private:
|
|||
const auto dupit = dupFinder.findDuplicate(nodep->valuep());
|
||||
if (dupit != dupFinder.end()) {
|
||||
const AstTraceDecl* const dupDeclp
|
||||
= VN_CAST_CONST(dupit->second->backp(), TraceDecl);
|
||||
= VN_AS_CONST(dupit->second->backp(), TraceDecl);
|
||||
UASSERT_OBJ(dupDeclp, nodep, "Trace duplicate of wrong type");
|
||||
TraceTraceVertex* const dupvertexp
|
||||
= dynamic_cast<TraceTraceVertex*>(dupDeclp->user1u().toGraphVertex());
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ private:
|
|||
// be unlinked as we go
|
||||
while (nextIrp) {
|
||||
AstIntfRef* const irp = nextIrp;
|
||||
nextIrp = VN_CAST(irp->nextp(), IntfRef);
|
||||
nextIrp = VN_AS(irp->nextp(), IntfRef);
|
||||
|
||||
const string irpName = irp->prettyName();
|
||||
if (scopeLen > irpName.length()) continue;
|
||||
|
|
@ -301,7 +301,7 @@ private:
|
|||
addIgnore("Unsupported: Unpacked struct/union");
|
||||
} else {
|
||||
for (const AstMemberDType* itemp = nodep->membersp(); itemp;
|
||||
itemp = VN_CAST_CONST(itemp->nextp(), MemberDType)) {
|
||||
itemp = VN_AS_CONST(itemp->nextp(), MemberDType)) {
|
||||
AstNodeDType* const subtypep = itemp->subDTypep()->skipRefToEnump();
|
||||
VL_RESTORER(m_traShowname);
|
||||
VL_RESTORER(m_traValuep);
|
||||
|
|
|
|||
|
|
@ -392,7 +392,7 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
}
|
||||
invarp->user1p(newp); // find envar given invarp
|
||||
}
|
||||
return VN_CAST(invarp->user1p(), Var);
|
||||
return VN_AS(invarp->user1p(), Var);
|
||||
}
|
||||
|
||||
AstVar* getCreateOutVarp(AstVar* invarp) {
|
||||
|
|
@ -410,7 +410,7 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
}
|
||||
invarp->user4p(newp); // find outvar given invarp
|
||||
}
|
||||
return VN_CAST(invarp->user4p(), Var);
|
||||
return VN_AS(invarp->user4p(), Var);
|
||||
}
|
||||
|
||||
AstVar* getCreateUnconnVarp(AstNode* fromp, AstNodeDType* dtypep) {
|
||||
|
|
@ -554,7 +554,7 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
outvarp->user3p(invarp->user3p()); // AstPull* propagation
|
||||
if (invarp->user3p()) UINFO(9, "propagate pull to " << outvarp << endl);
|
||||
} else if (invarp->user1p()) {
|
||||
envarp = VN_CAST(invarp->user1p(), Var); // From CASEEQ, foo === 1'bz
|
||||
envarp = VN_AS(invarp->user1p(), Var); // From CASEEQ, foo === 1'bz
|
||||
}
|
||||
|
||||
AstNode* orp = nullptr;
|
||||
|
|
@ -948,7 +948,7 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
// 3'b1z0 -> ((3'b101 == in__en) && (3'b100 == in))
|
||||
varrefp->unlinkFrBack();
|
||||
FileLine* fl = nodep->fileline();
|
||||
V3Number oneIfEn = VN_CAST(constp->user1p(), Const)
|
||||
V3Number oneIfEn = VN_AS(constp->user1p(), Const)
|
||||
->num(); // visit(AstConst) already split into en/ones
|
||||
const V3Number& oneIfEnOne = constp->num();
|
||||
AstVar* envarp = getCreateEnVarp(varrefp->varp());
|
||||
|
|
@ -989,11 +989,11 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
|
||||
virtual void visit(AstCountBits* nodep) override {
|
||||
std::array<bool, 3> dropop;
|
||||
dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_CAST(nodep->rhsp(), Const)->num().isAnyZ();
|
||||
dropop[1] = VN_IS(nodep->thsp(), Const) && VN_CAST(nodep->thsp(), Const)->num().isAnyZ();
|
||||
dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_CAST(nodep->fhsp(), Const)->num().isAnyZ();
|
||||
dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_AS(nodep->rhsp(), Const)->num().isAnyZ();
|
||||
dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyZ();
|
||||
dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_AS(nodep->fhsp(), Const)->num().isAnyZ();
|
||||
UINFO(4, " COUNTBITS(" << dropop[0] << dropop[1] << dropop[2] << " " << nodep << endl);
|
||||
AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef); // Input variable
|
||||
AstVarRef* varrefp = VN_AS(nodep->lhsp(), VarRef); // Input variable
|
||||
if (m_graphing) {
|
||||
iterateAndNextNull(nodep->lhsp());
|
||||
if (!dropop[0]) iterateAndNextNull(nodep->rhsp());
|
||||
|
|
@ -1050,10 +1050,10 @@ class TristateVisitor final : public TristateBaseVisitor {
|
|||
UINFO(9, dbgState() << nodep << endl);
|
||||
AstVarRef* varrefp = nullptr;
|
||||
if (VN_IS(nodep->lhsp(), VarRef)) {
|
||||
varrefp = VN_CAST(nodep->lhsp(), VarRef);
|
||||
varrefp = VN_AS(nodep->lhsp(), VarRef);
|
||||
} else if (VN_IS(nodep->lhsp(), Sel)
|
||||
&& VN_IS(VN_CAST(nodep->lhsp(), Sel)->fromp(), VarRef)) {
|
||||
varrefp = VN_CAST(VN_CAST(nodep->lhsp(), Sel)->fromp(), VarRef);
|
||||
&& VN_IS(VN_AS(nodep->lhsp(), Sel)->fromp(), VarRef)) {
|
||||
varrefp = VN_AS(VN_AS(nodep->lhsp(), Sel)->fromp(), VarRef);
|
||||
}
|
||||
if (!varrefp) {
|
||||
if (debug() >= 4) nodep->dumpTree(cout, "- ");
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ private:
|
|||
|
||||
// Already exists; rather than IF(a,... IF(b... optimize to IF(a&&b,
|
||||
// Saves us teaching V3Const how to optimize, and it won't be needed again.
|
||||
if (AstIf* ifp = VN_CAST(prep->user2p(), If)) {
|
||||
if (AstIf* ifp = VN_AS(prep->user2p(), If)) {
|
||||
UASSERT_OBJ(!needDly, prep, "Should have already converted to non-delay");
|
||||
AstNRelinker replaceHandle;
|
||||
AstNode* earliercondp = ifp->condp()->unlinkFrBack(&replaceHandle);
|
||||
|
|
@ -192,8 +192,8 @@ private:
|
|||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* newp;
|
||||
// If we got ==1'bx it can never be true (but 1'bx==1'bx can be!)
|
||||
if (((VN_IS(lhsp, Const) && VN_CAST(lhsp, Const)->num().isFourState())
|
||||
|| (VN_IS(rhsp, Const) && VN_CAST(rhsp, Const)->num().isFourState()))) {
|
||||
if (((VN_IS(lhsp, Const) && VN_AS(lhsp, Const)->num().isFourState())
|
||||
|| (VN_IS(rhsp, Const) && VN_AS(rhsp, Const)->num().isFourState()))) {
|
||||
newp = new AstConst(nodep->fileline(), AstConst::WidthedValue(), 1,
|
||||
(VN_IS(nodep, EqCase) ? 0 : 1));
|
||||
VL_DO_DANGLING(lhsp->deleteTree(), lhsp);
|
||||
|
|
@ -231,9 +231,9 @@ private:
|
|||
} else {
|
||||
// X or Z's become mask, ala case statements.
|
||||
V3Number nummask(rhsp, rhsp->width());
|
||||
nummask.opBitsNonX(VN_CAST(rhsp, Const)->num());
|
||||
nummask.opBitsNonX(VN_AS(rhsp, Const)->num());
|
||||
V3Number numval(rhsp, rhsp->width());
|
||||
numval.opBitsOne(VN_CAST(rhsp, Const)->num());
|
||||
numval.opBitsOne(VN_AS(rhsp, Const)->num());
|
||||
AstNode* and1p = new AstAnd(nodep->fileline(), lhsp,
|
||||
new AstConst(nodep->fileline(), nummask));
|
||||
AstNode* and2p = new AstConst(nodep->fileline(), numval);
|
||||
|
|
@ -266,9 +266,9 @@ private:
|
|||
virtual void visit(AstCountBits* nodep) override {
|
||||
// Ahh, we're two state, so this is easy
|
||||
std::array<bool, 3> dropop;
|
||||
dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_CAST(nodep->rhsp(), Const)->num().isAnyX();
|
||||
dropop[1] = VN_IS(nodep->thsp(), Const) && VN_CAST(nodep->thsp(), Const)->num().isAnyX();
|
||||
dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_CAST(nodep->fhsp(), Const)->num().isAnyX();
|
||||
dropop[0] = VN_IS(nodep->rhsp(), Const) && VN_AS(nodep->rhsp(), Const)->num().isAnyX();
|
||||
dropop[1] = VN_IS(nodep->thsp(), Const) && VN_AS(nodep->thsp(), Const)->num().isAnyX();
|
||||
dropop[2] = VN_IS(nodep->fhsp(), Const) && VN_AS(nodep->fhsp(), Const)->num().isAnyX();
|
||||
UINFO(4, " COUNTBITS(" << dropop[0] << dropop[1] << dropop[2] << " " << nodep << endl);
|
||||
|
||||
AstNode* nonXp = nullptr;
|
||||
|
|
|
|||
|
|
@ -115,8 +115,8 @@ private:
|
|||
if (!incAssp) return cantUnroll(nodep, "no increment assignment");
|
||||
if (incAssp->nextp()) return cantUnroll(nodep, "multiple increments");
|
||||
|
||||
m_forVarp = VN_CAST(initAssp->lhsp(), VarRef)->varp();
|
||||
m_forVscp = VN_CAST(initAssp->lhsp(), VarRef)->varScopep();
|
||||
m_forVarp = VN_AS(initAssp->lhsp(), VarRef)->varp();
|
||||
m_forVscp = VN_AS(initAssp->lhsp(), VarRef)->varScopep();
|
||||
if (VN_IS(nodep, GenFor) && !m_forVarp->isGenVar()) {
|
||||
nodep->v3error("Non-genvar used in generate for: " << m_forVarp->prettyNameQ());
|
||||
} else if (!VN_IS(nodep, GenFor) && m_forVarp->isGenVar()) {
|
||||
|
|
@ -155,7 +155,7 @@ private:
|
|||
if (debug() >= 9) nodep->dumpTree(cout, "- for: ");
|
||||
|
||||
if (!m_generate) {
|
||||
AstAssign* incpAssign = VN_CAST(incp, Assign);
|
||||
AstAssign* incpAssign = VN_AS(incp, Assign);
|
||||
if (!canSimulate(incpAssign->rhsp())) {
|
||||
return cantUnroll(incp, "Unable to simulate increment");
|
||||
}
|
||||
|
|
@ -255,7 +255,7 @@ private:
|
|||
outLoopsr++;
|
||||
|
||||
// Run inc
|
||||
AstAssign* incpass = VN_CAST(incp, Assign);
|
||||
AstAssign* incpass = VN_AS(incp, Assign);
|
||||
V3Number newLoopValue = V3Number(initp);
|
||||
if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) {
|
||||
return false;
|
||||
|
|
@ -345,7 +345,7 @@ private:
|
|||
}
|
||||
|
||||
// loopValue += valInc
|
||||
AstAssign* incpass = VN_CAST(incp, Assign);
|
||||
AstAssign* incpass = VN_AS(incp, Assign);
|
||||
V3Number newLoopValue = V3Number(nodep);
|
||||
if (!simulateTree(incpass->rhsp(), &loopValue, incpass, newLoopValue)) {
|
||||
nodep->v3error("Loop unrolling failed");
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ public:
|
|||
void V3VariableOrder::orderAll() {
|
||||
UINFO(2, __FUNCTION__ << ": " << endl);
|
||||
for (AstNodeModule* modp = v3Global.rootp()->modulesp(); modp;
|
||||
modp = VN_CAST(modp->nextp(), NodeModule)) {
|
||||
modp = VN_AS(modp->nextp(), NodeModule)) {
|
||||
VariableOrder::processModule(modp);
|
||||
}
|
||||
V3Global::dumpCheckGlobalTree("variableorder", 0, v3Global.opt.dumpTreeLevel(__FILE__) >= 3);
|
||||
|
|
|
|||
157
src/V3Width.cpp
157
src/V3Width.cpp
|
|
@ -928,11 +928,11 @@ private:
|
|||
// Must check bounds before adding a select that truncates the bound
|
||||
// Note we've already subtracted off LSB
|
||||
if (VN_IS(nodep->bitp(), Const)
|
||||
&& (VN_CAST(nodep->bitp(), Const)->toSInt() > (frommsb - fromlsb)
|
||||
|| VN_CAST(nodep->bitp(), Const)->toSInt() < 0)) {
|
||||
&& (VN_AS(nodep->bitp(), Const)->toSInt() > (frommsb - fromlsb)
|
||||
|| VN_AS(nodep->bitp(), Const)->toSInt() < 0)) {
|
||||
nodep->v3warn(SELRANGE,
|
||||
"Selection index out of range: "
|
||||
<< (VN_CAST(nodep->bitp(), Const)->toSInt() + fromlsb)
|
||||
<< (VN_AS(nodep->bitp(), Const)->toSInt() + fromlsb)
|
||||
<< " outside " << frommsb << ":" << fromlsb);
|
||||
UINFO(1, " Related node: " << nodep << endl);
|
||||
}
|
||||
|
|
@ -1405,7 +1405,7 @@ private:
|
|||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
} else if (VN_IS(nodep->dimp(), Const)) {
|
||||
const int dim = VN_CAST(nodep->dimp(), Const)->toSInt();
|
||||
const int dim = VN_AS(nodep->dimp(), Const)->toSInt();
|
||||
AstConst* newp = dimensionValue(nodep->fileline(), nodep->fromp()->dtypep(),
|
||||
nodep->attrType(), dim);
|
||||
nodep->replaceWith(newp);
|
||||
|
|
@ -1657,7 +1657,7 @@ private:
|
|||
// elimination should do much the same
|
||||
// Form: "( ((v > size) ? false : enum_valid[v[N:0]])
|
||||
// ? ExprStmt(ExprAssign(out, Cast(v, type)), 1) : 0)"
|
||||
auto* enumDtp = VN_CAST(toDtp, EnumDType);
|
||||
auto* enumDtp = VN_AS(toDtp, EnumDType);
|
||||
UASSERT_OBJ(enumDtp, nodep, "$cast determined as enum, but not enum type");
|
||||
uint64_t maxval = enumMaxValue(nodep, enumDtp);
|
||||
const int selwidth = V3Number::log2b(maxval) + 1; // Width to address a bit
|
||||
|
|
@ -1817,7 +1817,7 @@ private:
|
|||
UASSERT_OBJ(VN_IS(nodep->rhsp(), Const), nodep, "Unsupported: Non-const cast of size");
|
||||
// if (debug()) nodep->dumpTree(cout, " CastSizePre: ");
|
||||
if (m_vup->prelim()) {
|
||||
int width = VN_CAST(nodep->rhsp(), Const)->toSInt();
|
||||
int width = VN_AS(nodep->rhsp(), Const)->toSInt();
|
||||
if (width < 1) {
|
||||
nodep->v3error("Size-changing cast to zero or negative size");
|
||||
width = 1;
|
||||
|
|
@ -1839,7 +1839,7 @@ private:
|
|||
if (!underDtp) underDtp = underp->dtypep()->basicp();
|
||||
if (!underDtp) {
|
||||
nodep->v3warn(E_UNSUPPORTED, "Unsupported: Size-changing cast on non-basic data type");
|
||||
underDtp = VN_CAST(nodep->findBitDType(), BasicDType);
|
||||
underDtp = VN_AS(nodep->findBitDType(), BasicDType);
|
||||
}
|
||||
UASSERT_OBJ(underp == nodep->op1p(), nodep, "Assuming op1 is cast value");
|
||||
// A cast propagates its size to the lower expression and is included in the maximum
|
||||
|
|
@ -2022,7 +2022,7 @@ private:
|
|||
V3Number one(nodep, nodep->width(), 1);
|
||||
std::map<const V3Number, AstEnumItem*> inits;
|
||||
for (AstEnumItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), EnumItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), EnumItem)) {
|
||||
if (itemp->valuep()) {
|
||||
if (debug() >= 9) {
|
||||
UINFO(0, "EnumInit " << itemp << endl);
|
||||
|
|
@ -2052,7 +2052,7 @@ private:
|
|||
itemp->valuep(new AstConst(itemp->fileline(), num));
|
||||
}
|
||||
|
||||
AstConst* constp = VN_CAST(itemp->valuep(), Const);
|
||||
AstConst* constp = VN_AS(itemp->valuep(), Const);
|
||||
if (constp->num().isFourState() && nodep->dtypep()->basicp()
|
||||
&& !nodep->dtypep()->basicp()->isFourstate()) {
|
||||
itemp->v3error("Enum value with X/Zs cannot be assigned to non-fourstate type "
|
||||
|
|
@ -2102,7 +2102,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstConsAssoc* nodep) override {
|
||||
// Type computed when constructed here
|
||||
auto* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), AssocArrayDType);
|
||||
auto* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType);
|
||||
UASSERT_OBJ(vdtypep, nodep, "ConsAssoc requires assoc upper parent data type");
|
||||
if (m_vup->prelim()) {
|
||||
nodep->dtypeFrom(vdtypep);
|
||||
|
|
@ -2114,7 +2114,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstSetAssoc* nodep) override {
|
||||
// Type computed when constructed here
|
||||
auto* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), AssocArrayDType);
|
||||
auto* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), AssocArrayDType);
|
||||
UASSERT_OBJ(vdtypep, nodep, "SetsAssoc requires assoc upper parent data type");
|
||||
if (m_vup->prelim()) {
|
||||
nodep->dtypeFrom(vdtypep);
|
||||
|
|
@ -2127,7 +2127,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstConsDynArray* nodep) override {
|
||||
// Type computed when constructed here
|
||||
AstDynArrayDType* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), DynArrayDType);
|
||||
AstDynArrayDType* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), DynArrayDType);
|
||||
UASSERT_OBJ(vdtypep, nodep, "ConsDynArray requires queue upper parent data type");
|
||||
if (m_vup->prelim()) {
|
||||
userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, PRELIM).p());
|
||||
|
|
@ -2159,7 +2159,7 @@ private:
|
|||
}
|
||||
virtual void visit(AstConsQueue* nodep) override {
|
||||
// Type computed when constructed here
|
||||
AstQueueDType* vdtypep = VN_CAST(m_vup->dtypep()->skipRefp(), QueueDType);
|
||||
AstQueueDType* vdtypep = VN_AS(m_vup->dtypep()->skipRefp(), QueueDType);
|
||||
UASSERT_OBJ(vdtypep, nodep, "ConsQueue requires queue upper parent data type");
|
||||
if (m_vup->prelim()) {
|
||||
userIterateAndNext(nodep->lhsp(), WidthVP(vdtypep, PRELIM).p());
|
||||
|
|
@ -2300,7 +2300,7 @@ private:
|
|||
// MSB is first, so go backwards
|
||||
AstMemberDType* itemp;
|
||||
for (itemp = nodep->membersp(); itemp && itemp->nextp();
|
||||
itemp = VN_CAST(itemp->nextp(), MemberDType)) {}
|
||||
itemp = VN_AS(itemp->nextp(), MemberDType)) {}
|
||||
for (AstMemberDType* backip; itemp; itemp = backip) {
|
||||
if (itemp->isFourstate()) nodep->isFourstate(true);
|
||||
backip = VN_CAST(itemp->backp(), MemberDType);
|
||||
|
|
@ -2456,8 +2456,7 @@ private:
|
|||
// Should check types the method requires, but at present we don't do much
|
||||
userIterate(nodep->fromp(), WidthVP(SELF, BOTH).p());
|
||||
// Any AstWith is checked later when know types, in methodWithArgument
|
||||
for (AstArg* argp = VN_CAST(nodep->pinsp(), Arg); argp;
|
||||
argp = VN_CAST(argp->nextp(), Arg)) {
|
||||
for (AstArg* argp = VN_CAST(nodep->pinsp(), Arg); argp; argp = VN_AS(argp->nextp(), Arg)) {
|
||||
if (argp->exprp()) userIterate(argp->exprp(), WidthVP(SELF, BOTH).p());
|
||||
}
|
||||
// Find the fromp dtype - should be a class
|
||||
|
|
@ -2557,16 +2556,16 @@ private:
|
|||
newp = new AstConst(nodep->fileline(), AstConst::Signed32(),
|
||||
0); // Spec doesn't say what to do
|
||||
} else {
|
||||
newp = VN_CAST(itemp->valuep()->cloneTree(false), Const); // A const
|
||||
newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const
|
||||
}
|
||||
} else if (nodep->name() == "last") {
|
||||
AstEnumItem* itemp = adtypep->itemsp();
|
||||
while (itemp && itemp->nextp()) itemp = VN_CAST(itemp->nextp(), EnumItem);
|
||||
while (itemp && itemp->nextp()) itemp = VN_AS(itemp->nextp(), EnumItem);
|
||||
if (!itemp) {
|
||||
newp = new AstConst(nodep->fileline(), AstConst::Signed32(),
|
||||
0); // Spec doesn't say what to do
|
||||
} else {
|
||||
newp = VN_CAST(itemp->valuep()->cloneTree(false), Const); // A const
|
||||
newp = VN_AS(itemp->valuep()->cloneTree(false), Const); // A const
|
||||
}
|
||||
}
|
||||
UASSERT_OBJ(newp, nodep, "Enum method (perhaps enum item) not const");
|
||||
|
|
@ -2588,17 +2587,16 @@ private:
|
|||
|
||||
if (nodep->name() == "name") {
|
||||
methodOkArguments(nodep, 0, 0);
|
||||
} else if (nodep->pinsp() && !(VN_IS(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const))) {
|
||||
} else if (nodep->pinsp() && !(VN_IS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const))) {
|
||||
nodep->pinsp()->v3fatalSrc("Unsupported: enum next/prev with non-const argument");
|
||||
} else if (nodep->pinsp()
|
||||
&& !(VN_IS(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const)
|
||||
&& VN_CAST(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const)->toUInt() == 1
|
||||
&& !(VN_IS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)
|
||||
&& VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt() == 1
|
||||
&& !nodep->pinsp()->nextp())) {
|
||||
// Unroll of enumVar.next(k) to enumVar.next(1).next(k - 1)
|
||||
AstMethodCall* clonep = nodep->cloneTree(false);
|
||||
VN_CAST(VN_CAST(clonep->pinsp(), Arg)->exprp(), Const)->num().setLong(1);
|
||||
uint32_t stepWidth
|
||||
= VN_CAST(VN_CAST(nodep->pinsp(), Arg)->exprp(), Const)->toUInt();
|
||||
VN_AS(VN_AS(clonep->pinsp(), Arg)->exprp(), Const)->num().setLong(1);
|
||||
uint32_t stepWidth = VN_AS(VN_AS(nodep->pinsp(), Arg)->exprp(), Const)->toUInt();
|
||||
AstConst* constp = new AstConst(nodep->fileline(), stepWidth - 1);
|
||||
AstArg* argp = new AstArg(nodep->fileline(), "", constp);
|
||||
AstMethodCall* newp
|
||||
|
|
@ -2727,7 +2725,7 @@ private:
|
|||
iterateCheck(nodep, "index", index_exprp, CONTEXT, FINAL, adtypep->keyDTypep(),
|
||||
EXTEND_EXP);
|
||||
VL_DANGLING(index_exprp); // May have been edited
|
||||
return VN_CAST(nodep->pinsp(), Arg)->exprp();
|
||||
return VN_AS(nodep->pinsp(), Arg)->exprp();
|
||||
}
|
||||
void methodCallLValueRecurse(AstMethodCall* nodep, AstNode* childp, const VAccess& access) {
|
||||
if (AstNodeVarRef* varrefp = VN_CAST(childp, NodeVarRef)) {
|
||||
|
|
@ -2866,7 +2864,7 @@ private:
|
|||
methodOkArguments(nodep, 2, 2);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
AstNode* index_exprp = methodCallQueueIndexExpr(nodep);
|
||||
AstArg* argp = VN_CAST(nodep->pinsp()->nextp(), Arg);
|
||||
AstArg* argp = VN_AS(nodep->pinsp()->nextp(), Arg);
|
||||
iterateCheckTyped(nodep, "insert value", argp->exprp(), adtypep->subDTypep(), BOTH);
|
||||
if (index_exprp->isZero()) { // insert(0, ...) is a push_front
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
|
|
@ -2889,7 +2887,7 @@ private:
|
|||
} else if (nodep->name() == "push_back" || nodep->name() == "push_front") {
|
||||
methodOkArguments(nodep, 1, 1);
|
||||
methodCallLValueRecurse(nodep, nodep->fromp(), VAccess::WRITE);
|
||||
AstArg* argp = VN_CAST(nodep->pinsp(), Arg);
|
||||
AstArg* argp = VN_AS(nodep->pinsp(), Arg);
|
||||
iterateCheckTyped(nodep, "push value", argp->exprp(), adtypep->subDTypep(), BOTH);
|
||||
newp = new AstCMethodHard(nodep->fileline(), nodep->fromp()->unlinkFrBack(),
|
||||
nodep->name(), argp->exprp()->unlinkFrBack());
|
||||
|
|
@ -2961,10 +2959,10 @@ private:
|
|||
}
|
||||
}
|
||||
AstNode* methodCallQueueIndexExpr(AstMethodCall* nodep) {
|
||||
AstNode* index_exprp = VN_CAST(nodep->pinsp(), Arg)->exprp();
|
||||
AstNode* index_exprp = VN_AS(nodep->pinsp(), Arg)->exprp();
|
||||
iterateCheckSigned32(nodep, "index", index_exprp, BOTH);
|
||||
VL_DANGLING(index_exprp); // May have been edited
|
||||
return VN_CAST(nodep->pinsp(), Arg)->exprp();
|
||||
return VN_AS(nodep->pinsp(), Arg)->exprp();
|
||||
}
|
||||
void methodCallClass(AstMethodCall* nodep, AstClassRefDType* adtypep) {
|
||||
// No need to width-resolve the class, as it was done when we did the child
|
||||
|
|
@ -3114,7 +3112,7 @@ private:
|
|||
} else if (nodep->name() == "compare" || nodep->name() == "icompare") {
|
||||
const bool ignoreCase = nodep->name()[0] == 'i';
|
||||
methodOkArguments(nodep, 1, 1);
|
||||
AstArg* argp = VN_CAST(nodep->pinsp(), Arg);
|
||||
AstArg* argp = VN_AS(nodep->pinsp(), Arg);
|
||||
AstNode* lhs = nodep->fromp()->unlinkFrBack();
|
||||
AstNode* rhs = argp->exprp()->unlinkFrBack();
|
||||
AstNode* newp = new AstCompareNN(nodep->fileline(), lhs, rhs, ignoreCase);
|
||||
|
|
@ -3122,9 +3120,9 @@ private:
|
|||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
} else if (nodep->name() == "putc") {
|
||||
methodOkArguments(nodep, 2, 2);
|
||||
AstArg* arg0p = VN_CAST(nodep->pinsp(), Arg);
|
||||
AstArg* arg1p = VN_CAST(arg0p->nextp(), Arg);
|
||||
AstNodeVarRef* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), VarRef);
|
||||
AstArg* arg0p = VN_AS(nodep->pinsp(), Arg);
|
||||
AstArg* arg1p = VN_AS(arg0p->nextp(), Arg);
|
||||
AstNodeVarRef* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef);
|
||||
AstNode* rhsp = arg0p->exprp()->unlinkFrBack();
|
||||
AstNode* thsp = arg1p->exprp()->unlinkFrBack();
|
||||
AstVarRef* varrefp = new AstVarRef(nodep->fileline(), fromp->varp(), VAccess::READ);
|
||||
|
|
@ -3135,7 +3133,7 @@ private:
|
|||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
} else if (nodep->name() == "getc") {
|
||||
methodOkArguments(nodep, 1, 1);
|
||||
AstArg* arg0p = VN_CAST(nodep->pinsp(), Arg);
|
||||
AstArg* arg0p = VN_AS(nodep->pinsp(), Arg);
|
||||
AstNode* lhsp = nodep->fromp()->unlinkFrBack();
|
||||
AstNode* rhsp = arg0p->exprp()->unlinkFrBack();
|
||||
AstNode* newp = new AstGetcN(nodep->fileline(), lhsp, rhsp);
|
||||
|
|
@ -3143,8 +3141,8 @@ private:
|
|||
VL_DO_DANGLING(nodep->deleteTree(), nodep);
|
||||
} else if (nodep->name() == "substr") {
|
||||
methodOkArguments(nodep, 2, 2);
|
||||
AstArg* arg0p = VN_CAST(nodep->pinsp(), Arg);
|
||||
AstArg* arg1p = VN_CAST(arg0p->nextp(), Arg);
|
||||
AstArg* arg0p = VN_AS(nodep->pinsp(), Arg);
|
||||
AstArg* arg1p = VN_AS(arg0p->nextp(), Arg);
|
||||
AstNode* lhsp = nodep->fromp()->unlinkFrBack();
|
||||
AstNode* rhsp = arg0p->exprp()->unlinkFrBack();
|
||||
AstNode* thsp = arg1p->exprp()->unlinkFrBack();
|
||||
|
|
@ -3278,8 +3276,8 @@ private:
|
|||
nodep->dtypep(dtypep);
|
||||
// Determine replication count, and replicate initial value as
|
||||
// widths need to be individually determined
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
const int times = visitPatMemberRep(patp);
|
||||
for (int i = 1; i < times; i++) {
|
||||
AstNode* newp = patp->cloneTree(false);
|
||||
|
|
@ -3288,8 +3286,8 @@ private:
|
|||
}
|
||||
}
|
||||
// Convert any PatMember with multiple items to multiple PatMembers
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
if (patp->lhssp()->nextp()) {
|
||||
// Can't just addNext, as would add to end of all members.
|
||||
// So detach, add next and reattach
|
||||
|
|
@ -3307,8 +3305,8 @@ private:
|
|||
}
|
||||
}
|
||||
AstPatMember* defaultp = nullptr;
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
if (patp->isDefault()) {
|
||||
if (defaultp) nodep->v3error("Multiple '{ default: } clauses");
|
||||
defaultp = patp;
|
||||
|
|
@ -3331,7 +3329,7 @@ private:
|
|||
VL_DO_DANGLING(patternDynArray(nodep, vdtypep, defaultp), nodep);
|
||||
} else if (auto* vdtypep = VN_CAST(dtypep, QueueDType)) {
|
||||
VL_DO_DANGLING(patternQueue(nodep, vdtypep, defaultp), nodep);
|
||||
} else if (VN_IS(dtypep, BasicDType) && VN_CAST(dtypep, BasicDType)->isRanged()) {
|
||||
} else if (VN_IS(dtypep, BasicDType) && VN_AS(dtypep, BasicDType)->isRanged()) {
|
||||
VL_DO_DANGLING(patternBasic(nodep, dtypep, defaultp), nodep);
|
||||
} else {
|
||||
nodep->v3warn(
|
||||
|
|
@ -3385,18 +3383,18 @@ private:
|
|||
std::pair<PatMap::iterator, bool> ret = patmap.emplace(memp, patp);
|
||||
if (!ret.second) {
|
||||
patp->v3error("Assignment pattern contains duplicate entry: "
|
||||
<< VN_CAST(patp->keyp(), Text)->text());
|
||||
<< VN_AS(patp->keyp(), Text)->text());
|
||||
}
|
||||
}
|
||||
} while (false);
|
||||
// Next
|
||||
if (memp) memp = VN_CAST(memp->nextp(), MemberDType);
|
||||
if (patp) patp = VN_CAST(patp->nextp(), PatMember);
|
||||
if (memp) memp = VN_AS(memp->nextp(), MemberDType);
|
||||
if (patp) patp = VN_AS(patp->nextp(), PatMember);
|
||||
}
|
||||
}
|
||||
AstNode* newp = nullptr;
|
||||
for (AstMemberDType* memp = vdtypep->membersp(); memp;
|
||||
memp = VN_CAST(memp->nextp(), MemberDType)) {
|
||||
memp = VN_AS(memp->nextp(), MemberDType)) {
|
||||
const auto it = patmap.find(memp);
|
||||
AstPatMember* newpatp = nullptr;
|
||||
AstPatMember* patp = nullptr;
|
||||
|
|
@ -3467,7 +3465,7 @@ private:
|
|||
= new AstInitArray(nodep->fileline(), arrayDtp, nullptr);
|
||||
newp = newap;
|
||||
}
|
||||
VN_CAST(newp, InitArray)->addIndexValuep(ent - range.lo(), valuep);
|
||||
VN_AS(newp, InitArray)->addIndexValuep(ent - range.lo(), valuep);
|
||||
} else { // Packed. Convert to concat for now.
|
||||
if (!newp) {
|
||||
newp = valuep;
|
||||
|
|
@ -3496,8 +3494,8 @@ private:
|
|||
if (defaultp) defaultValuep = defaultp->lhssp()->unlinkFrBack();
|
||||
AstNode* newp = new AstConsAssoc(nodep->fileline(), defaultValuep);
|
||||
newp->dtypeFrom(arrayDtp);
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
patp->dtypep(arrayDtp->subDTypep());
|
||||
AstNode* valuep = patternMemberValueIterate(patp);
|
||||
AstNode* keyp = patp->keyp();
|
||||
|
|
@ -3512,8 +3510,8 @@ private:
|
|||
void patternDynArray(AstPattern* nodep, AstDynArrayDType* arrayp, AstPatMember*) {
|
||||
AstNode* newp = new AstConsDynArray(nodep->fileline());
|
||||
newp->dtypeFrom(arrayp);
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
patp->dtypep(arrayp->subDTypep());
|
||||
AstNode* valuep = patternMemberValueIterate(patp);
|
||||
auto* newap = new AstConsDynArray(nodep->fileline(), valuep, newp);
|
||||
|
|
@ -3527,8 +3525,8 @@ private:
|
|||
void patternQueue(AstPattern* nodep, AstQueueDType* arrayp, AstPatMember*) {
|
||||
AstNode* newp = new AstConsQueue(nodep->fileline());
|
||||
newp->dtypeFrom(arrayp);
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
patp->dtypep(arrayp->subDTypep());
|
||||
AstNode* valuep = patternMemberValueIterate(patp);
|
||||
auto* newap = new AstConsQueue(nodep->fileline(), valuep, newp);
|
||||
|
|
@ -3540,7 +3538,7 @@ private:
|
|||
VL_DO_DANGLING(pushDeletep(nodep), nodep); // Deletes defaultp also, if present
|
||||
}
|
||||
void patternBasic(AstPattern* nodep, AstNodeDType* vdtypep, AstPatMember* defaultp) {
|
||||
AstBasicDType* bdtypep = VN_CAST(vdtypep, BasicDType);
|
||||
AstBasicDType* bdtypep = VN_AS(vdtypep, BasicDType);
|
||||
const VNumRange range = bdtypep->declRange();
|
||||
PatVecMap patmap = patVectorMap(nodep, range);
|
||||
UINFO(9, "ent " << range.hi() << " to " << range.lo() << endl);
|
||||
|
|
@ -3596,7 +3594,7 @@ private:
|
|||
if (VN_IS(valuep, Const)) {
|
||||
// Forming a AstConcat will cause problems with
|
||||
// unsized (uncommitted sized) constants
|
||||
if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(VN_CAST(valuep, Const))) {
|
||||
if (AstNode* newp = WidthCommitVisitor::newIfConstCommitSize(VN_AS(valuep, Const))) {
|
||||
VL_DO_DANGLING(pushDeletep(valuep), valuep);
|
||||
valuep = newp;
|
||||
}
|
||||
|
|
@ -3660,8 +3658,7 @@ private:
|
|||
assertAtStatement(nodep);
|
||||
userIterateAndNext(nodep->exprp(), WidthVP(CONTEXT, PRELIM).p());
|
||||
for (AstCaseItem *nextip, *itemp = nodep->itemsp(); itemp; itemp = nextip) {
|
||||
nextip
|
||||
= VN_CAST(itemp->nextp(), CaseItem); // Prelim may cause the node to get replaced
|
||||
nextip = VN_AS(itemp->nextp(), CaseItem); // Prelim may cause the node to get replaced
|
||||
if (!VN_IS(nodep, GenCase)) userIterateAndNext(itemp->bodysp(), nullptr);
|
||||
for (AstNode *nextcp, *condp = itemp->condsp(); condp; condp = nextcp) {
|
||||
nextcp = condp->nextp(); // Prelim may cause the node to get replaced
|
||||
|
|
@ -3672,7 +3669,7 @@ private:
|
|||
// Take width as maximum across all items, if any is real whole thing is real
|
||||
AstNodeDType* subDTypep = nodep->exprp()->dtypep();
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
for (AstNode* condp = itemp->condsp(); condp; condp = condp->nextp()) {
|
||||
if (condp->dtypep() != subDTypep) {
|
||||
if (condp->dtypep()->isDouble()) {
|
||||
|
|
@ -3691,7 +3688,7 @@ private:
|
|||
iterateCheck(nodep, "Case expression", nodep->exprp(), CONTEXT, FINAL, subDTypep,
|
||||
EXTEND_LHS);
|
||||
for (AstCaseItem* itemp = nodep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), CaseItem)) {
|
||||
itemp = VN_AS(itemp->nextp(), CaseItem)) {
|
||||
for (AstNode *nextcp, *condp = itemp->condsp(); condp; condp = nextcp) {
|
||||
nextcp = condp->nextp(); // Final may cause the node to get replaced
|
||||
iterateCheck(nodep, "Case Item", condp, CONTEXT, FINAL, subDTypep, EXTEND_LHS);
|
||||
|
|
@ -4336,7 +4333,7 @@ private:
|
|||
// Pretend it's void so less special casing needed when look at dtypes
|
||||
nodep->dtypeSetVoid();
|
||||
} else if (nodep->fvarp()) {
|
||||
m_funcp = VN_CAST(nodep, Func);
|
||||
m_funcp = VN_AS(nodep, Func);
|
||||
UASSERT_OBJ(m_funcp, nodep, "FTask with function variable, but isn't a function");
|
||||
nodep->dtypeFrom(nodep->fvarp()); // Which will get it from fvarp()->dtypep()
|
||||
}
|
||||
|
|
@ -4368,7 +4365,7 @@ private:
|
|||
}
|
||||
|
||||
virtual void visit(AstFuncRef* nodep) override {
|
||||
visit(VN_CAST(nodep, NodeFTaskRef));
|
||||
visit(VN_AS(nodep, NodeFTaskRef));
|
||||
nodep->dtypeFrom(nodep->taskp());
|
||||
// if (debug()) nodep->dumpTree(cout, " FuncOut: ");
|
||||
}
|
||||
|
|
@ -4437,7 +4434,7 @@ private:
|
|||
AstNRelinker handle;
|
||||
argp->unlinkFrBackWithNext(&handle); // Format + additional args, if any
|
||||
AstNode* argsp = nullptr;
|
||||
while (AstArg* nextargp = VN_CAST(argp->nextp(), Arg)) {
|
||||
while (AstArg* nextargp = VN_AS(argp->nextp(), Arg)) {
|
||||
argsp = AstNode::addNext(
|
||||
argsp, nextargp->exprp()
|
||||
->unlinkFrBackWithNext()); // Expression goes to SFormatF
|
||||
|
|
@ -4445,7 +4442,7 @@ private:
|
|||
}
|
||||
string format;
|
||||
if (VN_IS(pinp, Const)) {
|
||||
format = VN_CAST(pinp, Const)->num().toString();
|
||||
format = VN_AS(pinp, Const)->num().toString();
|
||||
} else {
|
||||
pinp->v3error(
|
||||
"Format to $display-like function must have constant format string");
|
||||
|
|
@ -4464,7 +4461,7 @@ private:
|
|||
&& !VN_IS(pinp, SFormatF) // Already generates a string
|
||||
&& !VN_IS(portp->dtypep(), UnpackArrayDType) // Unpacked array must match
|
||||
&& !(VN_IS(pinp, VarRef)
|
||||
&& VN_CAST(pinp, VarRef)->varp()->basicp()->keyword()
|
||||
&& VN_AS(pinp, VarRef)->varp()->basicp()->keyword()
|
||||
== AstBasicDTypeKwd::STRING)) {
|
||||
UINFO(4, " Add CvtPackString: " << pinp << endl);
|
||||
AstNRelinker handle;
|
||||
|
|
@ -5275,7 +5272,7 @@ private:
|
|||
UASSERT_OBJ(stage == FINAL, nodep, "Bad width call");
|
||||
// We iterate and size the RHS based on the result of RHS evaluation
|
||||
bool lhsStream
|
||||
= (VN_IS(nodep, NodeAssign) && VN_IS(VN_CAST(nodep, NodeAssign)->lhsp(), NodeStream));
|
||||
= (VN_IS(nodep, NodeAssign) && VN_IS(VN_AS(nodep, NodeAssign)->lhsp(), NodeStream));
|
||||
rhsp = iterateCheck(nodep, side, rhsp, ASSIGN, FINAL, lhsDTypep,
|
||||
lhsStream ? EXTEND_OFF : EXTEND_LHS);
|
||||
// if (debug()) nodep->dumpTree(cout, "-checkout: ");
|
||||
|
|
@ -5305,7 +5302,7 @@ private:
|
|||
linker.relink(newp);
|
||||
} else if (VN_IS(underp->dtypep(), ClassRefDType)
|
||||
|| (VN_IS(underp->dtypep(), BasicDType)
|
||||
&& VN_CAST(underp->dtypep(), BasicDType)->keyword()
|
||||
&& VN_AS(underp->dtypep(), BasicDType)->keyword()
|
||||
== AstBasicDTypeKwd::CHANDLE)) {
|
||||
// Allow warning-free "if (handle)"
|
||||
VL_DO_DANGLING(fixWidthReduce(underp), underp); // Changed
|
||||
|
|
@ -5438,7 +5435,7 @@ private:
|
|||
underp = nullptr; // Changes underp
|
||||
return;
|
||||
}
|
||||
if (VN_IS(underp, Const) && VN_CAST(underp, Const)->num().isFromString()
|
||||
if (VN_IS(underp, Const) && VN_AS(underp, Const)->num().isFromString()
|
||||
&& expWidth > underp->width()
|
||||
&& (((expWidth - underp->width()) % 8) == 0)) { // At least it's character sized
|
||||
// reg [31:0] == "foo" we'll consider probably fine.
|
||||
|
|
@ -5704,7 +5701,7 @@ private:
|
|||
nodep->v3error("Argument needed for string." + nodep->prettyName() + " method");
|
||||
return;
|
||||
}
|
||||
AstNodeVarRef* fromp = VN_CAST(nodep->fromp()->unlinkFrBack(), VarRef);
|
||||
AstNodeVarRef* fromp = VN_AS(nodep->fromp()->unlinkFrBack(), VarRef);
|
||||
AstNode* newp = new AstAssign(
|
||||
nodep->fileline(), fromp,
|
||||
new AstSFormatF(nodep->fileline(), format, false, argp->exprp()->unlinkFrBack()));
|
||||
|
|
@ -5860,8 +5857,8 @@ private:
|
|||
// a map for when the value is many bits and sparse.
|
||||
uint64_t maxval = 0;
|
||||
for (const AstEnumItem* itemp = adtypep->itemsp(); itemp;
|
||||
itemp = VN_CAST(itemp->nextp(), EnumItem)) {
|
||||
const AstConst* vconstp = VN_CAST(itemp->valuep(), Const);
|
||||
itemp = VN_AS(itemp->nextp(), EnumItem)) {
|
||||
const AstConst* vconstp = VN_AS(itemp->valuep(), Const);
|
||||
UASSERT_OBJ(vconstp, errNodep, "Enum item without constified value");
|
||||
if (vconstp->toUQuad() >= maxval) maxval = vconstp->toUQuad();
|
||||
}
|
||||
|
|
@ -5923,10 +5920,10 @@ private:
|
|||
{
|
||||
AstEnumItem* firstp = nodep->itemsp();
|
||||
AstEnumItem* prevp = firstp; // Prev must start with last item
|
||||
while (prevp->nextp()) prevp = VN_CAST(prevp->nextp(), EnumItem);
|
||||
while (prevp->nextp()) prevp = VN_AS(prevp->nextp(), EnumItem);
|
||||
for (AstEnumItem* itemp = firstp; itemp;) {
|
||||
AstEnumItem* nextp = VN_CAST(itemp->nextp(), EnumItem);
|
||||
const AstConst* vconstp = VN_CAST(itemp->valuep(), Const);
|
||||
AstEnumItem* nextp = VN_AS(itemp->nextp(), EnumItem);
|
||||
const AstConst* vconstp = VN_AS(itemp->valuep(), Const);
|
||||
UASSERT_OBJ(vconstp, nodep, "Enum item without constified value");
|
||||
uint32_t i = vconstp->toUInt();
|
||||
if (attrType == AstAttrType::ENUM_NAME) {
|
||||
|
|
@ -5956,8 +5953,8 @@ private:
|
|||
PatVecMap patVectorMap(AstPattern* nodep, const VNumRange& range) {
|
||||
PatVecMap patmap;
|
||||
int element = range.left();
|
||||
for (AstPatMember* patp = VN_CAST(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_CAST(patp->nextp(), PatMember)) {
|
||||
for (AstPatMember* patp = VN_AS(nodep->itemsp(), PatMember); patp;
|
||||
patp = VN_AS(patp->nextp(), PatMember)) {
|
||||
if (patp->keyp()) {
|
||||
if (const AstConst* constp = VN_CAST(patp->keyp(), Const)) {
|
||||
element = constp->toSInt();
|
||||
|
|
@ -6052,11 +6049,11 @@ private:
|
|||
} else if (VN_IS(toDtp, EnumDType)) {
|
||||
if (fromNumericable) return DYNAMIC_ENUM;
|
||||
} else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromConstp, Const)) {
|
||||
if (VN_IS(fromConstp, Const) && VN_CAST(fromConstp, Const)->num().isNull())
|
||||
if (VN_IS(fromConstp, Const) && VN_AS(fromConstp, Const)->num().isNull())
|
||||
return COMPATIBLE;
|
||||
} else if (VN_IS(toDtp, ClassRefDType) && VN_IS(fromDtp, ClassRefDType)) {
|
||||
const auto toClassp = VN_CAST(toDtp, ClassRefDType)->classp();
|
||||
const auto fromClassp = VN_CAST(fromDtp, ClassRefDType)->classp();
|
||||
const auto toClassp = VN_AS(toDtp, ClassRefDType)->classp();
|
||||
const auto fromClassp = VN_AS(fromDtp, ClassRefDType)->classp();
|
||||
const bool downcast = AstClass::isClassExtendedFrom(toClassp, fromClassp);
|
||||
const bool upcast = AstClass::isClassExtendedFrom(fromClassp, toClassp);
|
||||
if (upcast) {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ private:
|
|||
iterateChildren(nodep);
|
||||
editDType(nodep);
|
||||
if (nodep->classMethod() && nodep->pureVirtual() && VN_IS(m_modp, Class)
|
||||
&& !VN_CAST(m_modp, Class)->isVirtual()) {
|
||||
&& !VN_AS(m_modp, Class)->isVirtual()) {
|
||||
nodep->v3error(
|
||||
"Illegal to have 'pure virtual' in non-virtual class (IEEE 1800-2017 8.21)");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,7 +75,7 @@ private:
|
|||
VNumRange fromRange; // constructs to isRanged(false)
|
||||
while (basefromp) {
|
||||
if (VN_IS(basefromp, AttrOf)) {
|
||||
basefromp = VN_CAST(basefromp, AttrOf)->fromp();
|
||||
basefromp = VN_AS(basefromp, AttrOf)->fromp();
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
|
|
@ -120,7 +120,7 @@ private:
|
|||
} else if (VN_IS(lhsp, Const)) {
|
||||
// Optional vs just making add/sub below, but saves constification some work
|
||||
V3Number num(lhsp, lhsp->width());
|
||||
num.opSub(VN_CAST(lhsp, Const)->num(), V3Number(lhsp, 32, rhs));
|
||||
num.opSub(VN_AS(lhsp, Const)->num(), V3Number(lhsp, 32, rhs));
|
||||
num.isSigned(lhsp->isSigned());
|
||||
AstNode* newp = new AstConst(lhsp->fileline(), num);
|
||||
return newp;
|
||||
|
|
@ -189,7 +189,7 @@ private:
|
|||
}
|
||||
|
||||
void warnTri(AstNode* nodep) {
|
||||
if (VN_IS(nodep, Const) && VN_CAST(nodep, Const)->num().isFourState()) {
|
||||
if (VN_IS(nodep, Const) && VN_AS(nodep, Const)->num().isFourState()) {
|
||||
nodep->v3error(
|
||||
"Selection index is constantly unknown or tristated: " << nodep->name());
|
||||
}
|
||||
|
|
@ -332,8 +332,8 @@ private:
|
|||
AstNode* fromp = nodep->fromp()->unlinkFrBack();
|
||||
AstNode* msbp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* lsbp = nodep->thsp()->unlinkFrBack();
|
||||
vlsint32_t msb = VN_CAST(msbp, Const)->toSInt();
|
||||
vlsint32_t lsb = VN_CAST(lsbp, Const)->toSInt();
|
||||
vlsint32_t msb = VN_AS(msbp, Const)->toSInt();
|
||||
vlsint32_t lsb = VN_AS(lsbp, Const)->toSInt();
|
||||
vlsint32_t elem = (msb > lsb) ? (msb - lsb + 1) : (lsb - msb + 1);
|
||||
const FromData fromdata = fromDataForArray(nodep, fromp);
|
||||
AstNodeDType* ddtypep = fromdata.m_dtypep;
|
||||
|
|
@ -479,7 +479,7 @@ private:
|
|||
AstNode* rhsp = nodep->rhsp()->unlinkFrBack();
|
||||
AstNode* widthp = nodep->thsp()->unlinkFrBack();
|
||||
warnTri(rhsp);
|
||||
const int width = VN_CAST(widthp, Const)->toSInt();
|
||||
const int width = VN_AS(widthp, Const)->toSInt();
|
||||
if (width > (1 << 28)) {
|
||||
nodep->v3error("Width of :+ or :- is huge; vector of over 1billion bits: "
|
||||
<< widthp->prettyName());
|
||||
|
|
@ -491,7 +491,7 @@ private:
|
|||
if (VN_IS(ddtypep, UnpackArrayDType)) {
|
||||
// Slice +: and -: extraction
|
||||
if (fromRange.elements() == width && VN_IS(rhsp, Const)
|
||||
&& VN_CAST(rhsp, Const)->toSInt()
|
||||
&& VN_AS(rhsp, Const)->toSInt()
|
||||
== fromRange.lo()) { // Extracting whole of original array
|
||||
nodep->replaceWith(fromp);
|
||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||
|
|
@ -500,7 +500,7 @@ private:
|
|||
nodep->replaceWith(newp);
|
||||
VL_DO_DANGLING(pushDeletep(nodep), nodep);
|
||||
} else if (VN_IS(rhsp, Const)) { // Slice
|
||||
vlsint32_t rhs = VN_CAST(rhsp, Const)->toSInt();
|
||||
vlsint32_t rhs = VN_AS(rhsp, Const)->toSInt();
|
||||
// down array: lsb/lo +: width
|
||||
// down array: msb/hi -: width
|
||||
// up array: msb/lo +: width
|
||||
|
|
@ -516,7 +516,7 @@ private:
|
|||
}
|
||||
} else if (VN_IS(ddtypep, BasicDType) || VN_IS(ddtypep, PackArrayDType)
|
||||
|| (VN_IS(ddtypep, NodeUOrStructDType)
|
||||
&& VN_CAST(ddtypep, NodeUOrStructDType)->packedUnsup())) {
|
||||
&& VN_AS(ddtypep, NodeUOrStructDType)->packedUnsup())) {
|
||||
int elwidth = 1;
|
||||
AstNode* newwidthp = widthp;
|
||||
if (const AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue