Internals: Width debug and null print check

This commit is contained in:
Wilson Snyder 2012-07-27 21:12:06 -04:00
parent 6e219f5831
commit 1899096ff4
5 changed files with 16 additions and 9 deletions

View File

@ -758,13 +758,16 @@ void AstNode::iterateAndNext(AstNVisitor& v, AstNUser* vup) {
// Future versions of this function may require the node to have a back to be iterated;
// there's no lower level reason yet though the back must exist.
AstNode* nodep=this;
#ifdef VL_DEBUG // Otherwise too hot of a function for debug
if (VL_UNLIKELY(nodep && !nodep->m_backp)) nodep->v3fatalSrc("iterateAndNext node has no back");
#endif
while (nodep) {
AstNode* niterp = nodep;
AstNode* niterp = nodep; // This address may get stomped via m_iterpp if the node is edited
ASTNODE_PREFETCH(nodep->m_nextp);
niterp->m_iterpp = &niterp;
niterp->accept(v, vup);
// accept may do a replaceNode and change niterp on us...
//if (niterp != nodep) UINFO(1,"iterateAndNext edited "<<(void*)nodep<<" now into "<<(void*)niterp<<endl); // niterp maybe NULL, so need cast
if (!niterp) return;
niterp->m_iterpp = NULL;
if (VL_UNLIKELY(niterp!=nodep)) { // Edited it

View File

@ -1144,7 +1144,7 @@ public:
// AstAlways* castAlways();
};
inline ostream& operator<<(ostream& os, AstNode* rhs) { rhs->dump(os); return os;}
inline ostream& operator<<(ostream& os, AstNode* rhs) { if (!rhs) os<<"NULL"; else rhs->dump(os); return os; }
inline void AstNRelinker::relink(AstNode* newp) { newp->AstNode::relink(this); }
//######################################################################

View File

@ -124,11 +124,7 @@ private:
#define ANYSIZE 0
// METHODS
static int debug() {
static int level = -1;
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
return level;
}
static int debug() { return V3Width::debug(); }
// VISITORS
// Naming: width_O{outputtype}_L{lhstype}_R{rhstype}_W{widthing}_S{signing}
@ -2125,6 +2121,12 @@ public:
//######################################################################
// Width class functions
int V3Width::debug() {
static int level = -1;
if (VL_UNLIKELY(level < 0)) level = v3Global.opt.debugSrcLevel(__FILE__);
return level;
}
void V3Width::width(AstNetlist* nodep) {
UINFO(2,__FUNCTION__<<": "<<endl);
// We should do it in bottom-up module order, but it works in any order.
@ -2137,7 +2139,7 @@ void V3Width::width(AstNetlist* nodep) {
//! Single node parameter propagation
//! Smaller step... Only do a single node for parameter propagation
AstNode* V3Width::widthParamsEdit (AstNode* nodep) {
UINFO(4,__FUNCTION__<<": "<<endl);
UINFO(4,__FUNCTION__<<": "<<nodep<<endl);
// We should do it in bottom-up module order, but it works in any order.
WidthVisitor visitor (true, false);
nodep = visitor.mainAcceptEdit(nodep);
@ -2157,7 +2159,7 @@ AstNode* V3Width::widthParamsEdit (AstNode* nodep) {
//! @return Pointer to the edited node.
AstNode* V3Width::widthGenerateParamsEdit(
AstNode* nodep) { //!< [in] AST whose parameters widths are to be analysed.
UINFO(4,__FUNCTION__<<": "<<endl);
UINFO(4,__FUNCTION__<<": "<<nodep<<endl);
// We should do it in bottom-up module order, but it works in any order.
WidthVisitor visitor (true, true);
nodep = visitor.mainAcceptEdit(nodep);

View File

@ -29,6 +29,7 @@
class V3Width {
public:
static int debug();
static void width(AstNetlist* nodep);
static AstNode* widthParamsEdit(AstNode* nodep);
static AstNode* widthGenerateParamsEdit(AstNode* nodep);

View File

@ -392,6 +392,7 @@ public:
// Width class functions
AstNode* V3Width::widthSelNoIterEdit(AstNode* nodep) {
UINFO(4,__FUNCTION__<<": "<<nodep<<endl);
WidthSelVisitor visitor;
nodep = visitor.mainAcceptEdit(nodep);
return nodep;