README: rename
[ppn.git] / pn2dot.cc
blob37160a7efbd92b0ed5bc616b8ff71fb2a6469402
1 #include <iostream>
3 #include <isa/yaml.h>
4 #include <isa/pdg.h>
6 using namespace std;
7 using namespace pdg;
9 int main(int argc, char * argv[])
11 PDG *pdg;
12 isl_ctx *ctx = isl_ctx_alloc();
13 pdg = PDG::Load(stdin, ctx);
15 printf("digraph dummy {\n");
16 for (int i = 0; i < pdg->nodes.size(); ++i) {
17 pdg::node *node = pdg->nodes[i];
18 if (node->statement->top_function)
19 printf("ND_%d [label = \"%s\"];\n",
20 node->nr, node->statement->top_function->name->s.c_str());
21 else
22 printf("ND_%d;\n", node->nr);
24 for (int i = 0; i < pdg->dependences.size(); ++i) {
25 pdg::dependence *dep = pdg->dependences[i];
26 if (dep->type == pdg::dependence::uninitialized)
27 continue;
28 if (dep->type == pdg::dependence::pn_part)
29 continue;
30 pdg::node* from = dep->from;
31 pdg::node* to = dep->to;
32 printf("ND_%d -> ND_%d [label = \"", from->nr, to->nr);
33 if (dep->array)
34 printf("%s", dep->array->name->s.c_str());
35 for (int j = 0; j < dep->from_controls.size(); ++j) {
36 if (j)
37 printf(",");
38 printf("%s", dep->from_controls[j]->s.c_str());
40 for (int j = 0; j < dep->to_controls.size(); ++j) {
41 if (j)
42 printf(",");
43 else
44 printf("; ");
45 printf("%s", dep->to_controls[j]->s.c_str());
47 printf(": %s\"%s];\n",
48 dep->size ? dep->size->s->c_str() : "?",
49 dep->type == pdg::dependence::pn_union ? " color=\"blue\"" :
50 dep->type == pdg::dependence::pn_hold ? " color=\"cyan\"" :
51 dep->type == pdg::dependence::pn_shift ? " color=\"magenta\"" :
52 dep->reordering ?
53 (dep->multiplicity ? " color=\"yellow\"": " color=\"green\"") :
54 (dep->multiplicity ? " color=\"red\"": ""));
56 printf("}\n");
58 pdg->free();
59 delete pdg;
60 isl_ctx_free(ctx);
62 return 0;