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
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
<?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="1715pt" height="302pt"
viewBox="0.00 0.00 1715.00 302.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 298)">
<title>Mir</title>
<polygon fill="white" stroke="none" points="-4,4 -4,-298 1711,-298 1711,4 -4,4"/>
<!-- BB0 -->
<g id="node1" class="node"><title>BB0</title>
<polygon fill="none" stroke="black" points="478.5,-268.5 478.5,-289.5 1053.5,-289.5 1053.5,-268.5 478.5,-268.5"/>
<text text-anchor="start" x="753.5" y="-276.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₀</text>
<polygon fill="none" stroke="black" points="478.5,-247.5 478.5,-268.5 1053.5,-268.5 1053.5,-247.5 478.5,-247.5"/>
<text text-anchor="start" x="481.5" y="-254.3" font-family="Times,serif" font-size="14.00">Var₀ = Arg₀</text>
<polygon fill="cornsilk" stroke="none" points="478.5,-226.5 478.5,-247.5 1053.5,-247.5 1053.5,-226.5 478.5,-226.5"/>
<polygon fill="none" stroke="black" points="478.5,-226.5 478.5,-247.5 1053.5,-247.5 1053.5,-226.5 478.5,-226.5"/>
<text text-anchor="start" x="481.5" y="-233.3" font-family="Times,serif" font-size="14.00">switchInt(Var₀, [Uint(5), Uint(10), Uint(15), Uint(20), Uint(30)]) &#45;&gt; [BB₃, BB₃, BB₃, BB₄, BB₄, BB₅]</text>
</g>
<!-- BB3 -->
<g id="node4" class="node"><title>BB3</title>
<polygon fill="none" stroke="black" points="8.5,-146.5 8.5,-167.5 549.5,-167.5 549.5,-146.5 8.5,-146.5"/>
<text text-anchor="start" x="266.5" y="-154.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₃</text>
<polygon fill="none" stroke="black" points="8.5,-125.5 8.5,-146.5 549.5,-146.5 549.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 = Constant { span: test.rs:50:24: 50:25, ty: usize, literal: Value { value: Uint(3) } }</text>
<polygon fill="cornsilk" stroke="none" points="8.5,-104.5 8.5,-125.5 549.5,-125.5 549.5,-104.5 8.5,-104.5"/>
<polygon fill="none" stroke="black" points="8.5,-104.5 8.5,-125.5 549.5,-125.5 549.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>
<!-- BB0&#45;&gt;BB3 -->
<g id="edge1" class="edge"><title>BB0&#45;&gt;BB3</title>
<path fill="none" stroke="black" d="M625.293,-222.952C563.679,-207.77 491.235,-189.919 428.536,-174.47"/>
<polygon fill="black" stroke="black" points="429.108,-171.006 418.561,-172.012 427.433,-177.803 429.108,-171.006"/>
<text text-anchor="middle" x="554" y="-193.8" font-family="Times,serif" font-size="14.00">0</text>
</g>
<!-- BB0&#45;&gt;BB3 -->
<g id="edge2" class="edge"><title>BB0&#45;&gt;BB3</title>
<path fill="none" stroke="black" d="M670.047,-222.933C636.078,-211.429 597.361,-199.213 561.5,-190 539.479,-184.342 516.346,-179.037 493.191,-174.138"/>
<polygon fill="black" stroke="black" points="493.775,-170.684 483.27,-172.064 492.342,-177.536 493.775,-170.684"/>
<text text-anchor="middle" x="616" y="-193.8" font-family="Times,serif" font-size="14.00">1</text>
</g>
<!-- BB0&#45;&gt;BB3 -->
<g id="edge3" class="edge"><title>BB0&#45;&gt;BB3</title>
<path fill="none" stroke="black" d="M703.12,-222.991C678.893,-210.896 650.512,-198.278 623.5,-190 604.459,-184.165 584.62,-178.962 564.501,-174.327"/>
<polygon fill="black" stroke="black" points="565.129,-170.88 554.605,-172.096 563.59,-177.709 565.129,-170.88"/>
<text text-anchor="middle" x="667" y="-193.8" font-family="Times,serif" font-size="14.00">2</text>
</g>
<!-- BB4 -->
<g id="node5" class="node"><title>BB4</title>
<polygon fill="none" stroke="black" points="583.5,-146.5 583.5,-167.5 1124.5,-167.5 1124.5,-146.5 583.5,-146.5"/>
<text text-anchor="start" x="841.5" y="-154.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₄</text>
<polygon fill="none" stroke="black" points="583.5,-125.5 583.5,-146.5 1124.5,-146.5 1124.5,-125.5 583.5,-125.5"/>
<text text-anchor="start" x="586.5" y="-132.3" font-family="Times,serif" font-size="14.00">ReturnPointer = Constant { span: test.rs:51:20: 51:21, ty: usize, literal: Value { value: Uint(2) } }</text>
<polygon fill="cornsilk" stroke="none" points="583.5,-104.5 583.5,-125.5 1124.5,-125.5 1124.5,-104.5 583.5,-104.5"/>
<polygon fill="none" stroke="black" points="583.5,-104.5 583.5,-125.5 1124.5,-125.5 1124.5,-104.5 583.5,-104.5"/>
<text text-anchor="start" x="586.5" y="-111.3" font-family="Times,serif" font-size="14.00">goto &#45;&gt; BB₁</text>
</g>
<!-- BB0&#45;&gt;BB4 -->
<g id="edge4" class="edge"><title>BB0&#45;&gt;BB4</title>
<path fill="none" stroke="black" d="M786.88,-222.966C793.831,-212.22 801.756,-200.453 809.5,-190 811.969,-186.667 814.582,-183.269 817.253,-179.883"/>
<polygon fill="black" stroke="black" points="820.016,-182.033 823.554,-172.046 814.56,-177.647 820.016,-182.033"/>
<text text-anchor="middle" x="813" y="-193.8" font-family="Times,serif" font-size="14.00">3</text>
</g>
<!-- BB0&#45;&gt;BB4 -->
<g id="edge5" class="edge"><title>BB0&#45;&gt;BB4</title>
<path fill="none" stroke="black" d="M801.709,-222.794C806.936,-217.07 812.046,-211.031 816.5,-205 821.981,-197.579 827.196,-189.253 831.891,-181.048"/>
<polygon fill="black" stroke="black" points="834.985,-182.685 836.768,-172.242 828.861,-179.294 834.985,-182.685"/>
<text text-anchor="middle" x="829" y="-193.8" font-family="Times,serif" font-size="14.00">4</text>
</g>
<!-- BB5 -->
<g id="node6" class="node"><title>BB5</title>
<polygon fill="none" stroke="black" points="1158.5,-146.5 1158.5,-167.5 1699.5,-167.5 1699.5,-146.5 1158.5,-146.5"/>
<text text-anchor="start" x="1416.5" y="-154.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₅</text>
<polygon fill="none" stroke="black" points="1158.5,-125.5 1158.5,-146.5 1699.5,-146.5 1699.5,-125.5 1158.5,-125.5"/>
<text text-anchor="start" x="1161.5" y="-132.3" font-family="Times,serif" font-size="14.00">ReturnPointer = Constant { span: test.rs:52:14: 52:15, ty: usize, literal: Value { value: Uint(1) } }</text>
<polygon fill="cornsilk" stroke="none" points="1158.5,-104.5 1158.5,-125.5 1699.5,-125.5 1699.5,-104.5 1158.5,-104.5"/>
<polygon fill="none" stroke="black" points="1158.5,-104.5 1158.5,-125.5 1699.5,-125.5 1699.5,-104.5 1158.5,-104.5"/>
<text text-anchor="start" x="1161.5" y="-111.3" font-family="Times,serif" font-size="14.00">goto &#45;&gt; BB₁</text>
</g>
<!-- BB0&#45;&gt;BB5 -->
<g id="edge6" class="edge"><title>BB0&#45;&gt;BB5</title>
<path fill="none" stroke="black" d="M956.378,-222.952C1041.47,-207.551 1141.73,-189.404 1227.92,-173.804"/>
<polygon fill="black" stroke="black" points="1228.61,-177.237 1237.82,-172.012 1227.36,-170.349 1228.61,-177.237"/>
<text text-anchor="middle" x="1140" y="-193.8" font-family="Times,serif" font-size="14.00">5</text>
</g>
<!-- BB1 -->
<g id="node2" class="node"><title>BB1</title>
<polygon fill="none" stroke="black" points="834.5,-25 834.5,-46 873.5,-46 873.5,-25 834.5,-25"/>
<text text-anchor="start" x="841.5" y="-32.8" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₁</text>
<polygon fill="cornsilk" stroke="none" points="834.5,-4 834.5,-25 873.5,-25 873.5,-4 834.5,-4"/>
<polygon fill="none" stroke="black" points="834.5,-4 834.5,-25 873.5,-25 873.5,-4 834.5,-4"/>
<text text-anchor="start" x="837.5" y="-10.8" font-family="Times,serif" font-size="14.00">return</text>
</g>
<!-- BB2 -->
<g id="node3" class="node"><title>BB2</title>
<polygon fill="none" stroke="black" points="1087.5,-258.5 1087.5,-279.5 1134.5,-279.5 1134.5,-258.5 1087.5,-258.5"/>
<text text-anchor="start" x="1098.5" y="-266.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₂</text>
<polygon fill="cornsilk" stroke="none" points="1087.5,-237.5 1087.5,-258.5 1134.5,-258.5 1134.5,-237.5 1087.5,-237.5"/>
<polygon fill="none" stroke="black" points="1087.5,-237.5 1087.5,-258.5 1134.5,-258.5 1134.5,-237.5 1087.5,-237.5"/>
<text text-anchor="start" x="1090.5" y="-244.3" font-family="Times,serif" font-size="14.00">diverge</text>
</g>
<!-- BB3&#45;&gt;BB1 -->
<g id="edge7" class="edge"><title>BB3&#45;&gt;BB1</title>
<path fill="none" stroke="black" d="M460.039,-100.929C586.45,-76.8555 744.639,-46.731 815.778,-33.1836"/>
<polygon fill="black" stroke="black" points="816.459,-36.6168 825.628,-31.3078 815.15,-29.7404 816.459,-36.6168"/>
<text text-anchor="middle" x="621" y="-71.8" font-family="Times,serif" font-size="14.00">0</text>
</g>
<!-- BB4&#45;&gt;BB1 -->
<g id="edge8" class="edge"><title>BB4&#45;&gt;BB1</title>
<path fill="none" stroke="black" d="M853.5,-100.854C853.5,-87.9306 853.5,-73.2725 853.5,-60.3742"/>
<polygon fill="black" stroke="black" points="857,-60.0302 853.5,-50.0302 850,-60.0303 857,-60.0302"/>
<text text-anchor="middle" x="857" y="-71.8" font-family="Times,serif" font-size="14.00">0</text>
</g>
<!-- BB5&#45;&gt;BB1 -->
<g id="edge9" class="edge"><title>BB5&#45;&gt;BB1</title>
<path fill="none" stroke="black" d="M1246.96,-100.929C1120.55,-76.8555 962.361,-46.731 891.222,-33.1836"/>
<polygon fill="black" stroke="black" points="891.85,-29.7404 881.372,-31.3078 890.541,-36.6168 891.85,-29.7404"/>
<text text-anchor="middle" x="1144" y="-71.8" font-family="Times,serif" font-size="14.00">0</text>
</g>
</g>
</svg>
#![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