kit

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

mem_widths.c (743B)


      1 /* mem: stores then loads at all four integer widths through a pointer, forcing
      2  * the 8/16/32/64-bit store + load forms.
      3  *
      4  * Volatile-qualified storage defeats store-to-load forwarding so each width
      5  * genuinely emits its own store and load. Stack slots use the unscaled
      6  * forms: sturb/ldurb (8-bit), sturh/ldurh (16-bit), stur w/ldur w (32-bit),
      7  * stur x/ldur x (64-bit). Each width's distinct opcode must round-trip.
      8  * Values are chosen so the sum is 42.
      9  *   c  = 5, s = 6, i = 9, l = 22   -> 5+6+9+22 = 42 */
     10 int test_main(void) {
     11   volatile unsigned char c = 5;
     12   volatile unsigned short s = 6;
     13   volatile unsigned int i = 9;
     14   volatile unsigned long l = 22;
     15   unsigned long sum = (unsigned long)c + s + i + l;
     16   return (int)sum;
     17 }