Implement invokeNative asm code for MinGW (#1753)
And update the document of building iwasm for MinGW.
This commit is contained in:
57
core/iwasm/common/arch/invokeNative_mingw_x64.s
Normal file
57
core/iwasm/common/arch/invokeNative_mingw_x64.s
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.globl invokeNative
|
||||
invokeNative:
|
||||
|
||||
# %rcx func_ptr
|
||||
# %rdx argv
|
||||
# %r8 n_stacks
|
||||
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
|
||||
mov %rcx, %r10 # func_ptr
|
||||
mov %rdx, %rax # argv
|
||||
mov %r8, %rcx # n_stacks
|
||||
|
||||
# fill all fp args
|
||||
movsd 0(%rax), %xmm0
|
||||
movsd 8(%rax), %xmm1
|
||||
movsd 16(%rax), %xmm2
|
||||
movsd 24(%rax), %xmm3
|
||||
|
||||
# check for stack args
|
||||
cmp $0, %rcx
|
||||
jz cycle_end
|
||||
|
||||
mov %rsp, %rdx
|
||||
and $15, %rdx
|
||||
jz no_abort
|
||||
int $3
|
||||
no_abort:
|
||||
mov %rcx, %rdx
|
||||
and $1, %rdx
|
||||
shl $3, %rdx
|
||||
sub %rdx, %rsp
|
||||
|
||||
# store stack args
|
||||
lea 56(%rax, %rcx, 8), %r9
|
||||
sub %rsp, %r9 # offset
|
||||
cycle:
|
||||
push (%rsp, %r9)
|
||||
loop cycle
|
||||
|
||||
cycle_end:
|
||||
mov 32(%rax), %rcx
|
||||
mov 40(%rax), %rdx
|
||||
mov 48(%rax), %r8
|
||||
mov 56(%rax), %r9
|
||||
|
||||
sub $32, %rsp # shadow space
|
||||
|
||||
call *%r10
|
||||
leave
|
||||
ret
|
||||
57
core/iwasm/common/arch/invokeNative_mingw_x64_simd.s
Normal file
57
core/iwasm/common/arch/invokeNative_mingw_x64_simd.s
Normal file
@ -0,0 +1,57 @@
|
||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||
|
||||
.text
|
||||
.align 2
|
||||
.globl invokeNative
|
||||
invokeNative:
|
||||
|
||||
# %rcx func_ptr
|
||||
# %rdx argv
|
||||
# %r8 n_stacks
|
||||
|
||||
push %rbp
|
||||
mov %rsp, %rbp
|
||||
|
||||
mov %rcx, %r10 # func_ptr
|
||||
mov %rdx, %rax # argv
|
||||
mov %r8, %rcx # n_stacks
|
||||
|
||||
# fill all fp args
|
||||
movdqu 0(%rax), %xmm0
|
||||
movdqu 16(%rax), %xmm1
|
||||
movdqu 32(%rax), %xmm2
|
||||
movdqu 48(%rax), %xmm3
|
||||
|
||||
# check for stack args
|
||||
cmp $0, %rcx
|
||||
jz cycle_end
|
||||
|
||||
mov %rsp, %rdx
|
||||
and $15, %rdx
|
||||
jz no_abort
|
||||
int $3
|
||||
no_abort:
|
||||
mov %rcx, %rdx
|
||||
and $1, %rdx
|
||||
shl $3, %rdx
|
||||
sub %rdx, %rsp
|
||||
|
||||
# store stack args
|
||||
lea 88(%rax, %rcx, 8), %r9
|
||||
sub %rsp, %r9 # offset
|
||||
cycle:
|
||||
push (%rsp, %r9)
|
||||
loop cycle
|
||||
|
||||
cycle_end:
|
||||
mov 64(%rax), %rcx
|
||||
mov 72(%rax), %rdx
|
||||
mov 80(%rax), %r8
|
||||
mov 88(%rax), %r9
|
||||
|
||||
sub $32, %rsp # shadow space
|
||||
|
||||
call *%r10
|
||||
leave
|
||||
ret
|
||||
@ -27,13 +27,21 @@ if (WAMR_BUILD_INVOKE_NATIVE_GENERAL EQUAL 1)
|
||||
elseif (WAMR_BUILD_TARGET STREQUAL "X86_64" OR WAMR_BUILD_TARGET STREQUAL "AMD_64")
|
||||
if (NOT WAMR_BUILD_SIMD EQUAL 1)
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.asm)
|
||||
if (NOT MINGW)
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.asm)
|
||||
else ()
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_mingw_x64.s)
|
||||
endif ()
|
||||
else ()
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64.s)
|
||||
endif ()
|
||||
else ()
|
||||
if (WAMR_BUILD_PLATFORM STREQUAL "windows")
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64_simd.asm)
|
||||
if (NOT MINGW)
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64_simd.asm)
|
||||
else ()
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_mingw_x64_simd.s)
|
||||
endif ()
|
||||
else()
|
||||
set (source_all ${c_source_all} ${IWASM_COMMON_DIR}/arch/invokeNative_em64_simd.s)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user