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 fpu to int conversions for aarch64 #9889

Merged
merged 8 commits into from
Jan 7, 2025
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
38 changes: 38 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f32_s/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(f32.const 1.0)
(i32.trunc_f32_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, #0x3f800000
;; fmov s0, w16
;; fcmp s0, s0
;; b.vs #0x64
;; 30: mov x16, #0xcf000000
;; fmov s31, w16
;; fcmp s31, s0
;; b.le #0x68
;; 40: mov x16, #0x4f000000
;; fmov s31, w16
;; fcmp s31, s0
;; b.ge #0x6c
;; 50: fcvtzs w0, s0
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 64: .byte 0x1f, 0xc1, 0x00, 0x00
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
41 changes: 41 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f32_s/locals.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(local f32)

(local.get 0)
(i32.trunc_f32_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]
;; mov x16, #0
;; stur x16, [x28]
;; ldur s0, [x28, #4]
;; fcmp s0, s0
;; b.vs #0x68
;; 34: mov x16, #0xcf000000
;; fmov s31, w16
;; fcmp s31, s0
;; b.le #0x6c
;; 44: mov x16, #0x4f000000
;; fmov s31, w16
;; fcmp s31, s0
;; b.ge #0x70
;; 54: fcvtzs w0, s0
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
;; 70: .byte 0x1f, 0xc1, 0x00, 0x00
38 changes: 38 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f32_s/params.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (param f32) (result i32)
(local.get 0)
(i32.trunc_f32_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 s0, [x28, #4]
;; ldur s0, [x28, #4]
;; fcmp s0, s0
;; b.vs #0x64
;; 30: mov x16, #0xcf000000
;; fmov s31, w16
;; fcmp s31, s0
;; b.le #0x68
;; 40: mov x16, #0x4f000000
;; fmov s31, w16
;; fcmp s31, s0
;; b.ge #0x6c
;; 50: fcvtzs w0, s0
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 64: .byte 0x1f, 0xc1, 0x00, 0x00
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
37 changes: 37 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f32_u/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(f32.const 1.0)
(i32.trunc_f32_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, #0x3f800000
;; fmov s0, w16
;; fcmp s0, s0
;; b.vs #0x60
;; 30: fmov s31, #-1.00000000
;; fcmp s31, s0
;; b.le #0x64
;; 3c: mov x16, #0x4f800000
;; fmov s31, w16
;; fcmp s31, s0
;; b.ge #0x68
;; 4c: fcvtzu w0, s0
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 60: .byte 0x1f, 0xc1, 0x00, 0x00
;; 64: .byte 0x1f, 0xc1, 0x00, 0x00
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
40 changes: 40 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f32_u/locals.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(local f32)

(local.get 0)
(i32.trunc_f32_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]
;; mov x16, #0
;; stur x16, [x28]
;; ldur s0, [x28, #4]
;; fcmp s0, s0
;; b.vs #0x64
;; 34: fmov s31, #-1.00000000
;; fcmp s31, s0
;; b.le #0x68
;; 40: mov x16, #0x4f800000
;; fmov s31, w16
;; fcmp s31, s0
;; b.ge #0x6c
;; 50: fcvtzu w0, s0
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 64: .byte 0x1f, 0xc1, 0x00, 0x00
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
37 changes: 37 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f32_u/params.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (param f32) (result i32)
(local.get 0)
(i32.trunc_f32_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 s0, [x28, #4]
;; ldur s0, [x28, #4]
;; fcmp s0, s0
;; b.vs #0x60
;; 30: fmov s31, #-1.00000000
;; fcmp s31, s0
;; b.le #0x64
;; 3c: mov x16, #0x4f800000
;; fmov s31, w16
;; fcmp s31, s0
;; b.ge #0x68
;; 4c: fcvtzu w0, s0
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 60: .byte 0x1f, 0xc1, 0x00, 0x00
;; 64: .byte 0x1f, 0xc1, 0x00, 0x00
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
39 changes: 39 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f64_s/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(f64.const 1.0)
(i32.trunc_f64_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, #0x3ff0000000000000
;; fmov d0, x16
;; fcmp d0, d0
;; b.vs #0x68
;; 30: mov x16, #0x200000
;; movk x16, #0xc1e0, lsl #48
;; fmov d31, x16
;; fcmp d31, d0
;; b.le #0x6c
;; 44: mov x16, #0x41e0000000000000
;; fmov d31, x16
;; fcmp d31, d0
;; b.ge #0x70
;; 54: fcvtzs w0, d0
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
;; 70: .byte 0x1f, 0xc1, 0x00, 0x00
42 changes: 42 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f64_s/locals.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(local f64)

(local.get 0)
(i32.trunc_f64_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]
;; mov x16, #0
;; stur x16, [x28]
;; ldur d0, [x28]
;; fcmp d0, d0
;; b.vs #0x6c
;; 34: mov x16, #0x200000
;; movk x16, #0xc1e0, lsl #48
;; fmov d31, x16
;; fcmp d31, d0
;; b.le #0x70
;; 48: mov x16, #0x41e0000000000000
;; fmov d31, x16
;; fcmp d31, d0
;; b.ge #0x74
;; 58: fcvtzs w0, d0
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
;; 70: .byte 0x1f, 0xc1, 0x00, 0x00
;; 74: .byte 0x1f, 0xc1, 0x00, 0x00
39 changes: 39 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f64_s/params.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (param f64) (result i32)
(local.get 0)
(i32.trunc_f64_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 d0, [x28]
;; ldur d0, [x28]
;; fcmp d0, d0
;; b.vs #0x68
;; 30: mov x16, #0x200000
;; movk x16, #0xc1e0, lsl #48
;; fmov d31, x16
;; fcmp d31, d0
;; b.le #0x6c
;; 44: mov x16, #0x41e0000000000000
;; fmov d31, x16
;; fcmp d31, d0
;; b.ge #0x70
;; 54: fcvtzs w0, d0
;; add sp, sp, #0x18
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
;; 6c: .byte 0x1f, 0xc1, 0x00, 0x00
;; 70: .byte 0x1f, 0xc1, 0x00, 0x00
37 changes: 37 additions & 0 deletions tests/disas/winch/aarch64/i32_trunc_f64_u/const.wat
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
;;! target = "aarch64"
;;! test = "winch"

(module
(func (result i32)
(f64.const 1.0)
(i32.trunc_f64_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, #0x3ff0000000000000
;; fmov d0, x16
;; fcmp d0, d0
;; b.vs #0x60
;; 30: fmov d31, #-1.00000000
;; fcmp d31, d0
;; b.le #0x64
;; 3c: mov x16, #0x41f0000000000000
;; fmov d31, x16
;; fcmp d31, d0
;; b.ge #0x68
;; 4c: fcvtzu w0, d0
;; add sp, sp, #0x10
;; mov x28, sp
;; ldp x29, x30, [sp], #0x10
;; ret
;; 60: .byte 0x1f, 0xc1, 0x00, 0x00
;; 64: .byte 0x1f, 0xc1, 0x00, 0x00
;; 68: .byte 0x1f, 0xc1, 0x00, 0x00
Loading
Loading