]> rtime.felk.cvut.cz Git - linux-conf-perf.git/commitdiff
kconfig2dot: Eliminate parallel edges between common expressions
authorMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 11 Oct 2015 07:44:30 +0000 (09:44 +0200)
committerMichal Sojka <sojkam1@fel.cvut.cz>
Sun, 11 Oct 2015 07:44:30 +0000 (09:44 +0200)
scripts/kconfig2dot/kconfig2dot.cc

index 6fb11ee22c9cf1f78b7aa3b17b437f1457b66939..042081909da4e7e929e541d30468fb510a83dacb 100644 (file)
@@ -9,6 +9,9 @@
 #include <build_files.h>
 #include <macros.h>
 
+#include <set>
+#include <string>
+
 #define STRINGIFY(val) #val
 #define TOSTRING(val) STRINGIFY(val)
 #define CHECK(cmd) ({ int ret = (cmd); if (ret == -1) { perror(#cmd " line " TOSTRING(__LINE__)); exit(1); }; ret; })
@@ -103,10 +106,17 @@ void print_symbol(FILE *f, struct symbol *sym);
 
 void print_oper(FILE *f, struct expr *e, const char *parent, const char *label)
 {
-    fprintf(f, "\"%s\" [shape=diamond,label=\"%s\"];\n", e->id, label);
+    using namespace std;
+    static set<string> seen_expr;
+
     fprintf(f, "\"%s\" -> \"%s\";\n", parent, e->id);
-    print_expr(f, e->left.expr, e->id, "l", "");
-    print_expr(f, e->right.expr, e->id, "r", "");
+
+    if (seen_expr.find(e->id) == seen_expr.end()) {
+       seen_expr.insert(e->id);
+       fprintf(f, "\"%s\" [shape=diamond,label=\"%s\"];\n", e->id, label);
+       print_expr(f, e->left.expr, e->id, "l", "");
+       print_expr(f, e->right.expr, e->id, "r", "");
+    }
 }
 
 void print_expr(FILE *f, struct expr *e, const char *parent, const char *suffix, const char *edge_opts)