summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt5
-rw-r--r--include/wabt/interp/interp-math.h4
-rw-r--r--src/config.h.in29
3 files changed, 32 insertions, 6 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 28f1c43d..48812d13 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -113,6 +113,11 @@ if (NOT USE_INTERNAL_SHA256)
endif()
if (WIN32)
+ if(${CMAKE_GENERATOR_PLATFORM} MATCHES "ARM64")
+ # https://discourse.cmake.org/t/visual-studio-error-unable-to-deploy-local-file-c-x64-release-zero-check/2072
+ # Target ZERO_CHECK blocks remote debugger of ARM64 in Visual Studio
+ set(CMAKE_SUPPRESS_REGENERATION ON)
+ endif()
check_symbol_exists(ENABLE_VIRTUAL_TERMINAL_PROCESSING "windows.h" HAVE_WIN32_VT100)
endif ()
diff --git a/include/wabt/interp/interp-math.h b/include/wabt/interp/interp-math.h
index ef93e336..072a35ef 100644
--- a/include/wabt/interp/interp-math.h
+++ b/include/wabt/interp/interp-math.h
@@ -22,7 +22,7 @@
#include <string>
#include <type_traits>
-#if COMPILER_IS_MSVC
+#if COMPILER_IS_MSVC && _M_X64
#include <emmintrin.h>
#include <immintrin.h>
#endif
@@ -189,7 +189,7 @@ RunResult WABT_VECTORCALL IntRem(T lhs, T rhs, T* out, std::string* out_msg) {
return RunResult::Ok;
}
-#if COMPILER_IS_MSVC
+#if COMPILER_IS_MSVC && _M_X64
template <typename T> T WABT_VECTORCALL FloatAbs(T val);
template <typename T> T WABT_VECTORCALL FloatCopysign(T lhs, T rhs);
diff --git a/src/config.h.in b/src/config.h.in
index 5eb8e0a6..f7187c32 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -158,7 +158,7 @@ inline int Clz(unsigned int mask) {
}
inline int Clz(unsigned __int64 mask) {
-#if _M_X64
+#if _M_X64 || _M_ARM64
if (mask == 0)
return 64;
@@ -190,7 +190,7 @@ inline int Ctz(unsigned int mask) {
}
inline int Ctz(unsigned __int64 mask) {
-#if _M_X64
+#if _M_X64 || _M_ARM64
if (mask == 0)
return 64;
@@ -208,12 +208,31 @@ inline int Ctz(unsigned __int64 mask) {
#endif
}
-inline int Popcount(uint8_t value) {
- return __popcnt(value);
+#if _M_ARM64
+//https://stackoverflow.com/a/70012905
+template <typename T>
+int BrianKernighanPopcount(T value) {
+ int count;
+ for(count = 0; value; count++)
+ {
+ value &= value - 1;
+ }
+ return count;
}
+#endif
inline int Popcount(unsigned long value) {
+ #if _M_X64 || _M_IX86
return __popcnt(value);
+#elif _M_ARM64
+ return BrianKernighanPopcount(value);
+#else
+#error unexpected architecture
+#endif
+}
+
+inline int Popcount(uint8_t value) {
+ return Popcount((unsigned long)value);
}
inline int Popcount(unsigned int value) {
@@ -225,6 +244,8 @@ inline int Popcount(unsigned __int64 value) {
return __popcnt64(value);
#elif _M_IX86
return Popcount(HighDword(value)) + Popcount(LowDword(value));
+#elif _M_ARM64
+ return BrianKernighanPopcount(value);
#else
#error unexpected architecture
#endif