This patch adds complete support for the `sub` and `add` WebAssembly instructions for x64, and complete support for the `add` WebAssembly instruction for aarch64. This patch also refactors how the binary operations get constructed within the `VisitOperator` trait implementation. The refactor adds methods in the `CodeGenContext` to abstract all the common steps to emit binary operations, making this process less repetitive and less brittle (e.g. omitting to push the resulting value to the stack, or omitting to free registers after used). This patch also improves test coverage and refactors the filetests directory to make it easier to add tests for other instructions.
18 lines
489 B
Plaintext
18 lines
489 B
Plaintext
;;! target = "aarch64"
|
|
|
|
(module
|
|
(func (result i32)
|
|
(i32.const 10)
|
|
(i32.const 20)
|
|
(i32.add)
|
|
)
|
|
)
|
|
;; 0: fd7bbfa9 stp x29, x30, [sp, #-0x10]!
|
|
;; 4: fd030091 mov x29, sp
|
|
;; 8: fc030091 mov x28, sp
|
|
;; c: 500180d2 mov x16, #0xa
|
|
;; 10: e003102a mov w0, w16
|
|
;; 14: 00500011 add w0, w0, #0x14
|
|
;; 18: fd7bc1a8 ldp x29, x30, [sp], #0x10
|
|
;; 1c: c0035fd6 ret
|