Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Winch: Implement rem for aarch64 #9781

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_rems/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 7)
(i32.const 5)
(i32.rem_s)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #5
;; mov w0, w16
;; mov x16, #7
;; mov w1, w16
;; cbz x0, #0x58
;; 34: sxtw x0, w0
;; sxtw x1, w1
;; sdiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_rems/one_zero.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 1)
(i32.const 0)
(i32.rem_s)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #0
;; mov w0, w16
;; mov x16, #1
;; mov w1, w16
;; cbz x0, #0x58
;; 34: sxtw x0, w0
;; sxtw x1, w1
;; sdiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_rems/overflow.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 0x80000000)
(i32.const -1)
(i32.rem_s)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; orr x16, xzr, #0xffffffff
;; mov w0, w16
;; mov x16, #0x80000000
;; mov w1, w16
;; cbz x0, #0x58
;; 34: sxtw x0, w0
;; sxtw x1, w1
;; sdiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_rems/params.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (param i32) (param i32) (result i32)
(local.get 0)
(local.get 1)
(i32.rem_s)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x18
;; mov x28, sp
;; stur x0, [x28, #0x10]
;; stur x1, [x28, #8]
;; stur w2, [x28, #4]
;; stur w3, [x28]
;; ldur w0, [x28]
;; ldur w1, [x28, #4]
;; cbz x0, #0x58
;; 34: sxtw x0, w0
;; sxtw x1, w1
;; sdiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_rems/zero_zero.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 0)
(i32.const 0)
(i32.rem_s)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #0
;; mov w0, w16
;; mov x16, #0
;; mov w1, w16
;; cbz x0, #0x58
;; 34: sxtw x0, w0
;; sxtw x1, w1
;; sdiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_remu/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 7)
(i32.const 5)
(i32.rem_u)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #5
;; mov w0, w16
;; mov x16, #7
;; mov w1, w16
;; cbz x0, #0x58
;; 34: mov w0, w0
;; mov w1, w1
;; udiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_remu/one_zero.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 1)
(i32.const 0)
(i32.rem_u)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #0
;; mov w0, w16
;; mov x16, #1
;; mov w1, w16
;; cbz x0, #0x58
;; 34: mov w0, w0
;; mov w1, w1
;; udiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_remu/params.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (param i32) (param i32) (result i32)
(local.get 0)
(local.get 1)
(i32.rem_u)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x18
;; mov x28, sp
;; stur x0, [x28, #0x10]
;; stur x1, [x28, #8]
;; stur w2, [x28, #4]
;; stur w3, [x28]
;; ldur w0, [x28]
;; ldur w1, [x28, #4]
;; cbz x0, #0x58
;; 34: mov w0, w0
;; mov w1, w1
;; udiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_remu/signed.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const -1)
(i32.const -1)
(i32.rem_u)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; orr x16, xzr, #0xffffffff
;; mov w0, w16
;; orr x16, xzr, #0xffffffff
;; mov w1, w16
;; cbz x0, #0x58
;; 34: mov w0, w0
;; mov w1, w1
;; udiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
35 changes: 35 additions & 0 deletions tests/disas/winch/aarch64/i32_remu/zero_zero.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(i32.const 0)
(i32.const 0)
(i32.rem_u)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #0
;; mov w0, w16
;; mov x16, #0
;; mov w1, w16
;; cbz x0, #0x58
;; 34: mov w0, w0
;; mov w1, w1
;; udiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov w0, w1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 58: .byte 0x1f, 0xc1, 0x00, 0x00
33 changes: 33 additions & 0 deletions tests/disas/winch/aarch64/i64_rems/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i64)
(i64.const 7)
(i64.const 5)
(i64.rem_s)
)
)

;; wasm[0]::function[0]:
;; stp x29, x30, [sp, #-0x10]!
;; mov x29, sp
;; mov x28, sp
;; mov x9, x0
;; sub sp, sp, #0x10
;; mov x28, sp
;; stur x0, [x28, #8]
;; stur x1, [x28]
;; mov x16, #5
;; mov x0, x16
;; mov x16, #7
;; mov x1, x16
;; cbz x0, #0x50
;; 34: sdiv x16, x1, x0
;; msub x1, x0, x16, x1
;; mov x0, x1
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 50: .byte 0x1f, 0xc1, 0x00, 0x00
Loading
Loading