Internals: Rename widthToFit, no functional change.
This commit is contained in:
parent
5083972536
commit
3658e5f0f1
|
|
@ -953,7 +953,7 @@ class AstConst final : public AstNodeExpr {
|
||||||
} else if (m_num.isString()) {
|
} else if (m_num.isString()) {
|
||||||
dtypeSetString();
|
dtypeSetString();
|
||||||
} else {
|
} else {
|
||||||
dtypeSetLogicUnsized(m_num.width(), (m_num.sized() ? 0 : m_num.widthMin()),
|
dtypeSetLogicUnsized(m_num.width(), (m_num.sized() ? 0 : m_num.widthToFit()),
|
||||||
VSigning::fromBool(m_num.isSigned()));
|
VSigning::fromBool(m_num.isSigned()));
|
||||||
}
|
}
|
||||||
m_num.nodep(this);
|
m_num.nodep(this);
|
||||||
|
|
@ -1000,14 +1000,14 @@ public:
|
||||||
: ASTGEN_SUPER_Const(fl)
|
: ASTGEN_SUPER_Const(fl)
|
||||||
, m_num(this, 32, num) {
|
, m_num(this, 32, num) {
|
||||||
m_num.width(32, false);
|
m_num.width(32, false);
|
||||||
dtypeSetLogicUnsized(32, m_num.widthMin(), VSigning::UNSIGNED);
|
dtypeSetLogicUnsized(32, m_num.widthToFit(), VSigning::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
|
||||||
: ASTGEN_SUPER_Const(fl)
|
: ASTGEN_SUPER_Const(fl)
|
||||||
, m_num(this, 32, num) {
|
, m_num(this, 32, num) {
|
||||||
m_num.width(32, true);
|
m_num.width(32, true);
|
||||||
dtypeSetLogicUnsized(32, m_num.widthMin(), VSigning::SIGNED);
|
dtypeSetLogicUnsized(32, m_num.widthToFit(), VSigning::SIGNED);
|
||||||
}
|
}
|
||||||
class Unsized64 {}; // for creator type-overload selection
|
class Unsized64 {}; // for creator type-overload selection
|
||||||
AstConst(FileLine* fl, Unsized64, uint64_t num)
|
AstConst(FileLine* fl, Unsized64, uint64_t num)
|
||||||
|
|
|
||||||
|
|
@ -317,7 +317,7 @@ class ConstBitOpTreeVisitor final : public VNVisitorConst {
|
||||||
if (needsMasking) {
|
if (needsMasking) {
|
||||||
// Reduce the masked term to the minimum known width,
|
// Reduce the masked term to the minimum known width,
|
||||||
// to use the smallest RedXor formula
|
// to use the smallest RedXor formula
|
||||||
const int widthMin = maskNum.widthMin();
|
const int widthMin = maskNum.widthToFit();
|
||||||
resultp->dtypeChgWidth(widthMin, widthMin);
|
resultp->dtypeChgWidth(widthMin, widthMin);
|
||||||
}
|
}
|
||||||
resultp = new AstRedXor{fl, resultp};
|
resultp = new AstRedXor{fl, resultp};
|
||||||
|
|
@ -1098,7 +1098,7 @@ class ConstVisitor final : public VNVisitor {
|
||||||
|
|
||||||
// Compute how many significant bits are in the mask
|
// Compute how many significant bits are in the mask
|
||||||
const AstConst* const constp = VN_AS(nodep->lhsp(), Const);
|
const AstConst* const constp = VN_AS(nodep->lhsp(), Const);
|
||||||
const uint32_t significantBits = constp->num().widthMin();
|
const uint32_t significantBits = constp->num().widthToFit();
|
||||||
|
|
||||||
AstOr* const orp = VN_AS(nodep->rhsp(), Or);
|
AstOr* const orp = VN_AS(nodep->rhsp(), Or);
|
||||||
|
|
||||||
|
|
@ -3551,13 +3551,13 @@ class ConstVisitor final : public VNVisitor {
|
||||||
TREEOPA("AstNodeCond{$condp.isNeqZero, $thenp.castConst, $elsep.castConst}", "replaceWChild(nodep,$thenp)");
|
TREEOPA("AstNodeCond{$condp.isNeqZero, $thenp.castConst, $elsep.castConst}", "replaceWChild(nodep,$thenp)");
|
||||||
TREEOP ("AstNodeCond{$condp, operandsSame($thenp,,$elsep)}","replaceWChild(nodep,$thenp)");
|
TREEOP ("AstNodeCond{$condp, operandsSame($thenp,,$elsep)}","replaceWChild(nodep,$thenp)");
|
||||||
// This visit function here must allow for short-circuiting.
|
// This visit function here must allow for short-circuiting.
|
||||||
TREEOPS("AstCond {$condp.isZero}", "replaceWIteratedThs(nodep)");
|
TREEOPS("AstCond{$condp.isZero}", "replaceWIteratedThs(nodep)");
|
||||||
TREEOPS("AstCond {$condp.isNeqZero}", "replaceWIteratedRhs(nodep)");
|
TREEOPS("AstCond{$condp.isNeqZero}", "replaceWIteratedRhs(nodep)");
|
||||||
TREEOP ("AstCond{$condp.castNot, $thenp, $elsep}", "AstCond{$condp->castNot()->lhsp(), $elsep, $thenp}");
|
TREEOP ("AstCond{$condp.castNot, $thenp, $elsep}", "AstCond{$condp->castNot()->lhsp(), $elsep, $thenp}");
|
||||||
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp.isAllOnes, $elsep}", "AstLogOr {$condp, $elsep}"); // a?1:b == a||b
|
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp.isAllOnes, $elsep}", "AstLogOr {$condp, $elsep}"); // a?1:b == a||b
|
||||||
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp, $elsep.isZero, !$elsep.isClassHandleValue}", "AstLogAnd{$condp, $thenp}"); // a?b:0 == a&&b
|
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp, $elsep.isZero, !$elsep.isClassHandleValue}", "AstLogAnd{$condp, $thenp}"); // a?b:0 == a&&b
|
||||||
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp, $elsep.isAllOnes}", "AstLogOr {AstNot{$condp}, $thenp}"); // a?b:1 == ~a||b
|
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp, $elsep.isAllOnes}", "AstLogOr {AstNot{$condp}, $thenp}"); // a?b:1 == ~a||b
|
||||||
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp.isZero, !$thenp.isClassHandleValue, $elsep}", "AstLogAnd{AstNot{$condp}, $elsep}"); // a?0:b == ~a&&b
|
TREEOP ("AstNodeCond{$condp.width1, $thenp.width1, $thenp.isZero, !$thenp.isClassHandleValue, $elsep}", "AstLogAnd{AstNot{$condp}, $elsep}"); // a?0:b == ~a&&b
|
||||||
TREEOP ("AstNodeCond{!$condp.width1, operandBoolShift(nodep->condp())}", "replaceBoolShift(nodep->condp())");
|
TREEOP ("AstNodeCond{!$condp.width1, operandBoolShift(nodep->condp())}", "replaceBoolShift(nodep->condp())");
|
||||||
// Prefer constants on left, since that often needs a shift, it lets
|
// Prefer constants on left, since that often needs a shift, it lets
|
||||||
// constant red remove the shift
|
// constant red remove the shift
|
||||||
|
|
|
||||||
|
|
@ -495,7 +495,7 @@ void EmitCFunc::emitConstant(AstConst* nodep, AstVarRef* assigntop, const string
|
||||||
} else if (nodep->num().isString()) {
|
} else if (nodep->num().isString()) {
|
||||||
emitConstantString(nodep);
|
emitConstantString(nodep);
|
||||||
} else if (nodep->isWide()) {
|
} else if (nodep->isWide()) {
|
||||||
int upWidth = nodep->num().widthMin();
|
int upWidth = nodep->num().widthToFit();
|
||||||
int chunks = 0;
|
int chunks = 0;
|
||||||
if (upWidth > EMITC_NUM_CONSTW * VL_EDATASIZE) {
|
if (upWidth > EMITC_NUM_CONSTW * VL_EDATASIZE) {
|
||||||
// Output e.g. 8 words in groups of e.g. 8
|
// Output e.g. 8 words in groups of e.g. 8
|
||||||
|
|
|
||||||
|
|
@ -372,7 +372,7 @@ void V3Number::create(const char* sourcep) {
|
||||||
|
|
||||||
// If was unsized, trim width per IEEE 1800-2023 5.7.1
|
// If was unsized, trim width per IEEE 1800-2023 5.7.1
|
||||||
if (!userSized && !m_data.m_autoExtend) {
|
if (!userSized && !m_data.m_autoExtend) {
|
||||||
width(std::max(32, base_align * ((widthMin() + base_align - 1) / base_align)), false);
|
width(std::max(32, base_align * ((widthToFit() + base_align - 1) / base_align)), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Z or X extend specific width values. Spec says we don't 1 extend.
|
// Z or X extend specific width values. Spec says we don't 1 extend.
|
||||||
|
|
@ -1131,7 +1131,7 @@ int V3Number::countZ(int lsb, int nbits) const VL_MT_SAFE {
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
int V3Number::widthMin() const {
|
int V3Number::widthToFit() const {
|
||||||
for (int bit = width() - 1; bit > 0; bit--) {
|
for (int bit = width() - 1; bit > 0; bit--) {
|
||||||
if (!bitIs0(bit)) return bit + 1;
|
if (!bitIs0(bit)) return bit + 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -584,7 +584,7 @@ public:
|
||||||
string displayed(AstNode* nodep, const string& vformat) const VL_MT_STABLE;
|
string displayed(AstNode* nodep, const string& vformat) const VL_MT_STABLE;
|
||||||
static bool displayedFmtLegal(char format, bool isScan); // Is this a valid format letter?
|
static bool displayedFmtLegal(char format, bool isScan); // Is this a valid format letter?
|
||||||
int width() const VL_MT_SAFE { return m_data.width(); }
|
int width() const VL_MT_SAFE { return m_data.width(); }
|
||||||
int widthMin() const; // Minimum width that can represent this number (~== log2(num)+1)
|
int widthToFit() const; // Minimum width that can represent this number (~== log2(num)+1)
|
||||||
bool sized() const VL_MT_SAFE { return m_data.m_sized; }
|
bool sized() const VL_MT_SAFE { return m_data.m_sized; }
|
||||||
bool autoExtend() const VL_MT_SAFE { return m_data.m_autoExtend; }
|
bool autoExtend() const VL_MT_SAFE { return m_data.m_autoExtend; }
|
||||||
bool isFromString() const { return m_data.m_fromString; }
|
bool isFromString() const { return m_data.m_fromString; }
|
||||||
|
|
|
||||||
|
|
@ -1325,7 +1325,7 @@ class WidthVisitor final : public VNVisitor {
|
||||||
} else if (nodep->num().sized()) {
|
} else if (nodep->num().sized()) {
|
||||||
nodep->dtypeChgWidth(nodep->num().width(), nodep->num().width());
|
nodep->dtypeChgWidth(nodep->num().width(), nodep->num().width());
|
||||||
} else {
|
} else {
|
||||||
nodep->dtypeChgWidth(nodep->num().width(), nodep->num().widthMin());
|
nodep->dtypeChgWidth(nodep->num().width(), nodep->num().widthToFit());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We don't size the constant until we commit the widths, as need parameters
|
// We don't size the constant until we commit the widths, as need parameters
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue