kit

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

call_indirect_arg_struct_field_two_parts.c (657B)


      1 /* Two-part DIRECT struct (16 bytes, two INT parts) passed via an
      2  * OPK_INDIRECT source operand. Exercises the multi-part load path:
      3  * each part must read from the same base register at distinct
      4  * `src_offset`s, so the base must survive across iterations. */
      5 typedef struct {
      6   unsigned long a;
      7   unsigned long b;
      8 } Pair;
      9 typedef struct {
     10   Pair p;
     11   int x;
     12 } Row;
     13 
     14 int sink(Pair v) { return (int)(v.a + v.b); }
     15 
     16 int call_pair(Row* row, int i) { return sink(row[i].p); }
     17 
     18 int test_main(void) {
     19   Row rows[2];
     20   rows[0].p.a = 30;
     21   rows[0].p.b = 12;
     22   rows[0].x = 0;
     23   rows[1].p.a = 99;
     24   rows[1].p.b = 99;
     25   rows[1].x = 0;
     26   return call_pair(rows, 0);
     27 }