Short-Language Compiler - a toy language compiler LLVM frontend

Short-Language Compiler - a toy language compiler LLVM frontend

fn fib(int i) : int
{
  if i <= 2 {
    ret 1;
  }
  ret fib(i-1)+fib(i-2);
}


fn fib_iter(int val) : int
{
  if val < 3 { ret 1; }
  var fib_1 = 1, fib_2 = 1, res = 0;
  var i : int;
  for i = 3; i <= val; ++i {
    res = fib_1 + fib_2;
    fib_2 = fib_1;
    fib_1 = res;
  }
  ret res;
}
Information updated 12/27/19
Note: This entry has not yet been moderated.
View Comments