qbe

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

abi4.ssa (612B)


      1 # return a large struct to C
      2 
      3 type :mem = { b 17 }
      4 
      5 function $alpha(l %p, w %l, l %n) {
      6 @ini
      7 	%pe =l add %p, %n
      8 @lop
      9 	%p1 =l phi @ini %p, @lop %p2
     10 	%l1 =w phi @ini %l, @lop %l2
     11 	storeb %l1, %p1
     12 	%p2 =l add %p1, 1
     13 	%l2 =w add %l1, 1
     14 	%c1 =w ceql %p1, %pe
     15 	jnz %c1, @end, @lop
     16 @end
     17 	storeb 0, %pe
     18 	ret
     19 }
     20 
     21 export
     22 function :mem $test() {
     23 @ini
     24 	%p =l alloc4 17
     25 	%r0 =w call $alpha(l %p, w 65, l 16)
     26 	ret %p
     27 }
     28 
     29 
     30 # >>> driver
     31 # #include <stdio.h>
     32 # typedef struct { char t[17]; } mem;
     33 # extern mem test(void);
     34 # int main() { mem m = test(); printf("%s\n", m.t); return 0; }
     35 # <<<
     36 
     37 # >>> output
     38 # ABCDEFGHIJKLMNOP
     39 # <<<