Internals: Add V3Number width-and-opAssign. No functional change.
This commit is contained in:
parent
5ca62de167
commit
4e667fabb7
|
|
@ -1368,8 +1368,7 @@ class ConstVisitor final : public VNVisitor {
|
|||
nodep->rhsp(smallerp);
|
||||
|
||||
constp->unlinkFrBack();
|
||||
V3Number num{constp, subsize};
|
||||
num.opAssign(constp->num());
|
||||
V3Number num{constp, subsize, constp->num()};
|
||||
nodep->lhsp(new AstConst{constp->fileline(), num});
|
||||
VL_DO_DANGLING(pushDeletep(constp), constp);
|
||||
if (debug() >= 9) nodep->dumpTree("- BI(EXTEND)-ou: ");
|
||||
|
|
|
|||
|
|
@ -466,6 +466,11 @@ public:
|
|||
V3Number(AstNode* nodep, int width) { // 0=unsized
|
||||
init(nodep, width, width > 0);
|
||||
}
|
||||
// Construct with value, changing to new width
|
||||
V3Number(AstNode* nodep, int width, const V3Number& value) {
|
||||
init(nodep, width, width > 0);
|
||||
opAssign(value);
|
||||
}
|
||||
V3Number(AstNode* nodep, int width, uint32_t value, bool sized = true) {
|
||||
init(nodep, width, sized);
|
||||
m_data.num()[0].m_value = value;
|
||||
|
|
|
|||
|
|
@ -603,8 +603,7 @@ private:
|
|||
// but in reality it would yield '0's without V3Table, so force 'x' bits to '0',
|
||||
// to ensure the result is the same with and without V3Table.
|
||||
if (!m_params && VN_IS(nodep, Sel) && valuep->num().isAnyX()) {
|
||||
V3Number num{valuep, valuep->width()};
|
||||
num.opAssign(valuep->num());
|
||||
V3Number num{valuep, valuep->width(), valuep->num()};
|
||||
valuep->num().opBitsOne(num);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6764,8 +6764,7 @@ class WidthVisitor final : public VNVisitor {
|
|||
if (nodep->rhsp()->width() > 32) {
|
||||
if (shiftp && shiftp->num().mostSetBitP1() <= 32) {
|
||||
// If (number)<<96'h1, then make it into (number)<<32'h1
|
||||
V3Number num(shiftp, 32, 0);
|
||||
num.opAssign(shiftp->num());
|
||||
V3Number num{shiftp, 32, shiftp->num()};
|
||||
AstNode* const shiftrhsp = nodep->rhsp();
|
||||
nodep->rhsp()->replaceWith(new AstConst{shiftrhsp->fileline(), num});
|
||||
VL_DO_DANGLING(shiftrhsp->deleteTree(), shiftrhsp);
|
||||
|
|
@ -6935,8 +6934,7 @@ class WidthVisitor final : public VNVisitor {
|
|||
const int expWidth = expDTypep->width();
|
||||
if (constp && !constp->num().isNegative()) {
|
||||
// Save later constant propagation work, just right-size it.
|
||||
V3Number num(nodep, expWidth);
|
||||
num.opAssign(constp->num());
|
||||
V3Number num{nodep, expWidth, constp->num()};
|
||||
num.isSigned(false);
|
||||
AstNodeExpr* const newp = new AstConst{nodep->fileline(), num};
|
||||
constp->replaceWith(newp);
|
||||
|
|
|
|||
|
|
@ -30,8 +30,7 @@ public:
|
|||
static AstConst* newIfConstCommitSize(AstConst* nodep) {
|
||||
if (((nodep->dtypep()->width() != nodep->num().width()) || !nodep->num().sized())
|
||||
&& !nodep->num().isString()) { // Need to force the number from unsized to sized
|
||||
V3Number num{nodep, nodep->dtypep()->width()};
|
||||
num.opAssign(nodep->num());
|
||||
V3Number num{nodep, nodep->dtypep()->width(), nodep->num()};
|
||||
num.isSigned(nodep->isSigned());
|
||||
AstConst* const newp = new AstConst{nodep->fileline(), num};
|
||||
newp->dtypeFrom(nodep);
|
||||
|
|
|
|||
Loading…
Reference in New Issue