kit

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

cg_native_inline_asm_machine_constraints.c (439B)


      1 int test_main(void) {
      2 #if defined(__aarch64__)
      3   double x = 1.0;
      4   double y = 2.0;
      5   __asm__ volatile("" : : "x"(x), "y"(y));
      6   return 42;
      7 #elif defined(__riscv) && __riscv_xlen == 64
      8   int a = 20;
      9   int b = 22;
     10   int out = 0;
     11   float fa = 1.0f;
     12   float fb = 2.0f;
     13   __asm__ volatile("add %0, %1, %2" : "=cr"(out) : "cr"(a), "cr"(b));
     14   __asm__ volatile("" : : "cf"(fa), "cf"(fb));
     15   return out == 42 ? 42 : 1;
     16 #else
     17   return 42;
     18 #endif
     19 }