kit

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

mem_global_array.c (451B)


      1 /* mem: read from a file-scope (global) array. Codegen materializes the array
      2  * base with adrp/add (ADR_PREL_PG_HI21 + ADD_ABS_LO12_NC against `tab`) then
      3  * indexes it; the loads against an initialized .data/.rodata array exercise
      4  * symbolic addressing plus a scaled load. Exit: tab[3] + tab[5] = 20 + 22 = 42.
      5  */
      6 static int tab[8] = {10, 12, 14, 20, 18, 22, 24, 26};
      7 int test_main(void) {
      8   volatile int i = 3, j = 5;
      9   return tab[i] + tab[j];
     10 }