Internals: Cleanup some slice code. No functional change.
This commit is contained in:
parent
8ee94dd7aa
commit
ae38a26af3
|
|
@ -139,37 +139,34 @@ class SliceCloneVisitor : public AstNVisitor {
|
||||||
UINFO(4, "Cloning "<<nodep->user2()<<" times: "<<nodep<<endl);
|
UINFO(4, "Cloning "<<nodep->user2()<<" times: "<<nodep<<endl);
|
||||||
|
|
||||||
AstNode* lhsp = NULL;
|
AstNode* lhsp = NULL;
|
||||||
AstNode* rhsp = NULL;
|
|
||||||
for (int i = 0; i < nodep->user2(); ++i) {
|
for (int i = 0; i < nodep->user2(); ++i) {
|
||||||
// Clone the node and iterate over the clone
|
// Clone the node and iterate over the clone
|
||||||
m_vecIdx = -1;
|
m_vecIdx = -1;
|
||||||
AstNodeUniop* clonep = nodep->cloneTree(false)->castNodeUniop();
|
AstNodeUniop* clonep = nodep->cloneTree(false)->castNodeUniop();
|
||||||
clonep->iterateChildren(*this);
|
clonep->iterateChildren(*this);
|
||||||
if (!lhsp) lhsp = clonep;
|
if (!lhsp) lhsp = clonep;
|
||||||
else rhsp = clonep;
|
else {
|
||||||
if (lhsp && rhsp) {
|
|
||||||
switch (nodep->type()) {
|
switch (nodep->type()) {
|
||||||
case AstType::atREDOR:
|
case AstType::atREDOR:
|
||||||
lhsp = new AstOr(nodep->fileline(), lhsp, rhsp);
|
lhsp = new AstOr(nodep->fileline(), lhsp, clonep);
|
||||||
break;
|
break;
|
||||||
case AstType::atREDAND:
|
case AstType::atREDAND:
|
||||||
lhsp = new AstAnd(nodep->fileline(), lhsp, rhsp);
|
lhsp = new AstAnd(nodep->fileline(), lhsp, clonep);
|
||||||
break;
|
break;
|
||||||
case AstType::atREDXOR:
|
case AstType::atREDXOR:
|
||||||
lhsp = new AstXor(nodep->fileline(), lhsp, rhsp);
|
lhsp = new AstXor(nodep->fileline(), lhsp, clonep);
|
||||||
break;
|
break;
|
||||||
case AstType::atREDXNOR:
|
case AstType::atREDXNOR:
|
||||||
lhsp = new AstXnor(nodep->fileline(), lhsp, rhsp);
|
lhsp = new AstXnor(nodep->fileline(), lhsp, clonep);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
nodep->v3fatalSrc("Unsupported: Unary operation on multiple packed dimensions");
|
nodep->v3fatalSrc("Unsupported: Unary operation on multiple packed dimensions");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
rhsp = NULL;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
nodep->addNextHere(lhsp);
|
nodep->replaceWith(lhsp);
|
||||||
nodep->unlinkFrBack()->deleteTree(); VL_DANGLING(nodep);
|
nodep->deleteTree(); VL_DANGLING(nodep);
|
||||||
}
|
}
|
||||||
virtual void visit(AstRedOr* nodep, AstNUser*) {
|
virtual void visit(AstRedOr* nodep, AstNUser*) {
|
||||||
cloneUniop(nodep);
|
cloneUniop(nodep);
|
||||||
|
|
@ -441,43 +438,37 @@ class SliceVisitor : public AstNVisitor {
|
||||||
}
|
}
|
||||||
|
|
||||||
void expandUniOp(AstNodeUniop* nodep) {
|
void expandUniOp(AstNodeUniop* nodep) {
|
||||||
nodep->user1(true);
|
if (!nodep->user1()) {
|
||||||
unsigned dim = 0;
|
nodep->user1(true);
|
||||||
if (AstArraySel* selp = nodep->lhsp()->castArraySel()) {
|
unsigned dim = 0;
|
||||||
// We have explicit dimensions, either packed or unpacked
|
if (AstArraySel* selp = nodep->lhsp()->castArraySel()) {
|
||||||
dim = explicitDimensions(selp);
|
// We have explicit dimensions, either packed or unpacked
|
||||||
}
|
dim = explicitDimensions(selp);
|
||||||
if (dim == 0 && !nodep->lhsp()->castVarRef()) {
|
}
|
||||||
// No ArraySel nor VarRef, not something we can expand
|
if (dim == 0 && !nodep->lhsp()->castVarRef()) {
|
||||||
nodep->iterateChildren(*this);
|
// No ArraySel nor VarRef, not something we can expand
|
||||||
} else {
|
nodep->iterateChildren(*this);
|
||||||
AstVarRef* refp = findVarRefRecurse(nodep->lhsp());
|
} else {
|
||||||
ArrayDimensions varDim = refp->varp()->dtypep()->dimensions(false);
|
AstVarRef* refp = findVarRefRecurse(nodep->lhsp());
|
||||||
if ((int)(dim - varDim.second) < 0) {
|
ArrayDimensions varDim = refp->varp()->dtypep()->dimensions(false);
|
||||||
// Unpacked dimensions are referenced first, make sure we have them all
|
if ((int)(dim - varDim.second) < 0) {
|
||||||
nodep->v3error("Unary operator used across unpacked dimensions");
|
// Unpacked dimensions are referenced first, make sure we have them all
|
||||||
|
nodep->v3error("Unary operator used across unpacked dimensions");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
virtual void visit(AstRedOr* nodep, AstNUser*) {
|
virtual void visit(AstRedOr* nodep, AstNUser*) {
|
||||||
if (!nodep->user1()) {
|
expandUniOp(nodep);
|
||||||
expandUniOp(nodep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virtual void visit(AstRedAnd* nodep, AstNUser*) {
|
virtual void visit(AstRedAnd* nodep, AstNUser*) {
|
||||||
if (!nodep->user1()) {
|
expandUniOp(nodep);
|
||||||
expandUniOp(nodep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virtual void visit(AstRedXor* nodep, AstNUser*) {
|
virtual void visit(AstRedXor* nodep, AstNUser*) {
|
||||||
if (!nodep->user1()) {
|
expandUniOp(nodep);
|
||||||
expandUniOp(nodep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
virtual void visit(AstRedXnor* nodep, AstNUser*) {
|
virtual void visit(AstRedXnor* nodep, AstNUser*) {
|
||||||
if (!nodep->user1()) {
|
expandUniOp(nodep);
|
||||||
expandUniOp(nodep);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual void visit(AstNode* nodep, AstNUser*) {
|
virtual void visit(AstNode* nodep, AstNUser*) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue