systems-nuts / unifico

Compiler and build harness for heterogeneous-ISA binaries with the same stack layout.
3 stars 1 forks source link

Moving 8-bit immediates to memory #304

Closed blackgeorge-boom closed 10 months ago

blackgeorge-boom commented 10 months ago
int main()
{
  lastrow  = NA-1;
  lastcol  = NA-1;

  printf(" Size: %11d\n", NA);

  naa = NA;
  nzz = NZ;
  randlc(&tran, amult);

  makea(naa, nzz, a, colidx, rowstr,
        0, lastrow, 0, lastcol,
        arow,
        (int (*)[NONZER+1])(void*)acol,
        (double (*)[NONZER+1])(void*)aelt,
        iv);

  return 0;
}
 make clean; make stackmaps-check -j10 OBJDUMP_FLAGS= OPT_LEVEL=-O1 TARGET_FUNC=main        

WARNING: main: callsite 0 has different number of architecture specific live locations (2 vs 1)
WARNING: main, callsite 0: arch-specific live value 0/0 has different location operand offset or constant (1 vs. 75000)
ERROR: stackmaps in 'main_aarch64_aligned.out' & 'main_x86_64_aligned.out' differ - different stack layout!
blackgeorge-boom commented 10 months ago

This is similar to https://github.com/systems-nuts/unifico/issues/104, but this time the immediate is 8-bit long:

AArch64:

  %1:gpr32 = MOVi32imm 1
  STRBBui %1:gpr32, %0:tcgpr64, target-flags(aarch64-pageoff, aarch64-nc) @lastrow, debug-location !72 :: (store 1 into @lastrow, align 4); main.c:91:12

X86:

  MOV8mi $rip, 1, $noreg, @lastrow, $noreg, 1, debug-location !72 :: (store 1 into @lastrow, align 4); main.c:91:12

AArch64 ends up using a CSR for the immediate:

  50103c:       mov w19, #0x1
...
  50104c:       strb    w19, [x8]