mirror of
https://github.com/verilator/verilator.git
synced 2025-04-05 04:02:37 +00:00
Internals: Merge from dtype. Create subDTypep. No functional change intended.
This commit is contained in:
parent
2b12ab4d5a
commit
4d0b964e36
@ -265,7 +265,7 @@ AstNodeDType* AstNodeDType::dtypeDimensionp(int dimension) {
|
|||||||
if ((dim++)==dimension) {
|
if ((dim++)==dimension) {
|
||||||
return dtypep;
|
return dtypep;
|
||||||
}
|
}
|
||||||
dtypep = adtypep->dtypep();
|
dtypep = adtypep->subDTypep();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (AstBasicDType* adtypep = dtypep->castBasicDType()) {
|
else if (AstBasicDType* adtypep = dtypep->castBasicDType()) {
|
||||||
@ -289,7 +289,7 @@ uint32_t AstNodeDType::arrayElements() {
|
|||||||
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
|
dtypep = dtypep->skipRefp(); // Skip AstRefDType/AstTypedef, or return same node
|
||||||
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
|
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
|
||||||
entries *= adtypep->elementsConst();
|
entries *= adtypep->elementsConst();
|
||||||
dtypep = adtypep->dtypep();
|
dtypep = adtypep->subDTypep();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// AstBasicDType - nothing below, 1
|
// AstBasicDType - nothing below, 1
|
||||||
@ -308,7 +308,7 @@ pair<uint32_t,uint32_t> AstNodeDType::dimensions() {
|
|||||||
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
|
if (AstArrayDType* adtypep = dtypep->castArrayDType()) {
|
||||||
if (adtypep->isPacked()) packed += 1;
|
if (adtypep->isPacked()) packed += 1;
|
||||||
else unpacked += 1;
|
else unpacked += 1;
|
||||||
dtypep = adtypep->dtypep();
|
dtypep = adtypep->subDTypep();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// AstBasicDType - nothing below, 1
|
// AstBasicDType - nothing below, 1
|
||||||
|
@ -170,6 +170,7 @@ public:
|
|||||||
ASTNODE_NODE_FUNCS(Typedef, TYPEDEF)
|
ASTNODE_NODE_FUNCS(Typedef, TYPEDEF)
|
||||||
AstNodeDType* dtypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
AstNodeDType* dtypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
||||||
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||||
|
AstNodeDType* subDTypep() const { return dtypep(); }
|
||||||
// METHODS
|
// METHODS
|
||||||
virtual string name() const { return m_name; }
|
virtual string name() const { return m_name; }
|
||||||
virtual bool maybePointedTo() const { return true; }
|
virtual bool maybePointedTo() const { return true; }
|
||||||
@ -239,6 +240,7 @@ public:
|
|||||||
AstNodeDType* dtypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
AstNodeDType* dtypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
||||||
AstNodeDType* dtypeSkipRefp() const { return dtypep()->skipRefp(); } // op1 = Range of variable
|
AstNodeDType* dtypeSkipRefp() const { return dtypep()->skipRefp(); } // op1 = Range of variable
|
||||||
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||||
|
AstNodeDType* subDTypep() const { return dtypep(); }
|
||||||
AstRange* arrayp() const { return op2p()->castRange(); } // op2 = Array(s) of variable
|
AstRange* arrayp() const { return op2p()->castRange(); } // op2 = Array(s) of variable
|
||||||
void arrayp(AstRange* nodep) { setOp2p(nodep); }
|
void arrayp(AstRange* nodep) { setOp2p(nodep); }
|
||||||
// METHODS
|
// METHODS
|
||||||
@ -354,6 +356,7 @@ public:
|
|||||||
ASTNODE_NODE_FUNCS(ConstDType, CONSTDTYPE)
|
ASTNODE_NODE_FUNCS(ConstDType, CONSTDTYPE)
|
||||||
AstNodeDType* dtypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
AstNodeDType* dtypep() const { return op1p()->castNodeDType(); } // op1 = Range of variable
|
||||||
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||||
|
AstNodeDType* subDTypep() const { return dtypep(); }
|
||||||
// METHODS
|
// METHODS
|
||||||
virtual AstBasicDType* basicp() const { return dtypep()->basicp(); } // (Slow) recurse down to find basic data type
|
virtual AstBasicDType* basicp() const { return dtypep()->basicp(); } // (Slow) recurse down to find basic data type
|
||||||
virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; }
|
virtual AstNodeDType* skipRefp() const { return (AstNodeDType*)this; }
|
||||||
@ -363,25 +366,25 @@ public:
|
|||||||
|
|
||||||
struct AstRefDType : public AstNodeDType {
|
struct AstRefDType : public AstNodeDType {
|
||||||
private:
|
private:
|
||||||
AstNodeDType* m_defp; // data type pointed to, BELOW the AstTypedef
|
AstNodeDType* m_subDTypep; // data type pointed to, BELOW the AstTypedef
|
||||||
string m_name; // Name of an AstTypedef
|
string m_name; // Name of an AstTypedef
|
||||||
AstPackage* m_packagep; // Package hierarchy
|
AstPackage* m_packagep; // Package hierarchy
|
||||||
public:
|
public:
|
||||||
AstRefDType(FileLine* fl, const string& name)
|
AstRefDType(FileLine* fl, const string& name)
|
||||||
: AstNodeDType(fl), m_defp(NULL), m_name(name), m_packagep(NULL) {}
|
: AstNodeDType(fl), m_subDTypep(NULL), m_name(name), m_packagep(NULL) {}
|
||||||
AstRefDType(FileLine* fl, AstNodeDType* defp)
|
AstRefDType(FileLine* fl, AstNodeDType* defp)
|
||||||
: AstNodeDType(fl), m_defp(defp), m_packagep(NULL) {
|
: AstNodeDType(fl), m_subDTypep(defp), m_packagep(NULL) {
|
||||||
widthSignedFrom(defp);
|
widthSignedFrom(defp);
|
||||||
}
|
}
|
||||||
ASTNODE_NODE_FUNCS(RefDType, REFDTYPE)
|
ASTNODE_NODE_FUNCS(RefDType, REFDTYPE)
|
||||||
// METHODS
|
// METHODS
|
||||||
virtual bool broken() const { return m_defp && !m_defp->brokeExists(); }
|
virtual bool broken() const { return m_subDTypep && !m_subDTypep->brokeExists(); }
|
||||||
virtual void cloneRelink() { if (m_defp && m_defp->clonep()) {
|
virtual void cloneRelink() { if (m_subDTypep && m_subDTypep->clonep()) {
|
||||||
m_defp = m_defp->clonep()->castNodeDType();
|
m_subDTypep = m_subDTypep->clonep()->castNodeDType();
|
||||||
}}
|
}}
|
||||||
virtual V3Hash sameHash() const { return V3Hash(skipRefp()); }
|
|
||||||
virtual bool same(AstNode* samep) const {
|
virtual bool same(AstNode* samep) const {
|
||||||
return skipRefp()->sameTree(samep->castRefDType()->skipRefp()); }
|
return skipRefp()->sameTree(samep->castRefDType()->skipRefp()); }
|
||||||
|
virtual V3Hash sameHash() const { return V3Hash(skipRefp()); }
|
||||||
virtual void dump(ostream& str=cout);
|
virtual void dump(ostream& str=cout);
|
||||||
virtual string name() const { return m_name; }
|
virtual string name() const { return m_name; }
|
||||||
virtual AstBasicDType* basicp() const { return defp() ? defp()->basicp() : NULL; }
|
virtual AstBasicDType* basicp() const { return defp() ? defp()->basicp() : NULL; }
|
||||||
@ -398,8 +401,9 @@ public:
|
|||||||
else { v3fatalSrc("Typedef not linked"); return NULL; }
|
else { v3fatalSrc("Typedef not linked"); return NULL; }
|
||||||
}
|
}
|
||||||
AstNodeDType* dtypeSkipRefp() const { return defp()->skipRefp(); } // op1 = Range of variable
|
AstNodeDType* dtypeSkipRefp() const { return defp()->skipRefp(); } // op1 = Range of variable
|
||||||
AstNodeDType* defp() const { return m_defp; }
|
AstNodeDType* defp() const { return m_subDTypep; }
|
||||||
void defp(AstNodeDType* nodep) { m_defp=nodep; }
|
AstNodeDType* subDTypep() const { return m_subDTypep; }
|
||||||
|
void subDTypep(AstNodeDType* nodep) { m_subDTypep=nodep; }
|
||||||
AstPackage* packagep() const { return m_packagep; }
|
AstPackage* packagep() const { return m_packagep; }
|
||||||
void packagep(AstPackage* nodep) { m_packagep=nodep; }
|
void packagep(AstPackage* nodep) { m_packagep=nodep; }
|
||||||
};
|
};
|
||||||
@ -460,6 +464,7 @@ public:
|
|||||||
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
void dtypep(AstNodeDType* nodep) { setOp1p(nodep); }
|
||||||
AstEnumItem* itemsp() const { return op2p()->castEnumItem(); } // op2 = AstEnumItem's
|
AstEnumItem* itemsp() const { return op2p()->castEnumItem(); } // op2 = AstEnumItem's
|
||||||
void addValuesp(AstNode* nodep) { addOp2p(nodep); }
|
void addValuesp(AstNode* nodep) { addOp2p(nodep); }
|
||||||
|
AstNodeDType* subDTypep() const { return dtypep(); }
|
||||||
// METHODS
|
// METHODS
|
||||||
virtual AstBasicDType* basicp() const { return dtypep()->basicp(); } // (Slow) recurse down to find basic data type
|
virtual AstBasicDType* basicp() const { return dtypep()->basicp(); } // (Slow) recurse down to find basic data type
|
||||||
virtual AstNodeDType* skipRefp() const { return dtypep()->skipRefp(); }
|
virtual AstNodeDType* skipRefp() const { return dtypep()->skipRefp(); }
|
||||||
|
@ -217,7 +217,7 @@ private:
|
|||||||
ToggleEnt newent (above.m_comment+string("[")+cvtToStr(index_docs)+"]",
|
ToggleEnt newent (above.m_comment+string("[")+cvtToStr(index_docs)+"]",
|
||||||
new AstArraySel(varp->fileline(), above.m_varRefp->cloneTree(true), index_code),
|
new AstArraySel(varp->fileline(), above.m_varRefp->cloneTree(true), index_code),
|
||||||
new AstArraySel(varp->fileline(), above.m_chgRefp->cloneTree(true), index_code));
|
new AstArraySel(varp->fileline(), above.m_chgRefp->cloneTree(true), index_code));
|
||||||
toggleVarRecurse(adtypep->dtypeSkipRefp(), depth+1,
|
toggleVarRecurse(adtypep->subDTypep()->skipRefp(), depth+1,
|
||||||
newent,
|
newent,
|
||||||
varp, chgVarp);
|
varp, chgVarp);
|
||||||
newent.cleanup();
|
newent.cleanup();
|
||||||
|
@ -889,7 +889,7 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
|
|||||||
puts(nodep->name());
|
puts(nodep->name());
|
||||||
if (isArray) {
|
if (isArray) {
|
||||||
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
||||||
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
|
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
|
||||||
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -910,7 +910,7 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
|
|||||||
if (nodep->isWide()) puts("W");
|
if (nodep->isWide()) puts("W");
|
||||||
puts("("+nodep->name());
|
puts("("+nodep->name());
|
||||||
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
||||||
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
|
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
|
||||||
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
||||||
}
|
}
|
||||||
puts(","+cvtToStr(basicp->msb())+","+cvtToStr(basicp->lsb()));
|
puts(","+cvtToStr(basicp->msb())+","+cvtToStr(basicp->lsb()));
|
||||||
@ -932,7 +932,7 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
|
|||||||
puts(nodep->vlArgType(true,false));
|
puts(nodep->vlArgType(true,false));
|
||||||
// This isn't very robust and may need cleanup for other data types
|
// This isn't very robust and may need cleanup for other data types
|
||||||
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
||||||
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
|
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
|
||||||
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
||||||
}
|
}
|
||||||
puts(";\n");
|
puts(";\n");
|
||||||
@ -958,7 +958,7 @@ void EmitCStmts::emitVarDecl(AstVar* nodep, const string& prefixIfImp) {
|
|||||||
puts(nodep->name());
|
puts(nodep->name());
|
||||||
// This isn't very robust and may need cleanup for other data types
|
// This isn't very robust and may need cleanup for other data types
|
||||||
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
for (AstArrayDType* arrayp=nodep->dtypeSkipRefp()->castArrayDType(); arrayp;
|
||||||
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
|
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
|
||||||
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
puts("["+cvtToStr(arrayp->elementsConst())+"]");
|
||||||
}
|
}
|
||||||
puts(","+cvtToStr(basicp->msb())+","+cvtToStr(basicp->lsb()));
|
puts(","+cvtToStr(basicp->msb())+","+cvtToStr(basicp->lsb()));
|
||||||
@ -1341,7 +1341,7 @@ void EmitCImp::emitVarResets(AstNodeModule* modp) {
|
|||||||
int vects = 0;
|
int vects = 0;
|
||||||
// This isn't very robust and may need cleanup for other data types
|
// This isn't very robust and may need cleanup for other data types
|
||||||
for (AstArrayDType* arrayp=varp->dtypeSkipRefp()->castArrayDType(); arrayp;
|
for (AstArrayDType* arrayp=varp->dtypeSkipRefp()->castArrayDType(); arrayp;
|
||||||
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
|
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
|
||||||
int vecnum = vects++;
|
int vecnum = vects++;
|
||||||
if (arrayp->msb() < arrayp->lsb()) varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
|
if (arrayp->msb() < arrayp->lsb()) varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
|
||||||
string ivar = string("__Vi")+cvtToStr(vecnum);
|
string ivar = string("__Vi")+cvtToStr(vecnum);
|
||||||
@ -1517,7 +1517,7 @@ void EmitCImp::emitSensitives() {
|
|||||||
int vects = 0;
|
int vects = 0;
|
||||||
// This isn't very robust and may need cleanup for other data types
|
// This isn't very robust and may need cleanup for other data types
|
||||||
for (AstArrayDType* arrayp=varp->dtypeSkipRefp()->castArrayDType(); arrayp;
|
for (AstArrayDType* arrayp=varp->dtypeSkipRefp()->castArrayDType(); arrayp;
|
||||||
arrayp = arrayp->dtypeSkipRefp()->castArrayDType()) {
|
arrayp = arrayp->subDTypep()->skipRefp()->castArrayDType()) {
|
||||||
int vecnum = vects++;
|
int vecnum = vects++;
|
||||||
if (arrayp->msb() < arrayp->lsb()) varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
|
if (arrayp->msb() < arrayp->lsb()) varp->v3fatalSrc("Should have swapped msb & lsb earlier.");
|
||||||
string ivar = string("__Vi")+cvtToStr(vecnum);
|
string ivar = string("__Vi")+cvtToStr(vecnum);
|
||||||
|
@ -465,7 +465,7 @@ void EmitCSyms::emitSymImp() {
|
|||||||
bounds += " ,"; bounds += cvtToStr(adtypep->arrayp()->msbConst());
|
bounds += " ,"; bounds += cvtToStr(adtypep->arrayp()->msbConst());
|
||||||
bounds += ","; bounds += cvtToStr(adtypep->arrayp()->lsbConst());
|
bounds += ","; bounds += cvtToStr(adtypep->arrayp()->lsbConst());
|
||||||
dim++;
|
dim++;
|
||||||
dtypep = adtypep->dtypep();
|
dtypep = adtypep->subDTypep();
|
||||||
}
|
}
|
||||||
else break; // AstBasicDType - nothing below, 1
|
else break; // AstBasicDType - nothing below, 1
|
||||||
}
|
}
|
||||||
|
@ -491,7 +491,11 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
|
|||||||
}
|
}
|
||||||
virtual void visit(AstConstDType* nodep, AstNUser*) {
|
virtual void visit(AstConstDType* nodep, AstNUser*) {
|
||||||
putfs(nodep,"const ");
|
putfs(nodep,"const ");
|
||||||
nodep->dtypep()->iterateAndNext(*this);
|
nodep->subDTypep()->iterateAndNext(*this);
|
||||||
|
}
|
||||||
|
virtual void visit(AstArrayDType* nodep, AstNUser*) {
|
||||||
|
nodep->subDTypep()->iterateAndNext(*this);
|
||||||
|
nodep->arrayp()->iterateAndNext(*this);
|
||||||
}
|
}
|
||||||
virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) {
|
virtual void visit(AstNodeFTaskRef* nodep, AstNUser*) {
|
||||||
if (nodep->dotted()!="") { putfs(nodep,nodep->dotted()); puts("."); puts(nodep->prettyName()); }
|
if (nodep->dotted()!="") { putfs(nodep,nodep->dotted()); puts("."); puts(nodep->prettyName()); }
|
||||||
|
@ -552,7 +552,7 @@ private:
|
|||||||
defp = m_curVarsp->findIdUpward(nodep->name())->castTypedef();
|
defp = m_curVarsp->findIdUpward(nodep->name())->castTypedef();
|
||||||
}
|
}
|
||||||
if (!defp) { nodep->v3error("Can't find typedef: "<<nodep->prettyName()); }
|
if (!defp) { nodep->v3error("Can't find typedef: "<<nodep->prettyName()); }
|
||||||
nodep->defp(defp->dtypep());
|
nodep->subDTypep(defp->subDTypep());
|
||||||
nodep->packagep(packageFor(defp));
|
nodep->packagep(packageFor(defp));
|
||||||
}
|
}
|
||||||
nodep->iterateChildren(*this);
|
nodep->iterateChildren(*this);
|
||||||
|
@ -80,7 +80,8 @@ private:
|
|||||||
if ((int)nodep->dtypep()->arrayElements() > v3Global.opt.traceMaxArray()) return "Wide memory > --trace-max-array ents";
|
if ((int)nodep->dtypep()->arrayElements() > v3Global.opt.traceMaxArray()) return "Wide memory > --trace-max-array ents";
|
||||||
if (!(nodep->dtypeSkipRefp()->castBasicDType()
|
if (!(nodep->dtypeSkipRefp()->castBasicDType()
|
||||||
|| (nodep->dtypeSkipRefp()->castArrayDType()
|
|| (nodep->dtypeSkipRefp()->castArrayDType()
|
||||||
&& nodep->dtypeSkipRefp()->castArrayDType()->dtypeSkipRefp()->castBasicDType()))) {
|
&& (nodep->dtypeSkipRefp()->castArrayDType()->subDTypep()
|
||||||
|
->skipRefp()->castBasicDType())))) {
|
||||||
return "Unsupported: Multi-dimensional array";
|
return "Unsupported: Multi-dimensional array";
|
||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
|
Loading…
Reference in New Issue
Block a user