forked from github/verilator
Internals: Shrink AstSelPlus code. No functional change.
This commit is contained in:
parent
85d790ff79
commit
8a8aab1aae
@ -390,40 +390,31 @@ private:
|
|||||||
if (ddtypep->castBasicDType()
|
if (ddtypep->castBasicDType()
|
||||||
|| (ddtypep->castNodeClassDType()
|
|| (ddtypep->castNodeClassDType()
|
||||||
&& ddtypep->castNodeClassDType()->packedUnsup())) {
|
&& ddtypep->castNodeClassDType()->packedUnsup())) {
|
||||||
AstSel* newp = NULL;
|
AstNode* newlsbp = NULL;
|
||||||
if (nodep->castSelPlus()) {
|
if (nodep->castSelPlus()) {
|
||||||
if (fromRange.littleEndian()) {
|
if (fromRange.littleEndian()) {
|
||||||
// SELPLUS(from,lsb,width) -> SEL(from, (vector_msb-width+1)-sel, width)
|
// SELPLUS(from,lsb,width) -> SEL(from, (vector_msb-width+1)-sel, width)
|
||||||
newp = new AstSel (nodep->fileline(),
|
newlsbp = newSubNeg((fromRange.hi()-width+1), rhsp);
|
||||||
fromp,
|
|
||||||
newSubNeg((fromRange.hi()-width+1), rhsp),
|
|
||||||
widthp);
|
|
||||||
} else {
|
} else {
|
||||||
// SELPLUS(from,lsb,width) -> SEL(from, lsb-vector_lsb, width)
|
// SELPLUS(from,lsb,width) -> SEL(from, lsb-vector_lsb, width)
|
||||||
newp = new AstSel (nodep->fileline(),
|
newlsbp = newSubNeg(rhsp, fromRange.lo());
|
||||||
fromp,
|
|
||||||
newSubNeg(rhsp, fromRange.lo()),
|
|
||||||
widthp);
|
|
||||||
}
|
}
|
||||||
} else if (nodep->castSelMinus()) {
|
} else if (nodep->castSelMinus()) {
|
||||||
if (fromRange.littleEndian()) {
|
if (fromRange.littleEndian()) {
|
||||||
// SELMINUS(from,msb,width) -> SEL(from, msb-[bit])
|
// SELMINUS(from,msb,width) -> SEL(from, msb-[bit])
|
||||||
newp = new AstSel (nodep->fileline(),
|
newlsbp = newSubNeg(fromRange.hi(), rhsp);
|
||||||
fromp,
|
|
||||||
newSubNeg(fromRange.hi(), rhsp),
|
|
||||||
widthp);
|
|
||||||
} else {
|
} else {
|
||||||
// SELMINUS(from,msb,width) -> SEL(from, msb-(width-1)-lsb#)
|
// SELMINUS(from,msb,width) -> SEL(from, msb-(width-1)-lsb#)
|
||||||
newp = new AstSel (nodep->fileline(),
|
newlsbp = newSubNeg(rhsp, fromRange.lo()+(width-1));
|
||||||
fromp,
|
|
||||||
newSubNeg(rhsp, fromRange.lo()+(width-1)),
|
|
||||||
widthp);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
nodep->v3fatalSrc("Bad Case");
|
nodep->v3fatalSrc("Bad Case");
|
||||||
}
|
}
|
||||||
|
AstSel* newp = new AstSel (nodep->fileline(),
|
||||||
|
fromp, newlsbp, widthp);
|
||||||
newp->declRange(fromRange);
|
newp->declRange(fromRange);
|
||||||
UINFO(6," new "<<newp<<endl);
|
UINFO(6," new "<<newp<<endl);
|
||||||
|
if (debug()>=9) newp->dumpTree(cout,"--SELNEW: ");
|
||||||
nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL;
|
nodep->replaceWith(newp); pushDeletep(nodep); nodep=NULL;
|
||||||
}
|
}
|
||||||
else { // NULL=bad extract, or unknown node type
|
else { // NULL=bad extract, or unknown node type
|
||||||
|
Loading…
Reference in New Issue
Block a user