[ARM64][SDK] Fix MinGW intrinsic declarations

This commit is contained in:
Ahmed ARIF
2026-07-25 17:46:38 +00:00
committed by Timo Kreuzer
parent f6efc98b37
commit 658328ca24
2 changed files with 57 additions and 71 deletions
+36 -2
View File
@@ -1007,9 +1007,43 @@ int _isunorderedf(float, float);
#endif /* _M_ARM */
#ifdef _M_ARM64
#if defined(_M_ARM64)
void __break(int);
unsigned char _BitScanForward64(unsigned long * _Index, unsigned __int64 _Mask);
unsigned char _BitScanReverse64(unsigned long * _Index, unsigned __int64 _Mask);
unsigned int _CountLeadingZeros(unsigned long);
unsigned int _CountLeadingZeros64(unsigned __int64);
unsigned int _CountOneBits(unsigned long);
unsigned int _CountOneBits64(unsigned __int64);
unsigned __int64 __getReg(int);
#endif
__int64 _InterlockedAdd64(_Interlocked_operand_ __int64 volatile * _Addend, __int64 _Value);
long _InterlockedAdd(_Interlocked_operand_ long volatile * _Addend, long _Value);
__int64 _InterlockedAnd64(_Interlocked_operand_ __int64 volatile * _Value, __int64 _Mask);
unsigned char _InterlockedCompareExchange128(_Interlocked_operand_ __int64 volatile * _Destination, __int64 _ExchangeHigh, __int64 _ExchangeLow, __int64 * _ComparandResult);
__int64 _InterlockedDecrement64(_Interlocked_operand_ __int64 volatile * _Addend);
__int64 _InterlockedExchange64(_Interlocked_operand_ __int64 volatile * _Target, __int64 _Value);
__int64 _InterlockedExchangeAdd64(_Interlocked_operand_ __int64 volatile * _Addend, __int64 _Value);
__int64 _InterlockedIncrement64(_Interlocked_operand_ __int64 volatile * _Addend);
__int64 _InterlockedOr64(_Interlocked_operand_ __int64 volatile * _Value, __int64 _Mask);
__int64 _InterlockedXor64(_Interlocked_operand_ __int64 volatile * _Value, __int64 _Mask);
void __yield(void);
__int64 __mulh(__int64, __int64);
unsigned __int64 __umulh(unsigned __int64, unsigned __int64);
unsigned char __readx18byte(unsigned long);
unsigned long __readx18dword(unsigned long);
unsigned __int64 __readx18qword(unsigned long);
unsigned short __readx18word(unsigned long);
void __writex18byte(unsigned long, unsigned char);
void __writex18dword(unsigned long, unsigned long);
void __writex18qword(unsigned long, unsigned __int64);
void __writex18word(unsigned long, unsigned short);
unsigned char _bittest64(__int64 const *, __int64);
unsigned char _bittestandcomplement64(__int64 *, __int64);
unsigned char _bittestandreset64(__int64 *, __int64);
unsigned char _bittestandset64(__int64 *, __int64);
unsigned char _interlockedbittestandreset64(__int64 volatile *, __int64);
unsigned char _interlockedbittestandset64(__int64 volatile *, __int64);
#endif /* _M_ARM64 */
#if defined(_M_CEE_PURE)
+21 -69
View File
@@ -387,6 +387,7 @@ __INTRIN_INLINE unsigned char _InterlockedCompareExchange128(
[xl] "r"((unsigned __int64)ExchangeLow),
[xh] "r"((unsigned __int64)ExchangeHigh)
: "cc", "memory");
__asm__ __volatile__("dmb ish" ::: "memory");
if (status == 0)
return 1;
ComparandResult[0] = (__int64)old_lo;
@@ -395,13 +396,6 @@ __INTRIN_INLINE unsigned char _InterlockedCompareExchange128(
}
#endif
#if !HAS_BUILTIN(_mm_pause)
__INTRIN_INLINE void _mm_pause(void)
{
__asm__ __volatile__("yield" : : : "memory");
}
#endif
#if !HAS_BUILTIN(__nop)
__INTRIN_INLINE void __nop(void)
{
@@ -632,49 +626,18 @@ __INTRIN_INLINE unsigned long __cdecl _lrotr(unsigned long value, int shift)
}
#endif
/*** 64-bit shifts ***/
#if !HAS_BUILTIN(__ll_lshift)
__INTRIN_INLINE unsigned long long __ll_lshift(unsigned long long Mask, int Bit)
{
return Mask << (Bit & 0x3F);
}
#endif
#if !HAS_BUILTIN(__ll_rshift)
__INTRIN_INLINE long long __ll_rshift(long long Mask, int Bit)
{
return Mask >> (Bit & 0x3F);
}
#endif
#if !HAS_BUILTIN(__ull_rshift)
__INTRIN_INLINE unsigned long long __ull_rshift(unsigned long long Mask, int Bit)
{
return Mask >> (Bit & 0x3F);
}
#endif
/*** Leading zero count and population count ***/
#if !HAS_BUILTIN(__lzcnt)
__INTRIN_INLINE unsigned int __lzcnt(unsigned int value)
/*** Bit count ***/
#if !HAS_BUILTIN(_CountLeadingZeros)
__INTRIN_INLINE unsigned int _CountLeadingZeros(unsigned long value)
{
if (!value)
return 32;
return __builtin_clz(value);
return sizeof(value) * 8;
return __builtin_clzl(value);
}
#endif
#if !HAS_BUILTIN(__lzcnt16)
__INTRIN_INLINE unsigned short __lzcnt16(unsigned short value)
{
if (!value)
return 16;
return (unsigned short)(__builtin_clz((unsigned int)value) - 16);
}
#endif
#if !HAS_BUILTIN(__lzcnt64)
__INTRIN_INLINE unsigned long long __lzcnt64(unsigned long long value)
#if !HAS_BUILTIN(_CountLeadingZeros64)
__INTRIN_INLINE unsigned int _CountLeadingZeros64(unsigned __int64 value)
{
if (!value)
return 64;
@@ -682,22 +645,15 @@ __INTRIN_INLINE unsigned long long __lzcnt64(unsigned long long value)
}
#endif
#if !HAS_BUILTIN(__popcnt)
__INTRIN_INLINE unsigned int __popcnt(unsigned int value)
#if !HAS_BUILTIN(_CountOneBits)
__INTRIN_INLINE unsigned int _CountOneBits(unsigned long value)
{
return __builtin_popcount(value);
return __builtin_popcountl(value);
}
#endif
#if !HAS_BUILTIN(__popcnt16)
__INTRIN_INLINE unsigned short __popcnt16(unsigned short value)
{
return __builtin_popcount(value);
}
#endif
#if !HAS_BUILTIN(__popcnt64)
__INTRIN_INLINE unsigned long long __popcnt64(unsigned long long value)
#if !HAS_BUILTIN(_CountOneBits64)
__INTRIN_INLINE unsigned int _CountOneBits64(unsigned __int64 value)
{
return __builtin_popcountll(value);
}
@@ -794,18 +750,14 @@ __INTRIN_INLINE void __isb(unsigned int type)
should use named MSR/MRS asm wrappers instead. */
#if !HAS_BUILTIN(__getReg)
__INTRIN_INLINE unsigned __int64 __getReg(int reg)
{
unsigned __int64 value;
if (reg == 18)
{
__asm__ __volatile__("mov %0, x18" : "=r"(value));
return value;
}
__builtin_trap();
}
#define __getReg(reg) \
__extension__({ \
_Static_assert((unsigned long long)(reg) <= 31ULL, \
"__getReg: register index out of range"); \
unsigned __int64 _value; \
__asm__ __volatile__("mov %0, x%c1" : "=r"(_value) : "i"(reg)); \
_value; \
})
#endif
/*** _InterlockedAdd (returns the new, post-add value) ***/