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
<?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="718pt" height="293pt"
viewBox="0.00 0.00 718.00 293.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 289)">
<title>Mir</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-289 714,-289 714,4 -4,4"/>
<text text-anchor="start" x="8" y="-67.8" font-family="monospace" font-size="14.00">fn(a0: &amp;mut [closure@test.rs:43:21: 43:43 prod:&amp;mut usize], a1: (), a2: usize) &#45;&gt; ()</text>
<text text-anchor="start" x="8" y="-52.8" font-family="monospace" font-size="14.00">let v0: 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: ();</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="170.75,-260 170.75,-281 441.75,-281 441.75,-260 170.75,-260"/>
<polygon fill="none" stroke="black" points="170.75,-260 170.75,-281 441.75,-281 441.75,-260 170.75,-260"/>
<text text-anchor="start" x="301.75" y="-266.8" font-family="monospace" font-size="14.00">0</text>
<polygon fill="none" stroke="black" points="170.75,-194 170.75,-260 441.75,-260 441.75,-194 170.75,-194"/>
<text text-anchor="start" x="173.75" y="-245.8" font-family="monospace" font-size="14.00">v0 = a1</text>
<text text-anchor="start" x="173.75" y="-230.8" font-family="monospace" font-size="14.00">t2 = v0</text>
<text text-anchor="start" x="173.75" y="-215.8" font-family="monospace" font-size="14.00">(*(*a0).0) = Mul((*(*a0).0), t2)</text>
<text text-anchor="start" x="173.75" y="-200.8" font-family="monospace" font-size="14.00">drop t1</text>
<polygon fill="none" stroke="black" points="170.75,-173 170.75,-194 441.75,-194 441.75,-173 170.75,-173"/>
<text text-anchor="start" x="173.75" y="-179.8" 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="277.75,-108 277.75,-129 333.75,-129 333.75,-108 277.75,-108"/>
<polygon fill="none" stroke="black" points="277.75,-108 277.75,-129 333.75,-129 333.75,-108 277.75,-108"/>
<text text-anchor="start" x="301.25" y="-114.8" font-family="monospace" font-size="14.00">1</text>
<polygon fill="none" stroke="black" points="277.75,-87 277.75,-108 333.75,-108 333.75,-87 277.75,-87"/>
<text text-anchor="start" x="280.75" y="-93.8" font-family="monospace" 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="M305.75,-168.871C305.75,-160.078 305.75,-151.244 305.75,-143.164"/>
<polygon fill="black" stroke="black" points="309.25,-143.043 305.75,-133.043 302.25,-143.043 309.25,-143.043"/>
</g>
<!-- bb2 -->
<g id="node3" class="node"><title>bb2</title>
<polygon fill="gray" stroke="none" points="475.75,-227 475.75,-248 539.75,-248 539.75,-227 475.75,-227"/>
<polygon fill="none" stroke="black" points="475.75,-227 475.75,-248 539.75,-248 539.75,-227 475.75,-227"/>
<text text-anchor="start" x="503.25" y="-233.8" font-family="monospace" font-size="14.00">2</text>
<polygon fill="none" stroke="black" points="475.75,-206 475.75,-227 539.75,-227 539.75,-206 475.75,-206"/>
<text text-anchor="start" x="478.75" y="-212.8" font-family="monospace" 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.
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