kit

kit
git clone https://git.ryansepassi.com/git/kit.git
Log | Files | Refs | README

agg_ret.c (488B)


      1 /* A small struct (two ints, 8 bytes) RETURNED by value, returned in an integer
      2  * register per the AArch64 PCS. Exercises the callee packing the result and the
      3  * caller unpacking it. `noinline` forces a real call. r.a + r.b = 19 + 23 = 42.
      4  */
      5 struct Pair {
      6   int a;
      7   int b;
      8 };
      9 __attribute__((noinline)) static struct Pair mk(int x, int y) {
     10   struct Pair p = {x, y};
     11   return p;
     12 }
     13 int test_main(void) {
     14   volatile int x = 19, y = 23;
     15   struct Pair r = mk(x, y);
     16   return r.a + r.b;
     17 }