qbe

Internal scc patchset buffer for QBE
Log | Files | Refs | README | LICENSE

eucl.ssa (375B)


      1 # euclide's algorithm in ssa
      2 # it is a fairly interesting
      3 # ssa program because of the
      4 # swap of b and a
      5 
      6 export
      7 function $test() {
      8 @start
      9 
     10 @loop
     11 	%a =w phi @start 380, @loop %r
     12 	%b =w phi @start 747, @loop %a
     13 	%r =w rem %b, %a
     14 	jnz %r, @loop, @end
     15 
     16 @end
     17 	storew %a, $a
     18 	ret
     19 }
     20 
     21 # >>> driver
     22 # extern void test(void);
     23 # int a;
     24 # int main() { test(); return !(a == 1); }
     25 # <<<