Internals: Merge from dtype. Add hasDType; still unused. No functional change.

This commit is contained in:
Wilson Snyder 2012-04-14 11:03:38 -04:00
parent 8114957e6d
commit 2b12ab4d5a
2 changed files with 17 additions and 0 deletions

View File

@ -1002,6 +1002,7 @@ public:
virtual int instrCount() const { return 0; } virtual int instrCount() const { return 0; }
virtual V3Hash sameHash() const { return V3Hash(V3Hash::Illegal()); } // Not a node that supports it virtual V3Hash sameHash() const { return V3Hash(V3Hash::Illegal()); } // Not a node that supports it
virtual bool same(AstNode* otherp) const { return true; } virtual bool same(AstNode* otherp) const { return true; }
virtual bool hasDType() const { return false; } // Iff has a data type; dtype() must be non null
virtual bool maybePointedTo() const { return false; } // Another AstNode* may have a pointer into this node, other then normal front/back/etc. virtual bool maybePointedTo() const { return false; } // Another AstNode* may have a pointer into this node, other then normal front/back/etc.
virtual bool broken() const { return false; } virtual bool broken() const { return false; }
@ -1038,6 +1039,7 @@ struct AstNodeMath : public AstNode {
: AstNode(fl) {} : AstNode(fl) {}
ASTNODE_BASE_FUNCS(NodeMath) ASTNODE_BASE_FUNCS(NodeMath)
// METHODS // METHODS
virtual bool hasDType() const { return true; }
virtual string emitVerilog() = 0; /// Format string for verilog writing; see V3EmitV virtual string emitVerilog() = 0; /// Format string for verilog writing; see V3EmitV
virtual string emitC() = 0; virtual string emitC() = 0;
virtual string emitSimpleOperator() { return ""; } virtual string emitSimpleOperator() { return ""; }
@ -1204,6 +1206,7 @@ struct AstNodeAssign : public AstNodeStmt {
AstNode* lhsp() const { return op2p()->castNode(); } // op2 = Assign to AstNode* lhsp() const { return op2p()->castNode(); } // op2 = Assign to
void rhsp(AstNode* np) { setOp1p(np); } void rhsp(AstNode* np) { setOp1p(np); }
void lhsp(AstNode* np) { setOp2p(np); } void lhsp(AstNode* np) { setOp2p(np); }
virtual bool hasDType() const { return true; }
virtual bool cleanRhs() { return true; } virtual bool cleanRhs() { return true; }
virtual int instrCount() const { return widthInstrs(); } virtual int instrCount() const { return widthInstrs(); }
virtual V3Hash sameHash() const { return V3Hash(); } virtual V3Hash sameHash() const { return V3Hash(); }
@ -1300,6 +1303,7 @@ public:
init(); init();
} }
ASTNODE_BASE_FUNCS(NodeVarRef) ASTNODE_BASE_FUNCS(NodeVarRef)
virtual bool hasDType() const { return true; }
virtual bool broken() const; virtual bool broken() const;
virtual int instrCount() const { return widthInstrs(); } virtual int instrCount() const { return widthInstrs(); }
virtual void cloneRelink(); virtual void cloneRelink();
@ -1346,6 +1350,7 @@ struct AstNodeDType : public AstNode {
ASTNODE_BASE_FUNCS(NodeDType) ASTNODE_BASE_FUNCS(NodeDType)
// Accessors // Accessors
virtual void dump(ostream& str); virtual void dump(ostream& str);
virtual bool hasDType() const { return true; }
virtual AstBasicDType* basicp() const = 0; // (Slow) recurse down to find basic data type virtual AstBasicDType* basicp() const = 0; // (Slow) recurse down to find basic data type
virtual AstNodeDType* skipRefp() const = 0; // recurses over typedefs to next non-typeref type virtual AstNodeDType* skipRefp() const = 0; // recurses over typedefs to next non-typeref type
virtual int widthAlignBytes() const = 0; // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this) virtual int widthAlignBytes() const = 0; // (Slow) recurses - Structure alignment 1,2,4 or 8 bytes (arrays affect this)
@ -1366,6 +1371,7 @@ struct AstNodeSel : public AstNodeBiop {
AstNode* bitp() const { return op2p()->castNode(); } // op2 = Msb selection expression AstNode* bitp() const { return op2p()->castNode(); } // op2 = Msb selection expression
void bitp(AstNode* nodep) { setOp2p(nodep); } void bitp(AstNode* nodep) { setOp2p(nodep); }
int bitConst() const; int bitConst() const;
virtual bool hasDType() const { return true; }
}; };
//###################################################################### //######################################################################

View File

@ -173,6 +173,7 @@ public:
// 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; }
virtual bool hasDType() const { return true; }
void name(const string& flag) { m_name = flag; } void name(const string& flag) { m_name = flag; }
}; };
@ -414,6 +415,7 @@ public:
ASTNODE_NODE_FUNCS(EnumItem, ENUMITEM) ASTNODE_NODE_FUNCS(EnumItem, ENUMITEM)
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; }
virtual bool hasDType() const { return true; }
void name(const string& flag) { m_name = flag; } void name(const string& flag) { m_name = flag; }
AstRange* rangep() const { return op1p()->castRange(); } // op1 = Range for name appending AstRange* rangep() const { return op1p()->castRange(); } // op1 = Range for name appending
void rangep(AstNode* nodep) { addOp1p(nodep); } void rangep(AstNode* nodep) { addOp1p(nodep); }
@ -696,6 +698,7 @@ public:
ASTNODE_NODE_FUNCS(Var, VAR) ASTNODE_NODE_FUNCS(Var, VAR)
virtual void dump(ostream& str); virtual void dump(ostream& str);
virtual string name() const { return m_name; } // * = Var name virtual string name() const { return m_name; } // * = Var name
virtual bool hasDType() const { return true; }
virtual bool maybePointedTo() const { return true; } virtual bool maybePointedTo() const { return true; }
virtual bool broken() const { return !dtypep(); } virtual bool broken() const { return !dtypep(); }
AstVarType varType() const { return m_varType; } // * = Type of variable AstVarType varType() const { return m_varType; } // * = Type of variable
@ -925,6 +928,7 @@ public:
virtual bool maybePointedTo() const { return true; } virtual bool maybePointedTo() const { return true; }
virtual string name() const {return scopep()->name()+"->"+varp()->name();} // * = Var name virtual string name() const {return scopep()->name()+"->"+varp()->name();} // * = Var name
virtual void dump(ostream& str); virtual void dump(ostream& str);
virtual bool hasDType() const { return true; }
AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable AstVar* varp() const { return m_varp; } // [After Link] Pointer to variable
AstScope* scopep() const { return m_scopep; } // Pointer to scope it's under AstScope* scopep() const { return m_scopep; } // Pointer to scope it's under
AstNode* valuep() const { return op1p(); } // op1 = Calculation of value of variable, NULL=complicated AstNode* valuep() const { return op1p(); } // op1 = Calculation of value of variable, NULL=complicated
@ -1244,6 +1248,7 @@ struct AstFunc : public AstNodeFTask {
addNOp1p(fvarsp); addNOp1p(fvarsp);
} }
ASTNODE_NODE_FUNCS(Func, FUNC) ASTNODE_NODE_FUNCS(Func, FUNC)
virtual bool hasDType() const { return true; }
}; };
struct AstTaskRef : public AstNodeFTaskRef { struct AstTaskRef : public AstNodeFTaskRef {
@ -1262,6 +1267,7 @@ struct AstFuncRef : public AstNodeFTaskRef {
AstFuncRef(FileLine* fl, const string& name, AstNode* pinsp) AstFuncRef(FileLine* fl, const string& name, AstNode* pinsp)
:AstNodeFTaskRef(fl, name, pinsp) {} :AstNodeFTaskRef(fl, name, pinsp) {}
ASTNODE_NODE_FUNCS(FuncRef, FUNCREF) ASTNODE_NODE_FUNCS(FuncRef, FUNCREF)
virtual bool hasDType() const { return true; }
}; };
struct AstDpiExport : public AstNode { struct AstDpiExport : public AstNode {
@ -2388,6 +2394,7 @@ public:
ASTNODE_NODE_FUNCS(TraceDecl, TRACEDECL) ASTNODE_NODE_FUNCS(TraceDecl, TRACEDECL)
virtual string name() const { return m_showname; } virtual string name() const { return m_showname; }
virtual bool maybePointedTo() const { return true; } virtual bool maybePointedTo() const { return true; }
virtual bool hasDType() const { return true; }
virtual bool same(AstNode* samep) const { return false; } virtual bool same(AstNode* samep) const { return false; }
string showname() const { return m_showname; } // * = Var name string showname() const { return m_showname; } // * = Var name
// Details on what we're tracing // Details on what we're tracing
@ -2419,6 +2426,7 @@ public:
virtual void cloneRelink() { if (m_declp->clonep()) m_declp = m_declp->clonep()->castTraceDecl(); } virtual void cloneRelink() { if (m_declp->clonep()) m_declp = m_declp->clonep()->castTraceDecl(); }
virtual void dump(ostream& str); virtual void dump(ostream& str);
virtual int instrCount() const { return 10+2*instrCountLd(); } virtual int instrCount() const { return 10+2*instrCountLd(); }
virtual bool hasDType() const { return true; }
virtual V3Hash sameHash() const { return V3Hash(declp()); } virtual V3Hash sameHash() const { return V3Hash(declp()); }
virtual bool same(AstNode* samep) const { virtual bool same(AstNode* samep) const {
return declp()==samep->castTraceInc()->declp(); } return declp()==samep->castTraceInc()->declp(); }
@ -2869,6 +2877,7 @@ struct AstCast : public AstNode {
if (dtp) { widthSignedFrom(dtp); } if (dtp) { widthSignedFrom(dtp); }
} }
ASTNODE_NODE_FUNCS(Cast, CAST) ASTNODE_NODE_FUNCS(Cast, CAST)
virtual bool hasDType() const { return true; }
virtual string emitVerilog() { return "((%r)'(%l))"; } virtual string emitVerilog() { return "((%r)'(%l))"; }
virtual string emitC() { V3ERROR_NA; return ""; } virtual string emitC() { V3ERROR_NA; return ""; }
virtual bool cleanOut() { V3ERROR_NA; return true;} virtual bool cleanLhs() {return true;} virtual bool cleanOut() { V3ERROR_NA; return true;} virtual bool cleanLhs() {return true;}
@ -3745,6 +3754,7 @@ struct AstPslClocked : public AstNode {
addOp3p(propp); addOp3p(propp);
} }
ASTNODE_NODE_FUNCS(PslClocked, PSLCLOCKED) ASTNODE_NODE_FUNCS(PslClocked, PSLCLOCKED)
virtual bool hasDType() const { return true; } // Used under PslCover, which expects a bool child
AstNodeSenItem* sensesp() const { return op1p()->castNodeSenItem(); } // op1 = Sensitivity list AstNodeSenItem* sensesp() const { return op1p()->castNodeSenItem(); } // op1 = Sensitivity list
AstNode* disablep() const { return op2p(); } // op2 = disable AstNode* disablep() const { return op2p(); } // op2 = disable
AstNode* propp() const { return op3p(); } // op3 = property AstNode* propp() const { return op3p(); } // op3 = property
@ -3811,6 +3821,7 @@ struct AstPslBool : public AstNode {
} }
ASTNODE_NODE_FUNCS(PslBool, PSLBOOL) ASTNODE_NODE_FUNCS(PslBool, PSLBOOL)
AstNode* exprp() const { return op1p()->castNode(); } // op1= expression AstNode* exprp() const { return op1p()->castNode(); } // op1= expression
virtual bool hasDType() const { return true; }
virtual bool isGateOptimizable() const { return false; } // Not relevant virtual bool isGateOptimizable() const { return false; } // Not relevant
virtual bool isPredictOptimizable() const { return false; } // Not relevant virtual bool isPredictOptimizable() const { return false; } // Not relevant
virtual int instrCount() const { return 0; } virtual int instrCount() const { return 0; }