Internals: Track some VAccess that can be ReadOnly. No functional change.

This commit is contained in:
Wilson Snyder 2020-10-30 22:28:51 -04:00
parent 51b0963e61
commit cf7b5c091a
9 changed files with 13 additions and 12 deletions

View File

@ -140,8 +140,9 @@ public:
: m_e(static_cast<en>(_e)) {} // Need () or GCC 4.8 false warning
operator en() const { return m_e; }
VAccess invert() const { return (m_e == WRITE) ? VAccess(READ) : VAccess(WRITE); }
bool isRead() const { return m_e == READ; }
bool isWrite() const { return m_e == WRITE; }
bool isReadOnly() const { return m_e == READ; } // False if/when support READWRITE
bool isWrite() const { return m_e == WRITE; } // Need audit if/when support READWRITE
bool isWriteOnly() const { return m_e == WRITE; } // False if/when support READWRITE
};
inline bool operator==(const VAccess& lhs, const VAccess& rhs) { return lhs.m_e == rhs.m_e; }
inline bool operator==(const VAccess& lhs, VAccess::en rhs) { return lhs.m_e == rhs; }

View File

@ -2360,7 +2360,7 @@ public:
}
}
virtual int instrCount() const override {
return widthInstrs() * (access().isWrite() ? 1 : instrCountLd());
return widthInstrs() * (access().isWriteOnly() ? 1 : instrCountLd());
}
virtual string emitVerilog() override { V3ERROR_NA_RETURN(""); }
virtual string emitC() override { V3ERROR_NA_RETURN(""); }

View File

@ -154,7 +154,7 @@ private:
}
}
virtual void visit(AstVarRef* nodep) override {
if (nodep->access().isRead() && !VN_IS(nodep->backp(), CCast)
if (nodep->access().isReadOnly() && !VN_IS(nodep->backp(), CCast)
&& VN_IS(nodep->backp(), NodeMath) && !VN_IS(nodep->backp(), ArraySel)
&& nodep->backp()->width() && castSize(nodep) != castSize(nodep->varp())) {
// Cast vars to IData first, else below has upper bits wrongly set

View File

@ -1605,7 +1605,7 @@ private:
// if (debug()) valuep->dumpTree(cout, " visitvaref: ");
iterateAndNextNull(nodep->varp()->valuep()); // May change nodep->varp()->valuep()
AstNode* valuep = nodep->varp()->valuep();
if (!nodep->access().isWrite()
if (nodep->access().isReadOnly()
&& ((!m_params // Can reduce constant wires into equations
&& m_doNConst
&& v3Global.opt.oConst()

View File

@ -842,7 +842,7 @@ private:
// It's possible we substitute into something that will be reduced more later,
// however, as we never delete the top Always/initial statement, all should be well.
m_didReplace = true;
UASSERT_OBJ(!nodep->access().isWrite(), nodep,
UASSERT_OBJ(nodep->access().isReadOnly(), nodep,
"Can't replace lvalue assignments with const var");
AstNode* substp = m_replaceTreep->cloneTree(false);
UASSERT_OBJ(

View File

@ -433,7 +433,7 @@ private:
}
}
if (!m_checkOnly && optimizable()) { // simulating
UASSERT_OBJ(!nodep->access().isWrite(), nodep,
UASSERT_OBJ(nodep->access().isReadOnly(), nodep,
"LHS varref should be handled in AstAssign visitor.");
{
// Return simulation value - copy by reference instead of value for speed

View File

@ -306,7 +306,7 @@ private:
iterate(nodep->rhsp());
AstVarRef* varrefp = VN_CAST(nodep->lhsp(), VarRef);
AstConst* constp = VN_CAST(nodep->rhsp(), Const);
if (varrefp && isSubstVar(varrefp->varp()) && !varrefp->access().isWrite() && constp) {
if (varrefp && isSubstVar(varrefp->varp()) && varrefp->access().isReadOnly() && constp) {
// Nicely formed lvalues handled in NodeAssign
// Other lvalues handled as unknown mess in AstVarRef
int word = constp->toUInt();

View File

@ -845,7 +845,7 @@ private:
virtual void visit(AstVarRef* nodep) override {
if (m_tracep) {
UASSERT_OBJ(nodep->varScopep(), nodep, "No var scope?");
UASSERT_OBJ(!nodep->access().isWrite(), nodep, "Lvalue in trace? Should be const.");
UASSERT_OBJ(nodep->access().isReadOnly(), nodep, "Lvalue in trace? Should be const.");
V3GraphVertex* varVtxp = nodep->varScopep()->user1u().toGraphVertex();
if (!varVtxp) {
varVtxp = new TraceVarVertex(&m_graph, nodep->varScopep());

View File

@ -280,10 +280,10 @@ private:
"Unsupported: String array operation on non-variable");
}
AstNode* newp;
if (varrefp && varrefp->access().isWrite()) {
newp = new AstGetcRefN(nodep->fileline(), fromp, rhsp);
} else {
if (varrefp && varrefp->access().isReadOnly()) {
newp = new AstGetcN(nodep->fileline(), fromp, rhsp);
} else {
newp = new AstGetcRefN(nodep->fileline(), fromp, rhsp);
}
UINFO(6, " new " << newp << endl);
nodep->replaceWith(newp);