From b1872a8e215f88ffb661768a544de4f23582ff21 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Mon, 1 Feb 2010 20:15:48 -0500 Subject: [PATCH] Internals: Add enum prefixes to reduce MSVC macro conflicts --- src/V3Active.cpp | 8 ++-- src/V3Assert.cpp | 18 ++++----- src/V3Ast.h | 89 +++++++++++++++++++++---------------------- src/V3AstNodes.h | 24 ++++++------ src/V3Branch.cpp | 4 +- src/V3Clean.cpp | 8 ++-- src/V3Clock.cpp | 12 +++--- src/V3Const.cpp | 16 ++++---- src/V3Descope.cpp | 2 +- src/V3EmitC.cpp | 4 +- src/V3Error.cpp | 64 +++++++++++++++---------------- src/V3Error.h | 32 ++++++++-------- src/V3LinkParse.cpp | 32 ++++++++-------- src/V3LinkResolve.cpp | 8 ++-- src/V3Options.cpp | 4 +- src/V3Options.h | 2 +- src/V3OrderGraph.h | 2 +- src/V3Stats.cpp | 4 +- src/V3Trace.cpp | 2 +- src/verilog.y | 70 +++++++++++++++++----------------- 20 files changed, 202 insertions(+), 203 deletions(-) diff --git a/src/V3Active.cpp b/src/V3Active.cpp index 4c03311df..4467c80db 100644 --- a/src/V3Active.cpp +++ b/src/V3Active.cpp @@ -333,15 +333,15 @@ private: } virtual void visit(AstSenGate* nodep, AstNUser*) { AstSenItem* subitemp = nodep->sensesp(); - if (subitemp->edgeType() != AstEdgeType::ANYEDGE - && subitemp->edgeType() != AstEdgeType::POSEDGE - && subitemp->edgeType() != AstEdgeType::NEGEDGE) { + if (subitemp->edgeType() != AstEdgeType::ET_ANYEDGE + && subitemp->edgeType() != AstEdgeType::ET_POSEDGE + && subitemp->edgeType() != AstEdgeType::ET_NEGEDGE) { nodep->v3fatalSrc("Strange activity type under SenGate"); } nodep->iterateChildren(*this); } virtual void visit(AstSenItem* nodep, AstNUser*) { - if (nodep->edgeType() == AstEdgeType::ANYEDGE) { + if (nodep->edgeType() == AstEdgeType::ET_ANYEDGE) { m_itemCombo = true; // Delete the sensitivity // We'll add it as a generic COMBO SenItem in a moment. diff --git a/src/V3Assert.cpp b/src/V3Assert.cpp index cda004d17..11d43284a 100644 --- a/src/V3Assert.cpp +++ b/src/V3Assert.cpp @@ -60,7 +60,7 @@ private: +"\\n"); } void replaceDisplay(AstDisplay* nodep, const string& prefix) { - nodep->displayType(AstDisplayType::WRITE); + nodep->displayType(AstDisplayType::DT_WRITE); nodep->fmtp()->text(assertDisplayMessage(nodep, prefix, nodep->fmtp()->text())); AstNode* timesp = nodep->fmtp()->exprsp(); if (timesp) timesp->unlinkFrBack(); timesp = timesp->addNext(new AstTime(nodep->fileline())); @@ -95,7 +95,7 @@ private: } AstNode* newFireAssert(AstNode* nodep, const string& message) { - AstDisplay* dispp = new AstDisplay (nodep->fileline(), AstDisplayType::ERROR, message, NULL, NULL); + AstDisplay* dispp = new AstDisplay (nodep->fileline(), AstDisplayType::DT_ERROR, message, NULL, NULL); AstNode* bodysp = dispp; replaceDisplay(dispp, "%%Error"); // Convert to standard DISPLAY format bodysp->addNext(new AstStop (nodep->fileline())); @@ -134,7 +134,7 @@ private: if (stmtsp) bodysp = bodysp->addNext(stmtsp); AstIf* ifp = new AstIf (nodep->fileline(), propp, bodysp, NULL); bodysp = ifp; - if (nodep->castPslAssert()) ifp->branchPred(AstBranchPred::UNLIKELY); + if (nodep->castPslAssert()) ifp->branchPred(AstBranchPred::BP_UNLIKELY); // AstNode* newp = new AstAlways (nodep->fileline(), sentreep, @@ -166,7 +166,7 @@ private: AstIf* ifp = new AstIf (nodep->fileline(), propp, passsp, failsp); AstNode* newp = ifp; - if (nodep->castVAssert()) ifp->branchPred(AstBranchPred::UNLIKELY); + if (nodep->castVAssert()) ifp->branchPred(AstBranchPred::BP_UNLIKELY); // // Install it nodep->replaceWith(newp); @@ -215,7 +215,7 @@ private: new AstLogNot (nodep->fileline(), ohot), newFireAssert(nodep, "synthesis parallel_case, but multiple matches found"), NULL); - ifp->branchPred(AstBranchPred::UNLIKELY); + ifp->branchPred(AstBranchPred::BP_UNLIKELY); nodep->addNotParallelp(ifp); } } @@ -226,12 +226,12 @@ private: virtual void visit(AstDisplay* nodep, AstNUser*) { nodep->iterateChildren(*this); // Replace the special types with standard text - if (nodep->displayType()==AstDisplayType::INFO) { + if (nodep->displayType()==AstDisplayType::DT_INFO) { replaceDisplay(nodep, "-Info"); - } else if (nodep->displayType()==AstDisplayType::WARNING) { + } else if (nodep->displayType()==AstDisplayType::DT_WARNING) { replaceDisplay(nodep, "%%Warning"); - } else if (nodep->displayType()==AstDisplayType::ERROR - || nodep->displayType()==AstDisplayType::FATAL) { + } else if (nodep->displayType()==AstDisplayType::DT_ERROR + || nodep->displayType()==AstDisplayType::DT_FATAL) { replaceDisplay(nodep, "%%Error"); } } diff --git a/src/V3Ast.h b/src/V3Ast.h index f5e0f7f80..7440bf28e 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -81,7 +81,7 @@ public: class AstCFuncType { public: enum en { - NORMAL, + FT_NORMAL, TRACE_INIT, TRACE_INIT_SUB, TRACE_FULL, @@ -110,19 +110,19 @@ public: // REMEMBER to edit the strings below too enum en { // These must be in general -> most specific order, as we sort by it in V3Const::visit AstSenTre - ILLEGAL, + ET_ILLEGAL, // Involving a variable - ANYEDGE, // Default for sensitivities; rip them out - BOTHEDGE, // POSEDGE | NEGEDGE - POSEDGE, - NEGEDGE, - HIGHEDGE, // Is high now (latches) - LOWEDGE, // Is low now (latches) + ET_ANYEDGE, // Default for sensitivities; rip them out + ET_BOTHEDGE, // POSEDGE | NEGEDGE + ET_POSEDGE, + ET_NEGEDGE, + ET_HIGHEDGE, // Is high now (latches) + ET_LOWEDGE, // Is low now (latches) // Not involving anything - COMBO, // Sensitive to all combo inputs to this block - INITIAL, // User initial statements - SETTLE, // Like combo but for initial wire resolutions after initial statement - NEVER // Never occurs (optimized away) + ET_COMBO, // Sensitive to all combo inputs to this block + ET_INITIAL, // User initial statements + ET_SETTLE, // Like combo but for initial wire resolutions after initial statement + ET_NEVER // Never occurs (optimized away) }; enum en m_e; bool clockedStmt() const { @@ -134,15 +134,15 @@ public: } AstEdgeType invert() const { switch (m_e) { - case ANYEDGE: return ANYEDGE; - case BOTHEDGE: return BOTHEDGE; - case POSEDGE: return NEGEDGE; - case NEGEDGE: return POSEDGE; - case HIGHEDGE: return LOWEDGE; - case LOWEDGE: return HIGHEDGE; + case ET_ANYEDGE: return ET_ANYEDGE; + case ET_BOTHEDGE: return ET_BOTHEDGE; + case ET_POSEDGE: return ET_NEGEDGE; + case ET_NEGEDGE: return ET_POSEDGE; + case ET_HIGHEDGE: return ET_LOWEDGE; + case ET_LOWEDGE: return ET_HIGHEDGE; default: UASSERT_STATIC(0,"Inverting bad edgeType()"); }; - return AstEdgeType::ILLEGAL; + return AstEdgeType::ET_ILLEGAL; } const char* ascii() const { static const char* names[] = { @@ -172,7 +172,7 @@ public: class AstAttrType { public: enum en { - BITS, // V3Const converts to constant + EXPR_BITS, // V3Const converts to constant // VAR_BASE, // V3LinkResolve creates for AstPreSel, V3LinkParam removes VAR_CLOCK, // V3LinkParse moves to AstVar::attrScClocked @@ -185,7 +185,7 @@ public: enum en m_e; const char* ascii() const { static const char* names[] = { - "BITS", "VAR_BASE", + "EXPR_BITS", "VAR_BASE", "VAR_CLOCK", "VAR_CLOCK_ENABLE", "VAR_PUBLIC", "VAR_PUBLIC_FLAT", "VAR_ISOLATE_ASSIGNMENTS", "VAR_SFORMAT" }; @@ -335,20 +335,20 @@ public: class AstBranchPred { public: enum en { - UNKNOWN=0, - LIKELY, - UNLIKELY, + BP_UNKNOWN=0, + BP_LIKELY, + BP_UNLIKELY, _ENUM_END }; enum en m_e; // CONSTRUCTOR - note defaults to *UNKNOWN* - inline AstBranchPred () : m_e(UNKNOWN) {} + inline AstBranchPred () : m_e(BP_UNKNOWN) {} inline AstBranchPred (en _e) : m_e(_e) {} explicit inline AstBranchPred (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } AstBranchPred invert() const { - if (m_e==UNLIKELY) return LIKELY; - else if (m_e==LIKELY) return UNLIKELY; + if (m_e==BP_UNLIKELY) return BP_LIKELY; + else if (m_e==BP_LIKELY) return BP_UNLIKELY; else return m_e; } const char* ascii() const { @@ -366,9 +366,9 @@ public: class AstCaseType { public: enum en { - CASE, - CASEX, - CASEZ + CT_CASE, + CT_CASEX, + CT_CASEZ }; enum en m_e; inline AstCaseType () {} @@ -385,20 +385,20 @@ public: class AstDisplayType { public: enum en { - DISPLAY, - WRITE, - INFO, - ERROR, - WARNING, - FATAL + DT_DISPLAY, + DT_WRITE, + DT_INFO, + DT_ERROR, + DT_WARNING, + DT_FATAL }; enum en m_e; inline AstDisplayType () {} inline AstDisplayType (en _e) : m_e(_e) {} explicit inline AstDisplayType (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } - bool addNewline() const { return m_e!=WRITE; } - bool needScopeTracking() const { return m_e!=DISPLAY && m_e!=WRITE; } + bool addNewline() const { return m_e!=DT_WRITE; } + bool needScopeTracking() const { return m_e!=DT_DISPLAY && m_e!=DT_WRITE; } const char* ascii() const { static const char* names[] = { "display","write","info","error","warning","fatal"}; @@ -413,15 +413,14 @@ public: class AstParseRefExp { public: enum en { - NONE, // Used in V3LinkParse only - VAR_MEM, - VAR_ANY, - TASK, - FUNC, - _ENUM_END + PX_NONE, // Used in V3LinkParse only + PX_VAR_MEM, + PX_VAR_ANY, + PX_TASK, + PX_FUNC }; enum en m_e; - inline AstParseRefExp() : m_e(NONE) {} + inline AstParseRefExp() : m_e(PX_NONE) {} inline AstParseRefExp (en _e) : m_e(_e) {} explicit inline AstParseRefExp (int _e) : m_e(static_cast(_e)) {} operator en () const { return m_e; } diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 5dd5cff5c..907cba462 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -1172,19 +1172,19 @@ public: } AstSenItem(FileLine* fl, Combo) : AstNodeSenItem(fl) { - m_edgeType = AstEdgeType::COMBO; + m_edgeType = AstEdgeType::ET_COMBO; } AstSenItem(FileLine* fl, Initial) : AstNodeSenItem(fl) { - m_edgeType = AstEdgeType::INITIAL; + m_edgeType = AstEdgeType::ET_INITIAL; } AstSenItem(FileLine* fl, Settle) : AstNodeSenItem(fl) { - m_edgeType = AstEdgeType::SETTLE; + m_edgeType = AstEdgeType::ET_SETTLE; } AstSenItem(FileLine* fl, Never) : AstNodeSenItem(fl) { - m_edgeType = AstEdgeType::NEVER; + m_edgeType = AstEdgeType::ET_NEVER; } ASTNODE_NODE_FUNCS(SenItem, SENITEM) virtual void dump(ostream& str); @@ -1197,10 +1197,10 @@ public: AstNodeVarRef* varrefp() const { return op1p()->castNodeVarRef(); } // op1 = Signal sensitized // virtual bool isClocked() const { return edgeType().clockedStmt(); } - virtual bool isCombo() const { return edgeType()==AstEdgeType::COMBO; } - virtual bool isInitial() const { return edgeType()==AstEdgeType::INITIAL; } - virtual bool isSettle() const { return edgeType()==AstEdgeType::SETTLE; } - virtual bool isNever() const { return edgeType()==AstEdgeType::NEVER; } + virtual bool isCombo() const { return edgeType()==AstEdgeType::ET_COMBO; } + virtual bool isInitial() const { return edgeType()==AstEdgeType::ET_INITIAL; } + virtual bool isSettle() const { return edgeType()==AstEdgeType::ET_SETTLE; } + virtual bool isNever() const { return edgeType()==AstEdgeType::ET_NEVER; } bool hasVar() const { return !(isCombo()||isInitial()||isSettle()||isNever()); } }; @@ -1515,8 +1515,8 @@ public: virtual string verilogKwd() const { return casez()?"casez":casex()?"casex":"case"; } virtual bool same(AstNode* samep) const { return m_casex==samep->castCase()->m_casex; } - bool casex() const { return m_casex==AstCaseType::CASEX; } - bool casez() const { return m_casex==AstCaseType::CASEZ; } + bool casex() const { return m_casex==AstCaseType::CT_CASEX; } + bool casez() const { return m_casex==AstCaseType::CT_CASEZ; } bool fullPragma() const { return m_fullPragma; } void fullPragma(bool flag) { m_fullPragma=flag; } bool parallelPragma() const { return m_parallelPragma; } @@ -3294,7 +3294,7 @@ private: public: AstCFunc(FileLine* fl, const string& name, AstScope* scopep, const string& rtnType="") : AstNode(fl) { - m_funcType = AstCFuncType::NORMAL; + m_funcType = AstCFuncType::FT_NORMAL; m_scopep = scopep; m_name = name; m_rtnType = rtnType; @@ -3331,7 +3331,7 @@ public: AstScope* scopep() const { return m_scopep; } void scopep(AstScope* nodep) { m_scopep = nodep; } string rtnTypeVoid() const { return ((m_rtnType=="") ? "void" : m_rtnType); } - bool dontCombine() const { return m_dontCombine || funcType()!=AstCFuncType::NORMAL; } + bool dontCombine() const { return m_dontCombine || funcType()!=AstCFuncType::FT_NORMAL; } void dontCombine(bool flag) { m_dontCombine = flag; } bool skipDecl() const { return m_skipDecl; } void skipDecl(bool flag) { m_skipDecl = flag; } diff --git a/src/V3Branch.cpp b/src/V3Branch.cpp index 7a7d0b50c..0da01fb24 100644 --- a/src/V3Branch.cpp +++ b/src/V3Branch.cpp @@ -76,9 +76,9 @@ private: // Compute int likeness = ifLikely - ifUnlikely - (elseLikely - elseUnlikely); if (likeness>0) { - nodep->branchPred(AstBranchPred::LIKELY); + nodep->branchPred(AstBranchPred::BP_LIKELY); } else if (likeness<0) { - nodep->branchPred(AstBranchPred::UNLIKELY); + nodep->branchPred(AstBranchPred::BP_UNLIKELY); } // else leave unknown } m_likely = lastLikely; diff --git a/src/V3Clean.cpp b/src/V3Clean.cpp index 7124a8bff..8451771e0 100644 --- a/src/V3Clean.cpp +++ b/src/V3Clean.cpp @@ -52,7 +52,7 @@ private: AstUser2InUse m_inuser2; // TYPES - enum CleanState { UNKNOWN, CLEAN, DIRTY }; + enum CleanState { CS_UNKNOWN, CS_CLEAN, CS_DIRTY }; // STATE AstNodeModule* m_modp; @@ -93,15 +93,15 @@ private: } bool isClean(AstNode* nodep) { CleanState clstate = getCleanState(nodep); - if (clstate==CLEAN) return true; - if (clstate==DIRTY) return false; + if (clstate==CS_CLEAN) return true; + if (clstate==CS_DIRTY) return false; nodep->v3fatalSrc("Unknown clean state on node: "+nodep->prettyTypeName()); return false; } void setClean(AstNode* nodep, bool isClean) { computeCppWidth (nodep); // Just to be sure it's in widthMin bool wholeUint = ((nodep->widthMin() % VL_WORDSIZE) == 0); //32,64,... - setCleanState(nodep, ((isClean||wholeUint) ? CLEAN:DIRTY)); + setCleanState(nodep, ((isClean||wholeUint) ? CS_CLEAN:CS_DIRTY)); } // Operate on nodes diff --git a/src/V3Clock.cpp b/src/V3Clock.cpp index f4df685f0..fbbd6d34f 100644 --- a/src/V3Clock.cpp +++ b/src/V3Clock.cpp @@ -123,7 +123,7 @@ private: // LOWEDGE: ~var AstNode* newp = NULL; AstVarScope* clkvscp = nodep->varrefp()->varScopep(); - if (nodep->edgeType()==AstEdgeType::POSEDGE) { + if (nodep->edgeType()==AstEdgeType::ET_POSEDGE) { AstVarScope* lastVscp = getCreateLastClk(clkvscp); newp = new AstAnd(nodep->fileline(), new AstVarRef(nodep->fileline(), @@ -131,23 +131,23 @@ private: new AstNot(nodep->fileline(), new AstVarRef(nodep->fileline(), lastVscp, false))); - } else if (nodep->edgeType()==AstEdgeType::NEGEDGE) { + } else if (nodep->edgeType()==AstEdgeType::ET_NEGEDGE) { AstVarScope* lastVscp = getCreateLastClk(clkvscp); newp = new AstAnd(nodep->fileline(), new AstNot(nodep->fileline(), new AstVarRef(nodep->fileline(), nodep->varrefp()->varScopep(), false)), new AstVarRef(nodep->fileline(), lastVscp, false)); - } else if (nodep->edgeType()==AstEdgeType::BOTHEDGE) { + } else if (nodep->edgeType()==AstEdgeType::ET_BOTHEDGE) { AstVarScope* lastVscp = getCreateLastClk(clkvscp); newp = new AstXor(nodep->fileline(), new AstVarRef(nodep->fileline(), nodep->varrefp()->varScopep(), false), new AstVarRef(nodep->fileline(), lastVscp, false)); - } else if (nodep->edgeType()==AstEdgeType::HIGHEDGE) { + } else if (nodep->edgeType()==AstEdgeType::ET_HIGHEDGE) { newp = new AstVarRef(nodep->fileline(), clkvscp, false); - } else if (nodep->edgeType()==AstEdgeType::LOWEDGE) { + } else if (nodep->edgeType()==AstEdgeType::ET_LOWEDGE) { newp = new AstNot(nodep->fileline(), new AstVarRef(nodep->fileline(), clkvscp, false)); @@ -506,7 +506,7 @@ private: ifstmtp->addNext(new AstIf(fl, new AstLt (fl, new AstConst(fl, 100), new AstVarRef(fl, countVarp, false)), - (new AstDisplay (fl, AstDisplayType::DISPLAY, + (new AstDisplay (fl, AstDisplayType::DT_DISPLAY, "%%Error: Verilated model didn't converge", NULL, NULL)) ->addNext(new AstStop (fl)), NULL)); diff --git a/src/V3Const.cpp b/src/V3Const.cpp index 63476045c..757ea1091 100644 --- a/src/V3Const.cpp +++ b/src/V3Const.cpp @@ -1106,7 +1106,7 @@ private: virtual void visit(AstAttrOf* nodep, AstNUser*) { // Don't iterate children, don't want to loose VarRef. - if (nodep->attrType()==AstAttrType::BITS) { + if (nodep->attrType()==AstAttrType::EXPR_BITS) { if (!nodep->fromp() || !nodep->fromp()->widthMin()) nodep->v3fatalSrc("Unsized expression"); V3Number num (nodep->fileline(), 32, nodep->fromp()->widthMin()); replaceNum(nodep, num); nodep=NULL; @@ -1278,16 +1278,16 @@ private: if ((litemp->varrefp() && ritemp->varrefp() && litemp->varrefp()->sameTree(ritemp->varrefp())) || (!litemp->varrefp() && !ritemp->varrefp())) { // We've sorted in the order ANY, BOTH, POS, NEG, so we don't need to try opposite orders - if (( litemp->edgeType()==AstEdgeType::ANYEDGE) // ANY or {BOTH|POS|NEG} -> ANY - || (litemp->edgeType()==AstEdgeType::BOTHEDGE) // BOTH or {POS|NEG} -> BOTH - || (litemp->edgeType()==AstEdgeType::POSEDGE // POS or NEG -> BOTH - && ritemp->edgeType()==AstEdgeType::NEGEDGE) + if (( litemp->edgeType()==AstEdgeType::ET_ANYEDGE) // ANY or {BOTH|POS|NEG} -> ANY + || (litemp->edgeType()==AstEdgeType::ET_BOTHEDGE) // BOTH or {POS|NEG} -> BOTH + || (litemp->edgeType()==AstEdgeType::ET_POSEDGE // POS or NEG -> BOTH + && ritemp->edgeType()==AstEdgeType::ET_NEGEDGE) || (litemp->edgeType()==ritemp->edgeType()) // Identical edges ) { // Fix edge of old node - if (litemp->edgeType()==AstEdgeType::POSEDGE - && ritemp->edgeType()==AstEdgeType::NEGEDGE) - litemp->edgeType(AstEdgeType::BOTHEDGE); + if (litemp->edgeType()==AstEdgeType::ET_POSEDGE + && ritemp->edgeType()==AstEdgeType::ET_NEGEDGE) + litemp->edgeType(AstEdgeType::ET_BOTHEDGE); // Remove redundant node ritemp->unlinkFrBack()->deleteTree(); ritemp=NULL; cmpp=NULL; // Try to collapse again diff --git a/src/V3Descope.cpp b/src/V3Descope.cpp index 859fb55f9..1290b72d5 100644 --- a/src/V3Descope.cpp +++ b/src/V3Descope.cpp @@ -166,7 +166,7 @@ private: } } // Not really any way the user could do this, and we'd need to come up with some return value - //newfuncp->addStmtsp(new AstDisplay (newfuncp->fileline(), AstDisplayType::DISPLAY, + //newfuncp->addStmtsp(new AstDisplay (newfuncp->fileline(), AstDisplayType::DT_DISPLAY, // string("%%Error: ")+name+"() called with bad scope", NULL)); //newfuncp->addStmtsp(new AstStop (newfuncp->fileline())); if (debug()>=9) newfuncp->dumpTree(cout," newfunc: "); diff --git a/src/V3EmitC.cpp b/src/V3EmitC.cpp index 3d84a188c..e6d8fa128 100644 --- a/src/V3EmitC.cpp +++ b/src/V3EmitC.cpp @@ -371,11 +371,11 @@ public: } virtual void visit(AstNodeIf* nodep, AstNUser*) { puts("if ("); - if (nodep->branchPred() != AstBranchPred::UNKNOWN) { + if (nodep->branchPred() != AstBranchPred::BP_UNKNOWN) { puts(nodep->branchPred().ascii()); puts("("); } nodep->condp()->iterateAndNext(*this); - if (nodep->branchPred() != AstBranchPred::UNKNOWN) puts(")"); + if (nodep->branchPred() != AstBranchPred::BP_UNKNOWN) puts(")"); puts(") {\n"); nodep->ifsp()->iterateAndNext(*this); if (nodep->elsesp()) { diff --git a/src/V3Error.cpp b/src/V3Error.cpp index c53d4f207..12cca0764 100644 --- a/src/V3Error.cpp +++ b/src/V3Error.cpp @@ -41,10 +41,10 @@ int V3Error::s_warnCount = 0; int V3Error::s_debugDefault = 0; int V3Error::s_tellManual = 0; ostringstream V3Error::s_errorStr; // Error string being formed -V3ErrorCode V3Error::s_errorCode = V3ErrorCode::FATAL; -bool V3Error::s_describedEachWarn[V3ErrorCode::MAX]; +V3ErrorCode V3Error::s_errorCode = V3ErrorCode::EC_FATAL; +bool V3Error::s_describedEachWarn[V3ErrorCode::_ENUM_MAX]; bool V3Error::s_describedWarnings = false; -bool V3Error::s_pretendError[V3ErrorCode::MAX]; +bool V3Error::s_pretendError[V3ErrorCode::_ENUM_MAX]; struct v3errorIniter { v3errorIniter() { V3Error::init(); } @@ -56,13 +56,13 @@ v3errorIniter v3errorInit; V3ErrorCode::V3ErrorCode(const char* msgp) { // Return error encoding for given string, or ERROR, which is a bad code - for (int codei=V3ErrorCode::FIRST_WARN; codeiwarnIsOff(code)) { this->warnOff(code, true); @@ -242,13 +242,13 @@ void FileLine::deleteAllRemaining() { // V3Error class functions void V3Error::init() { - for (int i=0; i=V3ErrorCode::FIRST_WARN) { + if (s_errorCode>=V3ErrorCode::EC_FIRST_WARN) { V3Stats::addStatSum(string("Warnings, Suppressed ")+s_errorCode.ascii(), 1); - s_errorCode=V3ErrorCode::SUPPRESS; + s_errorCode=V3ErrorCode::EC_SUPPRESS; } } void V3Error::v3errorEnd (ostringstream& sstr) { #ifdef __COVERITY__ - if (s_errorCode==V3ErrorCode::FATAL) __coverity_panic__(x); + if (s_errorCode==V3ErrorCode::EC_FATAL) __coverity_panic__(x); #endif - if (s_errorCode!=V3ErrorCode::SUPPRESS + if (s_errorCode!=V3ErrorCode::EC_SUPPRESS // On debug, show only non default-off warning to prevent pages of warnings || (debug() && !s_errorCode.defaultsOff())) { cerr<=V3ErrorCode::FIRST_WARN && !s_describedWarnings) { + if (s_errorCode>=V3ErrorCode::EC_FIRST_WARN && !s_describedWarnings) { cerr<=(level)) { cout<<"- "<=(level)) { cout< m_warnOn; + bitset m_warnOn; static FileLine s_defaultFileLine; struct EmptySecret {}; protected: diff --git a/src/V3LinkParse.cpp b/src/V3LinkParse.cpp index 21def993c..517265d12 100644 --- a/src/V3LinkParse.cpp +++ b/src/V3LinkParse.cpp @@ -69,9 +69,9 @@ private: } void checkExpected(AstNode* nodep) { - if (m_exp != AstParseRefExp::NONE) { + if (m_exp != AstParseRefExp::PX_NONE) { nodep->v3fatalSrc("Tree syntax error: Not expecting "<type()<<" under a "<backp()->type()); - m_exp = AstParseRefExp::NONE; + m_exp = AstParseRefExp::PX_NONE; } } @@ -84,9 +84,9 @@ private: // Due to a need to get the arguments, the ParseRefs are under here, // rather than the NodeFTaskRef under the ParseRef. if (nodep->namep()) { - m_exp = AstParseRefExp::FUNC; + m_exp = AstParseRefExp::PX_FUNC; nodep->namep()->accept(*this); // No next, we don't want to do the edit - m_exp = AstParseRefExp::NONE; + m_exp = AstParseRefExp::PX_NONE; if (!m_baseTextp) nodep->v3fatalSrc("No TEXT found to indicate function name"); nodep->name(m_baseTextp->text()); nodep->dotted(m_dotText); @@ -112,14 +112,14 @@ private: // Process lower nodes m_dotText = ""; m_baseTextp = NULL; - if (m_exp == AstParseRefExp::FUNC) { + if (m_exp == AstParseRefExp::PX_FUNC) { lhsp->accept(*this); // Return m_dotText to invoker - } else if (nodep->expect() == AstParseRefExp::VAR_MEM - || nodep->expect() == AstParseRefExp::VAR_ANY) { + } else if (nodep->expect() == AstParseRefExp::PX_VAR_MEM + || nodep->expect() == AstParseRefExp::PX_VAR_ANY) { m_exp = nodep->expect(); lhsp->accept(*this); - m_exp = AstParseRefExp::NONE; + m_exp = AstParseRefExp::PX_NONE; if (!m_baseTextp) nodep->v3fatalSrc("No TEXT found to indicate function name"); if (m_dotText == "") { AstNode* newp = new AstVarRef(nodep->fileline(), m_baseTextp->text(), false); // lvalue'ness computed later @@ -133,7 +133,7 @@ private: } nodep->deleteTree(); nodep=NULL; } - if (m_exp != AstParseRefExp::FUNC) { // Fuctions need to look at the name themself + if (m_exp != AstParseRefExp::PX_FUNC) { // Fuctions need to look at the name themself m_dotText = oldText; m_inModDot = oldDot; m_exp = oldExp; @@ -177,14 +177,14 @@ private: nodep->v3error("Unsupported: Non-constant inside []'s in the cell part of a dotted reference"); } // And pass up m_dotText - } else if (m_exp==AstParseRefExp::FUNC) { + } else if (m_exp==AstParseRefExp::PX_FUNC) { nodep->v3error("Syntax Error: Range selection '[]' is not allowed as part of function names"); } else { nodep->lhsp()->iterateAndNext(*this); AstParseRefExp lastExp = m_exp; AstText* lasttextp = m_baseTextp; { - m_exp = AstParseRefExp::NONE; + m_exp = AstParseRefExp::PX_NONE; nodep->rhsp()->iterateAndNext(*this); } m_baseTextp = lasttextp; @@ -198,16 +198,16 @@ private: nodep->user1(true); // Process only once. if (m_inModDot) { // Already under dot, so this is {modulepart} DOT {modulepart} nodep->v3error("Syntax Error: Range ':', '+:' etc are not allowed in the cell part of a dotted reference"); - } else if (m_exp==AstParseRefExp::FUNC) { + } else if (m_exp==AstParseRefExp::PX_FUNC) { nodep->v3error("Syntax Error: Range ':', '+:' etc are not allowed as part of function names"); - } else if (m_exp==AstParseRefExp::VAR_MEM) { + } else if (m_exp==AstParseRefExp::PX_VAR_MEM) { nodep->v3error("Syntax Error: Range ':', '+:' etc are not allowed when expecting memory reference"); } else { nodep->lhsp()->iterateAndNext(*this); AstParseRefExp lastExp = m_exp; AstText* lasttextp = m_baseTextp; { - m_exp = AstParseRefExp::NONE; + m_exp = AstParseRefExp::PX_NONE; nodep->rhsp()->iterateAndNext(*this); nodep->thsp()->iterateAndNext(*this); } @@ -219,7 +219,7 @@ private: virtual void visit(AstText* nodep, AstNUser*) { if (!nodep->user1()) { nodep->user1(true); // Process only once. - if (m_exp != AstParseRefExp::NONE) { + if (m_exp != AstParseRefExp::PX_NONE) { UINFO(7," "<text(); @@ -339,7 +339,7 @@ public: // CONSTUCTORS LinkParseVisitor(AstNetlist* rootp) { m_inModDot = false; - m_exp = AstParseRefExp::NONE; + m_exp = AstParseRefExp::PX_NONE; m_baseTextp = NULL; m_varp = NULL; rootp->accept(*this); diff --git a/src/V3LinkResolve.cpp b/src/V3LinkResolve.cpp index f2d6415b9..6088cc03b 100644 --- a/src/V3LinkResolve.cpp +++ b/src/V3LinkResolve.cpp @@ -324,10 +324,10 @@ private: nodep->iterateChildren(*this); if (nodep->filep()) expectDescriptor(nodep, nodep->filep()->castNodeVarRef()); if (!m_assertp - && (nodep->displayType() == AstDisplayType::INFO - || nodep->displayType() == AstDisplayType::WARNING - || nodep->displayType() == AstDisplayType::ERROR - || nodep->displayType() == AstDisplayType::FATAL)) { + && (nodep->displayType() == AstDisplayType::DT_INFO + || nodep->displayType() == AstDisplayType::DT_WARNING + || nodep->displayType() == AstDisplayType::DT_ERROR + || nodep->displayType() == AstDisplayType::DT_FATAL)) { nodep->v3error(nodep->verilogKwd()+" only allowed under an assertion."); } } diff --git a/src/V3Options.cpp b/src/V3Options.cpp index 53cc7a2ab..169646abe 100644 --- a/src/V3Options.cpp +++ b/src/V3Options.cpp @@ -144,7 +144,7 @@ string V3Options::allArgsString() { V3LangCode::V3LangCode (const char* textp) { // Return code for given string, or ERROR, which is a bad code - for (int codei=V3LangCode::L_ERROR; codeiv3fatal("Unknown warning specified: "<elsesp() || (nodep->branchPred()==AstBranchPred::LIKELY)) { + if (!nodep->elsesp() || (nodep->branchPred()==AstBranchPred::BP_LIKELY)) { // Always take the if - } else if (!nodep->ifsp() || (nodep->branchPred()==AstBranchPred::UNLIKELY)) { + } else if (!nodep->ifsp() || (nodep->branchPred()==AstBranchPred::BP_UNLIKELY)) { // Always take the else } else { // Take the longer path diff --git a/src/V3Trace.cpp b/src/V3Trace.cpp index e8adb17ec..28e84c9ac 100644 --- a/src/V3Trace.cpp +++ b/src/V3Trace.cpp @@ -458,7 +458,7 @@ private: else condp = selp; } AstIf* ifp = new AstIf (fl, condp, NULL, NULL); - ifp->branchPred(AstBranchPred::UNLIKELY); + ifp->branchPred(AstBranchPred::BP_UNLIKELY); m_chgFuncp->addStmtsp(ifp); lastactp = &actset; ifnodep = ifp; diff --git a/src/verilog.y b/src/verilog.y index 8458b682b..7118af90b 100644 --- a/src/verilog.y +++ b/src/verilog.y @@ -92,7 +92,7 @@ public: return new AstText(fileline, newtext); } AstDisplay* createDisplayError(FileLine* fileline) { - AstDisplay* nodep = new AstDisplay(fileline,AstDisplayType::ERROR, "", NULL,NULL); + AstDisplay* nodep = new AstDisplay(fileline,AstDisplayType::DT_ERROR, "", NULL,NULL); nodep->addNext(new AstStop(fileline)); return nodep; } @@ -1711,16 +1711,16 @@ senitem: // IEEE: part of event_expression, non-'OR' ',' terms ; senitemVar: - idClassSel { $$ = new AstSenItem(CRELINE(),AstEdgeType::ANYEDGE,$1); } + idClassSel { $$ = new AstSenItem(CRELINE(),AstEdgeType::ET_ANYEDGE,$1); } ; senitemEdge: // IEEE: part of event_expression - yPOSEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::POSEDGE,$2); } - | yNEGEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::NEGEDGE,$2); } - | yEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::BOTHEDGE,$2); } - | yPOSEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::POSEDGE,$3); } - | yNEGEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::NEGEDGE,$3); } - | yEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::BOTHEDGE,$3); } + yPOSEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::ET_POSEDGE,$2); } + | yNEGEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::ET_NEGEDGE,$2); } + | yEDGE idClassSel { $$ = new AstSenItem($1,AstEdgeType::ET_BOTHEDGE,$2); } + | yPOSEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::ET_POSEDGE,$3); } + | yNEGEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::ET_NEGEDGE,$3); } + | yEDGE '(' idClassSel ')' { $$ = new AstSenItem($1,AstEdgeType::ET_BOTHEDGE,$3); } //UNSUP yIFF... ; @@ -1922,9 +1922,9 @@ unique_priorityE: // IEEE: unique_priority + empty ; caseStart: // IEEE: part of case_statement - yCASE '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASE,$3,NULL); } - | yCASEX '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASEX,$3,NULL); } - | yCASEZ '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CASEZ,$3,NULL); } + yCASE '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CT_CASE,$3,NULL); } + | yCASEX '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CT_CASEX,$3,NULL); } + | yCASEZ '(' expr ')' { $$ = GRAMMARP->m_caseAttrp = new AstCase($1,AstCaseType::CT_CASEZ,$3,NULL); } ; caseAttrE: @@ -1981,16 +1981,16 @@ for_step: // IEEE: for_step // Functions/tasks taskRef: // IEEE: part of tf_call - idDotted { $$ = new AstTaskRef(CRELINE(),new AstParseRef($1->fileline(), AstParseRefExp::TASK, $1),NULL);} - | idDotted '(' list_of_argumentsE ')' { $$ = new AstTaskRef(CRELINE(),new AstParseRef($1->fileline(), AstParseRefExp::TASK, $1),$3);} - //UNSUP: package_scopeIdFollows idDotted { $$ = new AstTaskRef(CRELINE(),new AstParseRef($2->fileline(), AstParseRefExp::TASK, $2),NULL);} - //UNSUP: package_scopeIdFollows idDotted '(' list_of_argumentsE ')' { $$ = new AstTaskRef(CRELINE(),new AstParseRef($2->fileline(), AstParseRefExp::TASK, $2),$4);} + idDotted { $$ = new AstTaskRef(CRELINE(),new AstParseRef($1->fileline(), AstParseRefExp::PX_TASK, $1),NULL);} + | idDotted '(' list_of_argumentsE ')' { $$ = new AstTaskRef(CRELINE(),new AstParseRef($1->fileline(), AstParseRefExp::PX_TASK, $1),$3);} + //UNSUP: package_scopeIdFollows idDotted { $$ = new AstTaskRef(CRELINE(),new AstParseRef($2->fileline(), AstParseRefExp::PX_TASK, $2),NULL);} + //UNSUP: package_scopeIdFollows idDotted '(' list_of_argumentsE ')' { $$ = new AstTaskRef(CRELINE(),new AstParseRef($2->fileline(), AstParseRefExp::PX_TASK, $2),$4);} //UNSUP: idDotted is really just id to allow dotted method calls ; funcRef: // IEEE: part of tf_call - idDotted '(' list_of_argumentsE ')' { $$ = new AstFuncRef($2,new AstParseRef($1->fileline(), AstParseRefExp::FUNC, $1), $3); } - | package_scopeIdFollows idDotted '(' list_of_argumentsE ')' { $$ = new AstFuncRef($3,new AstParseRef($2->fileline(), AstParseRefExp::FUNC, $2), $4); $$->packagep($1); } + idDotted '(' list_of_argumentsE ')' { $$ = new AstFuncRef($2,new AstParseRef($1->fileline(), AstParseRefExp::PX_FUNC, $1), $3); } + | package_scopeIdFollows idDotted '(' list_of_argumentsE ')' { $$ = new AstFuncRef($3,new AstParseRef($2->fileline(), AstParseRefExp::PX_FUNC, $2), $4); $$->packagep($1); } //UNSUP: idDotted is really just id to allow dotted method calls ; @@ -2030,22 +2030,22 @@ system_t_call: // IEEE: system_tf_call (as task) | yD_SFORMAT '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); } | yD_SWRITE '(' expr ',' str commaEListE ')' { $$ = new AstSFormat($1,$3,*$5,$6); } // - | yD_DISPLAY parenE { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,"", NULL,NULL); } - | yD_DISPLAY '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,*$3,NULL,$4); } + | yD_DISPLAY parenE { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,"", NULL,NULL); } + | yD_DISPLAY '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,*$3,NULL,$4); } | yD_WRITE parenE { $$ = NULL; } // NOP - | yD_WRITE '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::WRITE, *$3,NULL,$4); } - | yD_FDISPLAY '(' idClassSel ')' { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,"",$3,NULL); } - | yD_FDISPLAY '(' idClassSel ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DISPLAY,*$5,$3,$6); } - | yD_FWRITE '(' idClassSel ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::WRITE, *$5,$3,$6); } - | yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::INFO, "", NULL,NULL); } - | yD_INFO '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::INFO, *$3,NULL,$4); } - | yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::WARNING,"", NULL,NULL); } - | yD_WARNING '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::WARNING,*$3,NULL,$4); } + | yD_WRITE '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, *$3,NULL,$4); } + | yD_FDISPLAY '(' idClassSel ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,"",$3,NULL); } + | yD_FDISPLAY '(' idClassSel ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_DISPLAY,*$5,$3,$6); } + | yD_FWRITE '(' idClassSel ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WRITE, *$5,$3,$6); } + | yD_INFO parenE { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, "", NULL,NULL); } + | yD_INFO '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_INFO, *$3,NULL,$4); } + | yD_WARNING parenE { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,"", NULL,NULL); } + | yD_WARNING '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_WARNING,*$3,NULL,$4); } | yD_ERROR parenE { $$ = GRAMMARP->createDisplayError($1); } - | yD_ERROR '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::ERROR, *$3,NULL,$4); $$->addNext(new AstStop($1)); } - | yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); } - | yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); } - | yD_FATAL '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); } + | yD_ERROR '(' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_ERROR, *$3,NULL,$4); $$->addNext(new AstStop($1)); } + | yD_FATAL parenE { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); } + | yD_FATAL '(' expr ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, "", NULL,NULL); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); } + | yD_FATAL '(' expr ',' str commaEListE ')' { $$ = new AstDisplay($1,AstDisplayType::DT_FATAL, *$5,NULL,$6); $$->addNext(new AstStop($1)); if ($3) $3->deleteTree(); } // | yD_READMEMB '(' expr ',' varRefMem ')' { $$ = new AstReadMem($1,false,$3,$5,NULL,NULL); } | yD_READMEMB '(' expr ',' varRefMem ',' expr ')' { $$ = new AstReadMem($1,false,$3,$5,$7,NULL); } @@ -2062,7 +2062,7 @@ system_f_call: // IEEE: system_tf_call (as func) | yaD_DPI parenE { $$ = new AstFuncRef($1,*$1,NULL); } | yaD_DPI '(' exprList ')' { $$ = new AstFuncRef($2,*$1,$3); } // - | yD_BITS '(' expr ')' { $$ = new AstAttrOf($1,AstAttrType::BITS,$3); } + | yD_BITS '(' expr ')' { $$ = new AstAttrOf($1,AstAttrType::EXPR_BITS,$3); } | yD_C '(' cStrList ')' { $$ = (v3Global.opt.ignc() ? NULL : new AstUCFunc($1,$3)); } | yD_CLOG2 '(' expr ')' { $$ = new AstCLog2($1,$3); } | yD_COUNTONES '(' expr ')' { $$ = new AstCountOnes($1,$3); } @@ -2786,12 +2786,12 @@ variable_lvalueConcList: // IEEE: part of variable_lvalue: '{' variable_l // VarRef to a Memory varRefMem: - idDotted { $$ = new AstParseRef($1->fileline(), AstParseRefExp::VAR_MEM, $1); } + idDotted { $$ = new AstParseRef($1->fileline(), AstParseRefExp::PX_VAR_MEM, $1); } ; // VarRef to dotted, and/or arrayed, and/or bit-ranged variable idClassSel: // Misc Ref to dotted, and/or arrayed, and/or bit-ranged variable - idDotted { $$ = new AstParseRef($1->fileline(), AstParseRefExp::VAR_ANY, $1); } + idDotted { $$ = new AstParseRef($1->fileline(), AstParseRefExp::PX_VAR_ANY, $1); } // // IEEE: [ implicit_class_handle . | package_scope ] hierarchical_variable_identifier select //UNSUP yTHIS '.' idDotted { UNSUP } //UNSUP ySUPER '.' idDotted { UNSUP } @@ -3005,7 +3005,7 @@ vltOffFront: | yVLT_TRACING_OFF { $$ = V3ErrorCode::I_TRACING; } | yVLT_LINT_OFF yVLT_D_MSG yaID__ETC { $$ = V3ErrorCode((*$3).c_str()); - if ($$ == V3ErrorCode::ERROR) { $1->v3error("Unknown Error Code: "<<*$3<v3error("Unknown Error Code: "<<*$3<