Skip to content

Commit

Permalink
Add Windows ARM64 support (#656)
Browse files Browse the repository at this point in the history
* Add Windows ARM64 support

* Add Windows ARM64/ARM64EC CI workflows
  • Loading branch information
jblazquez authored Apr 10, 2024
1 parent b8e9e99 commit d9bca64
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 6 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -388,6 +388,28 @@ jobs:
build-type: Debug
arch: x64
toolchain: ""
- os: windows-2022
build-type: Release
arch: ARM64
toolchain: ""
build-only: yes
- os: windows-2022
build-type: Debug
arch: ARM64
toolchain: ""
build-only: yes
- os: windows-2022
build-type: Release
arch: ARM64EC
toolchain: ""
extra-cmake-flags: -DCMAKE_SYSTEM_VERSION="10.0.22621.0"
build-only: yes
- os: windows-2022
build-type: Debug
arch: ARM64EC
toolchain: ""
extra-cmake-flags: -DCMAKE_SYSTEM_VERSION="10.0.22621.0"
build-only: yes

# Don't abort runners if a single one fails
fail-fast: false
Expand All @@ -403,6 +425,7 @@ jobs:
run: cmake --build ${{github.workspace}}/build -- /m /p:Configuration=${{ matrix.build-type }}
# Run the tests.
- name: Test
if: ${{ matrix.build-only != 'yes' }}
working-directory: ${{ github.workspace }}/build
run: ctest -j 2 --interactive-debug-mode 0 --output-on-failure -C ${{ matrix.build-type }} --timeout 400
timeout-minutes: 20
Expand Down
9 changes: 6 additions & 3 deletions src/snmalloc/aal/aal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@
#include <cstdint>
#include <utility>

#if defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
#if ( \
defined(__i386__) || defined(_M_IX86) || defined(_X86_) || \
defined(__amd64__) || defined(__x86_64__) || defined(_M_X64) || \
defined(_M_AMD64)
defined(_M_AMD64)) && \
!defined(_M_ARM64EC)
# if defined(SNMALLOC_SGX)
# define PLATFORM_IS_X86_SGX
# define SNMALLOC_NO_AAL_BUILTINS
Expand All @@ -25,7 +27,8 @@
# endif
#endif

#if defined(__arm__) || defined(__aarch64__)
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM64) || \
defined(_M_ARM64EC)
# define PLATFORM_IS_ARM
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/snmalloc/aal/aal_arm.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#if defined(__aarch64__)
#if defined(__aarch64__) || defined(_M_ARM64) || defined(_M_ARM64EC)
# define SNMALLOC_VA_BITS_64
# ifdef _MSC_VER
# include <arm64_neon.h>
Expand Down
13 changes: 11 additions & 2 deletions src/snmalloc/ds_core/bits.h
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,11 @@ namespace snmalloc
SNMALLOC_ASSERT(x != 0); // Calling with 0 is UB on some implementations

#if defined(_MSC_VER) && !defined(__clang__)
# ifdef _WIN64
# if defined(_M_ARM64) || defined(_M_ARM64EC)
unsigned long n = 0;
_BitScanForward64(&n, static_cast<unsigned __int64>(x));
return static_cast<size_t>(n);
# elif defined(_WIN64)
return _tzcnt_u64(static_cast<unsigned __int64>(x));
# else
return _tzcnt_u32(static_cast<unsigned int>(x));
Expand Down Expand Up @@ -203,7 +207,12 @@ namespace snmalloc
overflow = __builtin_mul_overflow(x, y, &prod);
return prod;
#elif defined(_MSC_VER)
# ifdef _WIN64
# if defined(_M_ARM64) || defined(_M_ARM64EC)
size_t high_prod = __umulh(x, y);
size_t prod = x * y;
overflow = high_prod != 0;
return prod;
# elif defined(_WIN64)
size_t high_prod;
size_t prod = _umul128(x, y, &high_prod);
overflow = high_prod != 0;
Expand Down

0 comments on commit d9bca64

Please sign in to comment.