daily pastebin goal
21%
SHARE
TWEET

Untitled

a guest Jan 19th, 2018 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // source code
  2. i32 fib(i32 number)
  3. {
  4.     if (number < 1) return 0;
  5.     if (number < 3) return 1;
  6.     return fib(number-1) + fib(number-2);
  7. }
  8.  
  9. // Generated from AST directly
  10. function i32 $fib (i32 number)
  11. {
  12.   @start
  13.   @ifstmt_1
  14.     lit_3 = 1
  15.     temp_4 = LESS number_2, lit_3
  16.     jnz temp_4, @ift_1, @ifend_1
  17.   @ift_1
  18.     lit_5 = 0
  19.     ret lit_5
  20.   @ifend_1
  21.   @ifstmt_6
  22.     lit_8 = 3
  23.     temp_9 = LESS number_7, lit_8
  24.     jnz temp_9, @ift_6, @ifend_6
  25.   @ift_6
  26.     lit_10 = 1
  27.     ret lit_10
  28.   @ifend_6
  29.   lit_12 = 1
  30.   temp_13 = MINUS number_11, lit_12
  31.   res_14 = call fib (temp_13)
  32.   lit_16 = 2
  33.   temp_17 = MINUS number_15, lit_16
  34.   res_18 = call fib (temp_17)
  35.   temp_19 = PLUS res_14, res_18
  36.   ret temp_19
  37. }
  38.  
  39. // Generated from binary IR
  40. function i32 $fib (i32 %number) {
  41.   @start
  42.     %__tmp_1 = lt %number, 1
  43.     jnz %__tmp_1 @then_1, @blk_1
  44.   @then_1
  45.     return 0
  46.   @blk_1
  47.     %__tmp_2 = lt %number, 3
  48.     jnz %__tmp_2 @then_2, @blk_2
  49.   @then_2
  50.     return 1
  51.   @blk_2
  52.     %__tmp_3 = sub %number, 1
  53.     %__tmp_4 = call $fib(%__tmp_3)
  54.     %__tmp_5 = sub %number, 2
  55.     %__tmp_6 = call $fib(%__tmp_5)
  56.     %__tmp_7 = add %__tmp_4, %__tmp_6
  57.     return %__tmp_7
  58. }
  59.  
  60. // timing
  61. parse 118us
  62. print 0.00ys
  63. semantic insert 21.0us
  64. semantic lookup 14.3us
  65. semantic types 7.10us
  66. print2 500ns
  67. IR text gen 246us
  68. IR bin gen 28.2us
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top