-
Notifications
You must be signed in to change notification settings - Fork 7.4k
[gmp] arm64 windows asm optimization #26764
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
Changes from all commits
47a1a72
1b98bfe
4b10959
606779d
5116efe
367a4c1
7f0a155
9060d64
5efb2e6
8c19de4
68ed75f
d3b45d4
f888ed8
513b561
0f6022c
ecd1aaa
844d822
5feb5ec
abcb618
d331aaf
5c3d162
eb299f2
80661de
f0e7878
ee37e13
f696c88
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,73 @@ | ||
| diff --git a/configure.ac b/configure.ac | ||
| index bd92bc4..bd2c0af 100644 | ||
| --- a/configure.ac | ||
| +++ b/configure.ac | ||
| @@ -3704,6 +3704,8 @@ if test "$gmp_asm_syntax_testing" != no; then | ||
| case $host in | ||
| *-*-darwin*) | ||
| GMP_INCLUDE_MPN(arm64/darwin.m4) ;; | ||
| + *-pc-mingw32) | ||
| + GMP_INCLUDE_MPN(arm64/coff.m4) ;; | ||
| *) | ||
| GMP_INCLUDE_MPN(arm64/arm64-defs.m4) ;; | ||
| esac | ||
| diff --git a/mpn/arm64/coff.m4 b/mpn/arm64/coff.m4 | ||
| new file mode 100644 | ||
| index 0000000..88605b3 | ||
| --- /dev/null | ||
| +++ b/mpn/arm64/coff.m4 | ||
| @@ -0,0 +1,54 @@ | ||
| +divert(-1) | ||
| + | ||
| +dnl m4 macros for ARM64 COFF assembler. | ||
| + | ||
| +dnl Copyright 2020 Free Software Foundation, Inc. | ||
| + | ||
| +dnl This file is part of the GNU MP Library. | ||
| +dnl | ||
| +dnl The GNU MP Library is free software; you can redistribute it and/or modify | ||
| +dnl it under the terms of either: | ||
| +dnl | ||
| +dnl * the GNU Lesser General Public License as published by the Free | ||
| +dnl Software Foundation; either version 3 of the License, or (at your | ||
| +dnl option) any later version. | ||
| +dnl | ||
| +dnl or | ||
| +dnl | ||
| +dnl * the GNU General Public License as published by the Free Software | ||
| +dnl Foundation; either version 2 of the License, or (at your option) any | ||
| +dnl later version. | ||
| +dnl | ||
| +dnl or both in parallel, as here. | ||
| +dnl | ||
| +dnl The GNU MP Library is distributed in the hope that it will be useful, but | ||
| +dnl WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY | ||
| +dnl or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
| +dnl for more details. | ||
| +dnl | ||
| +dnl You should have received copies of the GNU General Public License and the | ||
| +dnl GNU Lesser General Public License along with the GNU MP Library. If not, | ||
| +dnl see https://www.gnu.org/licenses/. | ||
| + | ||
| + | ||
| +dnl Standard commenting is with @, the default m4 # is for constants and we | ||
| +dnl don't want to disable macro expansions in or after them. | ||
| + | ||
| +changecom | ||
| + | ||
| + | ||
| +dnl LEA_HI(reg,gmp_symbol), LEA_LO(reg,gmp_symbol) | ||
| +dnl | ||
| +dnl Load the address of gmp_symbol into a register. We split this into two | ||
| +dnl parts to allow separation for manual insn scheduling. | ||
| + | ||
| +define(`LEA_HI', `ldr $1, =$2')dnl | ||
| +define(`LEA_LO')dnl | ||
| + | ||
| +dnl Usage: ALIGN(bytes) | ||
| +dnl | ||
| +dnl Emit a ".align" directive. | ||
| + | ||
| +define(`ALIGN', ` .align 8')dnl | ||
| + | ||
| +divert`'dnl |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,6 +12,41 @@ vcpkg_download_distfile( | |
| if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) | ||
| set(PATCHES yasm.patch | ||
| msvc_symbol.patch) | ||
|
|
||
| if(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm64") | ||
| # Hint to use clang x86/x64 version in emulation mode on an ARM device | ||
| vcpkg_add_to_path("$ENV{VCINSTALLDIR}/Tools/Llvm/bin") | ||
|
|
||
| find_program(clang-cl-check clang-cl) | ||
| if (NOT clang-cl-check) | ||
| message(FATAL_ERROR "${PORT} requires Clang installed for ${VCPKG_TARGET_ARCHITECTURE} target architecture. For instance, Clang can be installed by using Visual Studio or LLVM installers") | ||
| endif() | ||
|
|
||
| set(ENV{CCAS} "clang-cl --target=arm64-pc-win32 -c") | ||
eukarpov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| # Avoid the x18 register since it is reserved on Darwin. | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The x18 register is a platform register based on ARM64 ABI for Windows convention. It turned out that Darwin has the same issue. I would change the comment to avoid confusion why Darwin patch is used to avoid issue on ARM64 Windows.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's fine; I was just copying the upstream comment. |
||
| vcpkg_download_distfile( | ||
| ARM64PATCH | ||
| URLS https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc | ||
| FILENAME gmp-arm64-asm-fix-5f32dbc41afc.patch | ||
| SHA512 4a7c50dc0a78e6c297c0ac53129ed367dbf669100a613653987d0eddf175376296254ed26ecce15d02b0544b99e44719af49635e54982b22e745f22e2f8d1eda | ||
| ) | ||
|
|
||
| list(APPEND PATCHES "${ARM64PATCH}" arm64-coff.patch) | ||
| elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "arm") | ||
| list(APPEND OPTIONS --enable-assembly=no) | ||
| else() | ||
| set(ENV{CCAS} "${CURRENT_HOST_INSTALLED_DIR}/tools/yasm/yasm${VCPKG_HOST_EXECUTABLE_SUFFIX}") | ||
| if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") | ||
| set(asmflag win64) | ||
| elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") | ||
| set(asmflag win32) | ||
| endif() | ||
| set(ENV{ASMFLAGS} "-Xvc -f ${asmflag} -pgas -rraw") | ||
eukarpov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| endif() | ||
|
|
||
| list(APPEND OPTIONS ac_cv_func_memset=yes | ||
| "gmp_cv_asm_w32=.word" | ||
| ) | ||
| endif() | ||
|
|
||
| vcpkg_extract_source_archive_ex( | ||
|
|
@@ -23,30 +58,12 @@ vcpkg_extract_source_archive_ex( | |
| tools.patch | ||
| ) | ||
|
|
||
| if(VCPKG_TARGET_IS_WINDOWS AND NOT VCPKG_TARGET_IS_MINGW) | ||
| set(ENV{CCAS} "${CURRENT_HOST_INSTALLED_DIR}/tools/yasm/yasm${VCPKG_HOST_EXECUTABLE_SUFFIX}") | ||
| if(VCPKG_TARGET_ARCHITECTURE STREQUAL "x64") | ||
| set(asmflag win64) | ||
| elseif(VCPKG_TARGET_ARCHITECTURE STREQUAL "x86") | ||
| set(asmflag win32) | ||
| endif() | ||
| set(ENV{ASMFLAGS} "-Xvc -f ${asmflag} -pgas -rraw") | ||
| set(OPTIONS ac_cv_func_memset=yes | ||
| "gmp_cv_asm_w32=.word" | ||
| ) | ||
|
|
||
| endif() | ||
|
|
||
| if(VCPKG_CROSSCOMPILING) | ||
| # Silly trick to make configure accept CC_FOR_BUILD but in reallity CC_FOR_BUILD is deactivated. | ||
| # Silly trick to make configure accept CC_FOR_BUILD but in reallity CC_FOR_BUILD is deactivated. | ||
| set(ENV{CC_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") | ||
| set(ENV{CPP_FOR_BUILD} "touch a.out | touch conftest${VCPKG_HOST_EXECUTABLE_SUFFIX} | true") | ||
| endif() | ||
|
|
||
| if(VCPKG_TARGET_IS_WINDOWS AND VCPKG_TARGET_ARCHITECTURE MATCHES "^(arm|arm64)$") | ||
| list(APPEND OPTIONS --enable-assembly=no) | ||
| endif() | ||
|
|
||
| vcpkg_configure_make( | ||
| SOURCE_PATH "${SOURCE_PATH}" | ||
| AUTOCONFIG | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.