diff options
Diffstat (limited to 'src/osd/eigccppc.h')
-rw-r--r-- | src/osd/eigccppc.h | 66 |
1 files changed, 56 insertions, 10 deletions
diff --git a/src/osd/eigccppc.h b/src/osd/eigccppc.h index 3a1b2093d4e..b1f0fc638a7 100644 --- a/src/osd/eigccppc.h +++ b/src/osd/eigccppc.h @@ -204,7 +204,7 @@ _recip_approx(float value) multiply and return the full 128 bit result -------------------------------------------------*/ -#if defined(__ppc64__) +#if defined(__ppc64__) || defined(__PPC64___) || defined(_ARCH_PPC64) #define mul_64x64 _mul_64x64 inline int64_t ATTR_FORCE_INLINE _mul_64x64(int64_t a, int64_t b, int64_t &hi) @@ -221,7 +221,7 @@ _mul_64x64(int64_t a, int64_t b, int64_t &hi) bit multiply and return the full 128 bit result -------------------------------------------------*/ -#if defined(__ppc64__) +#if defined(__ppc64__) || defined(__PPC64___) || defined(_ARCH_PPC64) #define mulu_64x64 _mulu_64x64 inline uint64_t ATTR_FORCE_INLINE _mulu_64x64(uint64_t a, uint64_t b, uint64_t &hi) @@ -239,13 +239,13 @@ _mulu_64x64(uint64_t a, uint64_t b, uint64_t &hi) ***************************************************************************/ /*------------------------------------------------- - count_leading_zeros - return the number of + count_leading_zeros_32 - return the number of leading zero bits in a 32-bit value -------------------------------------------------*/ -#define count_leading_zeros _count_leading_zeros +#define count_leading_zeros_32 _count_leading_zeros_32 inline uint8_t ATTR_CONST ATTR_FORCE_INLINE -_count_leading_zeros(uint32_t value) +_count_leading_zeros_32(uint32_t value) { uint32_t result; @@ -255,18 +255,18 @@ _count_leading_zeros(uint32_t value) : [value] "r" (value) ); - return result; + return uint8_t(result); } /*------------------------------------------------- - count_leading_ones - return the number of + count_leading_ones_32 - return the number of leading one bits in a 32-bit value -------------------------------------------------*/ -#define count_leading_ones _count_leading_ones +#define count_leading_ones_32 _count_leading_ones_32 inline uint8_t ATTR_CONST ATTR_FORCE_INLINE -_count_leading_ones(uint32_t value) +_count_leading_ones_32(uint32_t value) { uint32_t result; @@ -276,7 +276,53 @@ _count_leading_ones(uint32_t value) : [value] "r" (~value) ); - return result; + return uint8_t(result); +} + + +/*------------------------------------------------- + count_leading_zeros_64 - return the number of + leading zero bits in a 64-bit value +-------------------------------------------------*/ + +#if defined(__ppc64__) || defined(__PPC64___) || defined(_ARCH_PPC64) +#define count_leading_zeros_64 _count_leading_zeros_64 +inline uint8_t ATTR_CONST ATTR_FORCE_INLINE +_count_leading_zeros_64(uint64_t value) +{ + uint64_t result; + + __asm__ ( + " cntlzd %[result], %[value] \n" + : [result] "=r" (result) + : [value] "r" (value) + ); + + return uint8_t(result); } +#endif + + +/*------------------------------------------------- + count_leading_ones_64 - return the number of + leading one bits in a 64-bit value +-------------------------------------------------*/ + +#if defined(__ppc64__) || defined(__PPC64___) || defined(_ARCH_PPC64) +#define count_leading_ones_64 _count_leading_ones_64 +inline uint8_t ATTR_CONST ATTR_FORCE_INLINE +_count_leading_ones_64(uint64_t value) +{ + uint64_t result; + + __asm__ ( + " cntlzd %[result], %[value] \n" + : [result] "=r" (result) + : [value] "r" (~value) + ); + + return uint8_t(result); +} +#endif #endif // MAME_OSD_EIGCCPPC_H |