mirror of
https://github.com/holub/mame
synced 2025-10-06 17:08:28 +03:00
add GCC/clang implementations of 64*64->128 multiply for x86_64, and adjust some integer casts
This commit is contained in:
parent
a7c5845317
commit
05d0305c08
@ -456,6 +456,40 @@ _recip_approx(float value)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------
|
||||||
|
mul_64x64 - perform a signed 64 bit x 64 bit
|
||||||
|
multiply and return the full 128 bit result
|
||||||
|
-------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
|
#define mul_64x64 _mul_64x64
|
||||||
|
inline int64_t ATTR_FORCE_INLINE
|
||||||
|
_mul_64x64(int64_t a, int64_t b, int64_t *hi)
|
||||||
|
{
|
||||||
|
__int128 const r(__int128(a) * b);
|
||||||
|
*hi = int64_t(uint64_t((unsigned __int128)r >> 64));
|
||||||
|
return int64_t(uint64_t((unsigned __int128)r));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
/*-------------------------------------------------
|
||||||
|
mulu_64x64 - perform an unsigned 64 bit x 64
|
||||||
|
bit multiply and return the full 128 bit result
|
||||||
|
-------------------------------------------------*/
|
||||||
|
|
||||||
|
#ifdef __x86_64__
|
||||||
|
#define mulu_64x64 _mulu_64x64
|
||||||
|
inline uint64_t ATTR_FORCE_INLINE
|
||||||
|
_mulu_64x64(uint64_t a, uint64_t b, uint64_t *hi)
|
||||||
|
{
|
||||||
|
unsigned __int128 const r((unsigned __int128)a * b);
|
||||||
|
*hi = uint64_t(r >> 64);
|
||||||
|
return uint64_t(r);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
INLINE BIT MANIPULATION FUNCTIONS
|
INLINE BIT MANIPULATION FUNCTIONS
|
||||||
|
@ -268,10 +268,10 @@ inline float recip_approx(float value)
|
|||||||
#ifndef mul_64x64
|
#ifndef mul_64x64
|
||||||
inline int64_t mul_64x64(int64_t a, int64_t b, int64_t *hi)
|
inline int64_t mul_64x64(int64_t a, int64_t b, int64_t *hi)
|
||||||
{
|
{
|
||||||
uint64_t const a_hi = uint32_t(a >> 32);
|
uint64_t const a_hi = uint64_t(a) >> 32;
|
||||||
uint64_t const b_hi = uint32_t(b >> 32);
|
uint64_t const b_hi = uint64_t(b) >> 32;
|
||||||
uint64_t const a_lo = uint32_t(a);
|
uint64_t const a_lo = uint32_t(uint64_t(a));
|
||||||
uint64_t const b_lo = uint32_t(b);
|
uint64_t const b_lo = uint32_t(uint64_t(b));
|
||||||
|
|
||||||
uint64_t const ab_lo = a_lo * b_lo;
|
uint64_t const ab_lo = a_lo * b_lo;
|
||||||
uint64_t const ab_m1 = a_hi * b_lo;
|
uint64_t const ab_m1 = a_hi * b_lo;
|
||||||
@ -317,6 +317,8 @@ inline uint64_t mulu_64x64(uint64_t a, uint64_t b, uint64_t *hi)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
INLINE BIT MANIPULATION FUNCTIONS
|
INLINE BIT MANIPULATION FUNCTIONS
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
|
Loading…
Reference in New Issue
Block a user