Skip to content

Instantly share code, notes, and snippets.

@solson
Created December 29, 2015 00:17
Show Gist options
  • Save solson/480175dcf7639df69906 to your computer and use it in GitHub Desktop.
Save solson/480175dcf7639df69906 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
<?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.38.0 (20140413.2041)
-->
<!-- Title: Mir Pages: 1 -->
<svg width="316pt" height="264pt"
viewBox="0.00 0.00 316.00 264.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<g id="graph0" class="graph" transform="scale(1 1) rotate(0) translate(4 260)">
<title>Mir</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-260 312,-260 312,4 -4,4"/>
<!-- BB0 -->
<g id="node1" class="node"><title>BB0</title>
<polygon fill="none" stroke="black" points="8.5,-230.5 8.5,-251.5 219.5,-251.5 219.5,-230.5 8.5,-230.5"/>
<text text-anchor="start" x="101.5" y="-238.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₀</text>
<polygon fill="none" stroke="black" points="8.5,-209.5 8.5,-230.5 219.5,-230.5 219.5,-209.5 8.5,-209.5"/>
<text text-anchor="start" x="11.5" y="-216.3" font-family="Times,serif" font-size="14.00">Var₀ = Arg₀</text>
<polygon fill="none" stroke="black" points="8.5,-188.5 8.5,-209.5 219.5,-209.5 219.5,-188.5 8.5,-188.5"/>
<text text-anchor="start" x="11.5" y="-195.3" font-family="Times,serif" font-size="14.00">Var₁ = Arg₁</text>
<polygon fill="none" stroke="black" points="8.5,-167.5 8.5,-188.5 219.5,-188.5 219.5,-167.5 8.5,-167.5"/>
<text text-anchor="start" x="11.5" y="-174.3" font-family="Times,serif" font-size="14.00">Temp₁ = Var₀</text>
<polygon fill="none" stroke="black" points="8.5,-146.5 8.5,-167.5 219.5,-167.5 219.5,-146.5 8.5,-146.5"/>
<text text-anchor="start" x="11.5" y="-153.3" font-family="Times,serif" font-size="14.00">Temp₂ = Var₁</text>
<polygon fill="none" stroke="black" points="8.5,-125.5 8.5,-146.5 219.5,-146.5 219.5,-125.5 8.5,-125.5"/>
<text text-anchor="start" x="11.5" y="-132.3" font-family="Times,serif" font-size="14.00">ReturnPointer = Mul(Temp₁,Temp₂)</text>
<polygon fill="cornsilk" stroke="none" points="8.5,-104.5 8.5,-125.5 219.5,-125.5 219.5,-104.5 8.5,-104.5"/>
<polygon fill="none" stroke="black" points="8.5,-104.5 8.5,-125.5 219.5,-125.5 219.5,-104.5 8.5,-104.5"/>
<text text-anchor="start" x="11.5" y="-111.3" font-family="Times,serif" font-size="14.00">goto &#45;&gt; BB₁</text>
</g>
<!-- BB1 -->
<g id="node2" class="node"><title>BB1</title>
<polygon fill="none" stroke="black" points="94.5,-25 94.5,-46 133.5,-46 133.5,-25 94.5,-25"/>
<text text-anchor="start" x="101.5" y="-32.8" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₁</text>
<polygon fill="cornsilk" stroke="none" points="94.5,-4 94.5,-25 133.5,-25 133.5,-4 94.5,-4"/>
<polygon fill="none" stroke="black" points="94.5,-4 94.5,-25 133.5,-25 133.5,-4 94.5,-4"/>
<text text-anchor="start" x="97.5" y="-10.8" font-family="Times,serif" font-size="14.00">return</text>
</g>
<!-- BB0&#45;&gt;BB1 -->
<g id="edge1" class="edge"><title>BB0&#45;&gt;BB1</title>
<path fill="none" stroke="black" d="M113.5,-100.862C113.5,-86.5577 113.5,-72.2953 113.5,-60.116"/>
<polygon fill="black" stroke="black" points="117,-60.0004 113.5,-50.0004 110,-60.0004 117,-60.0004"/>
<text text-anchor="middle" x="117" y="-71.8" font-family="Times,serif" font-size="14.00">0</text>
</g>
<!-- BB2 -->
<g id="node3" class="node"><title>BB2</title>
<polygon fill="none" stroke="black" points="253.5,-178.5 253.5,-199.5 300.5,-199.5 300.5,-178.5 253.5,-178.5"/>
<text text-anchor="start" x="264.5" y="-186.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₂</text>
<polygon fill="cornsilk" stroke="none" points="253.5,-157.5 253.5,-178.5 300.5,-178.5 300.5,-157.5 253.5,-157.5"/>
<polygon fill="none" stroke="black" points="253.5,-157.5 253.5,-178.5 300.5,-178.5 300.5,-157.5 253.5,-157.5"/>
<text text-anchor="start" x="256.5" y="-164.3" font-family="Times,serif" font-size="14.00">diverge</text>
</g>
</g>
</svg>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#![feature(rustc_attrs)]
#![allow(dead_code)]
#[rustc_mir(graphviz = "empty.dot")]
fn empty() {}
#[rustc_mir(graphviz = "constant.dot")]
fn constant() -> i32 {
42
}
#[rustc_mir(graphviz = "increment.dot")]
fn increment(x: i32) -> i32 {
x + 1
}
#[rustc_mir(graphviz = "factorial_recursive.dot")]
fn factorial_recursive(n: usize) -> usize {
if n == 0 {
1
} else {
n * factorial_recursive(n - 1)
}
}
#[rustc_mir(graphviz = "factorial_iterative.dot")]
fn factorial_iterative(n: usize) -> usize {
let mut prod = 1;
for x in 1..n {
prod *= x;
}
prod
}
#[rustc_mir(graphviz = "factorial_fold.dot")]
fn factorial_fold(n: usize) -> usize {
(1..n).fold(1, |prod, x| prod * x)
}
#[rustc_mir(graphviz = "wat.dot")]
fn wat(n: usize) -> usize {
let mut prod = 1;
(1..n).fold((), |(), x| { prod *= x; });
prod
}
#[rustc_mir(graphviz = "multi_switch.dot")]
fn multi_switch(n: usize) -> usize {
match n {
5 | 10 | 15 => 3,
20 | 30 => 2,
_ => 1,
}
}
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment