Internals: Call common V3NUmber function to zero data type. Cleanup chandle clearling.
This commit is contained in:
parent
a1a9147267
commit
9049c93009
|
|
@ -639,6 +639,7 @@ public:
|
|||
int widthWords() const { return VL_WORDS_I(width()); }
|
||||
bool isQuad() const VL_MT_STABLE { return (width() > VL_IDATASIZE && width() <= VL_QUADSIZE); }
|
||||
bool isWide() const VL_MT_STABLE { return (width() > VL_QUADSIZE); }
|
||||
inline bool isCHandle() const VL_MT_STABLE;
|
||||
inline bool isDouble() const VL_MT_STABLE;
|
||||
inline bool isSigned() const VL_MT_STABLE;
|
||||
inline bool isString() const VL_MT_STABLE;
|
||||
|
|
|
|||
|
|
@ -591,6 +591,7 @@ public:
|
|||
|| m_e == RANDOM_GENERATOR || m_e == RANDOM_STDGENERATOR || m_e == DOUBLE
|
||||
|| m_e == UNTYPED);
|
||||
}
|
||||
bool isCHandle() const VL_MT_SAFE { return m_e == CHANDLE; }
|
||||
bool isDouble() const VL_MT_SAFE { return m_e == DOUBLE; }
|
||||
bool isEvent() const { return m_e == EVENT; }
|
||||
bool isString() const VL_MT_SAFE { return m_e == STRING; }
|
||||
|
|
|
|||
|
|
@ -33,6 +33,9 @@ bool AstNode::width1() const { // V3Const uses to know it can optimize
|
|||
int AstNode::widthInstrs() const {
|
||||
return (!dtypep() ? 1 : (dtypep()->isWide() ? dtypep()->widthWords() : 1));
|
||||
}
|
||||
bool AstNode::isCHandle() const VL_MT_STABLE {
|
||||
return dtypep() && dtypep()->basicp() && dtypep()->basicp()->isCHandle();
|
||||
}
|
||||
bool AstNode::isDouble() const VL_MT_STABLE {
|
||||
return dtypep() && dtypep()->basicp() && dtypep()->basicp()->isDouble();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,6 +458,7 @@ public:
|
|||
return m.m_keyword;
|
||||
}
|
||||
bool isBitLogic() const { return keyword().isBitLogic(); }
|
||||
bool isCHandle() const VL_MT_STABLE { return keyword().isCHandle(); }
|
||||
bool isDouble() const VL_MT_STABLE { return keyword().isDouble(); }
|
||||
bool isEvent() const VL_MT_STABLE { return keyword() == VBasicDTypeKwd::EVENT; }
|
||||
bool isForkSync() const VL_MT_SAFE { return keyword() == VBasicDTypeKwd::FORK_SYNC; }
|
||||
|
|
|
|||
|
|
@ -877,8 +877,7 @@ string AstVar::dpiTmpVarType(const string& varName) const {
|
|||
string primitive(const AstVar* varp) const override {
|
||||
string type = dpiTypesToStringConverter::primitive(varp);
|
||||
if (varp->isWritable() || VN_IS(varp->dtypep()->skipRefp(), UnpackArrayDType)) {
|
||||
if (!varp->isWritable() && varp->basicp()->keyword() == VBasicDTypeKwd::CHANDLE)
|
||||
type = "const " + type;
|
||||
if (!varp->isWritable() && varp->basicp()->isCHandle()) type = "const " + type;
|
||||
}
|
||||
type += ' ' + m_name + arraySuffix(varp, 0);
|
||||
return type;
|
||||
|
|
|
|||
|
|
@ -116,12 +116,15 @@ V3Number::V3Number(AstNode* nodep, VerilogStringLiteral, const string& str) {
|
|||
}
|
||||
|
||||
V3Number::V3Number(AstNode* nodep, const AstNodeDType* nodedtypep) {
|
||||
if (nodedtypep->isString()) {
|
||||
if (nodedtypep->isCHandle()) {
|
||||
init(nodep);
|
||||
setString("");
|
||||
setNull();
|
||||
} else if (nodedtypep->isDouble()) {
|
||||
init(nodep, 64);
|
||||
setDouble(0.0);
|
||||
} else if (nodedtypep->isString()) {
|
||||
init(nodep);
|
||||
setString("");
|
||||
} else {
|
||||
init(nodep, nodedtypep->width(), nodedtypep->widthSized());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -340,6 +340,11 @@ class V3Number final {
|
|||
FileLine* m_fileline = nullptr; // Source location - if no parent node is reasonable
|
||||
|
||||
// METHODS
|
||||
void setNull() {
|
||||
m_data.setLogic();
|
||||
m_data.m_isNull = true;
|
||||
m_data.m_autoExtend = true;
|
||||
}
|
||||
V3Number& setSingleBits(char value);
|
||||
V3Number& setString(const string& str) {
|
||||
m_data.setString(str);
|
||||
|
|
@ -512,9 +517,7 @@ public:
|
|||
class Null {};
|
||||
V3Number(AstNode* nodep, Null) {
|
||||
init(nodep);
|
||||
m_data.setLogic();
|
||||
m_data.m_isNull = true;
|
||||
m_data.m_autoExtend = true;
|
||||
setNull();
|
||||
}
|
||||
explicit V3Number(const V3Number* nump, int width = 1) {
|
||||
init(nullptr, width);
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ private:
|
|||
if (const AstBasicDType* const basicp = nodep->dtypeSkipRefp()->basicp()) {
|
||||
AstConst cnst{nodep->fileline(), AstConst::WidthedValue{}, basicp->widthMin(), 0};
|
||||
if (basicp->isZeroInit()) {
|
||||
cnst.num().setAllBits0();
|
||||
cnst.num() = V3Number{nodep, basicp};
|
||||
} else {
|
||||
cnst.num().setAllBitsX();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8264,7 +8264,7 @@ class WidthVisitor final : public VNVisitor {
|
|||
linker.relink(newp);
|
||||
} else if (VN_IS(underVDTypep, ClassRefDType) || VN_IS(underVDTypep, IfaceRefDType)
|
||||
|| (VN_IS(underVDTypep, BasicDType)
|
||||
&& VN_AS(underVDTypep, BasicDType)->keyword() == VBasicDTypeKwd::CHANDLE)) {
|
||||
&& VN_AS(underVDTypep, BasicDType)->isCHandle())) {
|
||||
// Allow warning-free "if (handle)"
|
||||
VL_DO_DANGLING(fixWidthReduce(VN_AS(underp, NodeExpr)), underp); // Changed
|
||||
} else if (!underVDTypep->basicp()) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue