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="1643pt" height="564pt" | |
viewBox="0.00 0.00 1643.00 564.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 560)"> | |
<title>Mir</title> | |
<polygon fill="white" stroke="none" points="-4,4 -4,-560 1639,-560 1639,4 -4,4"/> | |
<!-- BB0 --> | |
<g id="node1" class="node"><title>BB0</title> | |
<polygon fill="none" stroke="black" points="35.5,-530.5 35.5,-551.5 606.5,-551.5 606.5,-530.5 35.5,-530.5"/> | |
<text text-anchor="start" x="308.5" y="-538.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₀</text> | |
<polygon fill="none" stroke="black" points="35.5,-509.5 35.5,-530.5 606.5,-530.5 606.5,-509.5 35.5,-509.5"/> | |
<text text-anchor="start" x="38.5" y="-516.3" font-family="Times,serif" font-size="14.00">Var₀ = Arg₀</text> | |
<polygon fill="none" stroke="black" points="35.5,-488.5 35.5,-509.5 606.5,-509.5 606.5,-488.5 35.5,-488.5"/> | |
<text text-anchor="start" x="38.5" y="-495.3" font-family="Times,serif" font-size="14.00">Temp₂ = Var₀</text> | |
<polygon fill="none" stroke="black" points="35.5,-467.5 35.5,-488.5 606.5,-488.5 606.5,-467.5 35.5,-467.5"/> | |
<text text-anchor="start" x="38.5" y="-474.3" font-family="Times,serif" font-size="14.00">Temp₁ = Eq(Temp₂,Constant { span: test.rs:19:13: 19:14, ty: usize, literal: Value { value: Uint(0) } })</text> | |
<polygon fill="cornsilk" stroke="none" points="35.5,-446.5 35.5,-467.5 606.5,-467.5 606.5,-446.5 35.5,-446.5"/> | |
<polygon fill="none" stroke="black" points="35.5,-446.5 35.5,-467.5 606.5,-467.5 606.5,-446.5 35.5,-446.5"/> | |
<text text-anchor="start" x="38.5" y="-453.3" font-family="Times,serif" font-size="14.00">if(Temp₁) -> (BB₃, BB₄)</text> | |
</g> | |
<!-- BB3 --> | |
<g id="node4" class="node"><title>BB3</title> | |
<polygon fill="none" stroke="black" points="8.5,-235.5 8.5,-256.5 543.5,-256.5 543.5,-235.5 8.5,-235.5"/> | |
<text text-anchor="start" x="263.5" y="-243.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₃</text> | |
<polygon fill="none" stroke="black" points="8.5,-214.5 8.5,-235.5 543.5,-235.5 543.5,-214.5 8.5,-214.5"/> | |
<text text-anchor="start" x="11.5" y="-221.3" font-family="Times,serif" font-size="14.00">ReturnPointer = Constant { span: test.rs:20:9: 20:10, ty: usize, literal: Value { value: Uint(1) } }</text> | |
<polygon fill="cornsilk" stroke="none" points="8.5,-193.5 8.5,-214.5 543.5,-214.5 543.5,-193.5 8.5,-193.5"/> | |
<polygon fill="none" stroke="black" points="8.5,-193.5 8.5,-214.5 543.5,-214.5 543.5,-193.5 8.5,-193.5"/> | |
<text text-anchor="start" x="11.5" y="-200.3" font-family="Times,serif" font-size="14.00">goto -> BB₁</text> | |
</g> | |
<!-- BB0->BB3 --> | |
<g id="edge1" class="edge"><title>BB0->BB3</title> | |
<path fill="none" stroke="black" d="M187.329,-442.823C168.188,-429.04 151.084,-412.256 139.5,-392 114.568,-348.403 111.093,-320.416 139.5,-279 142.19,-275.078 145.217,-271.45 148.519,-268.092"/> | |
<polygon fill="black" stroke="black" points="151.101,-270.475 156.158,-261.166 146.399,-265.29 151.101,-270.475"/> | |
<text text-anchor="middle" x="168" y="-413.8" font-family="Times,serif" font-size="14.00">0</text> | |
</g> | |
<!-- BB4 --> | |
<g id="node5" class="node"><title>BB4</title> | |
<polygon fill="none" stroke="black" points="156.5,-366.5 156.5,-387.5 1627.5,-387.5 1627.5,-366.5 156.5,-366.5"/> | |
<text text-anchor="start" x="879.5" y="-374.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₄</text> | |
<polygon fill="none" stroke="black" points="156.5,-345.5 156.5,-366.5 1627.5,-366.5 1627.5,-345.5 156.5,-345.5"/> | |
<text text-anchor="start" x="159.5" y="-352.3" font-family="Times,serif" font-size="14.00">Temp₃ = Var₀</text> | |
<polygon fill="none" stroke="black" points="156.5,-324.5 156.5,-345.5 1627.5,-345.5 1627.5,-324.5 156.5,-324.5"/> | |
<text text-anchor="start" x="159.5" y="-331.3" font-family="Times,serif" font-size="14.00">Temp₆ = Var₀</text> | |
<polygon fill="none" stroke="black" points="156.5,-303.5 156.5,-324.5 1627.5,-324.5 1627.5,-303.5 156.5,-303.5"/> | |
<text text-anchor="start" x="159.5" y="-310.3" font-family="Times,serif" font-size="14.00">Temp₅ = Sub(Temp₆,Constant { span: test.rs:22:37: 22:38, ty: usize, literal: Value { value: Uint(1) } })</text> | |
<polygon fill="cornsilk" stroke="none" points="156.5,-282.5 156.5,-303.5 1627.5,-303.5 1627.5,-282.5 156.5,-282.5"/> | |
<polygon fill="none" stroke="black" points="156.5,-282.5 156.5,-303.5 1627.5,-303.5 1627.5,-282.5 156.5,-282.5"/> | |
<text text-anchor="start" x="159.5" y="-289.3" font-family="Times,serif" font-size="14.00">Temp₄ = Constant { span: test.rs:22:13: 22:32, ty: fn(usize) -> usize {factorial_recursive}, literal: Item { def_id: DefId { krate: 0, node: DefIndex(8) => factorial_recursive }, kind: Function, substs: Substs[types=[[];[];[]], regions=[[];[];[]]] } }(Temp₅) -> (BB₅, BB₂)</text> | |
</g> | |
<!-- BB0->BB4 --> | |
<g id="edge2" class="edge"><title>BB0->BB4</title> | |
<path fill="none" stroke="black" d="M516.207,-442.975C570.874,-427.466 630.431,-410.569 685.664,-394.898"/> | |
<polygon fill="black" stroke="black" points="686.9,-398.186 695.565,-392.089 684.989,-391.452 686.9,-398.186"/> | |
<text text-anchor="middle" x="627" y="-413.8" font-family="Times,serif" font-size="14.00">1</text> | |
</g> | |
<!-- BB1 --> | |
<g id="node2" class="node"><title>BB1</title> | |
<polygon fill="none" stroke="black" points="566.5,-25 566.5,-46 605.5,-46 605.5,-25 566.5,-25"/> | |
<text text-anchor="start" x="573.5" y="-32.8" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₁</text> | |
<polygon fill="cornsilk" stroke="none" points="566.5,-4 566.5,-25 605.5,-25 605.5,-4 566.5,-4"/> | |
<polygon fill="none" stroke="black" points="566.5,-4 566.5,-25 605.5,-25 605.5,-4 566.5,-4"/> | |
<text text-anchor="start" x="569.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="705.5,-136.5 705.5,-157.5 752.5,-157.5 752.5,-136.5 705.5,-136.5"/> | |
<text text-anchor="start" x="716.5" y="-144.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₂</text> | |
<polygon fill="cornsilk" stroke="none" points="705.5,-115.5 705.5,-136.5 752.5,-136.5 752.5,-115.5 705.5,-115.5"/> | |
<polygon fill="none" stroke="black" points="705.5,-115.5 705.5,-136.5 752.5,-136.5 752.5,-115.5 705.5,-115.5"/> | |
<text text-anchor="start" x="708.5" y="-122.3" font-family="Times,serif" font-size="14.00">diverge</text> | |
</g> | |
<!-- BB3->BB1 --> | |
<g id="edge3" class="edge"><title>BB3->BB1</title> | |
<path fill="none" stroke="black" d="M329.498,-189.924C392.598,-149.52 495.253,-83.7871 549.411,-49.1087"/> | |
<polygon fill="black" stroke="black" points="551.455,-51.9556 557.99,-43.6156 547.681,-46.0605 551.455,-51.9556"/> | |
<text text-anchor="middle" x="467" y="-132.8" font-family="Times,serif" font-size="14.00">0</text> | |
</g> | |
<!-- BB4->BB2 --> | |
<g id="edge5" class="edge"><title>BB4->BB2</title> | |
<path fill="none" stroke="black" d="M845.444,-278.838C816.187,-243.477 779.36,-198.969 754.933,-169.447"/> | |
<polygon fill="black" stroke="black" points="757.46,-167.011 748.389,-161.538 752.067,-171.473 757.46,-167.011"/> | |
<text text-anchor="middle" x="832" y="-221.8" font-family="Times,serif" font-size="14.00">1</text> | |
</g> | |
<!-- BB5 --> | |
<g id="node6" class="node"><title>BB5</title> | |
<polygon fill="none" stroke="black" points="786.5,-146.5 786.5,-167.5 997.5,-167.5 997.5,-146.5 786.5,-146.5"/> | |
<text text-anchor="start" x="879.5" y="-154.3" font-family="Times,serif" font-weight="bold" font-size="14.00">BB₅</text> | |
<polygon fill="none" stroke="black" points="786.5,-125.5 786.5,-146.5 997.5,-146.5 997.5,-125.5 786.5,-125.5"/> | |
<text text-anchor="start" x="789.5" y="-132.3" font-family="Times,serif" font-size="14.00">ReturnPointer = Mul(Temp₃,Temp₄)</text> | |
<polygon fill="cornsilk" stroke="none" points="786.5,-104.5 786.5,-125.5 997.5,-125.5 997.5,-104.5 786.5,-104.5"/> | |
<polygon fill="none" stroke="black" points="786.5,-104.5 786.5,-125.5 997.5,-125.5 997.5,-104.5 786.5,-104.5"/> | |
<text text-anchor="start" x="789.5" y="-111.3" font-family="Times,serif" font-size="14.00">goto -> BB₁</text> | |
</g> | |
<!-- BB4->BB5 --> | |
<g id="edge4" class="edge"><title>BB4->BB5</title> | |
<path fill="none" stroke="black" d="M891.5,-278.838C891.5,-248.336 891.5,-211.028 891.5,-182.403"/> | |
<polygon fill="black" stroke="black" points="895,-182.278 891.5,-172.278 888,-182.278 895,-182.278"/> | |
<text text-anchor="middle" x="895" y="-221.8" font-family="Times,serif" font-size="14.00">0</text> | |
</g> | |
<!-- BB5->BB1 --> | |
<g id="edge6" class="edge"><title>BB5->BB1</title> | |
<path fill="none" stroke="black" d="M794.68,-100.854C736.324,-79.9713 665.306,-54.5581 622.837,-39.361"/> | |
<polygon fill="black" stroke="black" points="623.79,-35.9844 613.195,-35.9105 621.431,-42.5752 623.79,-35.9844"/> | |
<text text-anchor="middle" x="742" y="-71.8" font-family="Times,serif" font-size="14.00">0</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