From 942cb5e87e7a1b83f8d439c18a43ae792a0f9581 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Wed, 9 May 2012 22:12:57 -0400 Subject: [PATCH] Internals: Make findDtype functions use this. No functional change. --- src/V3Ast.cpp | 12 ++++++------ src/V3Ast.h | 31 ++++++++++++++++++------------- src/V3AstNodes.h | 4 ++-- src/V3LinkJump.cpp | 2 +- src/V3Table.cpp | 2 +- src/V3Task.cpp | 2 +- 6 files changed, 29 insertions(+), 24 deletions(-) diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index f8a24422fa..64e127d2ca 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -1075,19 +1075,19 @@ void AstNode::dtypeChgWidthSigned(int width, int widthMin, bool issigned) { } } -AstNodeDType* AstNode::findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd) { +AstNodeDType* AstNode::findBasicDType(AstBasicDTypeKwd kwd) { // For 'simple' types we use the global directory. These are all unsized. // More advanced types land under the module/task/etc return v3Global.rootp()->typeTablep() - ->findBasicDType(fl, kwd); + ->findBasicDType(fileline(), kwd); } -AstNodeDType* AstNode::findBitDType(FileLine* fl, int width, int widthMin, AstNumeric numeric) { +AstNodeDType* AstNode::findBitDType(int width, int widthMin, AstNumeric numeric) { return v3Global.rootp()->typeTablep() - ->findLogicBitDType(fl, AstBasicDTypeKwd::BIT, width, widthMin, numeric); + ->findLogicBitDType(fileline(), AstBasicDTypeKwd::BIT, width, widthMin, numeric); } -AstNodeDType* AstNode::findLogicDType(FileLine* fl, int width, int widthMin, AstNumeric numeric) { +AstNodeDType* AstNode::findLogicDType(int width, int widthMin, AstNumeric numeric) { return v3Global.rootp()->typeTablep() - ->findLogicBitDType(fl, AstBasicDTypeKwd::LOGIC, width, widthMin, numeric); + ->findLogicBitDType(fileline(), AstBasicDTypeKwd::LOGIC, width, widthMin, numeric); } AstBasicDType* AstNode::findInsertSameDType(AstBasicDType* nodep) { return v3Global.rootp()->typeTablep() diff --git a/src/V3Ast.h b/src/V3Ast.h index f6a69730d6..5737d367dd 100644 --- a/src/V3Ast.h +++ b/src/V3Ast.h @@ -1058,13 +1058,24 @@ class AstNode { void dtypeChgSigned(bool flag=true); void dtypeChgWidth(int width, int widthMin); void dtypeChgWidthSigned(int width, int widthMin, bool issigned); - void dtypeSetBitSized(int width, int widthMin, AstNumeric numeric) { dtypep(findBitDType(fileline(),width,widthMin,numeric)); } - void dtypeSetLogicSized(int width, int widthMin, AstNumeric numeric) { dtypep(findLogicDType(fileline(),width,widthMin,numeric)); } - void dtypeSetLogicBool() { dtypep(findBasicDType(fileline(),AstBasicDTypeKwd::LOGIC)); } - void dtypeSetDouble() { dtypep(findBasicDType(fileline(),AstBasicDTypeKwd::DOUBLE)); } - void dtypeSetSigned32() { dtypep(findBasicDType(fileline(),AstBasicDTypeKwd::INTEGER)); } - void dtypeSetUInt32() { dtypep(findBasicDType(fileline(),AstBasicDTypeKwd::UINT32)); } // Twostate - void dtypeSetUInt64() { dtypep(findBasicDType(fileline(),AstBasicDTypeKwd::UINT64)); } // Twostate + void dtypeSetBitSized(int width, int widthMin, AstNumeric numeric) { dtypep(findBitDType(width,widthMin,numeric)); } + void dtypeSetLogicSized(int width, int widthMin, AstNumeric numeric) { dtypep(findLogicDType(width,widthMin,numeric)); } + void dtypeSetLogicBool() { dtypep(findLogicBoolDType()); } + void dtypeSetDouble() { dtypep(findDoubleDType()); } + void dtypeSetSigned32() { dtypep(findSigned32DType()); } + void dtypeSetUInt32() { dtypep(findUInt32DType()); } // Twostate + void dtypeSetUInt64() { dtypep(findUInt64DType()); } // Twostate + + // Data type locators + AstNodeDType* findLogicBoolDType() { return findBasicDType(AstBasicDTypeKwd::LOGIC); } + AstNodeDType* findDoubleDType() { return findBasicDType(AstBasicDTypeKwd::DOUBLE); } + AstNodeDType* findSigned32DType() { return findBasicDType(AstBasicDTypeKwd::INTEGER); } + AstNodeDType* findUInt32DType() { return findBasicDType(AstBasicDTypeKwd::UINT32); } // Twostate + AstNodeDType* findUInt64DType() { return findBasicDType(AstBasicDTypeKwd::UINT64); } // Twostate + AstNodeDType* findBitDType(int width, int widthMin, AstNumeric numeric); + AstNodeDType* findLogicDType(int width, int widthMin, AstNumeric numeric); + AstNodeDType* findBasicDType(AstBasicDTypeKwd kwd); + AstBasicDType* findInsertSameDType(AstBasicDType* nodep); // METHODS - dump and error void v3errorEnd(ostringstream& str) const; @@ -1088,12 +1099,6 @@ class AstNode { virtual void addNextStmt(AstNode* newp, AstNode* belowp); // When calling, "this" is second argument virtual void addBeforeStmt(AstNode* newp, AstNode* belowp); // When calling, "this" is second argument - // Data type locators - static AstNodeDType* findBasicDType(FileLine* fl, AstBasicDTypeKwd kwd); - static AstNodeDType* findBitDType(FileLine* fl, int width, int widthMin, AstNumeric numeric); - static AstNodeDType* findLogicDType(FileLine* fl, int width, int widthMin, AstNumeric numeric); - static AstBasicDType* findInsertSameDType(AstBasicDType* nodep); - // METHODS - Iterate on a tree AstNode* cloneTree(bool cloneNextLink); bool sameTree(AstNode* node2p); // Does tree of this == node2p? diff --git a/src/V3AstNodes.h b/src/V3AstNodes.h index 64d24e0d21..60f998a6d7 100644 --- a/src/V3AstNodes.h +++ b/src/V3AstNodes.h @@ -767,14 +767,14 @@ struct AstVar : public AstNode { , m_name(name) { init(); combineType(type); - dtypep(findLogicDType(fl,wantwidth,wantwidth,AstNumeric::UNSIGNED)); + dtypeSetLogicSized(wantwidth,wantwidth,AstNumeric::UNSIGNED); } AstVar(FileLine* fl, AstVarType type, const string& name, VFlagBitPacked, int wantwidth) :AstNode(fl) , m_name(name) { init(); combineType(type); - dtypep(findLogicDType(fl,wantwidth,wantwidth,AstNumeric::UNSIGNED)); + dtypeSetLogicSized(wantwidth,wantwidth,AstNumeric::UNSIGNED); } AstVar(FileLine* fl, AstVarType type, const string& name, AstVar* examplep) :AstNode(fl) diff --git a/src/V3LinkJump.cpp b/src/V3LinkJump.cpp index 1a1574b13c..3df3aeb438 100644 --- a/src/V3LinkJump.cpp +++ b/src/V3LinkJump.cpp @@ -140,7 +140,7 @@ class LinkJumpVisitor : public AstNVisitor { string name = string("__Vrepeat")+cvtToStr(m_repeatNum++); // Spec says value is integral, if negative is ignored AstVar* varp = new AstVar(nodep->fileline(), AstVarType::BLOCKTEMP, name, - nodep->findBasicDType(nodep->fileline(), AstBasicDTypeKwd::INTEGER)); + nodep->findSigned32DType()); varp->usedLoopIdx(true); m_modp->addStmtp(varp); AstNode* initsp = new AstAssign(nodep->fileline(), new AstVarRef(nodep->fileline(), varp, true), diff --git a/src/V3Table.cpp b/src/V3Table.cpp index ece2ccc874..5ba3acd10d 100644 --- a/src/V3Table.cpp +++ b/src/V3Table.cpp @@ -192,7 +192,7 @@ class TableVisitor : public AstNVisitor { FileLine* fl = nodep->fileline(); AstNodeDType* dtypep = new AstArrayDType (fl, - nodep->findBitDType(nodep->fileline(), m_outVarps.size(), + nodep->findBitDType(m_outVarps.size(), m_outVarps.size(), AstNumeric::UNSIGNED), new AstRange (fl, VL_MASK_I(m_inWidth), 0), false); v3Global.rootp()->typeTablep()->addTypesp(dtypep); diff --git a/src/V3Task.cpp b/src/V3Task.cpp index a0f3853ff9..2a747f4729 100644 --- a/src/V3Task.cpp +++ b/src/V3Task.cpp @@ -336,7 +336,7 @@ class TaskVisitor : public AstNVisitor { } AstVarScope* createInputVar(AstCFunc* funcp, const string& name, AstBasicDTypeKwd kwd) { AstVar* newvarp = new AstVar (funcp->fileline(), AstVarType::BLOCKTEMP, name, - funcp->findBasicDType(funcp->fileline(), kwd)); + funcp->findBasicDType(kwd)); newvarp->funcLocal(true); newvarp->combineType(AstVarType::INPUT); funcp->addArgsp(newvarp);