diff --git a/tests/disas/winch/aarch64/memory_offsets/index.wat b/tests/disas/winch/aarch64/memory_offsets/index.wat new file mode 100644 index 000000000000..d727a3bb3c98 --- /dev/null +++ b/tests/disas/winch/aarch64/memory_offsets/index.wat @@ -0,0 +1,1334 @@ +;;! target = "aarch64" +;;! test = "winch" + +(module + (type (;0;) (func (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64))) + (global (;0;) (mut i32) i32.const 10) + (export "main" (func 0)) + (func (;0;) (type 0) (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64) + call 1 + call 1 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + br 0 + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + f64.const 0x1.54e5e9c49a8a3p+224 (;=35900759953881640000000000000000000000000000000000000000000000000000;) + f32.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + i64.const 0 + f64.const 0x0p+0 (;=0;) + ) + (func (;1;) (type 0) (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64) + f64.const 0x0p+0 (;=0;) + f32.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + i64.const 0 + f64.const 0x0p+0 (;=0;) + ) + (func (;2;) (type 0) (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64) + f64.const 0x0p+0 (;=0;) + f32.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + i64.const 0 + f64.const 0x0p+0 (;=0;) + ) +) +;; wasm[0]::function[0]: +;; stp x29, x30, [sp, #-0x10]! +;; mov x29, sp +;; str x28, [sp, #-0x10]! +;; mov x28, sp +;; ldur x16, [x1, #8] +;; ldur x16, [x16, #0x18] +;; mov x17, #0 +;; movk x17, #0xf10 +;; add x16, x16, x17 +;; cmp sp, x16 +;; b.lo #0x8a8 +;; 2c: mov x9, x1 +;; sub x28, x28, #0x18 +;; mov sp, x28 +;; stur x1, [x28, #0x10] +;; stur x2, [x28, #8] +;; stur x0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0x8c0 +;; 64: add x28, x28, #0xc +;; mov sp, x28 +;; ldur x9, [x28, #0x7c] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0x8c0 +;; 9c: add x28, x28, #8 +;; mov sp, x28 +;; ldur x9, [x28, #0xf0] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; d4: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0x164 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 108: ldr x9, [x28, #0x1d8] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 138: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0x24c +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 174: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0x2c0] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 1ac: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0x334 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 1e0: ldr x9, [x28, #0x3a8] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 210: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0x41c +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 24c: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0x490] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 284: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0x504 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 2b8: ldr x9, [x28, #0x578] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 2e8: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0x5ec +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 324: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0x660] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 35c: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0x6d4 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 390: ldr x9, [x28, #0x748] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 3c0: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0x7bc +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 3fc: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0x830] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 434: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0x8a4 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 468: ldr x9, [x28, #0x918] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 498: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0x98c +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 4d4: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0xa00] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 50c: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0xa74 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 540: ldr x9, [x28, #0xae8] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 570: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0xb5c +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 5ac: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0xbd0] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 5e4: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0xc44 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 618: ldr x9, [x28, #0xcb8] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 648: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0xd2c +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #8 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #8 +;; bl #0xaa0 +;; 684: add x28, x28, #8 +;; mov sp, x28 +;; ldr x9, [x28, #0xda0] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #4 +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #4 +;; bl #0xaa0 +;; 6bc: add x28, x28, #4 +;; mov sp, x28 +;; mov x16, #0xe14 +;; ldr x9, [x28, x16, sxtx] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0 +;; bl #0xaa0 +;; 6f0: ldr x9, [x28, #0xe88] +;; sub x28, x28, #8 +;; mov sp, x28 +;; stur d0, [x28] +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; sub x28, x28, #0xc +;; mov sp, x28 +;; mov x1, x9 +;; mov x2, x9 +;; add x0, x28, #0xc +;; bl #0xaa0 +;; 720: add x28, x28, #0xc +;; mov sp, x28 +;; mov x16, #0xefc +;; ldr x9, [x28, x16, sxtx] +;; ldur x16, [x28, #0x64] +;; mov x17, #0xee4 +;; str x16, [x28, x17, sxtx] +;; ldur w16, [x28, #0x60] +;; str w16, [x28, #0xee0] +;; ldur x16, [x28, #0x58] +;; str x16, [x28, #0xed8] +;; ldur x16, [x28, #0x50] +;; str x16, [x28, #0xed0] +;; ldur x16, [x28, #0x48] +;; str x16, [x28, #0xec8] +;; ldur x16, [x28, #0x40] +;; str x16, [x28, #0xec0] +;; ldur x16, [x28, #0x38] +;; str x16, [x28, #0xeb8] +;; ldur x16, [x28, #0x30] +;; str x16, [x28, #0xeb0] +;; ldur x16, [x28, #0x28] +;; str x16, [x28, #0xea8] +;; ldur x16, [x28, #0x20] +;; str x16, [x28, #0xea0] +;; ldur x16, [x28, #0x18] +;; str x16, [x28, #0xe98] +;; ldur x16, [x28, #0x10] +;; str x16, [x28, #0xe90] +;; ldur x16, [x28, #8] +;; str x16, [x28, #0xe88] +;; ldur x16, [x28] +;; str x16, [x28, #0xe80] +;; add x28, x28, #0xe80 +;; mov sp, x28 +;; ldur x0, [x28, #0x6c] +;; ldur x16, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur x16, [x0] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #8] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x10] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x18] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x20] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x28] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x30] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x38] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x40] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x48] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x50] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x58] +;; ldur s31, [x28] +;; add x28, x28, #4 +;; mov sp, x28 +;; stur s31, [x0, #0x60] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x64] +;; add x28, x28, #0x18 +;; mov sp, x28 +;; mov sp, x28 +;; ldr x28, [sp], #0x10 +;; ldp x29, x30, [sp], #0x10 +;; ret +;; 8a8: .byte 0x1f, 0xc1, 0x00, 0x00 +;; +;; wasm[0]::function[1]: +;; stp x29, x30, [sp, #-0x10]! +;; mov x29, sp +;; str x28, [sp, #-0x10]! +;; mov x28, sp +;; ldur x16, [x1, #8] +;; ldur x16, [x16, #0x18] +;; mov x17, #0 +;; movk x17, #0x84 +;; add x16, x16, x17 +;; cmp sp, x16 +;; b.lo #0xa7c +;; 8ec: mov x9, x1 +;; sub x28, x28, #0x18 +;; mov sp, x28 +;; stur x1, [x28, #0x10] +;; stur x2, [x28, #8] +;; stur x0, [x28] +;; ldr d0, #0xa80 +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x16, #0 +;; stur x16, [x28] +;; ldr d31, #0xa80 +;; stur d31, [x28, #8] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x10] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x18] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x20] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x28] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x30] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x38] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x40] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x48] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x50] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x58] +;; ldr s31, #0xa88 +;; stur s31, [x28, #0x60] +;; ldr d31, #0xa80 +;; stur d31, [x28, #0x64] +;; ldur x0, [x28, #0x6c] +;; ldur x16, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur x16, [x0] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #8] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x10] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x18] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x20] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x28] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x30] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x38] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x40] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x48] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x50] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x58] +;; ldur s31, [x28] +;; add x28, x28, #4 +;; mov sp, x28 +;; stur s31, [x0, #0x60] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x64] +;; add x28, x28, #0x18 +;; mov sp, x28 +;; mov sp, x28 +;; ldr x28, [sp], #0x10 +;; ldp x29, x30, [sp], #0x10 +;; ret +;; a7c: .byte 0x1f, 0xc1, 0x00, 0x00 +;; a80: .byte 0x00, 0x00, 0x00, 0x00 +;; a84: .byte 0x00, 0x00, 0x00, 0x00 +;; a88: .byte 0x00, 0x00, 0x00, 0x00 +;; +;; wasm[0]::function[2]: +;; stp x29, x30, [sp, #-0x10]! +;; mov x29, sp +;; str x28, [sp, #-0x10]! +;; mov x28, sp +;; ldur x16, [x1, #8] +;; ldur x16, [x16, #0x18] +;; mov x17, #0 +;; movk x17, #0x84 +;; add x16, x16, x17 +;; cmp sp, x16 +;; b.lo #0xc5c +;; acc: mov x9, x1 +;; sub x28, x28, #0x18 +;; mov sp, x28 +;; stur x1, [x28, #0x10] +;; stur x2, [x28, #8] +;; stur x0, [x28] +;; ldr d0, #0xc60 +;; sub x28, x28, #0x6c +;; mov sp, x28 +;; mov x16, #0 +;; stur x16, [x28] +;; ldr d31, #0xc60 +;; stur d31, [x28, #8] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x10] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x18] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x20] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x28] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x30] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x38] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x40] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x48] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x50] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x58] +;; ldr s31, #0xc68 +;; stur s31, [x28, #0x60] +;; ldr d31, #0xc60 +;; stur d31, [x28, #0x64] +;; ldur x0, [x28, #0x6c] +;; ldur x16, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur x16, [x0] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #8] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x10] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x18] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x20] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x28] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x30] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x38] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x40] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x48] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x50] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x58] +;; ldur s31, [x28] +;; add x28, x28, #4 +;; mov sp, x28 +;; stur s31, [x0, #0x60] +;; ldur d31, [x28] +;; add x28, x28, #8 +;; mov sp, x28 +;; stur d31, [x0, #0x64] +;; add x28, x28, #0x18 +;; mov sp, x28 +;; mov sp, x28 +;; ldr x28, [sp], #0x10 +;; ldp x29, x30, [sp], #0x10 +;; ret +;; c5c: .byte 0x1f, 0xc1, 0x00, 0x00 +;; c60: .byte 0x00, 0x00, 0x00, 0x00 +;; c64: .byte 0x00, 0x00, 0x00, 0x00 +;; c68: .byte 0x00, 0x00, 0x00, 0x00 diff --git a/tests/misc_testsuite/winch/memory_offsets.wast b/tests/misc_testsuite/winch/memory_offsets.wast new file mode 100644 index 000000000000..b671cb923264 --- /dev/null +++ b/tests/misc_testsuite/winch/memory_offsets.wast @@ -0,0 +1,559 @@ +(module + (type (;0;) (func (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64))) + (global (;0;) (mut i32) i32.const 10) + (export "main" (func 0)) + (func (;0;) (type 0) (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64) + call 1 + call 1 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + call 2 + br 0 + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + drop + f64.const 0x1.54e5e9c49a8a3p+224 (;=35900759953881640000000000000000000000000000000000000000000000000000;) + f32.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + i64.const 0 + f64.const 0x0p+0 (;=0;) + ) + (func (;1;) (type 0) (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64) + f64.const 0x0p+0 (;=0;) + f32.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + i64.const 0 + f64.const 0x0p+0 (;=0;) + ) + (func (;2;) (type 0) (result f64 f32 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 f64 i64 f64) + f64.const 0x0p+0 (;=0;) + f32.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + f64.const 0x0p+0 (;=0;) + i64.const 0 + f64.const 0x0p+0 (;=0;) + ) +) + +(assert_return (invoke "main") + (f64.const 0x0p+0) + (f32.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (f64.const 0x0p+0) + (i64.const 0) + (f64.const 0x0p+0) +) diff --git a/winch/codegen/src/isa/aarch64/address.rs b/winch/codegen/src/isa/aarch64/address.rs index 8ea19eb6f05f..af35e46bb049 100644 --- a/winch/codegen/src/isa/aarch64/address.rs +++ b/winch/codegen/src/isa/aarch64/address.rs @@ -1,12 +1,14 @@ //! Aarch64 addressing mode. use super::regs; -use crate::reg::Reg; -use crate::{Context as _, Result, format_err}; -use cranelift_codegen::VCodeConstant; -use cranelift_codegen::{ - ir::types, - isa::aarch64::inst::{AMode, PairAMode, SImm7Scaled, SImm9}, +use crate::Result; +use crate::{ + masm::{IntScratch, MacroAssembler as Masm, OperandSize, RegImm}, + reg::Reg, +}; +use cranelift_codegen::ir::{Type, types}; +use cranelift_codegen::isa::aarch64::inst::{ + AMode, ExtendOp, PairAMode, SImm7Scaled, SImm9, UImm12Scaled, }; /// Aarch64 indexing mode. @@ -21,47 +23,63 @@ pub(crate) enum Indexing { /// Memory address representation. #[derive(Debug, Copy, Clone)] pub(crate) enum Address { - /// Base register with an arbitrary offset. Potentially gets - /// lowered into multiple instructions during code emission - /// depending on the offset. + /// Base register with an arbitrary offset. Offset { /// Base register. base: Reg, /// Offset. offset: i64, }, - /// Specialized indexed register and offset variant using - /// the stack pointer. - IndexedSPOffset { - /// Offset. - offset: i64, - /// Indexing mode. + /// SP-indexed addressing mode for single register loads/stores. + SPIndexedSingle { + /// 9-bit signed offset. + offset: SImm9, + /// Indexing mode (pre or post). + indexing: Indexing, + }, + /// SP-indexed addressing mode for register pair loads/stores. + SPIndexedPair { + /// 7-bit signed scaled offset. + offset: SImm7Scaled, + /// Indexing mode (pre or post). indexing: Indexing, }, - /// Address of a constant in the constant pool. - Const(VCodeConstant), } impl Address { - /// Create a pre-indexed addressing mode from the stack pointer. - pub fn pre_indexed_from_sp(offset: i64) -> Self { - Self::IndexedSPOffset { + /// Create a pre-indexed addressing mode from the stack pointer for single register operations. + pub fn pre_indexed_from_sp(offset: SImm9) -> Self { + Self::SPIndexedSingle { offset, indexing: Indexing::Pre, } } - /// Create a post-indexed addressing mode from the stack pointer. - pub fn post_indexed_from_sp(offset: i64) -> Self { - Self::IndexedSPOffset { + /// Create a post-indexed addressing mode from the stack pointer for single register operations. + pub fn post_indexed_from_sp(offset: SImm9) -> Self { + Self::SPIndexedSingle { offset, indexing: Indexing::Post, } } - /// Create an offset addressing mode with - /// the shadow stack pointer register - /// as a base. + /// Create a pre-indexed addressing mode from the stack pointer for register pair operations. + pub fn pre_indexed_from_sp_for_pair(offset: SImm7Scaled) -> Self { + Self::SPIndexedPair { + offset, + indexing: Indexing::Pre, + } + } + + /// Create a post-indexed addressing mode from the stack pointer for register pair operations. + pub fn post_indexed_from_sp_for_pair(offset: SImm7Scaled) -> Self { + Self::SPIndexedPair { + offset, + indexing: Indexing::Post, + } + } + + /// Create an offset addressing mode with the shadow stack pointer register as a base. pub fn from_shadow_sp(offset: i64) -> Self { Self::Offset { base: regs::shadow_sp(), @@ -75,8 +93,7 @@ impl Address { // sp generally should not be used as a base register in an // address. In the cases where its usage is required and where // we are sure that it's 16-byte aligned, the address should - // be constructed via the `Self::pre_indexed_sp` and - // Self::post_indexed_sp functions. + // be constructed via the SP-indexed constructors. // For more details around the stack pointer and shadow stack // pointer see the docs at regs::shadow_sp(). assert!( @@ -86,77 +103,104 @@ impl Address { Self::Offset { base, offset } } - /// Create an address for a constant. - pub fn constant(data: VCodeConstant) -> Self { - Self::Const(data) - } - - /// Returns the register base and immediate offset of the given [`Address`]. - /// + /// Converts self to cranelift's [`PairAMode`]. /// # Panics - /// This function panics if the [`Address`] is not [`Address::Offset`]. - pub fn unwrap_offset(&self) -> (Reg, i64) { + /// This function panics if self cannot be converted to [`PairAMode`]. + /// NB: that all uses of this function currently guarantee that + /// the offset will fit in a 7-bit signed offset. + pub fn to_pair_addressing_mode(self) -> PairAMode { match self { - Self::Offset { base, offset } => (*base, *offset), - _ => panic!("Expected register and offset addressing mode"), - } - } -} - -// Conversions between `winch-codegen`'s addressing mode representation -// and `cranelift-codegen`s addressing mode representation for aarch64. - -impl TryFrom
for PairAMode { - type Error = crate::Error; - - fn try_from(addr: Address) -> Result