Created
January 4, 2011 07:51
-
-
Save oskimura/764512 to your computer and use it in GitHub Desktop.
fib.llvm
This file contains hidden or 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
| define i32 @fib(i32 %n) | |
| { | |
| %1 = icmp ule i32 %n, 1 | |
| br i1 %1, label %b1, label %b2 | |
| b1: | |
| ret i32 %n | |
| b2: | |
| %2 = sub i32 %n, 1 | |
| %3 = call i32 @fib(i32 %2) | |
| %4 = sub i32 %n, 2 | |
| %5 = call i32 @fib(i32 %4) | |
| %retval = add i32 %3, %5 | |
| ret i32 %retval | |
| } | |
| @.LC0 = internal constant [4 x i8] c"%d\0A\00" | |
| declare i32 @printf(i8 *, ...) | |
| define i32 @main() | |
| { | |
| %1 = call i32 @fib(i32 10) | |
| %cast210 = getelementptr [4 x i8]* @.LC0, i64 0, i64 0 | |
| call i32 (i8 *, ...)* @printf(i8 * %cast210,i32 %1, i32 0) | |
| ret i32 0 | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment