Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overload dflow_print to allow printing dataflow elements #19

Merged
merged 1 commit into from
Mar 7, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
168 changes: 87 additions & 81 deletions act/lang.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3032,97 +3032,103 @@ act_initialize *initialize_expand (act_initialize *init, ActNamespace *ns,
}


void dflow_print (FILE *fp, act_dataflow *d)
void dflow_print (FILE *fp, act_dataflow_element *e)
{
listitem_t *li;
act_dataflow_element *e;

if (!d) return;
fprintf (fp, "dataflow {\n");
for (li = list_first (d->dflow); li; li = list_next (li)) {
e = (act_dataflow_element *) list_value (li);
switch (e->t) {
case ACT_DFLOW_FUNC:
print_expr (fp, e->u.func.lhs);
fprintf (fp, " -> ");
if (e->u.func.nbufs) {
if (e->u.func.istransparent) {
fprintf (fp, "(");
}
else {
fprintf (fp, "[");
}
print_expr (fp, e->u.func.nbufs);
if (e->u.func.init) {
fprintf (fp, ",");
print_expr (fp, e->u.func.init);
}
if (e->u.func.istransparent) {
fprintf (fp, ") ");
}
else {
fprintf (fp, "] ");
}
switch (e->t) {
case ACT_DFLOW_FUNC:
print_expr (fp, e->u.func.lhs);
fprintf (fp, " -> ");
if (e->u.func.nbufs) {
if (e->u.func.istransparent) {
fprintf (fp, "(");
}
e->u.func.rhs->Print (fp);
break;

case ACT_DFLOW_SPLIT:
fprintf (fp, "{");
e->u.splitmerge.guard->Print (fp);
fprintf (fp, "} ");
e->u.splitmerge.single->Print (fp);
fprintf (fp, " -> ");
for (int i=0; i < e->u.splitmerge.nmulti; i++) {
if (e->u.splitmerge.multi[i]) {
e->u.splitmerge.multi[i]->Print (fp);
}
else {
fprintf (fp, "*");
}
if (i != e->u.splitmerge.nmulti-1) {
fprintf (fp, ", ");
}
else {
fprintf (fp, "[");
}
break;

case ACT_DFLOW_MERGE:
case ACT_DFLOW_MIXER:
case ACT_DFLOW_ARBITER:
fprintf (fp, "{");
if (e->t == ACT_DFLOW_MERGE) {
e->u.splitmerge.guard->Print (fp);
print_expr (fp, e->u.func.nbufs);
if (e->u.func.init) {
fprintf (fp, ",");
print_expr (fp, e->u.func.init);
}
else if (e->t == ACT_DFLOW_MIXER) {
fprintf (fp, "*");
if (e->u.func.istransparent) {
fprintf (fp, ") ");
}
else {
fprintf (fp, "|");
fprintf (fp, "] ");
}
fprintf (fp, "} ");
for (int i=0; i < e->u.splitmerge.nmulti; i++) {
if (e->u.splitmerge.multi[i]) {
e->u.splitmerge.multi[i]->Print (fp);
}
else {
fprintf (fp, "*");
}
if (i != e->u.splitmerge.nmulti-1) {
fprintf (fp, ", ");
}
}
e->u.func.rhs->Print (fp);
break;

case ACT_DFLOW_SPLIT:
fprintf (fp, "{");
e->u.splitmerge.guard->Print (fp);
fprintf (fp, "} ");
e->u.splitmerge.single->Print (fp);
fprintf (fp, " -> ");
for (int i=0; i < e->u.splitmerge.nmulti; i++) {
if (e->u.splitmerge.multi[i]) {
e->u.splitmerge.multi[i]->Print (fp);
}
fprintf (fp, " -> ");
e->u.splitmerge.single->Print (fp);
if (e->u.splitmerge.nondetctrl) {
fprintf (fp, ", ");
e->u.splitmerge.nondetctrl->Print (fp);
else {
fprintf (fp, "*");
}
if (i != e->u.splitmerge.nmulti-1) {
fprintf (fp, ", ");
}
break;

default:
fatal_error ("What?");
break;
}
break;

case ACT_DFLOW_MERGE:
case ACT_DFLOW_MIXER:
case ACT_DFLOW_ARBITER:
fprintf (fp, "{");
if (e->t == ACT_DFLOW_MERGE) {
e->u.splitmerge.guard->Print (fp);
}
else if (e->t == ACT_DFLOW_MIXER) {
fprintf (fp, "*");
}
else {
fprintf (fp, "|");
}
fprintf (fp, "} ");
for (int i=0; i < e->u.splitmerge.nmulti; i++) {
if (e->u.splitmerge.multi[i]) {
e->u.splitmerge.multi[i]->Print (fp);
}
else {
fprintf (fp, "*");
}
if (i != e->u.splitmerge.nmulti-1) {
fprintf (fp, ", ");
}
}
fprintf (fp, " -> ");
e->u.splitmerge.single->Print (fp);
if (e->u.splitmerge.nondetctrl) {
fprintf (fp, ", ");
e->u.splitmerge.nondetctrl->Print (fp);
}
break;

default:
fatal_error ("What?");
break;
}
}


void dflow_print (FILE *fp, act_dataflow *d)
{
listitem_t *li;
act_dataflow_element *e;

if (!d) return;
fprintf (fp, "dataflow {\n");
for (li = list_first (d->dflow); li; li = list_next (li)) {
e = (act_dataflow_element *) list_value (li);
dflow_print(fp, e);
if (list_next (li)) {
fprintf (fp, ";");
}
Expand Down
1 change: 1 addition & 0 deletions act/lang.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ void refine_print (FILE *, act_refine *);
void sizing_print (FILE *, act_sizing *);
void initialize_print (FILE *, act_initialize *);
void dflow_print (FILE *, act_dataflow *);
void dflow_print (FILE *, act_dataflow_element *);

class ActNamespace;
class Scope;
Expand Down