V3Number cleanup
This commit is contained in:
parent
a3fd105acb
commit
654571bd1c
|
|
@ -86,42 +86,42 @@ public:
|
||||||
}
|
}
|
||||||
AstConst(FileLine* fl, uint32_t num)
|
AstConst(FileLine* fl, uint32_t num)
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(this, 32, num)) {
|
, m_num(this, 32, num) {
|
||||||
dtypeSetLogicSized(m_num.width(), 0, AstNumeric::UNSIGNED);
|
dtypeSetLogicSized(m_num.width(), 0, AstNumeric::UNSIGNED);
|
||||||
}
|
}
|
||||||
class Unsized32 {}; // for creator type-overload selection
|
class Unsized32 {}; // for creator type-overload selection
|
||||||
AstConst(FileLine* fl, Unsized32, uint32_t num) // Unsized 32-bit integer of specified value
|
AstConst(FileLine* fl, Unsized32, uint32_t num) // Unsized 32-bit integer of specified value
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(this, 32, num)) {
|
, m_num(this, 32, num) {
|
||||||
m_num.width(32, false);
|
m_num.width(32, false);
|
||||||
dtypeSetLogicSized(32, m_num.widthMin(), AstNumeric::UNSIGNED);
|
dtypeSetLogicSized(32, m_num.widthMin(), AstNumeric::UNSIGNED);
|
||||||
}
|
}
|
||||||
class Signed32 {}; // for creator type-overload selection
|
class Signed32 {}; // for creator type-overload selection
|
||||||
AstConst(FileLine* fl, Signed32, int32_t num) // Signed 32-bit integer of specified value
|
AstConst(FileLine* fl, Signed32, int32_t num) // Signed 32-bit integer of specified value
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(this, 32, num)) {
|
, m_num(this, 32, num) {
|
||||||
m_num.width(32, 32);
|
m_num.width(32, 32);
|
||||||
dtypeSetLogicSized(32, m_num.widthMin(), AstNumeric::SIGNED);
|
dtypeSetLogicSized(32, m_num.widthMin(), AstNumeric::SIGNED);
|
||||||
}
|
}
|
||||||
class RealDouble {}; // for creator type-overload selection
|
class RealDouble {}; // for creator type-overload selection
|
||||||
AstConst(FileLine* fl, RealDouble, double num)
|
AstConst(FileLine* fl, RealDouble, double num)
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(this, 64)) { m_num.setDouble(num); dtypeSetDouble(); }
|
, m_num(this, 64) { m_num.setDouble(num); dtypeSetDouble(); }
|
||||||
class String {}; // for creator type-overload selection
|
class String {}; // for creator type-overload selection
|
||||||
AstConst(FileLine* fl, String, const string& num)
|
AstConst(FileLine* fl, String, const string& num)
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(V3Number::String(), this, num)) { dtypeSetString(); }
|
, m_num(V3Number::String(), this, num) { dtypeSetString(); }
|
||||||
class LogicFalse {};
|
class LogicFalse {};
|
||||||
AstConst(FileLine* fl, LogicFalse) // Shorthand const 0, dtype should be a logic of size 1
|
AstConst(FileLine* fl, LogicFalse) // Shorthand const 0, dtype should be a logic of size 1
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(this, 1, 0)) { dtypeSetLogicBool(); }
|
, m_num(this, 1, 0) { dtypeSetLogicBool(); }
|
||||||
class LogicTrue {};
|
class LogicTrue {};
|
||||||
AstConst(FileLine* fl, LogicTrue) // Shorthand const 1, dtype should be a logic of size 1
|
AstConst(FileLine* fl, LogicTrue) // Shorthand const 1, dtype should be a logic of size 1
|
||||||
: AstNodeMath(fl)
|
: AstNodeMath(fl)
|
||||||
, m_num(V3Number(this, 1, 1)) { dtypeSetLogicBool(); }
|
, m_num(this, 1, 1) { dtypeSetLogicBool(); }
|
||||||
ASTNODE_NODE_FUNCS(Const)
|
ASTNODE_NODE_FUNCS(Const)
|
||||||
virtual string name() const { return num().ascii(); } // * = Value
|
virtual string name() const { return num().ascii(); } // * = Value
|
||||||
virtual const V3Number& num() const { return m_num; } // * = Value
|
const V3Number& num() const { return m_num; } // * = Value
|
||||||
uint32_t toUInt() const { return num().toUInt(); }
|
uint32_t toUInt() const { return num().toUInt(); }
|
||||||
vlsint32_t toSInt() const { return num().toSInt(); }
|
vlsint32_t toSInt() const { return num().toSInt(); }
|
||||||
vluint64_t toUQuad() const { return num().toUQuad(); }
|
vluint64_t toUQuad() const { return num().toUQuad(); }
|
||||||
|
|
|
||||||
|
|
@ -131,7 +131,7 @@ private:
|
||||||
int width = itemp->width();
|
int width = itemp->width();
|
||||||
int lsb = itemp->lsb();
|
int lsb = itemp->lsb();
|
||||||
int msb = lsb + width - 1;
|
int msb = lsb + width - 1;
|
||||||
V3Number fieldNum = V3Number(nump, width);
|
V3Number fieldNum(nump, width);
|
||||||
fieldNum.opSel(*nump, msb, lsb);
|
fieldNum.opSel(*nump, msb, lsb);
|
||||||
out<<itemp->name()<<": ";
|
out<<itemp->name()<<": ";
|
||||||
if (AstNodeDType * childTypep = itemp->subDTypep()) {
|
if (AstNodeDType * childTypep = itemp->subDTypep()) {
|
||||||
|
|
@ -153,7 +153,7 @@ private:
|
||||||
int width = childTypep->width();
|
int width = childTypep->width();
|
||||||
int lsb = width * element;
|
int lsb = width * element;
|
||||||
int msb = lsb + width - 1;
|
int msb = lsb + width - 1;
|
||||||
V3Number fieldNum = V3Number(nump, width);
|
V3Number fieldNum(nump, width);
|
||||||
fieldNum.opSel(*nump, msb, lsb);
|
fieldNum.opSel(*nump, msb, lsb);
|
||||||
int arrayElem = arrayp->lsb() + element;
|
int arrayElem = arrayp->lsb() + element;
|
||||||
out<<arrayElem<<" = "<<prettyNumber(&fieldNum, childTypep);
|
out<<arrayElem<<" = "<<prettyNumber(&fieldNum, childTypep);
|
||||||
|
|
@ -568,14 +568,14 @@ private:
|
||||||
|
|
||||||
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
void handleAssignSel(AstNodeAssign* nodep, AstSel* selp) {
|
||||||
AstVarRef* varrefp = NULL;
|
AstVarRef* varrefp = NULL;
|
||||||
V3Number lsb = V3Number(nodep);
|
V3Number lsb(nodep);
|
||||||
iterateAndNextNull(nodep->rhsp()); // Value to assign
|
iterateAndNextNull(nodep->rhsp()); // Value to assign
|
||||||
handleAssignSelRecurse(nodep, selp, varrefp/*ref*/, lsb/*ref*/, 0);
|
handleAssignSelRecurse(nodep, selp, varrefp/*ref*/, lsb/*ref*/, 0);
|
||||||
if (!m_checkOnly && optimizable()) {
|
if (!m_checkOnly && optimizable()) {
|
||||||
UASSERT_OBJ(varrefp, nodep,
|
UASSERT_OBJ(varrefp, nodep,
|
||||||
"Indicated optimizable, but no variable found on RHS of select");
|
"Indicated optimizable, but no variable found on RHS of select");
|
||||||
AstNode* vscp = varOrScope(varrefp);
|
AstNode* vscp = varOrScope(varrefp);
|
||||||
V3Number outnum = V3Number(nodep);
|
V3Number outnum(nodep);
|
||||||
if (V3Number* vscpnump = fetchOutNumberNull(vscp)) {
|
if (V3Number* vscpnump = fetchOutNumberNull(vscp)) {
|
||||||
outnum = *vscpnump;
|
outnum = *vscpnump;
|
||||||
} else if (V3Number* vscpnump = fetchNumberNull(vscp)) {
|
} else if (V3Number* vscpnump = fetchNumberNull(vscp)) {
|
||||||
|
|
@ -606,7 +606,7 @@ private:
|
||||||
lsbRef = *fetchNumber(selp->lsbp());
|
lsbRef = *fetchNumber(selp->lsbp());
|
||||||
return; // And presumably still optimizable()
|
return; // And presumably still optimizable()
|
||||||
} else if (AstSel* subselp = VN_CAST(selp->lhsp(), Sel)) {
|
} else if (AstSel* subselp = VN_CAST(selp->lhsp(), Sel)) {
|
||||||
V3Number sublsb = V3Number(nodep);
|
V3Number sublsb(nodep);
|
||||||
handleAssignSelRecurse(nodep, subselp, outVarrefpRef, sublsb/*ref*/, depth+1);
|
handleAssignSelRecurse(nodep, subselp, outVarrefpRef, sublsb/*ref*/, depth+1);
|
||||||
if (optimizable()) {
|
if (optimizable()) {
|
||||||
lsbRef = sublsb;
|
lsbRef = sublsb;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue