winch: Small clean-up for x64 (#5691)

This commit contains a small set of clean up items for x64.

Notably:

* Adds filetests
* Documents why 16 for the arg base offset abi implementation, for clarity.
* Fixes a bug in the spill implementation caught while anlyzing the
filetests results. The fix consists of emitting a load instead of a store into
the scratch register before spiiling its value.
* Remove dead code for pretty printing registers which is not needed anymore
since we now have proper disassembly.
This commit is contained in:
Saúl Cabrera
2023-02-02 11:40:31 -05:00
committed by GitHub
parent 446337c746
commit f5f517e811
8 changed files with 82 additions and 102 deletions

View File

@@ -0,0 +1,16 @@
;;! target = "x86_64"
(module
(export "main" (func $main))
(func $main (result i32)
(i32.const 10)
(i32.const 20)
i32.add)
)
;; 0: 55 push rbp
;; 1: 4889e5 mov rbp, rsp
;; 4: b80a000000 mov eax, 0xa
;; 9: 83c014 add eax, 0x14
;; c: 5d pop rbp
;; d: c3 ret

View File

@@ -0,0 +1,32 @@
;;! target = "x86_64"
(module
(export "main" (func $main))
(func $main (result i32)
(local $foo i32)
(local $bar i32)
(i32.const 10)
(local.set $foo)
(i32.const 20)
(local.set $bar)
(local.get $foo)
(local.get $bar)
i32.add)
)
;; 0: 55 push rbp
;; 1: 4889e5 mov rbp, rsp
;; 4: 4883ec08 sub rsp, 8
;; 8: 48c7042400000000 mov qword ptr [rsp], 0
;; 10: b80a000000 mov eax, 0xa
;; 15: 89442404 mov dword ptr [rsp + 4], eax
;; 19: b814000000 mov eax, 0x14
;; 1e: 890424 mov dword ptr [rsp], eax
;; 21: 8b0424 mov eax, dword ptr [rsp]
;; 24: 8b4c2404 mov ecx, dword ptr [rsp + 4]
;; 28: 01c1 add ecx, eax
;; 2a: 4889c8 mov rax, rcx
;; 2d: 4883c408 add rsp, 8
;; 31: 5d pop rbp
;; 32: c3 ret

View File

@@ -0,0 +1,22 @@
;;! target = "x86_64"
(module
(export "main" (func $main))
(func $main (param i32) (param i32) (result i32)
(local.get 0)
(local.get 1)
i32.add)
)
;; 0: 55 push rbp
;; 1: 4889e5 mov rbp, rsp
;; 4: 4883ec08 sub rsp, 8
;; 8: 897c2404 mov dword ptr [rsp + 4], edi
;; c: 893424 mov dword ptr [rsp], esi
;; f: 8b0424 mov eax, dword ptr [rsp]
;; 12: 8b4c2404 mov ecx, dword ptr [rsp + 4]
;; 16: 01c1 add ecx, eax
;; 18: 4889c8 mov rax, rcx
;; 1b: 4883c408 add rsp, 8
;; 1f: 5d pop rbp
;; 20: c3 ret