From 9b5a9d751ec23817117047786688f4abdbe8646f Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:08:47 -0500 Subject: [PATCH 1/5] Fix const issue with erase and erase_if in string --- include/fast_io_dsal/impl/string.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/fast_io_dsal/impl/string.h b/include/fast_io_dsal/impl/string.h index bbe5eca7..745b14d0 100644 --- a/include/fast_io_dsal/impl/string.h +++ b/include/fast_io_dsal/impl/string.h @@ -1463,7 +1463,7 @@ class }; template <::std::integral chtype, typename allocator1, typename U> -inline constexpr void erase(::fast_io::containers::basic_string const &c, U const &value) +inline constexpr void erase(::fast_io::containers::basic_string &c, U const &value) { auto it = ::std::remove(c.begin(), c.end(), value); auto r = c.end() - it; @@ -1472,7 +1472,7 @@ inline constexpr void erase(::fast_io::containers::basic_string -inline constexpr void erase_if(::fast_io::containers::basic_string const &c, Pred pred) +inline constexpr void erase_if(::fast_io::containers::basic_string &c, Pred pred) { auto it = ::std::remove_if(c.begin(), c.end(), pred); auto r = c.end() - it; From f01f951dff4131d36b536bbbe077bff39305e0a1 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Sun, 24 Nov 2024 21:13:41 -0500 Subject: [PATCH 2/5] return type should be size_t not void for erase and erase_if --- include/fast_io_dsal/impl/string.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/fast_io_dsal/impl/string.h b/include/fast_io_dsal/impl/string.h index 5c1d2de1..4b570a27 100644 --- a/include/fast_io_dsal/impl/string.h +++ b/include/fast_io_dsal/impl/string.h @@ -1468,21 +1468,21 @@ class }; template <::std::integral chtype, typename allocator1, typename U> -inline constexpr void erase(::fast_io::containers::basic_string &c, U const &value) +inline constexpr ::fast_io::containers::basic_string::size_type erase(::fast_io::containers::basic_string &c, U const &value) { auto it = ::std::remove(c.begin(), c.end(), value); auto r = c.end() - it; c.erase(it, c.end()); - return r; + return static_cast<::fast_io::containers::basic_string::size_type>(r); } template <::std::integral chtype, typename allocator1, typename Pred> -inline constexpr void erase_if(::fast_io::containers::basic_string &c, Pred pred) +inline constexpr ::fast_io::containers::basic_string::size_type erase_if(::fast_io::containers::basic_string &c, Pred pred) { auto it = ::std::remove_if(c.begin(), c.end(), pred); auto r = c.end() - it; c.erase(it, c.end()); - return r; + return static_cast<::fast_io::containers::basic_string::size_type>(r); } template <::std::integral chtype, typename allocator1, typename allocator2> From 72f8b27973bcda87065023aa2173e0adb6dda45a Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Mon, 25 Nov 2024 04:29:24 -0500 Subject: [PATCH 3/5] fix compilation issues for arm64ec --- include/fast_io_core_impl/intrinsics/udivmod.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fast_io_core_impl/intrinsics/udivmod.h b/include/fast_io_core_impl/intrinsics/udivmod.h index a1b07728..20df39da 100644 --- a/include/fast_io_core_impl/intrinsics/udivmod.h +++ b/include/fast_io_core_impl/intrinsics/udivmod.h @@ -26,7 +26,7 @@ Referenced from template inline constexpr tuint udivbigbysmalltosmalldefault(T u1, T u0, T v) noexcept { -#if defined(__x86_64__) || defined(_M_AMD64) +#if (defined(__x86_64__) || defined(_M_AMD64)) && !defined(__arm64ec__) if constexpr (sizeof(T) == sizeof(::std::uint_least64_t)) { #if defined(__cpp_if_consteval) From c93f644f40579b78bac5f496a3d83137b85fff36 Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Mon, 25 Nov 2024 04:35:56 -0500 Subject: [PATCH 4/5] Fix nt_preliminary_definition.h for aarch64 --- include/fast_io_hosted/platforms/nt/nt_preliminary_definition.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/fast_io_hosted/platforms/nt/nt_preliminary_definition.h b/include/fast_io_hosted/platforms/nt/nt_preliminary_definition.h index fc203805..f5560fef 100644 --- a/include/fast_io_hosted/platforms/nt/nt_preliminary_definition.h +++ b/include/fast_io_hosted/platforms/nt/nt_preliminary_definition.h @@ -461,7 +461,7 @@ inline peb *nt_get_current_peb() noexcept #endif #elif defined(_MSC_VER) #if defined(_M_ARM64) || defined(_M_ARM64EC) - return reinterpret_cast<::fast_io::win32::nt::peb *>(::fast_io::intrinsics::msvc::arm::__getReg(18))->ProcessEnvironmentBlock; + return reinterpret_cast<::fast_io::win32::nt::teb *>(::fast_io::intrinsics::msvc::arm::__getReg(18))->ProcessEnvironmentBlock; #elif defined(_M_AMD64) return reinterpret_cast<::fast_io::win32::nt::peb *>(::fast_io::intrinsics::msvc::x86::__readgsqword(0x60)); #elif defined(_M_IX86) From 4e83fa4bc1681e3eb2485d5473cb3b4616f8232f Mon Sep 17 00:00:00 2001 From: cqwrteur <100043421+trcrsired@users.noreply.github.com> Date: Mon, 25 Nov 2024 04:43:49 -0500 Subject: [PATCH 5/5] Fix some issues related to arm64ec --- include/fast_io_core_impl/intrinsics/carry.h | 4 ++-- include/fast_io_core_impl/intrinsics/msvc/impl.h | 2 ++ include/fast_io_core_impl/intrinsics/udivmod.h | 6 +++--- include/fast_io_core_impl/intrinsics/umul.h | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/fast_io_core_impl/intrinsics/carry.h b/include/fast_io_core_impl/intrinsics/carry.h index 41cffbfe..918ea80a 100644 --- a/include/fast_io_core_impl/intrinsics/carry.h +++ b/include/fast_io_core_impl/intrinsics/carry.h @@ -26,7 +26,7 @@ inline constexpr T addc(T a, T b, bool carryin, bool &carryout) noexcept if (!__builtin_is_constant_evaluated()) #endif { -#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_IX86) || defined(_M_AMD64)) +#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_IX86) || defined(_M_AMD64)) && !defined(__arm64ec__) && !defined(_M_ARM64EC) #if !__has_cpp_attribute(assume) __assume(carryin == 0 || carryin == 1); #endif @@ -104,7 +104,7 @@ inline constexpr T subc(T a, T b, bool carryin, bool &carryout) noexcept if (!__builtin_is_constant_evaluated()) #endif { -#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_IX86) || defined(_M_AMD64)) +#if defined(_MSC_VER) && !defined(__clang__) && (defined(_M_IX86) || defined(_M_AMD64)) && !defined(__arm64ec__) && !defined(_M_ARM64EC) #if !__has_cpp_attribute(assume) __assume(carryin == 0 || carryin == 1); #endif diff --git a/include/fast_io_core_impl/intrinsics/msvc/impl.h b/include/fast_io_core_impl/intrinsics/msvc/impl.h index 1e073419..1f0ce5a9 100644 --- a/include/fast_io_core_impl/intrinsics/msvc/impl.h +++ b/include/fast_io_core_impl/intrinsics/msvc/impl.h @@ -1,7 +1,9 @@ #pragma once #if defined(_MSC_VER) && !defined(__clang__) +#if !defined(_M_ARM64EC) #include "x86.h" +#endif #include "arm.h" #include "common.h" #endif diff --git a/include/fast_io_core_impl/intrinsics/udivmod.h b/include/fast_io_core_impl/intrinsics/udivmod.h index 20df39da..fb1632c6 100644 --- a/include/fast_io_core_impl/intrinsics/udivmod.h +++ b/include/fast_io_core_impl/intrinsics/udivmod.h @@ -26,7 +26,7 @@ Referenced from template inline constexpr tuint udivbigbysmalltosmalldefault(T u1, T u0, T v) noexcept { -#if (defined(__x86_64__) || defined(_M_AMD64)) && !defined(__arm64ec__) +#if (defined(__x86_64__) || defined(_M_AMD64)) && !defined(__arm64ec__) && !defined(_M_ARM64EC) if constexpr (sizeof(T) == sizeof(::std::uint_least64_t)) { #if defined(__cpp_if_consteval) @@ -112,7 +112,7 @@ inline constexpr tuint udivbigbysmalltosmalldefault(T u1, T u0, T v) noexcept template inline constexpr T shiftleft(T low, T high, unsigned shift) noexcept { -#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_AMD64) +#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_AMD64) && !defined(__arm64ec__) && !defined(_M_ARM64EC) if constexpr (sizeof(T) == sizeof(long long unsigned)) { #if defined(__cpp_if_consteval) @@ -137,7 +137,7 @@ inline constexpr T shiftleft(T low, T high, unsigned shift) noexcept template inline constexpr T shiftright(T low, T high, unsigned shift) noexcept { -#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_AMD64) +#if defined(_MSC_VER) && !defined(__clang__) && defined(_M_AMD64) && !defined(__arm64ec__) && !defined(_M_ARM64EC) if constexpr (sizeof(T) == sizeof(long long unsigned)) { #if defined(__cpp_if_consteval) diff --git a/include/fast_io_core_impl/intrinsics/umul.h b/include/fast_io_core_impl/intrinsics/umul.h index 36917883..35840e76 100644 --- a/include/fast_io_core_impl/intrinsics/umul.h +++ b/include/fast_io_core_impl/intrinsics/umul.h @@ -418,7 +418,7 @@ inline constexpr T umul(U a, T b, U &high) noexcept return static_cast(res); } } -#elif defined(_MSC_VER) && defined(_M_X64) +#elif defined(_MSC_VER) && defined(_M_X64) && !defined(__arm64ec__) && !defined(_M_ARM64EC) #if defined(__cpp_lib_is_constant_evaluated) || defined(__cpp_if_consteval) #if defined(__cpp_if_consteval) if consteval @@ -526,7 +526,7 @@ inline constexpr U umulh(U a, T b) noexcept return static_cast(res >> 64u); } } -#elif defined(_MSC_VER) && defined(_M_X64) +#elif defined(_MSC_VER) && defined(_M_X64) && !defined(__arm64ec__) && !defined(_M_ARM64EC) #if defined(__cpp_lib_is_constant_evaluated) || defined(__cpp_if_consteval) #if defined(__cpp_if_consteval) if consteval