Internals: Rename NodeClassDType. No functional change.

This commit is contained in:
Wilson Snyder 2019-12-16 22:46:09 -05:00
parent f514049c04
commit 53c6b7df63
13 changed files with 42 additions and 40 deletions

View File

@ -1949,7 +1949,8 @@ public:
const char* charIQWN() const { return (isString() ? "N" : isWide() ? "W" : isQuad() ? "Q" : "I"); }
};
class AstNodeClassDType : public AstNodeDType {
class AstNodeUOrStructDType : public AstNodeDType {
// A struct or union; common handling
private:
// TYPES
typedef std::map<string,AstMemberDType*> MemberNameMap;
@ -1959,14 +1960,14 @@ private:
bool m_isFourstate;
MemberNameMap m_members;
public:
AstNodeClassDType(FileLine* fl, AstNumeric numericUnpack)
AstNodeUOrStructDType(FileLine* fl, AstNumeric numericUnpack)
: AstNodeDType(fl) {
// AstNumeric::NOSIGN overloaded to indicate not packed
m_packed = (numericUnpack != AstNumeric::NOSIGN);
m_isFourstate = false; // V3Width computes
numeric(AstNumeric::fromBool(numericUnpack.isSigned()));
}
ASTNODE_BASE_FUNCS(NodeClassDType)
ASTNODE_BASE_FUNCS(NodeUOrStructDType)
virtual const char* broken() const;
virtual void dump(std::ostream& str) const;
// For basicp() we reuse the size to indicate a "fake" basic type of same size

View File

@ -65,7 +65,7 @@ int AstNodeSel::bitConst() const {
return (constp ? constp->toSInt() : 0);
}
void AstNodeClassDType::repairMemberCache() {
void AstNodeUOrStructDType::repairMemberCache() {
clearCache();
for (AstMemberDType* itemp = membersp(); itemp; itemp=VN_CAST(itemp->nextp(), MemberDType)) {
if (m_members.find(itemp->name())!=m_members.end()) {
@ -74,7 +74,7 @@ void AstNodeClassDType::repairMemberCache() {
}
}
const char* AstNodeClassDType::broken() const {
const char* AstNodeUOrStructDType::broken() const {
vl_unordered_set<AstMemberDType*> exists;
for (AstMemberDType* itemp = membersp(); itemp; itemp=VN_CAST(itemp->nextp(), MemberDType)) {
exists.insert(itemp);
@ -107,14 +107,14 @@ int AstBasicDType::widthTotalBytes() const {
else return widthWords() * (VL_EDATASIZE / 8);
}
int AstNodeClassDType::widthTotalBytes() const {
int AstNodeUOrStructDType::widthTotalBytes() const {
if (width()<=8) return 1;
else if (width()<=16) return 2;
else if (isQuad()) return 8;
else return widthWords() * (VL_EDATASIZE / 8);
}
int AstNodeClassDType::widthAlignBytes() const {
int AstNodeUOrStructDType::widthAlignBytes() const {
// Could do max across members but that would be slow,
// instead intuit based on total structure size
if (width()<=8) return 1;
@ -580,7 +580,7 @@ AstNodeDType* AstNodeDType::dtypeDimensionp(int dimension) {
}
return NULL;
}
else if (AstNodeClassDType* adtypep = VN_CAST(dtypep, NodeClassDType)) {
else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) {
if (adtypep->packed()) {
if ((dim++) == dimension) {
return adtypep;
@ -1030,7 +1030,7 @@ void AstRefDType::dump(std::ostream& str) const {
}
else { str<<" -> UNLINKED"; }
}
void AstNodeClassDType::dump(std::ostream& str) const {
void AstNodeUOrStructDType::dump(std::ostream& str) const {
this->AstNode::dump(str);
if (packed()) str<<" [PACKED]";
if (isFourstate()) str<<" [4STATE]";

View File

@ -842,26 +842,26 @@ public:
void packagep(AstPackage* nodep) { m_packagep = nodep; }
};
class AstStructDType : public AstNodeClassDType {
class AstStructDType : public AstNodeUOrStructDType {
public:
AstStructDType(FileLine* fl, AstNumeric numericUnpack)
: AstNodeClassDType(fl, numericUnpack) {}
: AstNodeUOrStructDType(fl, numericUnpack) {}
ASTNODE_NODE_FUNCS(StructDType)
virtual string verilogKwd() const { return "struct"; }
};
class AstUnionDType : public AstNodeClassDType {
class AstUnionDType : public AstNodeUOrStructDType {
public:
//UNSUP: bool isTagged;
AstUnionDType(FileLine* fl, AstNumeric numericUnpack)
: AstNodeClassDType(fl, numericUnpack) {}
: AstNodeUOrStructDType(fl, numericUnpack) {}
ASTNODE_NODE_FUNCS(UnionDType)
virtual string verilogKwd() const { return "union"; }
};
class AstMemberDType : public AstNodeDType {
// A member of a struct/union
// PARENT: AstNodeClassDType
// PARENT: AstNodeUOrStructDType
private:
AstNodeDType* m_refDTypep; // Elements of this type (after widthing)
string m_name; // Name of variable

View File

@ -175,7 +175,7 @@ private:
m_newRvEqnp = origNREp;
}
}
virtual void visit(AstNodeClassDType* nodep) {
virtual void visit(AstNodeUOrStructDType* nodep) {
if (nodep->packedUnsup()) {
newChangeDet();
} else {

View File

@ -373,11 +373,11 @@ private:
}
for (std::vector<AstNode*>::iterator it = m_dtypesp.begin(); it != m_dtypesp.end();++it) {
if ((*it)->user1() == 0) {
AstNodeClassDType *classp;
AstNodeUOrStructDType *classp;
// It's possible that there if a reference to each individual member, but
// not to the dtype itself. Check and don't remove the parent dtype if
// members are still alive.
if ((classp = VN_CAST((*it), NodeClassDType))) {
if ((classp = VN_CAST((*it), NodeUOrStructDType))) {
bool cont = true;
for (AstMemberDType *memberp = classp->membersp();
memberp; memberp = VN_CAST(memberp->nextp(), MemberDType)) {

View File

@ -542,7 +542,7 @@ class EmitVBaseVisitor : public EmitCBaseVisitor {
iterate(nodep->subDTypep());
iterateAndNextNull(nodep->rangep());
}
virtual void visit(AstNodeClassDType* nodep) {
virtual void visit(AstNodeUOrStructDType* nodep) {
puts(nodep->verilogKwd()+" ");
if (nodep->packed()) puts("packed ");
puts("\n");

View File

@ -132,7 +132,7 @@ private:
}
visitIterateNodeDType(nodep);
}
virtual void visit(AstNodeClassDType* nodep) {
virtual void visit(AstNodeUOrStructDType* nodep) {
if (nodep->name() == "") {
nodep->name(nameFromTypedef(nodep)); // Might still remain ""
}

View File

@ -73,7 +73,7 @@ struct V3ParseBisonYYSType {
AstConst* constp;
AstMemberDType* memberp;
AstNodeModule* modulep;
AstNodeClassDType* classp;
AstNodeUOrStructDType* uorstructp;
AstNodeDType* dtypep;
AstNodeFTask* ftaskp;
AstNodeFTaskRef* ftaskrefp;

View File

@ -306,7 +306,7 @@ private:
}
}
}
virtual void visit(AstNodeClassDType* nodep) {
virtual void visit(AstNodeUOrStructDType* nodep) {
if (m_traVscp) {
if (nodep->packed() && !v3Global.opt.traceStructs()) {
// Everything downstream is packed, so deal with as one trace unit

View File

@ -1374,7 +1374,7 @@ private:
}
else if (nodep->isIO() && !(VN_IS(nodep->dtypeSkipRefp(), BasicDType)
|| VN_IS(nodep->dtypeSkipRefp(), NodeArrayDType)
|| VN_IS(nodep->dtypeSkipRefp(), NodeClassDType))) {
|| VN_IS(nodep->dtypeSkipRefp(), NodeUOrStructDType))) {
nodep->v3error("Unsupported: Inputs and outputs must be simple data types");
}
if (VN_IS(nodep->dtypep()->skipRefToConstp(), ConstDType)) {
@ -1647,7 +1647,7 @@ private:
nodep->widthForce(1, 1); // Not really relevant
UINFO(4,"dtWidthed "<<nodep<<endl);
}
virtual void visit(AstNodeClassDType* nodep) {
virtual void visit(AstNodeUOrStructDType* nodep) {
if (nodep->didWidthAndSet()) return; // This node is a dtype & not both PRELIMed+FINALed
UINFO(5," NODECLASS "<<nodep<<endl);
//if (debug()>=9) nodep->dumpTree("-class-in--");
@ -1697,7 +1697,7 @@ private:
AstNodeDType* fromDtp = nodep->fromp()->dtypep()->skipRefToEnump();
UINFO(9," from dt "<<fromDtp<<endl);
AstMemberDType* memberp = NULL; // NULL=error below
if (AstNodeClassDType* adtypep = VN_CAST(fromDtp, NodeClassDType)) {
if (AstNodeUOrStructDType* adtypep = VN_CAST(fromDtp, NodeUOrStructDType)) {
// No need to width-resolve the class, as it was done when we did the child
memberp = adtypep->findMember(nodep->name());
if (!memberp) {
@ -2255,8 +2255,8 @@ private:
while (const AstConstDType* vdtypep = VN_CAST(dtypep, ConstDType)) {
dtypep = vdtypep->subDTypep()->skipRefp();
}
if (AstNodeClassDType* vdtypep = VN_CAST(dtypep, NodeClassDType)) {
patternClass(nodep, vdtypep, defaultp); VL_DANGLING(nodep);
if (AstNodeUOrStructDType* vdtypep = VN_CAST(dtypep, NodeUOrStructDType)) {
patternUOrStruct(nodep, vdtypep, defaultp); VL_DANGLING(nodep);
}
else if (AstNodeArrayDType* vdtypep = VN_CAST(dtypep, NodeArrayDType)) {
patternArray(nodep, vdtypep, defaultp); VL_DANGLING(nodep);
@ -2270,7 +2270,8 @@ private:
}
}
}
void patternClass(AstPattern* nodep, AstNodeClassDType* vdtypep, AstPatMember* defaultp) {
void patternUOrStruct(AstPattern* nodep, AstNodeUOrStructDType* vdtypep,
AstPatMember* defaultp) {
// Due to "default" and tagged patterns, we need to determine
// which member each AstPatMember corresponds to before we can
// determine the dtypep for that PatMember's value, and then
@ -4336,7 +4337,7 @@ private:
declRange = adtypep->declRange();
if (i<dim) dtypep = adtypep->subDTypep()->skipRefp();
continue;
} else if (AstNodeClassDType* adtypep = VN_CAST(dtypep, NodeClassDType)) {
} else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) {
declRange = adtypep->declRange();
if (adtypep) {} // UNUSED
break; // Sub elements don't look like arrays and can't iterate into
@ -4357,7 +4358,7 @@ private:
bits *= adtypep->declRange().elements();
dtypep = adtypep->subDTypep()->skipRefp();
continue;
} else if (AstNodeClassDType* adtypep = VN_CAST(dtypep, NodeClassDType)) {
} else if (AstNodeUOrStructDType* adtypep = VN_CAST(dtypep, NodeUOrStructDType)) {
bits *= adtypep->width();
break;
} else if (AstBasicDType* adtypep = VN_CAST(dtypep, BasicDType)) {

View File

@ -129,7 +129,7 @@ private:
virtual void visit(AstNodeDType* nodep) {
visitIterateNodeDType(nodep);
}
virtual void visit(AstNodeClassDType* nodep) {
virtual void visit(AstNodeUOrStructDType* nodep) {
if (nodep->user1SetOnce()) return; // Process once
visitIterateNodeDType(nodep);
nodep->clearCache();

View File

@ -95,7 +95,7 @@ private:
}
else if (const AstQueueDType* adtypep = VN_CAST(ddtypep, QueueDType)) {
}
else if (const AstNodeClassDType* adtypep = VN_CAST(ddtypep, NodeClassDType)) {
else if (const AstNodeUOrStructDType* adtypep = VN_CAST(ddtypep, NodeUOrStructDType)) {
fromRange = adtypep->declRange();
}
else if (AstBasicDType* adtypep = VN_CAST(ddtypep, BasicDType)) {
@ -280,7 +280,7 @@ private:
if (debug()>=9) newp->dumpTree(cout, "--SELBTn: ");
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
}
else if (VN_IS(ddtypep, NodeClassDType)) { // It's packed, so a bit from the packed struct
else if (VN_IS(ddtypep, NodeUOrStructDType)) { // A bit from the packed struct
// SELBIT(range, index) -> SEL(array, index, 1)
AstSel* newp = new AstSel(nodep->fileline(),
fromp,
@ -389,7 +389,7 @@ private:
//if (debug()>=9) newp->dumpTree(cout, "--SELEXnew: ");
nodep->replaceWith(newp); pushDeletep(nodep); VL_DANGLING(nodep);
}
else if (VN_IS(ddtypep, NodeClassDType)) {
else if (VN_IS(ddtypep, NodeUOrStructDType)) {
// Classes aren't little endian
if (lsb > msb) {
nodep->v3error("["<<msb<<":"<<lsb<<"] Range extract has backward bit ordering, perhaps you wanted ["
@ -443,8 +443,8 @@ private:
VNumRange fromRange = fromdata.m_fromRange;
if (VN_IS(ddtypep, BasicDType)
|| VN_IS(ddtypep, PackArrayDType)
|| (VN_IS(ddtypep, NodeClassDType)
&& VN_CAST(ddtypep, NodeClassDType)->packedUnsup())) {
|| (VN_IS(ddtypep, NodeUOrStructDType)
&& VN_CAST(ddtypep, NodeUOrStructDType)->packedUnsup())) {
int elwidth = 1;
AstNode* newwidthp = widthp;
if (const AstPackArrayDType* adtypep = VN_CAST(ddtypep, PackArrayDType)) {

View File

@ -1521,14 +1521,14 @@ var_data_type<dtypep>: // ==IEEE: var_data_type
| yVAR implicit_typeE { $$ = $2; }
;
struct_unionDecl<classp>: // IEEE: part of data_type
struct_unionDecl<uorstructp>: // IEEE: part of data_type
// // packedSigningE is NOP for unpacked
ySTRUCT packedSigningE '{' { $<classp>$ = new AstStructDType($1, $2); SYMP->pushNew($<classp>$); }
ySTRUCT packedSigningE '{' { $<uorstructp>$ = new AstStructDType($1, $2); SYMP->pushNew($<uorstructp>$); }
/*cont*/ struct_union_memberList '}'
{ $$=$<classp>4; $$->addMembersp($5); SYMP->popScope($$); }
| yUNION taggedE packedSigningE '{' { $<classp>$ = new AstUnionDType($1, $3); SYMP->pushNew($<classp>$); }
{ $$=$<uorstructp>4; $$->addMembersp($5); SYMP->popScope($$); }
| yUNION taggedE packedSigningE '{' { $<uorstructp>$ = new AstUnionDType($1, $3); SYMP->pushNew($<uorstructp>$); }
/*cont*/ struct_union_memberList '}'
{ $$=$<classp>5; $$->addMembersp($6); SYMP->popScope($$); }
{ $$=$<uorstructp>5; $$->addMembersp($6); SYMP->popScope($$); }
;
struct_union_memberList<nodep>: // IEEE: { struct_union_member }