Created
December 29, 2015 00:17
-
-
Save solson/480175dcf7639df69906 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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="635pt" height="323pt" | |
viewBox="0.00 0.00 635.00 323.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 319)"> | |
<title>Mir</title> | |
<polygon fill="white" stroke="none" points="-4,4 -4,-319 631,-319 631,4 -4,4"/> | |
<text text-anchor="start" x="8" y="-82.8" font-family="monospace" font-size="14.00">fn(a0: &mut [closure@test.rs:37:20: 37:38], a1: usize, a2: usize) -> usize</text> | |
<text text-anchor="start" x="8" y="-67.8" font-family="monospace" font-size="14.00">let v0: usize; // prod</text> | |
<text text-anchor="start" x="8" y="-52.8" font-family="monospace" font-size="14.00">let v1: usize; // x</text> | |
<text text-anchor="start" x="8" y="-37.8" font-family="monospace" font-size="14.00">let t0: ();</text> | |
<text text-anchor="start" x="8" y="-22.8" font-family="monospace" font-size="14.00">let t1: usize;</text> | |
<text text-anchor="start" x="8" y="-7.8" font-family="monospace" font-size="14.00">let t2: usize;</text> | |
<!-- bb0 --> | |
<g id="node1" class="node"><title>bb0</title> | |
<polygon fill="gray" stroke="none" points="150.25,-289.5 150.25,-310.5 379.25,-310.5 379.25,-289.5 150.25,-289.5"/> | |
<polygon fill="none" stroke="black" points="150.25,-289.5 150.25,-310.5 379.25,-310.5 379.25,-289.5 150.25,-289.5"/> | |
<text text-anchor="start" x="260.25" y="-296.3" font-family="monospace" font-size="14.00">0</text> | |
<polygon fill="none" stroke="black" points="150.25,-208.5 150.25,-289.5 379.25,-289.5 379.25,-208.5 150.25,-208.5"/> | |
<text text-anchor="start" x="153.25" y="-275.3" font-family="monospace" font-size="14.00">v0 = a0</text> | |
<text text-anchor="start" x="153.25" y="-260.3" font-family="monospace" font-size="14.00">v1 = a1</text> | |
<text text-anchor="start" x="153.25" y="-245.3" font-family="monospace" font-size="14.00">t1 = v0</text> | |
<text text-anchor="start" x="153.25" y="-230.3" font-family="monospace" font-size="14.00">t2 = v1</text> | |
<text text-anchor="start" x="153.25" y="-215.3" font-family="monospace" font-size="14.00">ReturnPointer = Mul(t1, t2)</text> | |
<polygon fill="none" stroke="black" points="150.25,-187.5 150.25,-208.5 379.25,-208.5 379.25,-187.5 150.25,-187.5"/> | |
<text text-anchor="start" x="153.25" y="-194.3" font-family="monospace" font-size="14.00">goto</text> | |
</g> | |
<!-- bb1 --> | |
<g id="node2" class="node"><title>bb1</title> | |
<polygon fill="gray" stroke="none" points="236.25,-123 236.25,-144 292.25,-144 292.25,-123 236.25,-123"/> | |
<polygon fill="none" stroke="black" points="236.25,-123 236.25,-144 292.25,-144 292.25,-123 236.25,-123"/> | |
<text text-anchor="start" x="259.75" y="-129.8" font-family="monospace" font-size="14.00">1</text> | |
<polygon fill="none" stroke="black" points="236.25,-102 236.25,-123 292.25,-123 292.25,-102 236.25,-102"/> | |
<text text-anchor="start" x="239.25" y="-108.8" font-family="monospace" font-size="14.00">return</text> | |
</g> | |
<!-- bb0->bb1 --> | |
<g id="edge1" class="edge"><title>bb0->bb1</title> | |
<path fill="none" stroke="black" d="M264.25,-183.697C264.25,-175.005 264.25,-166.378 264.25,-158.498"/> | |
<polygon fill="black" stroke="black" points="267.75,-158.278 264.25,-148.278 260.75,-158.278 267.75,-158.278"/> | |
</g> | |
<!-- bb2 --> | |
<g id="node3" class="node"><title>bb2</title> | |
<polygon fill="gray" stroke="none" points="413.25,-249.5 413.25,-270.5 477.25,-270.5 477.25,-249.5 413.25,-249.5"/> | |
<polygon fill="none" stroke="black" points="413.25,-249.5 413.25,-270.5 477.25,-270.5 477.25,-249.5 413.25,-249.5"/> | |
<text text-anchor="start" x="440.75" y="-256.3" font-family="monospace" font-size="14.00">2</text> | |
<polygon fill="none" stroke="black" points="413.25,-228.5 413.25,-249.5 477.25,-249.5 477.25,-228.5 413.25,-228.5"/> | |
<text text-anchor="start" x="416.25" y="-235.3" font-family="monospace" font-size="14.00">diverge</text> | |
</g> | |
</g> | |
</svg> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![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, | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment