summaryrefslogtreecommitdiff
path: root/chapter02/docs/02-pre-peephole-ex1.svg
diff options
context:
space:
mode:
authorDibyendu Majumdar <dibyendumajumdar@users.noreply.github.com>2023-09-26 17:43:36 +0100
committerGitHub <noreply@github.com>2023-09-26 09:43:36 -0700
commit29def92f2ddbfca64ba827f116172fe98b2df491 (patch)
treea49affb27d57e908429beafe300756d5e4c0c273 /chapter02/docs/02-pre-peephole-ex1.svg
parent62bfd0d619b28892152a7d89639f3437bc9df573 (diff)
downloadSimple-29def92f2ddbfca64ba827f116172fe98b2df491.tar.gz
Simple-29def92f2ddbfca64ba827f116172fe98b2df491.zip
Chapter 2 (#4)
* Start on Chapter 2. * Start on Chapter 2. * Refactor * Refactor * Initial attempt at peephole opt for add operation * cleanup unused import * Start on graph visualizer * Start on graph visualizer * Rework chapter 2 Add a short discourse on the Types, and provide a Bottom type. Make a final toString; require each Node to specify its special printing via label(). Add a recursing printer called print(); toString is used by default in the debugger and so cannot be recursive. Make the peephole rules based on a proper Type and idealize calls. Big comments about the Type computations. Every node picks up a _print, compute and idealize() call. Rename long arith ops Divide, UnaryMinus, Multiply, Subtract into shorter uniform-length names. Cleans up the parser where he does the precedence op parsing. Rework Parser: - Drop Token class, its all Strings except in the one place we know a number is coming - Embed the Lexer as a field in the Parser, instead of trying to pass it around everywhere in the Parser - StartNode becomes a read-only global, so we don't have to pass it around everywhere in the Parser AND optimizer. - Lexer matches on strings and returns strings. Match and consume *at the moment* instead of carrying around a current token/string and forcing the next-token after consuming the current one. - All parse subexpressions shrink by 1/2 after these changes. * Initial writeup of Chapter 2 * Initial writeup of Chapter 2 * Initial writeup of Chapter 2 * Initial writeup of Chapter 2 * Remove range * progress Chapter 2 Drop integer ranges. Broader lattice pic. Lots of prose changes in the readme. Fixed title in gviz dot generation. Fixed bug with peephole making redundant constants. * Implement compute for all the arithmetic node types Add a flag to switch off peephole so we can see the full graph Add post peephole graph to writeup * Implement compute for all the arithmetic node types Add a flag to switch off peephole so we can see the full graph Add post peephole graph to writeup * Fix bad path to the svg * Update pre-peephole diagram * Add dead code elimination ...and a set_def to proper update graph edges. * Update README.md * Cleanup the GraphVisualizer a bit. Update the graphs. Update the chapter list as chapter 3 deleted, and chapter 4 is now chapter 3. --------- Co-authored-by: Cliff Click <cliffc@acm.org>
Diffstat (limited to 'chapter02/docs/02-pre-peephole-ex1.svg')
-rw-r--r--chapter02/docs/02-pre-peephole-ex1.svg156
1 files changed, 156 insertions, 0 deletions
diff --git a/chapter02/docs/02-pre-peephole-ex1.svg b/chapter02/docs/02-pre-peephole-ex1.svg
new file mode 100644
index 00000000..dc33c7f5
--- /dev/null
+++ b/chapter02/docs/02-pre-peephole-ex1.svg
@@ -0,0 +1,156 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN"
+ "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
+<!-- Generated by graphviz version 2.43.0 (0)
+ -->
+<!-- Title: chapter02 Pages: 1 -->
+<svg width="301pt" height="404pt"
+ viewBox="0.00 0.00 301.08 404.00" xmlns="http://www.w3.org/2000/svg">
+ <g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 400)">
+ <title>chapter02</title>
+ <polygon fill="white" stroke="transparent" points="-4,4 -4,-400 297.08,-400 297.08,4 -4,4"/>
+ <!-- Start1 -->
+ <g id="node1" class="node">
+ <title>Start1</title>
+ <polygon fill="none" stroke="black" points="169.34,-396 115.34,-396 115.34,-360 169.34,-360 169.34,-396"/>
+ <text text-anchor="middle" x="142.34" y="-374.3" font-family="Times,serif" font-size="14.00">Start</text>
+ </g>
+ <!-- Con12 -->
+ <g id="node2" class="node">
+ <title>Con12</title>
+ <ellipse fill="none" stroke="black" cx="46.34" cy="-162" rx="34.39" ry="18"/>
+ <text text-anchor="middle" x="46.34" y="-158.3" font-family="Times,serif" font-size="14.00">Con1</text>
+ </g>
+ <!-- Start1&#45;&gt;Con12 -->
+ <g id="edge1" class="edge">
+ <title>Start1&#45;&gt;Con12</title>
+ <path fill="none" stroke="black" stroke-dasharray="1,5"
+ d="M115.19,-374.6C84.32,-370.26 35.25,-358.08 12.34,-324 -15.78,-282.17 11,-221.54 30.37,-187.88"/>
+ <polygon fill="black" stroke="black" points="33.47,-189.52 35.59,-179.14 27.46,-185.93 33.47,-189.52"/>
+ </g>
+ <!-- Con23 -->
+ <g id="node3" class="node">
+ <title>Con23</title>
+ <ellipse fill="none" stroke="black" cx="55.34" cy="-306" rx="34.39" ry="18"/>
+ <text text-anchor="middle" x="55.34" y="-302.3" font-family="Times,serif" font-size="14.00">Con2</text>
+ </g>
+ <!-- Start1&#45;&gt;Con23 -->
+ <g id="edge2" class="edge">
+ <title>Start1&#45;&gt;Con23</title>
+ <path fill="none" stroke="black" stroke-dasharray="1,5"
+ d="M120.83,-359.7C108.86,-350.07 93.88,-338.01 81.26,-327.86"/>
+ <polygon fill="black" stroke="black" points="83.35,-325.05 73.37,-321.51 78.97,-330.5 83.35,-325.05"/>
+ </g>
+ <!-- Con34 -->
+ <g id="node4" class="node">
+ <title>Con34</title>
+ <ellipse fill="none" stroke="black" cx="142.34" cy="-306" rx="34.39" ry="18"/>
+ <text text-anchor="middle" x="142.34" y="-302.3" font-family="Times,serif" font-size="14.00">Con3</text>
+ </g>
+ <!-- Start1&#45;&gt;Con34 -->
+ <g id="edge3" class="edge">
+ <title>Start1&#45;&gt;Con34</title>
+ <path fill="none" stroke="black" stroke-dasharray="1,5"
+ d="M142.34,-359.7C142.34,-351.98 142.34,-342.71 142.34,-334.11"/>
+ <polygon fill="black" stroke="black" points="145.84,-334.1 142.34,-324.1 138.84,-334.1 145.84,-334.1"/>
+ </g>
+ <!-- Con56 -->
+ <g id="node6" class="node">
+ <title>Con56</title>
+ <ellipse fill="none" stroke="black" cx="229.34" cy="-306" rx="34.39" ry="18"/>
+ <text text-anchor="middle" x="229.34" y="-302.3" font-family="Times,serif" font-size="14.00">Con5</text>
+ </g>
+ <!-- Start1&#45;&gt;Con56 -->
+ <g id="edge6" class="edge">
+ <title>Start1&#45;&gt;Con56</title>
+ <path fill="none" stroke="black" stroke-dasharray="1,5"
+ d="M163.84,-359.7C175.81,-350.07 190.8,-338.01 203.41,-327.86"/>
+ <polygon fill="black" stroke="black" points="205.71,-330.5 211.31,-321.51 201.32,-325.05 205.71,-330.5"/>
+ </g>
+ <!-- Return10 -->
+ <g id="node10" class="node">
+ <title>Return10</title>
+ <polygon fill="none" stroke="black" points="268.34,-36 202.34,-36 202.34,0 268.34,0 268.34,-36"/>
+ <text text-anchor="middle" x="235.34" y="-14.3" font-family="Times,serif" font-size="14.00">Return</text>
+ </g>
+ <!-- Start1&#45;&gt;Return10 -->
+ <g id="edge13" class="edge">
+ <title>Start1&#45;&gt;Return10</title>
+ <path fill="none" stroke="red"
+ d="M169.34,-373.51C199.13,-368.18 246.29,-355.12 272.34,-324 298.3,-292.99 291.34,-275.45 291.34,-235 291.34,-235 291.34,-235 291.34,-161 291.34,-117.91 268.74,-72.26 252.26,-44.7"/>
+ <polygon fill="red" stroke="red" points="255.17,-42.75 246.94,-36.07 249.21,-46.42 255.17,-42.75"/>
+ </g>
+ <!-- Add9 -->
+ <g id="node9" class="node">
+ <title>Add9</title>
+ <ellipse fill="none" stroke="black" cx="180.34" cy="-90" rx="28.7" ry="18"/>
+ <text text-anchor="middle" x="180.34" y="-86.3" font-family="Times,serif" font-size="14.00">Add</text>
+ </g>
+ <!-- Con12&#45;&gt;Add9 -->
+ <g id="edge10" class="edge">
+ <title>Con12&#45;&gt;Add9</title>
+ <path fill="none" stroke="black" d="M69.99,-148.65C92.27,-137 125.77,-119.5 150.02,-106.84"/>
+ <polygon fill="black" stroke="black" points="151.89,-109.81 159.13,-102.08 148.65,-103.61 151.89,-109.81"/>
+ </g>
+ <!-- Mul5 -->
+ <g id="node5" class="node">
+ <title>Mul5</title>
+ <ellipse fill="none" stroke="black" cx="137.34" cy="-234" rx="28.7" ry="18"/>
+ <text text-anchor="middle" x="137.34" y="-230.3" font-family="Times,serif" font-size="14.00">Mul</text>
+ </g>
+ <!-- Con23&#45;&gt;Mul5 -->
+ <g id="edge4" class="edge">
+ <title>Con23&#45;&gt;Mul5</title>
+ <path fill="none" stroke="black" d="M72.73,-290.15C84.56,-280.05 100.38,-266.55 113.4,-255.43"/>
+ <polygon fill="black" stroke="black" points="115.76,-258.03 121.09,-248.87 111.21,-252.7 115.76,-258.03"/>
+ </g>
+ <!-- Con34&#45;&gt;Mul5 -->
+ <g id="edge5" class="edge">
+ <title>Con34&#45;&gt;Mul5</title>
+ <path fill="none" stroke="black" d="M141.1,-287.7C140.55,-279.98 139.89,-270.71 139.27,-262.11"/>
+ <polygon fill="black" stroke="black" points="142.76,-261.83 138.56,-252.1 135.78,-262.33 142.76,-261.83"/>
+ </g>
+ <!-- Add8 -->
+ <g id="node8" class="node">
+ <title>Add8</title>
+ <ellipse fill="none" stroke="black" cx="180.34" cy="-162" rx="28.7" ry="18"/>
+ <text text-anchor="middle" x="180.34" y="-158.3" font-family="Times,serif" font-size="14.00">Add</text>
+ </g>
+ <!-- Mul5&#45;&gt;Add8 -->
+ <g id="edge8" class="edge">
+ <title>Mul5&#45;&gt;Add8</title>
+ <path fill="none" stroke="black" d="M147.31,-216.76C152.58,-208.19 159.15,-197.49 165.04,-187.9"/>
+ <polygon fill="black" stroke="black" points="168.17,-189.5 170.42,-179.15 162.2,-185.84 168.17,-189.5"/>
+ </g>
+ <!-- Minus7 -->
+ <g id="node7" class="node">
+ <title>Minus7</title>
+ <ellipse fill="none" stroke="black" cx="223.34" cy="-234" rx="39.79" ry="18"/>
+ <text text-anchor="middle" x="223.34" y="-230.3" font-family="Times,serif" font-size="14.00">Minus</text>
+ </g>
+ <!-- Con56&#45;&gt;Minus7 -->
+ <g id="edge7" class="edge">
+ <title>Con56&#45;&gt;Minus7</title>
+ <path fill="none" stroke="black" d="M227.85,-287.7C227.19,-279.98 226.4,-270.71 225.66,-262.11"/>
+ <polygon fill="black" stroke="black" points="229.15,-261.77 224.8,-252.1 222.17,-262.37 229.15,-261.77"/>
+ </g>
+ <!-- Minus7&#45;&gt;Add8 -->
+ <g id="edge9" class="edge">
+ <title>Minus7&#45;&gt;Add8</title>
+ <path fill="none" stroke="black" d="M213.15,-216.41C207.88,-207.83 201.34,-197.19 195.49,-187.67"/>
+ <polygon fill="black" stroke="black" points="198.38,-185.68 190.16,-178.99 192.41,-189.34 198.38,-185.68"/>
+ </g>
+ <!-- Add8&#45;&gt;Add9 -->
+ <g id="edge11" class="edge">
+ <title>Add8&#45;&gt;Add9</title>
+ <path fill="none" stroke="black" d="M180.34,-143.7C180.34,-135.98 180.34,-126.71 180.34,-118.11"/>
+ <polygon fill="black" stroke="black" points="183.84,-118.1 180.34,-108.1 176.84,-118.1 183.84,-118.1"/>
+ </g>
+ <!-- Add9&#45;&gt;Return10 -->
+ <g id="edge12" class="edge">
+ <title>Add9&#45;&gt;Return10</title>
+ <path fill="none" stroke="black" d="M192.54,-73.46C199.2,-64.99 207.61,-54.29 215.21,-44.61"/>
+ <polygon fill="black" stroke="black" points="218.19,-46.49 221.62,-36.46 212.69,-42.16 218.19,-46.49"/>
+ </g>
+ </g>
+</svg>