Initial commit (TFM Carlos)

This commit is contained in:
Carlos Galindo 2019-10-18 08:54:33 +00:00
commit d7d30674fe
24 changed files with 889 additions and 0 deletions

9
img/Makefile Normal file
View file

@ -0,0 +1,9 @@
dotfiles = $(shell ls *.dot | sed 's/\.dot/\.pdf/' -)
all: $(dotfiles)
%.pdf: %.dot
dot -Tpdf $< -o $@
clean:
rm -f *.pdf

8
img/breakcfg.dot Normal file
View file

@ -0,0 +1,8 @@
digraph g {
Start [shape=box];
End [shape=box];
Start -> End [style=dashed];
Start -> "int a = 1" -> "while (a > 0)" -> "if (a > 10)" -> "break" -> "print(a)";
"break" -> "a++" [style=dashed];
"if (a > 10)" -> "a++" -> "while (a > 0)" -> "print(a)" -> End;
}

22
img/breakpdg.dot Normal file
View file

@ -0,0 +1,22 @@
digraph g {
"f()" [shape=box, rank=min];
// Rank adjustment
{ rank = same; "int a = 1"; "while (a > 0)"; }
{ rank = same; "print(a)"; "a++"; }
{ rank = max; "a++"; "print(a)"; }
// Control flow
"f()" -> "int a = 1" [style=bold];
"f()" -> "while (a > 0)" [style=bold];
"while (a > 0)" -> "if (a > 10)" [style=bold];
"if (a > 10)" -> "break" [style=bold];
"break" -> "print(a)" [style=bold];
"break" -> "a++" [style=bold];
"break" -> "while (a > 0)" [style=bold];
// Data flow
"int a = 1" -> "while (a > 0)" [color=red];
"int a = 1" -> "if (a > 10)" [color=red];
"int a = 1" -> "print(a)" [color=red];
"a++" -> "a++" -> "while (a > 0)" [color=red];
"a++" -> "if (a > 10)" [color=red];
"a++" -> "print(a)" [color=red];
}

6
img/cfgsimple.dot Normal file
View file

@ -0,0 +1,6 @@
digraph g {
Start [shape=box];
End [shape=box];
f [label=<x_in = a<br/>y_in = b<br/>f (a, b)<br/>b = x_out>]
Start -> "a = 10" -> "b = 20" -> f -> "print(a)" -> End;
}

5
img/cfgsimple2.dot Normal file
View file

@ -0,0 +1,5 @@
digraph g {
s [shape=box,label=<Start<br/>x = x_in<br/>y = y_in>];
End [shape=box,label=<x_out = x<br/>End>];
s -> "while (x > y)" -> "x = x - 1" -> "while (x > y)" -> "print(x)" -> End;
}

42
img/legendsimple.dot Normal file
View file

@ -0,0 +1,42 @@
digraph g {
rankdir=LR
node [shape=plaintext]
subgraph cluster_01 {
label = "Legend";
key [label=<<table border="0" cellpadding="2" cellspacing="0" cellborder="0">
<tr><td align="right" port="i1">Control dependency</td></tr>
<tr><td align="right" port="i2">Data dependency</td></tr>
<tr><td align="right" port="i3">Call, param-in, param-out</td></tr>
<tr><td align="right" port="i4">Summary</td></tr>
</table>>]
key2 [label=<<table border="0" cellpadding="2" cellspacing="0" cellborder="0">
<tr><td port="i1">&nbsp;</td></tr>
<tr><td port="i2">&nbsp;</td></tr>
<tr><td port="i3">&nbsp;</td></tr>
<tr><td port="i4">&nbsp;</td></tr>
</table>>]
key:i1:e -> key2:i1:w [style=bold]
key:i2:e -> key2:i2:w [color=red]
key:i3:e -> key2:i3:w [style=dashed]
key:i4:e -> key2:i4:w [color=blue]
}
}

5
img/multiplycfg.dot Normal file
View file

@ -0,0 +1,5 @@
digraph g {
Start [shape=box];
End [shape=box];
Start -> "int result = 0" -> "while (x > 0)" -> "result += y" -> "x--" -> "while (x > 0)" -> "System.out.println(result)" -> "return result" -> "End";
}

26
img/multiplypdg.dot Normal file
View file

@ -0,0 +1,26 @@
digraph g { "multiply()" [shape=box, rank=min];
// Rank adjustment
{ rank = same; "int result = 0"; "while (x > 0)"; "System.out.println(result)"; "return result"; }
{ rank = same; "result += y"; "x--"; }
// Control flow
"multiply()" -> "int result = 0" [style=bold];
"multiply()" -> "while (x > 0)" [style=bold];
"multiply()" -> "System.out.println(result)" [style=bold];
"multiply()" -> "return result" [style=bold];
"while (x > 0)" -> "result += y" [style=bold];
"while (x > 0)" -> "x--" [style=bold];
// Data flow
"int result = 0" -> "result += y" [color=red];
"int result = 0" -> "System.out.println(result)" [color=red];
"int result = 0" -> "return result" [color=red];
"result += y" -> "result += y" [color=red];
"result += y" -> "System.out.println(result)" [color=red];
"result += y" -> "return result" [color=red];
"x--" -> "x--" [color=red];
"x--" -> "while (x > 0)" [color=red];
// Order adjustment
"int result = 0" -> "while (x > 0)" [style=invis];
"while (x > 0)" -> "System.out.println(result)" [style=invis];
"System.out.println(result)" -> "return result" [style=invis];
"result += y" -> "x--" [style=invis];
}

52
img/multiplysdg.dot Normal file
View file

@ -0,0 +1,52 @@
digraph g {
"main()" [shape=box];
"main()" -> "multiply(3, 2)" [style=bold];
{ rank = same; "x"; "y"; "out" }
"x" -> "y" [style=invis];
"y" -> "out" [style=invis];
"multiply(3, 2)" -> "multiply()" [style=dotted];
"multiply(3, 2)" -> "x";
"multiply(3, 2)" -> "y";
"multiply(3, 2)" -> "out";
"x" -> "x_in" [style=dotted];
"y" -> "y_in" [style=dotted];
"output" -> "out" [style=dotted];
"x" -> "out" [style=bold, color=blue];
"y" -> "out" [style=bold, color=blue];
"multiply()" [shape=box];
// Rank adjustment
{ rank = same; "x_in"; "y_in"; "output" }
{ rank = same; "int result = 0"; "while (x > 0)"; "System.out.println(result)"; "return result"; }
{ rank = same; "result += y"; "x--"; }
// Input/output
"multiply()" -> "x_in";
"multiply()" -> "y_in";
"multiply()" -> "output"
"x_in" -> "while (x > 0)" [color=red];
"x_in" -> "x--" [color=red];
"y_in" -> "result += y" [color=red];
"return result" -> "output" [color=red];
// Control flow
"multiply()" -> "int result = 0" [style=bold];
"multiply()" -> "while (x > 0)" [style=bold];
"multiply()" -> "System.out.println(result)" [style=bold];
"multiply()" -> "return result" [style=bold];
"while (x > 0)" -> "result += y" [style=bold];
"while (x > 0)" -> "x--" [style=bold];
// Data flow
"int result = 0" -> "result += y" [color=red];
"int result = 0" -> "System.out.println(result)" [color=red];
"int result = 0" -> "return result" [color=red];
"result += y" -> "result += y" [color=red];
"result += y" -> "System.out.println(result)" [color=red];
"result += y" -> "return result" [color=red];
"x--" -> "x--" [color=red];
"x--" -> "while (x > 0)" [color=red];
// Order adjustment
"int result = 0" -> "while (x > 0)" [style=invis];
"while (x > 0)" -> "System.out.println(result)" [style=invis];
"System.out.println(result)" -> "return result" [style=invis];
"result += y" -> "x--" [style=invis];
"x_in" -> "y_in" [style=invis];
}

30
img/pdgsimple.dot Normal file
View file

@ -0,0 +1,30 @@
digraph g {
Start [shape=box];
l2 [label="a = 10"];
l3 [label="b = 20"];
l4 [label="f(a, b)"];
p1 [label="x_in = a"];
p2 [label="y_in = b"];
p3 [label="a = x_out"];
l5 [label="print(a)"];
// Rank
{ rank = same; l2; l3; l4; l5; }
{ rank = min; Start; }
{ rank = same; p1; p2; p3; }
// Control
{ edge [style = bold];
Start -> { l2 l3 l4 l5 };
l4 -> { p1 p2 p3 };
}
// Data
{ edge [color = red];
l2 -> p1;
l3 -> p2;
p3 -> l5;
}
// Order
{ edge [style = invis];
l2 -> l3 -> l4 -> l5;
p1 -> p2 -> p3;
}
}

27
img/pdgsimple2.dot Normal file
View file

@ -0,0 +1,27 @@
digraph g {
Start [shape=box];
s1 [label="x = x_in"];
s0 [label="y = y_in"];
s2 [label="while (x > y)"];
s3 [label="x = x + 1"];
s4 [label="print(x)"];
s5 [label="x_out = x"];
// Rank
{ rank=same; s0; s1; s5; }
{ rank=same; s2; s4; }
{ rank=min; Start; }
s0 -> s2 [style=invis];
// Control
{
edge [style = bold];
Start -> {s0 s1 s2 s4 s5};
s2 -> s3;
}
// Data
{
edge [color = red];
edge [constraint = false];
{s1 s3} -> {s2 s3 s4 s5};
s0 -> s2;
}
}

50
img/sdgsimple.dot Normal file
View file

@ -0,0 +1,50 @@
digraph g {
subgraph {
l1; l2; l3; l4; l5;
"x_in = a"; "y_in = b"; "a = x_out";
}
subgraph {
l8; l9; l10; l12;
"x = x_in"; "y = y_in"; "x_out = x";
}
l1 [label="main()"];
l2 [label="a = 10"];
l3 [label="b = 20"];
l4 [label="f(a, b)"];
l5 [label="print(a)"];
l8 [label="f()"];
l9 [label="while (x > y)"];
l10 [label="x = x + 1"];
l12 [label="print(x)"];
// Rank
{ rank = same; l9; l12; }
// s0 -> s2 [style=invis];
// Control
{
edge [style = bold];
l1 -> {l2 l3 l4 l5};
l4 -> {"x_in = a" "y_in = b" "a = x_out"};
l8 -> {"x = x_in" "y = y_in" l9 l12 "x_out = x"};
l9 -> l10;
}
// Data
{
edge [color = red];
edge [constraint = false];
l2 -> "x_in = a";
l3 -> "y_in = b";
"a = x_out" -> l5;
{"x = x_in" l10} -> {l9 l10 l12 "x_out = x"};
"y = y_in" -> l9;
}
{
edge [style=dashed];
edge [constraint=false];
"x_in = a" -> "x = x_in";
"y_in = b" -> "y = y_in";
l4 -> l8 [constraint=true];
"x_out = x" -> "a = x_out";
}
{edge [color=blue,constraint=false]; {"x_in = a" "y_in = b"} -> "a = x_out"}
{edge [style=invis]; "y_in = b" -> l8; "y = y_in" -> l9; }
}