Skip to content

Commit

Permalink
Internals: Make findDtype functions use this. No functional change.
Browse files Browse the repository at this point in the history
  • Loading branch information
wsnyder committed May 10, 2012
1 parent 37a3a7c commit 942cb5e
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 24 deletions.
12 changes: 6 additions & 6 deletions src/V3Ast.cpp
Expand Up @@ -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()
Expand Down
31 changes: 18 additions & 13 deletions src/V3Ast.h
Expand Up @@ -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;
Expand All @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions src/V3AstNodes.h
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion src/V3LinkJump.cpp
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion src/V3Table.cpp
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/V3Task.cpp
Expand Up @@ -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);
Expand Down

0 comments on commit 942cb5e

Please sign in to comment.