forked from github/verilator
Internals: Make findDtype functions use this. No functional change.
This commit is contained in:
parent
37a3a7cdce
commit
942cb5e87e
@ -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()
|
||||
|
31
src/V3Ast.h
31
src/V3Ast.h
@ -1058,13 +1058,24 @@ public:
|
||||
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 @@ public:
|
||||
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?
|
||||
|
@ -767,14 +767,14 @@ public:
|
||||
, 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)
|
||||
|
@ -140,7 +140,7 @@ private:
|
||||
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),
|
||||
|
@ -192,7 +192,7 @@ private:
|
||||
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);
|
||||
|
@ -336,7 +336,7 @@ private:
|
||||
}
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user