diff options
author | 2021-06-21 13:53:49 -0700 | |
---|---|---|
committer | 2021-06-21 13:53:49 -0700 | |
commit | 32dbba7d2d4513774b2d877b4c88f2d0760bcf54 (patch) | |
tree | f9e6426cf8dc28413c456bdbcd450c85cb302422 /src/osd/eigccx86.h | |
parent | 5522729235b3ce81c839f3932c1aadc14de59e2b (diff) | |
parent | 2709c0143a8c7009715242c135b28403eeffce8b (diff) |
Merge branch 'master' into deprecateddeprecated
Diffstat (limited to 'src/osd/eigccx86.h')
-rw-r--r-- | src/osd/eigccx86.h | 64 |
1 files changed, 56 insertions, 8 deletions
diff --git a/src/osd/eigccx86.h b/src/osd/eigccx86.h index b3bbf7bd0ec..35f02e12f5e 100644 --- a/src/osd/eigccx86.h +++ b/src/osd/eigccx86.h @@ -433,13 +433,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; __asm__ ( @@ -450,18 +450,18 @@ _count_leading_zeros(uint32_t value) , [bias] "rm" (~uint32_t(0)) // 'bias' can be register or memory : "cc" // clobbers condition codes ); - return 31U - result; + return uint8_t(31U - 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; __asm__ ( @@ -472,7 +472,55 @@ _count_leading_ones(uint32_t value) , [bias] "rm" (~uint32_t(0)) // 'bias' can be register or memory : "cc" // clobbers condition codes ); - return 31U - result; + return uint8_t(31U - result); } + +/*------------------------------------------------- + count_leading_zeros_64 - return the number of + leading zero bits in a 64-bit value +-------------------------------------------------*/ + +#ifdef __x86_64__ +#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__ ( + " bsrq %[value], %[result] ;" + " cmovzq %[bias], %[result] ;" + : [result] "=&r" (result) // result can be in any register + : [value] "rm" (value) // 'value' can be register or memory + , [bias] "rm" (~uint64_t(0)) // 'bias' can be register or memory + : "cc" // clobbers condition codes + ); + return uint8_t(63U - result); +} +#endif + + +/*------------------------------------------------- + count_leading_ones_64 - return the number of + leading one bits in a 64-bit value +-------------------------------------------------*/ + +#ifdef __x86_64__ +#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__ ( + " bsrq %[value], %[result] ;" + " cmovzq %[bias], %[result] ;" + : [result] "=&r" (result) // result can be in any register + : [value] "rm" (~value) // 'value' can be register or memory + , [bias] "rm" (~uint64_t(0)) // 'bias' can be register or memory + : "cc" // clobbers condition codes + ); + return uint8_t(63U - result); +} +#endif + #endif // MAME_OSD_EIGCCX86_H |