abi1.ssa 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # test calling into C with two
  2. # large struct arguments (passed
  3. # on the stack)
  4. type :mem = { b 17 }
  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. export
  21. function $test() {
  22. @start
  23. %p =l alloc4 17
  24. %q =l alloc4 17
  25. %r0 =w call $alpha(l %p, w 65, l 16)
  26. %r1 =w call $alpha(l %q, w 97, l 16)
  27. %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)
  28. ret
  29. }
  30. # >>> driver
  31. # #include <stdio.h>
  32. # typedef struct { char t[17]; } mem;
  33. # extern void test();
  34. # void fcb(mem m, int i1, int i2, int i3, int i4, int i5, int i6, int i7, int i8, int i9, mem n) {
  35. # printf("fcb: m = (mem){ t = \"%s\" }\n", m.t);
  36. # printf(" n = (mem){ t = \"%s\" }\n", n.t);
  37. # #define T(n) printf(" i%d = %d\n", n, i##n);
  38. # T(1) T(2) T(3) T(4) T(5) T(6) T(7) T(8) T(9)
  39. # }
  40. # int main() { test(); return 0; }
  41. # <<<
  42. # >>> output
  43. # fcb: m = (mem){ t = "ABCDEFGHIJKLMNOP" }
  44. # n = (mem){ t = "abcdefghijklmnop" }
  45. # i1 = 1
  46. # i2 = 2
  47. # i3 = 3
  48. # i4 = 4
  49. # i5 = 5
  50. # i6 = 6
  51. # i7 = 7
  52. # i8 = 8
  53. # i9 = 9
  54. # <<<