qbe

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

loop.ssa (357B)


      1 # simple looping program
      2 # sums all integers from 100 to 0
      3 
      4 export
      5 function $test() {
      6 @start
      7 
      8 @loop
      9 	%s  =w phi @start   0, @loop %s1
     10 	%n  =w phi @start 100, @loop %n1
     11 	%s1 =w add %s, %n
     12 	%n1 =w sub %n, 1
     13 	jnz %n1, @loop, @end
     14 
     15 @end
     16 	storew %s1, $a
     17 	ret
     18 }
     19 
     20 # >>> driver
     21 # extern void test(void);
     22 # int a;
     23 # int main() { test(); return !(a == 5050); }
     24 # <<<