From 00d1b8eed7406fc8e150dd5f789cfac48db14286 Mon Sep 17 00:00:00 2001 From: Dibyendu Majumdar Date: Sun, 30 Jun 2024 01:58:08 +0100 Subject: Cliff's GCM implementation for chapter 11 (#88) --- chapter11/docs/11-grammar.md | 128 ++++++++++++ chapter11/docs/Makefile | 12 ++ chapter11/docs/build-graphs.sh | 9 + chapter11/docs/graph1.gv | 76 +++++++ chapter11/docs/graph1.svg | 285 ++++++++++++++++++++++++++ chapter11/docs/graph2.gv | 80 ++++++++ chapter11/docs/graph2.svg | 309 ++++++++++++++++++++++++++++ chapter11/docs/graph3-snip.jpg | Bin 0 -> 19681 bytes chapter11/docs/graph3.gv | 81 ++++++++ chapter11/docs/graph3.svg | 316 ++++++++++++++++++++++++++++ chapter11/docs/graph4.gv | 107 ++++++++++ chapter11/docs/graph4.svg | 408 +++++++++++++++++++++++++++++++++++++ chapter11/docs/graph5.gv | 113 +++++++++++ chapter11/docs/graph5.svg | 452 +++++++++++++++++++++++++++++++++++++++++ chapter11/docs/graph6.gv | 113 +++++++++++ chapter11/docs/graph6.svg | 437 +++++++++++++++++++++++++++++++++++++++ chapter11/docs/graph7.gv | 23 +++ chapter11/docs/graph7.svg | 54 +++++ chapter11/docs/graph8.gv | 45 ++++ chapter11/docs/graph8.svg | 115 +++++++++++ 20 files changed, 3163 insertions(+) create mode 100644 chapter11/docs/11-grammar.md create mode 100644 chapter11/docs/Makefile create mode 100644 chapter11/docs/build-graphs.sh create mode 100644 chapter11/docs/graph1.gv create mode 100644 chapter11/docs/graph1.svg create mode 100644 chapter11/docs/graph2.gv create mode 100644 chapter11/docs/graph2.svg create mode 100644 chapter11/docs/graph3-snip.jpg create mode 100644 chapter11/docs/graph3.gv create mode 100644 chapter11/docs/graph3.svg create mode 100644 chapter11/docs/graph4.gv create mode 100644 chapter11/docs/graph4.svg create mode 100644 chapter11/docs/graph5.gv create mode 100644 chapter11/docs/graph5.svg create mode 100644 chapter11/docs/graph6.gv create mode 100644 chapter11/docs/graph6.svg create mode 100644 chapter11/docs/graph7.gv create mode 100644 chapter11/docs/graph7.svg create mode 100644 chapter11/docs/graph8.gv create mode 100644 chapter11/docs/graph8.svg (limited to 'chapter11/docs') diff --git a/chapter11/docs/11-grammar.md b/chapter11/docs/11-grammar.md new file mode 100644 index 00000000..0aaf0619 --- /dev/null +++ b/chapter11/docs/11-grammar.md @@ -0,0 +1,128 @@ +# Grammar for Chapter 11 + +```antlrv4 +grammar SimpleLanguage; + +program + : statement+ EOF + ; + +statement + : returnStatement + | structDeclaration + | declStatement + | blockStatment + | expressionStatement + | ifStatement + | whileStatement + | breakStatement + | continueStatment + | metaStatement + ; + +field + : 'int' IDENTIFIER ';' + ; + +fields + : field+ + ; + +structDeclaration + : 'struct' IDENTIFIER '{' fields '}' + ; + +whileStatement + : 'while' '(' expression ')' statement + ; + +breakStatement + : 'break' ';' + ; + +continueStatement + : 'continue' ';' + ; + +ifStatement + : 'if' '(' expression ')' statement ('else' statement)? + ; + +metaStatement + : '#showGraph' ';' + ; + +expressionStatement + : IDENTIFIER '=' expression ';' + | fieldExpression '=' expression ';' + ; + +blockStatement + : '{' statement+ '}' + ; + +structName + : IDENTIFIER + ; + +declStatement + : 'int' IDENTIFIER '=' expression ';' + | structName IDENTIFIER ('?')? '=' expression ';' + ; + +returnStatement + : 'return' expression ';' + ; + +expression + : comparisonExpression + ; + +comparisonExpression + : additiveExpression (('==' | '!='| '>'| '<'| '>='| '<=') additiveExpression)* + ; + +additiveExpression + : multiplicativeExpression (('+' | '-') multiplicativeExpression)* + ; + +multiplicativeExpression + : unaryExpression (('*' | '/') unaryExpression)* + ; + +unaryExpression + : ('-') unaryExpression + | primaryExpression + ; + +newExpression + : 'new' IDENTIFIER + ; + +fieldExpression + : primaryExpresson '.' IDENTIFIER + ; + +primaryExpression + : IDENTIFIER + | INTEGER_LITERAL + | 'true' + | 'false' + | 'null' + | newExpression + | '(' expression ')' + | fieldExpression + ; + +INTEGER_LITERAL + : [1-9][0-9]* + | [0] + ; + +IDENTIFIER + : NON_DIGIT (NON_DIGIT | DIGIT)* + ; + +NON_DIGIT: [a-zA-Z_]; +DEC_DIGIT: [0-9]; +``` \ No newline at end of file diff --git a/chapter11/docs/Makefile b/chapter11/docs/Makefile new file mode 100644 index 00000000..12659b8f --- /dev/null +++ b/chapter11/docs/Makefile @@ -0,0 +1,12 @@ +GV := $(wildcard *.gv) +SVG := $(patsubst %.gv,%.svg,$(GV)) + +.PHONY: all +all: $(SVG) + +%.svg: %.gv + dot -Tsvg $< > $@ + +.PHONY: clean +clean: + @rm -f $(SVG) diff --git a/chapter11/docs/build-graphs.sh b/chapter11/docs/build-graphs.sh new file mode 100644 index 00000000..839a36ba --- /dev/null +++ b/chapter11/docs/build-graphs.sh @@ -0,0 +1,9 @@ +dot -Tsvg graph1.gv > graph1.svg +dot -Tsvg graph2.gv > graph2.svg +dot -Tsvg graph3.gv > graph3.svg +dot -Tsvg graph4.gv > graph4.svg +dot -Tsvg graph5.gv > graph5.svg +dot -Tsvg graph6.gv > graph6.svg +dot -Tsvg graph7.gv > graph7.svg +dot -Tsvg graph8.gv > graph8.svg + diff --git a/chapter11/docs/graph1.gv b/chapter11/docs/graph1.gv new file mode 100644 index 00000000..97815f63 --- /dev/null +++ b/chapter11/docs/graph1.gv @@ -0,0 +1,76 @@ +digraph chapter11 { +/* +struct S { int f; } +S v=new S; +v.f = 2; +int i=new S.f; +i=v.f; +if (arg) v.f=1; +return i; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg$2
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + new9 [ label="new S" ]; + Con_11 [ label="#2" ]; + Store12 [ label=".f =" ]; + new13 [ label="new S" ]; + Store14 [ label=".f =" ]; + Load16 [ label=".f" ]; + If17 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Con_21 [ label="#1" ]; + Store22 [ label=".f =" ]; + Region23 [ shape=box style=filled fillcolor=yellow label="Region" ]; + Phi_224 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Return25 [ shape=box style=filled fillcolor=yellow label="Return" ]; + { rank=same; Region23;Phi_224;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Stop3 -> Return25[taillabel=0 color=red]; + new9 -> Start2:p0[taillabel=0 color=green]; + Store12 -> Start2:p2[taillabel=1 color=blue]; + Store12 -> new9[taillabel=2]; + Store12 -> Con_11[taillabel=3]; + new13 -> Start2:p0[taillabel=0 color=green]; + Store14 -> Store12[taillabel=1 color=blue]; + Store14 -> new13[taillabel=2]; + Store14 -> Con_4[taillabel=3]; + Load16 -> Store14[taillabel=1 color=blue]; + Load16 -> new9[taillabel=2]; + If17 -> Start2:p0[taillabel=0 color=red]; + If17 -> Start2:p1[taillabel=1]; + Store22 -> Store14[taillabel=1 color=blue]; + Store22 -> new9[taillabel=2]; + Store22 -> Con_21[taillabel=3]; + Region23 -> If17:p0[taillabel=1 color=red]; + Region23 -> If17:p1[taillabel=2 color=red]; + Phi_224 -> Region23 [style=dotted taillabel=0]; + Phi_224 -> Store22[taillabel=1 color=blue]; + Phi_224 -> Store14[taillabel=2 color=blue constraint=false]; + Return25 -> Region23[taillabel=0 color=red]; + Return25 -> Load16[taillabel=1]; + Return25 -> Phi_224[taillabel=2 color=blue]; +} \ No newline at end of file diff --git a/chapter11/docs/graph1.svg b/chapter11/docs/graph1.svg new file mode 100644 index 00000000..592db961 --- /dev/null +++ b/chapter11/docs/graph1.svg @@ -0,0 +1,285 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + +arg + +$2 + + + +Stop3 + +Stop + + + +Return25 + +Return + + + +Stop3->Return25 + + +0 + + + +Con_4 + +#0 + + + +new9 + +new S + + + +new9->Start2:p0 + + +0 + + + +Con_11 + +#2 + + + +Store12 + +.f = + + + +Store12->Start2:p2 + + +1 + + + +Store12->new9 + + +2 + + + +Store12->Con_11 + + +3 + + + +new13 + +new S + + + +new13->Start2:p0 + + +0 + + + +Store14 + +.f = + + + +Store14->Con_4 + + +3 + + + +Store14->Store12 + + +1 + + + +Store14->new13 + + +2 + + + +Load16 + +.f + + + +Load16->new9 + + +2 + + + +Load16->Store14 + + +1 + + + +If17 + + +If + + + +True + + +False + + + +If17->Start2:p0 + + +0 + + + +Con_21 + +#1 + + + +Store22 + +.f = + + + +Store22->new9 + + +2 + + + +Store22->Store14 + + +1 + + + +Store22->Con_21 + + +3 + + + +Region23 + +Region + + + +Region23->If17:p0 + + +1 + + + +Region23->If17:p1 + + +2 + + + +Phi_224 + +φ_$2 + + + +Phi_224->Store14 + + +2 + + + +Phi_224->Store22 + + +1 + + + +Phi_224->Region23 + + +0 + + + +Return25->Load16 + + +1 + + + +Return25->Region23 + + +0 + + + +Return25->Phi_224 + + +2 + + + diff --git a/chapter11/docs/graph2.gv b/chapter11/docs/graph2.gv new file mode 100644 index 00000000..04d02a3f --- /dev/null +++ b/chapter11/docs/graph2.gv @@ -0,0 +1,80 @@ +digraph chapter11 { +/* +struct S { int f; } +S v=new S; +v.f = 2; +int i=new S.f; +i=v.f; +if (arg) v.f=1; +return i; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg$2
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + new9 [ label="new S" ]; + Con_11 [ label="#2" ]; + Store12 [ label=".f =" ]; + new13 [ label="new S" ]; + Store14 [ label=".f =" ]; + Load16 [ label=".f" ]; + If17 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Con_21 [ label="#1" ]; + Store22 [ label=".f =" ]; + Region23 [ shape=box style=filled fillcolor=yellow label="Region" ]; + Phi_224 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Return25 [ shape=box style=filled fillcolor=yellow label="Return" ]; + { rank=same; Region23;Phi_224;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Stop3 -> Return25[taillabel=0 color=red]; + new9 -> Start2:p0[taillabel=0 color=green]; + Store12 -> Start2:p0[taillabel=0 color=red]; + Store12 -> Start2:p2[taillabel=1 color=blue]; + Store12 -> new9[taillabel=2]; + Store12 -> Con_11[taillabel=3]; + new13 -> Start2:p0[taillabel=0 color=green]; + Store14 -> Start2:p0[taillabel=0 color=red]; + Store14 -> Store12[taillabel=1 color=blue]; + Store14 -> new13[taillabel=2]; + Store14 -> Con_4[taillabel=3]; + Load16 -> Start2:p0[taillabel=0 color=red]; + Load16 -> Store14[taillabel=1 color=blue]; + Load16 -> new9[taillabel=2]; + If17 -> Start2:p0[taillabel=0 color=red]; + If17 -> Start2:p1[taillabel=1]; + Store22 -> Start2:p0[taillabel=0 color=red]; + Store22 -> Store14[taillabel=1 color=blue]; + Store22 -> new9[taillabel=2]; + Store22 -> Con_21[taillabel=3]; + Region23 -> If17:p0[taillabel=1 color=red]; + Region23 -> If17:p1[taillabel=2 color=red]; + Phi_224 -> Region23 [style=dotted taillabel=0]; + Phi_224 -> Store22[taillabel=1 color=blue]; + Phi_224 -> Store14[taillabel=2 color=blue constraint=false]; + Return25 -> Region23[taillabel=0 color=red]; + Return25 -> Load16[taillabel=1]; + Return25 -> Phi_224[taillabel=2 color=blue]; +} diff --git a/chapter11/docs/graph2.svg b/chapter11/docs/graph2.svg new file mode 100644 index 00000000..00f7b594 --- /dev/null +++ b/chapter11/docs/graph2.svg @@ -0,0 +1,309 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + +arg + +$2 + + + +Stop3 + +Stop + + + +Return25 + +Return + + + +Stop3->Return25 + + +0 + + + +Con_4 + +#0 + + + +new9 + +new S + + + +new9->Start2:p0 + + +0 + + + +Con_11 + +#2 + + + +Store12 + +.f = + + + +Store12->Start2:p0 + + + +0 + + + +Store12->new9 + + +2 + + + +Store12->Con_11 + + +3 + + + +new13 + +new S + + + +new13->Start2:p0 + + +0 + + + +Store14 + +.f = + + + +Store14->Start2:p0 + + +0 + + + +Store14->Con_4 + + +3 + + + +Store14->Store12 + + +1 + + + +Store14->new13 + + + +2 + + + +Load16 + +.f + + + +Load16->Start2:p0 + + + +0 + + + +Load16->new9 + + +2 + + + +Load16->Store14 + + +1 + + + +If17 + + +If + + + +True + + +False + + + +If17->Start2:p0 + +0 + + + +Con_21 + +#1 + + + +Store22 + +.f = + + + +Store22->Start2:p0 + + +0 + + + +Store22->new9 + + + +2 + + + +Store22->Store14 + + +1 + + + +Store22->Con_21 + + +3 + + + +Region23 + +Region + + + +Region23->If17:p0 + + +1 + + + +Region23->If17:p1 + + +2 + + + +Phi_224 + +φ_$2 + + + +Phi_224->Store14 + + +2 + + + +Phi_224->Store22 + + +1 + + + +Phi_224->Region23 + + +0 + + + +Return25->Load16 + + +1 + + + +Return25->Region23 + + +0 + + + +Return25->Phi_224 + + +2 + + + diff --git a/chapter11/docs/graph3-snip.jpg b/chapter11/docs/graph3-snip.jpg new file mode 100644 index 00000000..804a32c4 Binary files /dev/null and b/chapter11/docs/graph3-snip.jpg differ diff --git a/chapter11/docs/graph3.gv b/chapter11/docs/graph3.gv new file mode 100644 index 00000000..c47ac565 --- /dev/null +++ b/chapter11/docs/graph3.gv @@ -0,0 +1,81 @@ +digraph chapter11 { +/* +struct S { int f; } +S v=new S; +v.f = 2; +int i=new S.f; +i=v.f; +if (arg) v.f=1; +return i; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg$2
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + new9 [ label="new S" ]; + Con_11 [ label="#2" ]; + Store12 [ label=".f =" ]; + new13 [ label="new S" ]; + Store14 [ label=".f =" ]; + Load16 [ label=".f" ]; + If17 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Con_21 [ label="#1" ]; + Store22 [ label=".f =" ]; + Region23 [ shape=box style=filled fillcolor=yellow label="Region" ]; + Phi_224 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Return25 [ shape=box style=filled fillcolor=yellow label="Return" ]; + { rank=same; Region23;Phi_224;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Stop3 -> Return25[taillabel=0 color=red]; + new9 -> Start2:p0[taillabel=0 color=green]; + Store12 -> Start2:p0[taillabel=0 color=red]; + Store12 -> Start2:p2[taillabel=1 color=blue]; + Store12 -> new9[taillabel=2]; + Store12 -> Con_11[taillabel=3]; + new13 -> Start2:p0[taillabel=0 color=green]; + Store14 -> Start2:p0[taillabel=0 color=red]; + Store14 -> Store12[taillabel=1 color=blue]; + Store14 -> new13[taillabel=2]; + Store14 -> Con_4[taillabel=3]; + Load16 -> Start2:p0[taillabel=0 color=red]; + Load16 -> Store14[taillabel=1 color=blue]; + Load16 -> new9[taillabel=2]; + If17 -> Start2:p0[taillabel=0 color=red]; + If17 -> Start2:p1[taillabel=1]; + Store22 -> If17:p0[taillabel=0 color=red]; + Store22 -> Store14[taillabel=1 color=blue]; + Store22 -> new9[taillabel=2]; + Store22 -> Con_21[taillabel=3]; + Store22 -> Load16[taillabel=4]; + Region23 -> If17:p0[taillabel=1 color=red]; + Region23 -> If17:p1[taillabel=2 color=red]; + Phi_224 -> Region23 [style=dotted taillabel=0]; + Phi_224 -> Store22[taillabel=1 color=blue]; + Phi_224 -> Store14[taillabel=2 color=blue constraint=false]; + Return25 -> Region23[taillabel=0 color=red]; + Return25 -> Load16[taillabel=1]; + Return25 -> Phi_224[taillabel=2 color=blue]; +} diff --git a/chapter11/docs/graph3.svg b/chapter11/docs/graph3.svg new file mode 100644 index 00000000..e017c4af --- /dev/null +++ b/chapter11/docs/graph3.svg @@ -0,0 +1,316 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + +arg + +$2 + + + +Stop3 + +Stop + + + +Return25 + +Return + + + +Stop3->Return25 + + +0 + + + +Con_4 + +#0 + + + +new9 + +new S + + + +new9->Start2:p0 + + +0 + + + +Con_11 + +#2 + + + +Store12 + +.f = + + + +Store12->Start2:p0 + + + +0 + + + +Store12->new9 + + +2 + + + +Store12->Con_11 + + +3 + + + +new13 + +new S + + + +new13->Start2:p0 + + +0 + + + +Store14 + +.f = + + + +Store14->Start2:p0 + + +0 + + + +Store14->Con_4 + + +3 + + + +Store14->Store12 + + +1 + + + +Store14->new13 + + + +2 + + + +Load16 + +.f + + + +Load16->Start2:p0 + + + +0 + + + +Load16->new9 + + +2 + + + +Load16->Store14 + + +1 + + + +If17 + + +If + + + +True + + +False + + + +If17->Start2:p0 + +0 + + + +Con_21 + +#1 + + + +Store22 + +.f = + + + +Store22->new9 + + +2 + + + +Store22->Store14 + + + +1 + + + +Store22->Load16 + + +4 + + + +Store22->If17:p0 + + +0 + + + +Store22->Con_21 + + +3 + + + +Region23 + +Region + + + +Region23->If17:p0 + + +1 + + + +Region23->If17:p1 + + +2 + + + +Phi_224 + +φ_$2 + + + +Phi_224->Store14 + + +2 + + + +Phi_224->Store22 + + +1 + + + +Phi_224->Region23 + + +0 + + + +Return25->Load16 + + +1 + + + +Return25->Region23 + + +0 + + + +Return25->Phi_224 + + +2 + + + diff --git a/chapter11/docs/graph4.gv b/chapter11/docs/graph4.gv new file mode 100644 index 00000000..190e83dd --- /dev/null +++ b/chapter11/docs/graph4.gv @@ -0,0 +1,107 @@ +digraph chapter11 { +/* +struct S { int f; } +S v = new S; +int i = arg; +while (arg > 0) { + int j = i/3; + if (arg == 5) + v.f = j; + arg = arg - 1; +} +return v; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg$2
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + new9 [ label="new S" ]; + Store10 [ label=".f =" ]; + Loop11 [ shape=box style=filled fillcolor=yellow label="Loop" ]; + Phi_arg13 [ style=filled fillcolor=lightyellow label="φ_arg" ]; + LT14 [ label="<" ]; + If16 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Div21 [ label="//" ]; + Con_22 [ label="#3" ]; + EQ23 [ label="==" ]; + Con_24 [ label="#5" ]; + If25 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Phi_230 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Store31 [ label=".f =" ]; + Region32 [ shape=box style=filled fillcolor=yellow label="Region" ]; + Phi_233 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Sub35 [ label="-" ]; + Con_36 [ label="#1" ]; + Return37 [ shape=box style=filled fillcolor=yellow label="Return" ]; + { rank=same; Loop11;Phi_230;Phi_arg13;} + { rank=same; Region32;Phi_233;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Stop3 -> Return37[taillabel=0 color=red]; + new9 -> Start2:p0[taillabel=0 color=green]; + Store10 -> Start2:p2[taillabel=1 color=blue]; + Store10 -> new9[taillabel=2]; + Store10 -> Con_4[taillabel=3]; + Loop11 -> Start2:p0[taillabel=1 color=red]; + Loop11 -> Region32[taillabel=2 color=red constraint=false]; + Phi_arg13 -> Loop11 [style=dotted taillabel=0]; + Phi_arg13 -> Start2:p1[taillabel=1]; + Phi_arg13 -> Sub35[taillabel=2 constraint=false]; + LT14 -> Con_4[taillabel=1]; + LT14 -> Phi_arg13[taillabel=2]; + If16 -> Loop11[taillabel=0 color=red]; + If16 -> LT14[taillabel=1]; + Div21 -> Start2:p1[taillabel=1]; + Div21 -> Con_22[taillabel=2]; + EQ23 -> Phi_arg13[taillabel=1]; + EQ23 -> Con_24[taillabel=2]; + If25 -> If16:p0[taillabel=0 color=red]; + If25 -> EQ23[taillabel=1]; + Phi_230 -> Loop11 [style=dotted taillabel=0]; + Phi_230 -> Store10[taillabel=1 color=blue]; + Phi_230 -> Phi_233[taillabel=2 color=blue constraint=false]; + Store31 -> Phi_230[taillabel=1 color=blue]; + Store31 -> new9[taillabel=2]; + Store31 -> Div21[taillabel=3]; + Region32 -> If25:p0[taillabel=1 color=red]; + Region32 -> If25:p1[taillabel=2 color=red]; + Phi_233 -> Region32 [style=dotted taillabel=0]; + Phi_233 -> Store31[taillabel=1 color=blue]; + Phi_233 -> Phi_230[taillabel=2 color=blue constraint=false]; + Sub35 -> Phi_arg13[taillabel=1]; + Sub35 -> Con_36[taillabel=2]; + Return37 -> If16:p1[taillabel=0 color=red]; + Return37 -> new9[taillabel=1]; + Return37 -> Phi_230[taillabel=2 color=blue]; +} \ No newline at end of file diff --git a/chapter11/docs/graph4.svg b/chapter11/docs/graph4.svg new file mode 100644 index 00000000..7f392664 --- /dev/null +++ b/chapter11/docs/graph4.svg @@ -0,0 +1,408 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + +arg + +$2 + + + +Stop3 + +Stop + + + +Return37 + +Return + + + +Stop3->Return37 + + +0 + + + +Con_4 + +#0 + + + +new9 + +new S + + + +new9->Start2:p0 + + +0 + + + +Store10 + +.f = + + + +Store10->Start2:p2 + + +1 + + + +Store10->Con_4 + + +3 + + + +Store10->new9 + + +2 + + + +Loop11 + +Loop + + + +Loop11->Start2:p0 + + +1 + + + +Region32 + +Region + + + +Loop11->Region32 + + +2 + + + +Phi_arg13 + +φ_arg + + + +Phi_arg13->Start2:p1 + + +1 + + + +Phi_arg13->Loop11 + + +0 + + + +Sub35 + +- + + + +LT14 + +< + + + +LT14->Con_4 + + +1 + + + +LT14->Phi_arg13 + + +2 + + + +If16 + + +If + + + +True + + +False + + + +If16->Loop11 + + +0 + + + +If16->LT14 + + +1 + + + +Div21 + +// + + + +Div21->Start2:p1 + + +1 + + + +Con_22 + +#3 + + + +Div21->Con_22 + + +2 + + + +EQ23 + +== + + + +EQ23->Phi_arg13 + + +1 + + + +Con_24 + +#5 + + + +EQ23->Con_24 + + +2 + + + +If25 + + +If + + + +True + + +False + + + +If25->If16:p0 + + +0 + + + +If25->EQ23 + + +1 + + + +Phi_230 + +φ_$2 + + + +Phi_230->Store10 + + +1 + + + +Phi_230->Loop11 + + +0 + + + +Phi_233 + +φ_$2 + + + +Store31 + +.f = + + + +Store31->new9 + +2 + + + +Store31->Div21 + + +3 + + + +Store31->Phi_230 + + +1 + + + +Region32->If25:p0 + + +1 + + + +Region32->If25:p1 + + +2 + + + +Phi_233->Phi_230 + + + +2 + + + +Phi_233->Store31 + + +1 + + + +Phi_233->Region32 + + +0 + + + +Sub35->Phi_arg13 + + + +1 + + + +Con_36 + +#1 + + + +Sub35->Con_36 + + +2 + + + +Return37->new9 + + + +1 + + + +Return37->If16:p1 + + +0 + + + +Return37->Phi_230 + + +2 + + + diff --git a/chapter11/docs/graph5.gv b/chapter11/docs/graph5.gv new file mode 100644 index 00000000..9ebc11cb --- /dev/null +++ b/chapter11/docs/graph5.gv @@ -0,0 +1,113 @@ +digraph chapter11 { +/* +struct S { int f; } +S v = new S; +int i = arg; +while (arg > 0) { + int j = i/3; + if (arg == 5) + v.f = j; + arg = arg - 1; +} +return v; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg$2
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + new9 [ label="new S" ]; + Store10 [ label=".f =" ]; + Loop11 [ shape=box style=filled fillcolor=yellow label="Loop" ]; + Phi_arg13 [ style=filled fillcolor=lightyellow label="φ_arg" ]; + LT14 [ label="<" ]; + If16 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Div21 [ label="//" ]; + Con_22 [ label="#3" ]; + EQ23 [ label="==" ]; + Con_24 [ label="#5" ]; + If25 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Phi_230 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Store31 [ label=".f =" ]; + Region32 [ shape=box style=filled fillcolor=yellow label="Region" ]; + Phi_233 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Sub35 [ label="-" ]; + Con_36 [ label="#1" ]; + Return37 [ shape=box style=filled fillcolor=yellow label="Return" ]; + { rank=same; Loop11;Phi_230;Phi_arg13;} + { rank=same; Region32;Phi_233;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Stop3 -> Return37[taillabel=0 color=red]; + new9 -> Start2:p0[taillabel=0 color=green]; + Store10 -> Start2:p0[taillabel=0 color=red]; + Store10 -> Start2:p2[taillabel=1 color=blue]; + Store10 -> new9[taillabel=2]; + Store10 -> Con_4[taillabel=3]; + Loop11 -> Start2:p0[taillabel=1 color=red]; + Loop11 -> Region32[taillabel=2 color=red constraint=false]; + Phi_arg13 -> Loop11 [style=dotted taillabel=0]; + Phi_arg13 -> Start2:p1[taillabel=1]; + Phi_arg13 -> Sub35[taillabel=2 constraint=false]; + LT14 -> Loop11[taillabel=0 color=red]; + LT14 -> Con_4[taillabel=1]; + LT14 -> Phi_arg13[taillabel=2]; + If16 -> Loop11[taillabel=0 color=red]; + If16 -> LT14[taillabel=1]; + Div21 -> Start2[taillabel=0 color=red]; + Div21 -> Start2:p1[taillabel=1]; + Div21 -> Con_22[taillabel=2]; + EQ23 -> Loop11[taillabel=0 color=red]; + EQ23 -> Phi_arg13[taillabel=1]; + EQ23 -> Con_24[taillabel=2]; + If25 -> If16:p0[taillabel=0 color=red]; + If25 -> EQ23[taillabel=1]; + Phi_230 -> Loop11 [style=dotted taillabel=0]; + Phi_230 -> Store10[taillabel=1 color=blue]; + Phi_230 -> Phi_233[taillabel=2 color=blue constraint=false]; + Store31 -> Loop11[taillabel=0 color=red]; + Store31 -> Phi_230[taillabel=1 color=blue]; + Store31 -> new9[taillabel=2]; + Store31 -> Div21[taillabel=3]; + Region32 -> If25:p0[taillabel=1 color=red]; + Region32 -> If25:p1[taillabel=2 color=red]; + Phi_233 -> Region32 [style=dotted taillabel=0]; + Phi_233 -> Store31[taillabel=1 color=blue]; + Phi_233 -> Phi_230[taillabel=2 color=blue constraint=false]; + Sub35 -> Loop11[taillabel=0 color=red]; + Sub35 -> Phi_arg13[taillabel=1]; + Sub35 -> Con_36[taillabel=2]; + Return37 -> If16:p1[taillabel=0 color=red]; + Return37 -> new9[taillabel=1]; + Return37 -> Phi_230[taillabel=2 color=blue]; +} \ No newline at end of file diff --git a/chapter11/docs/graph5.svg b/chapter11/docs/graph5.svg new file mode 100644 index 00000000..6dbf29f9 --- /dev/null +++ b/chapter11/docs/graph5.svg @@ -0,0 +1,452 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + +arg + +$2 + + + +Stop3 + +Stop + + + +Return37 + +Return + + + +Stop3->Return37 + + +0 + + + +Con_4 + +#0 + + + +new9 + +new S + + + +new9->Start2:p0 + + +0 + + + +Store10 + +.f = + + + +Store10->Start2:p0 + + + +0 + + + +Store10->Start2:p2 + + +1 + + + +Store10->Con_4 + + +3 + + + +Store10->new9 + + +2 + + + +Loop11 + +Loop + + + +Loop11->Start2:p0 + +1 + + + +Region32 + +Region + + + +Loop11->Region32 + + +2 + + + +Phi_arg13 + +φ_arg + + + +Phi_arg13->Start2:p1 + + +1 + + + +Phi_arg13->Loop11 + + +0 + + + +Sub35 + +- + + + +LT14 + +< + + + +LT14->Con_4 + + +1 + + + +LT14->Loop11 + + +0 + + + +LT14->Phi_arg13 + + +2 + + + +If16 + + +If + + + +True + + +False + + + +If16->Loop11 + + +0 + + + +If16->LT14 + + +1 + + + +Div21 + +// + + + +Div21->Start2 + + +0 + + + +Div21->Start2:p1 + + +1 + + + +Con_22 + +#3 + + + +Div21->Con_22 + + +2 + + + +EQ23 + +== + + + +EQ23->Loop11 + + +0 + + + +EQ23->Phi_arg13 + + +1 + + + +Con_24 + +#5 + + + +EQ23->Con_24 + + +2 + + + +If25 + + +If + + + +True + + +False + + + +If25->If16:p0 + + +0 + + + +If25->EQ23 + + +1 + + + +Phi_230 + +φ_$2 + + + +Phi_230->Store10 + + +1 + + + +Phi_230->Loop11 + + +0 + + + +Phi_233 + +φ_$2 + + + +Store31 + +.f = + + + +Store31->new9 + + +2 + + + +Store31->Loop11 + + +0 + + + +Store31->Div21 + + + +3 + + + +Store31->Phi_230 + + +1 + + + +Region32->If25:p0 + + +1 + + + +Region32->If25:p1 + + +2 + + + +Phi_233->Phi_230 + + + +2 + + + +Phi_233->Store31 + + +1 + + + +Phi_233->Region32 + + +0 + + + +Sub35->Loop11 + + +0 + + + +Sub35->Phi_arg13 + + + +1 + + + +Con_36 + +#1 + + + +Sub35->Con_36 + + +2 + + + +Return37->new9 + + + +1 + + + +Return37->If16:p1 + + +0 + + + +Return37->Phi_230 + + +2 + + + diff --git a/chapter11/docs/graph6.gv b/chapter11/docs/graph6.gv new file mode 100644 index 00000000..b108c44d --- /dev/null +++ b/chapter11/docs/graph6.gv @@ -0,0 +1,113 @@ +digraph chapter11 { +/* +struct S { int f; } +S v = new S; +int i = arg; +while (arg > 0) { + int j = i/3; + if (arg == 5) + v.f = j; + arg = arg - 1; +} +return v; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrlarg$2
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + new9 [ label="new S" ]; + Store10 [ label=".f =" ]; + Loop11 [ shape=box style=filled fillcolor=yellow label="Loop" ]; + Phi_arg13 [ style=filled fillcolor=lightyellow label="φ_arg" ]; + LT14 [ label="<" ]; + If16 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Div21 [ label="//" ]; + Con_22 [ label="#3" ]; + EQ23 [ label="==" ]; + Con_24 [ label="#5" ]; + If25 [ shape=plaintext label=< + + + +
If
+ + +
TrueFalse
+
> + ]; + Phi_230 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Store31 [ label=".f =" ]; + Region32 [ shape=box style=filled fillcolor=yellow label="Region" ]; + Phi_233 [ style=filled fillcolor=lightyellow label="φ_$2" ]; + Sub35 [ label="-" ]; + Con_36 [ label="#1" ]; + Return37 [ shape=box style=filled fillcolor=yellow label="Return" ]; + { rank=same; Loop11;Phi_230;Phi_arg13;} + { rank=same; Region32;Phi_233;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Stop3 -> Return37[taillabel=0 color=red]; + new9 -> Start2:p0[taillabel=0 color=green]; + Store10 -> Start2:p0[taillabel=0 color=red]; + Store10 -> Start2:p2[taillabel=1 color=blue]; + Store10 -> new9[taillabel=2]; + Store10 -> Con_4[taillabel=3]; + Loop11 -> Start2:p0[taillabel=1 color=red]; + Loop11 -> Region32[taillabel=2 color=red constraint=false]; + Phi_arg13 -> Loop11 [style=dotted taillabel=0]; + Phi_arg13 -> Start2:p1[taillabel=1]; + Phi_arg13 -> Sub35[taillabel=2 constraint=false]; + LT14 -> Loop11[taillabel=0 color=red]; + LT14 -> Con_4[taillabel=1]; + LT14 -> Phi_arg13[taillabel=2]; + If16 -> Loop11[taillabel=0 color=red]; + If16 -> LT14[taillabel=1]; + Div21 -> Start2:p0[taillabel=0 color=red]; + Div21 -> Start2:p1[taillabel=1]; + Div21 -> Con_22[taillabel=2]; + EQ23 -> If16:p0[taillabel=0 color=red]; + EQ23 -> Phi_arg13[taillabel=1]; + EQ23 -> Con_24[taillabel=2]; + If25 -> If16:p0[taillabel=0 color=red]; + If25 -> EQ23[taillabel=1]; + Phi_230 -> Loop11 [style=dotted taillabel=0]; + Phi_230 -> Store10[taillabel=1 color=blue]; + Phi_230 -> Phi_233[taillabel=2 color=blue constraint=false]; + Store31 -> If25:p0[taillabel=0 color=red]; + Store31 -> Phi_230[taillabel=1 color=blue]; + Store31 -> new9[taillabel=2]; + Store31 -> Div21[taillabel=3]; + Region32 -> If25:p0[taillabel=1 color=red]; + Region32 -> If25:p1[taillabel=2 color=red]; + Phi_233 -> Region32 [style=dotted taillabel=0]; + Phi_233 -> Store31[taillabel=1 color=blue]; + Phi_233 -> Phi_230[taillabel=2 color=blue constraint=false]; + Sub35 -> Region32[taillabel=0 color=red]; + Sub35 -> Phi_arg13[taillabel=1]; + Sub35 -> Con_36[taillabel=2]; + Return37 -> If16:p1[taillabel=0 color=red]; + Return37 -> new9[taillabel=1]; + Return37 -> Phi_230[taillabel=2 color=blue]; +} \ No newline at end of file diff --git a/chapter11/docs/graph6.svg b/chapter11/docs/graph6.svg new file mode 100644 index 00000000..354f5d2f --- /dev/null +++ b/chapter11/docs/graph6.svg @@ -0,0 +1,437 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + +arg + +$2 + + + +Stop3 + +Stop + + + +Return37 + +Return + + + +Stop3->Return37 + + +0 + + + +Con_4 + +#0 + + + +new9 + +new S + + + +new9->Start2:p0 + + +0 + + + +Store10 + +.f = + + + +Store10->Start2:p0 + + +0 + + + +Store10->Con_4 + + +3 + + + +Store10->new9 + + +2 + + + +Loop11 + +Loop + + + +Loop11->Start2:p0 + + +1 + + + +Region32 + +Region + + + +Loop11->Region32 + + +2 + + + +Phi_arg13 + +φ_arg + + + +Phi_arg13->Start2:p1 + + +1 + + + +Phi_arg13->Loop11 + + +0 + + + +Sub35 + +- + + + +LT14 + +< + + + +LT14->Con_4 + + +1 + + + +LT14->Loop11 + + +0 + + + +LT14->Phi_arg13 + + +2 + + + +If16 + + +If + + + +True + + +False + + + +If16->Loop11 + + +0 + + + +If16->LT14 + + +1 + + + +Div21 + +// + + + +Div21->Start2:p0 + + +0 + + + +Div21->Start2:p1 + + +1 + + + +Con_22 + +#3 + + + +Div21->Con_22 + + +2 + + + +EQ23 + +== + + + +EQ23->Phi_arg13 + + +1 + + + +EQ23->If16:p0 + + +0 + + + +Con_24 + +#5 + + + +EQ23->Con_24 + + +2 + + + +If25 + + +If + + + +True + + +False + + + +If25->If16:p0 + + +0 + + + +If25->EQ23 + + +1 + + + +Phi_230 + +φ_$2 + + + +Phi_230->Store10 + + +1 + + + +Phi_230->Loop11 + + +0 + + + +Phi_233 + +φ_$2 + + + +Store31 + +.f = + + + +Store31->new9 + + + +2 + + + +Store31->Div21 + + +3 + + + +Store31->If25:p0 + + +0 + + + +Store31->Phi_230 + + +1 + + + +Region32->If25:p0 + + +1 + + + +Phi_233->Phi_230 + + + +2 + + + +Phi_233->Store31 + + +1 + + + +Phi_233->Region32 + + +0 + + + +Sub35->Phi_arg13 + + + +1 + + + +Sub35->Region32 + + +0 + + + +Con_36 + +#1 + + + +Sub35->Con_36 + + +2 + + + +Return37->new9 + + +1 + + + +Return37->If16:p1 + + +0 + + + +Return37->Phi_230 + + +2 + + + diff --git a/chapter11/docs/graph7.gv b/chapter11/docs/graph7.gv new file mode 100644 index 00000000..e9e380ff --- /dev/null +++ b/chapter11/docs/graph7.gv @@ -0,0 +1,23 @@ +digraph chapter11 { + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrl
+
> + ]; + Con_4 [ label="#0" ]; + Loop8 [ shape=box style=filled fillcolor=yellow label="Loop" ]; + { rank=same; Loop8;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Loop8 -> Start2:p0[taillabel=1 color=red]; + Loop8 -> Loop8[taillabel=2 color=red constraint=false]; +} \ No newline at end of file diff --git a/chapter11/docs/graph7.svg b/chapter11/docs/graph7.svg new file mode 100644 index 00000000..854660ec --- /dev/null +++ b/chapter11/docs/graph7.svg @@ -0,0 +1,54 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Start2 + + +Start + + + +$ctrl + + + +Con_4 + +#0 + + + +Loop8 + +Loop + + + +Loop8->Start2:p0 + + +1 + + + +Loop8->Loop8 + + +2 + + + diff --git a/chapter11/docs/graph8.gv b/chapter11/docs/graph8.gv new file mode 100644 index 00000000..4189dae8 --- /dev/null +++ b/chapter11/docs/graph8.gv @@ -0,0 +1,45 @@ +digraph chapter11 { +/* +while (1) {} +return 0; + +*/ + rankdir=BT; + concentrate="true"; + compound="true"; + subgraph cluster_Nodes { + Never18 [ shape=plaintext label=< + + + +
Never
+ + +
TrueFalse
+
> + ]; + Start2 [ shape=plaintext label=< + + + +
Start
+ + +
$ctrl
+
> + ]; + Stop3 [ shape=box style=filled fillcolor=yellow label="Stop" ]; + Con_4 [ label="#0" ]; + Return21 [ shape=box style=filled fillcolor=yellow label="Return" ]; + Loop8 [ shape=box style=filled fillcolor=yellow label="Loop" ]; + { rank=same; Loop8;} + } + edge [ fontname=Helvetica, fontsize=8 ]; + Never18 -> Loop8[taillabel=0 color=red]; + Never18 -> Con_4[taillabel=1]; + Stop3 -> Return21[taillabel=0 color=red]; + Return21 -> Never18:p0[taillabel=0 color=red]; + Return21 -> Con_4[taillabel=1]; + Loop8 -> Start2:p0[taillabel=1 color=red]; + Loop8 -> Never18:p1[taillabel=2 color=red constraint=false]; +} \ No newline at end of file diff --git a/chapter11/docs/graph8.svg b/chapter11/docs/graph8.svg new file mode 100644 index 00000000..c577cf84 --- /dev/null +++ b/chapter11/docs/graph8.svg @@ -0,0 +1,115 @@ + + + + + + +chapter11 + + +cluster_Nodes + + + + +Never18 + + +Never + + + +True + + +False + + + +Con_4 + +#0 + + + +Never18->Con_4 + + +1 + + + +Loop8 + +Loop + + + +Never18->Loop8 + + +0 + + + +Start2 + + +Start + + + +$ctrl + + + +Stop3 + +Stop + + + +Return21 + +Return + + + +Stop3->Return21 + + +0 + + + +Return21->Never18:p0 + + +0 + + + +Return21->Con_4 + + +1 + + + +Loop8->Never18:p1 + + +2 + + + +Loop8->Start2:p0 + + +1 + + + -- cgit v1.2.3