Skip to content

Instantly share code, notes, and snippets.

@modocache
Created November 2, 2015 07:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save modocache/0b688175ca77cebc46f8 to your computer and use it in GitHub Desktop.
Save modocache/0b688175ca77cebc46f8 to your computer and use it in GitHub Desktop.
sil @fibonacci: $(Swift.Int) -> () {
entry(%limi: $Swift.Int):
%lim = struct_extract %limi: $Swift.Int, #Int.value
%print = function_ref @print: $(Swift.Int) -> ()
%a0 = integer_literal $Builtin.Int64, 0
%b0 = integer_literal $Builtin.Int64, 1
br loop(%a0: $Builtin.Int64, %b0: $Builtin.Int64)
loop(%a: $Builtin.Int64, %b: $Builtin.Int64):
%lt = builtin "icmp_lt_Int64"(%b: $Builtin.Int64, %lim: $Builtin.Int64): $Builtin.Int1
cond_br %lt: $Builtin.Int1, body, exit
body:
%b1 = struct $Swift.Int (%b: $Builtin.Int64)
apply %print(%b1) : $(Swift.Int) -> ()
%c = builtin "add_Int64"(%a: $Builtin.Int64, %b: $Builtin.Int64): $Builtin.Int64
br loop(%b: $Builtin.Int64, %c: $Builtin.Int64)
exit:
%unit = tuple ()
return %unit: $()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment