qbe

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

abi1.ssa (1257B)


      1 # test calling into C with two
      2 # large struct arguments (passed
      3 # on the stack)
      4 
      5 type :mem = { b 17 }
      6 
      7 function $alpha(l %p, w %l, l %n) {
      8 @ini
      9 	%pe =l add %p, %n
     10 @lop
     11 	%p1 =l phi @ini %p, @lop %p2
     12 	%l1 =w phi @ini %l, @lop %l2
     13 	storeb %l1, %p1
     14 	%p2 =l add %p1, 1
     15 	%l2 =w add %l1, 1
     16 	%c1 =w ceql %p1, %pe
     17 	jnz %c1, @end, @lop
     18 @end
     19 	storeb 0, %pe
     20 	ret
     21 }
     22 
     23 export
     24 function $test() {
     25 @start
     26 	%p =l alloc4 17
     27 	%q =l alloc4 17
     28 	%r0 =w call $alpha(l %p, w 65, l 16)
     29 	%r1 =w call $alpha(l %q, w 97, l 16)
     30 	%r2 =w call $fcb(:mem %p, w 1, w 2, w 3, w 4, w 5, w 6, w 7, w 8, w 9, :mem %q)
     31 	ret
     32 }
     33 
     34 
     35 # >>> driver
     36 # #include <stdio.h>
     37 # typedef struct { char t[17]; } mem;
     38 # extern void test();
     39 # void fcb(mem m, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, mem n) {
     40 # 	printf("fcb: m = (mem){ t = \"%s\" }\n", m.t);
     41 # 	printf("     n = (mem){ t = \"%s\" }\n", n.t);
     42 # 	#define T(n) printf("     i%d = %d\n", n, i##n);
     43 # 	T(1) T(2) T(3) T(4) T(5) T(6) T(7) T(8) T(9)
     44 # }
     45 # int main() { test(); return 0; }
     46 # <<<
     47 
     48 # >>> output
     49 # fcb: m = (mem){ t = "ABCDEFGHIJKLMNOP" }
     50 #      n = (mem){ t = "abcdefghijklmnop" }
     51 #      i1 = 1
     52 #      i2 = 2
     53 #      i3 = 3
     54 #      i4 = 4
     55 #      i5 = 5
     56 #      i6 = 6
     57 #      i7 = 7
     58 #      i8 = 8
     59 #      i9 = 9
     60 # <<<