kit

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

glob_array.c (392B)


      1 /* glob: read a file-scope (non-const) global int array. Codegen materializes
      2  * the array base with adrp/add (ADR_PREL_PG_HI21 + ADD_ABS_LO12_NC against
      3  * `tab`) and indexes it with scaled loads. A volatile index defeats folding.
      4  * Exit: tab[2] + tab[4] = 13 + 29 = 42. */
      5 int tab[6] = {5, 9, 13, 17, 29, 31};
      6 int test_main(void) {
      7   volatile int i = 2, j = 4;
      8   return tab[i] + tab[j];
      9 }