Support dotted references in foreach in early parsing (for UVM)

This commit is contained in:
Wilson Snyder 2020-08-24 19:33:26 -04:00
parent 6acd5847e7
commit 4265f9499d
3 changed files with 8 additions and 12 deletions

View File

@ -421,7 +421,7 @@ private:
return;
}
AstNode* arrayp = nodep->arrayp(); // Maybe different node since bracketp looked
if (!VN_IS(arrayp, ParseRef)) {
if (!VN_IS(arrayp, ParseRef) && !VN_IS(arrayp, Dot)) {
// Code below needs to use other then attributes to figure out the bounds
// Also need to deal with queues, etc
arrayp->v3warn(E_UNSUPPORTED, "Unsupported: foreach on non-simple variable reference");
@ -442,14 +442,11 @@ private:
AstNode* varp
= new AstVar(fl, AstVarType::BLOCKTEMP, varsp->name(), nodep->findSigned32DType());
// These will be the left and right dimensions and size of the array:
AstNode* leftp = new AstAttrOf(fl, AstAttrType::DIM_LEFT,
new AstVarRef(fl, arrayp->name(), false),
AstNode* leftp = new AstAttrOf(fl, AstAttrType::DIM_LEFT, arrayp->cloneTree(false),
new AstConst(fl, dimension));
AstNode* rightp = new AstAttrOf(fl, AstAttrType::DIM_RIGHT,
new AstVarRef(fl, arrayp->name(), false),
AstNode* rightp = new AstAttrOf(fl, AstAttrType::DIM_RIGHT, arrayp->cloneTree(false),
new AstConst(fl, dimension));
AstNode* sizep = new AstAttrOf(fl, AstAttrType::DIM_SIZE,
new AstVarRef(fl, arrayp->name(), false),
AstNode* sizep = new AstAttrOf(fl, AstAttrType::DIM_SIZE, arrayp->cloneTree(false),
new AstConst(fl, dimension));
AstNode* stmtsp = varp;
// Assign left-dimension into the loop var:

View File

@ -116,13 +116,15 @@ static void process() {
cout << "--debug-exit-parse: Exiting after parse\n";
exit(0);
}
// Convert parseref's to varrefs, and other directly post parsing fixups
V3LinkParse::linkParse(v3Global.rootp());
if (v3Global.opt.debugExitUvm()) {
V3Error::abortIfErrors();
cout << "--debug-exit-uvm: Exiting after UVM-supported pass\n";
exit(0);
}
// Convert parseref's to varrefs, and other directly post parsing fixups
V3LinkParse::linkParse(v3Global.rootp());
// Cross-link signal names
// Cross-link dotted hierarchical references
V3LinkDot::linkDotPrimary(v3Global.rootp());

View File

@ -1,7 +1,4 @@
%Error: t/t_foreach_bad.v:14:7: Syntax error; foreach missing bracketed index variable (IEEE 1800-2017 12.7.3)
14 | foreach (array);
| ^~~~~~~
%Error-UNSUPPORTED: t/t_foreach_bad.v:16:21: Unsupported: foreach on non-simple variable reference
16 | foreach (array.array[a]);
| ^
%Error: Exiting due to