@@ -1964,6 +1964,78 @@ extern UWtype __MPN(udiv_qrnnd) (UWtype *, UWtype, UWtype, UWtype);
1964
1964
1965
1965
#endif /* NO_ASM */
1966
1966
1967
+ #ifdef _MSC_VER
1968
+ #include <intrin.h>
1969
+ #include <immintrin.h>
1970
+ #if W_TYPE_SIZE == 32
1971
+ #ifndef count_leading_zeros
1972
+ #define count_leading_zeros (count , x ) \
1973
+ do { \
1974
+ USItype __cbtmp; \
1975
+ ASSERT ((x) != 0); \
1976
+ _BitScanReverse(&__cbtmp, x); \
1977
+ (count) = __cbtmp ^ 31; \
1978
+ } while (0)
1979
+ #endif
1980
+
1981
+ #ifndef count_trailing_zeros
1982
+ #define count_trailing_zeros (count , x ) \
1983
+ do { \
1984
+ ASSERT ((x) != 0); \
1985
+ _BitScanForward(&(count), x); \
1986
+ } while (0)
1987
+ #endif
1988
+
1989
+ #elif W_TYPE_SIZE == 64
1990
+ #ifndef count_leading_zeros
1991
+ #define count_leading_zeros (count , x ) \
1992
+ do { \
1993
+ USItype __cbtmp; \
1994
+ ASSERT ((x) != 0); \
1995
+ _BitScanReverse64(&__cbtmp, x); \
1996
+ (count) = __cbtmp ^ 63; \
1997
+ } while (0)
1998
+ #endif
1999
+
2000
+ #ifndef count_trailing_zeros
2001
+ #define count_trailing_zeros (count , x ) \
2002
+ do { \
2003
+ ASSERT ((x) != 0); \
2004
+ _BitScanForward64(&(count), x); \
2005
+ } while (0)
2006
+ #endif
2007
+
2008
+ #ifndef umul_ppmm
2009
+ #define umul_ppmm (w1 , w0 , u , v ) \
2010
+ do { \
2011
+ (w0) = _umul128(u, v, &(w1)); \
2012
+ } while (0)
2013
+ #endif
2014
+
2015
+ #ifndef smul_ppmm
2016
+ #define smul_ppmm (w1 , w0 , u , v ) \
2017
+ do { \
2018
+ (w0) = _mul128(u, v, &(w1)); \
2019
+ } while (0)
2020
+ #endif
2021
+
2022
+ #if _MSC_VER >= 1920
2023
+ #ifndef udiv_qrnnd
2024
+ #define udiv_qrnnd (q , r , n1 , n0 , dx ) \
2025
+ do { \
2026
+ (q) = _udiv128(n1, n0, dx, &(r)); \
2027
+ } while (0)
2028
+ #endif
2029
+
2030
+ #ifndef sdiv_qrnnd
2031
+ #define sdiv_qrnnd (q , r , n1 , n0 , dx ) \
2032
+ do { \
2033
+ (q) = _div128(n1, n0, dx, &(r)); \
2034
+ } while (0)
2035
+ #endif
2036
+ #endif
2037
+ #endif
2038
+ #endif
1967
2039
1968
2040
/* FIXME: "sidi" here is highly doubtful, should sometimes be "diti". */
1969
2041
#if !defined (umul_ppmm ) && defined (__umulsidi3 )
0 commit comments