mirror of
https://github.com/yuzu-emu/unicorn.git
synced 2025-01-10 22:45:36 +00:00
Drop QEMU_GNUC_PREREQ() checks for gcc older than 4.1
We already require gcc 4.1 or newer (for the atomic support), so the fallback codepaths for older gcc versions than that are now dead code and we can just delete them. NB: clang reports itself as gcc 4.2 (regardless of clang version), so clang won't be using the fallbacks either. Backports commit fa54abb8c298f892639ffc4bc2f61448ac3be4a1 from qemu
This commit is contained in:
parent
2935a9af7a
commit
b8b70dfcd2
|
@ -104,11 +104,7 @@ static union MSVC_FLOAT_HACK __NAN = {{0x00, 0x00, 0xC0, 0x7F}};
|
|||
#define QEMU_UNUSED_VAR __attribute__((unused))
|
||||
#define QEMU_UNUSED_FUNC __attribute__((unused))
|
||||
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
#define QEMU_WARN_UNUSED_RESULT __attribute__((warn_unused_result))
|
||||
#else
|
||||
#define QEMU_WARN_UNUSED_RESULT
|
||||
#endif
|
||||
|
||||
#if QEMU_GNUC_PREREQ(4, 3)
|
||||
#define QEMU_ARTIFICIAL __attribute__((always_inline, artificial))
|
||||
|
|
|
@ -118,37 +118,7 @@ static inline uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c)
|
|||
*/
|
||||
static inline int clz32(uint32_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return val ? __builtin_clz(val) : 32;
|
||||
#else
|
||||
/* Binary search for the leading one bit. */
|
||||
int cnt = 0;
|
||||
|
||||
if (!(val & 0xFFFF0000U)) {
|
||||
cnt += 16;
|
||||
val <<= 16;
|
||||
}
|
||||
if (!(val & 0xFF000000U)) {
|
||||
cnt += 8;
|
||||
val <<= 8;
|
||||
}
|
||||
if (!(val & 0xF0000000U)) {
|
||||
cnt += 4;
|
||||
val <<= 4;
|
||||
}
|
||||
if (!(val & 0xC0000000U)) {
|
||||
cnt += 2;
|
||||
val <<= 2;
|
||||
}
|
||||
if (!(val & 0x80000000U)) {
|
||||
cnt++;
|
||||
val <<= 1;
|
||||
}
|
||||
if (!(val & 0x80000000U)) {
|
||||
cnt++;
|
||||
}
|
||||
return cnt;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -171,19 +141,7 @@ static inline int clo32(uint32_t val)
|
|||
*/
|
||||
static inline int clz64(uint64_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return val ? __builtin_clzll(val) : 64;
|
||||
#else
|
||||
int cnt = 0;
|
||||
|
||||
if (!(val >> 32)) {
|
||||
cnt += 32;
|
||||
} else {
|
||||
val >>= 32;
|
||||
}
|
||||
|
||||
return cnt + clz32((uint32_t)val);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -206,39 +164,7 @@ static inline int clo64(uint64_t val)
|
|||
*/
|
||||
static inline int ctz32(uint32_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return val ? __builtin_ctz(val) : 32;
|
||||
#else
|
||||
/* Binary search for the trailing one bit. */
|
||||
int cnt;
|
||||
|
||||
cnt = 0;
|
||||
if (!(val & 0x0000FFFFUL)) {
|
||||
cnt += 16;
|
||||
val >>= 16;
|
||||
}
|
||||
if (!(val & 0x000000FFUL)) {
|
||||
cnt += 8;
|
||||
val >>= 8;
|
||||
}
|
||||
if (!(val & 0x0000000FUL)) {
|
||||
cnt += 4;
|
||||
val >>= 4;
|
||||
}
|
||||
if (!(val & 0x00000003UL)) {
|
||||
cnt += 2;
|
||||
val >>= 2;
|
||||
}
|
||||
if (!(val & 0x00000001UL)) {
|
||||
cnt++;
|
||||
val >>= 1;
|
||||
}
|
||||
if (!(val & 0x00000001UL)) {
|
||||
cnt++;
|
||||
}
|
||||
|
||||
return cnt;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -261,19 +187,7 @@ static inline int cto32(uint32_t val)
|
|||
*/
|
||||
static inline int ctz64(uint64_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return val ? __builtin_ctzll(val) : 64;
|
||||
#else
|
||||
int cnt;
|
||||
|
||||
cnt = 0;
|
||||
if (!((uint32_t)val)) {
|
||||
cnt += 32;
|
||||
val >>= 32;
|
||||
}
|
||||
|
||||
return cnt + ctz32((uint32_t)val);
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -325,15 +239,7 @@ static inline int clrsb64(uint64_t val)
|
|||
*/
|
||||
static inline int ctpop8(uint8_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return __builtin_popcount(val);
|
||||
#else
|
||||
val = (val & 0x55) + ((val >> 1) & 0x55);
|
||||
val = (val & 0x33) + ((val >> 2) & 0x33);
|
||||
val = (val + (val >> 4)) & 0x0f;
|
||||
|
||||
return val;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,16 +248,7 @@ static inline int ctpop8(uint8_t val)
|
|||
*/
|
||||
static inline int ctpop16(uint16_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return __builtin_popcount(val);
|
||||
#else
|
||||
val = (val & 0x5555) + ((val >> 1) & 0x5555);
|
||||
val = (val & 0x3333) + ((val >> 2) & 0x3333);
|
||||
val = (val + (val >> 4)) & 0x0f0f;
|
||||
val = (val + (val >> 8)) & 0x00ff;
|
||||
|
||||
return val;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -360,16 +257,7 @@ static inline int ctpop16(uint16_t val)
|
|||
*/
|
||||
static inline int ctpop32(uint32_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return __builtin_popcount(val);
|
||||
#else
|
||||
val = (val & 0x55555555) + ((val >> 1) & 0x55555555);
|
||||
val = (val & 0x33333333) + ((val >> 2) & 0x33333333);
|
||||
val = (val + (val >> 4)) & 0x0f0f0f0f;
|
||||
val = (val * 0x01010101) >> 24;
|
||||
|
||||
return val;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -378,16 +266,7 @@ static inline int ctpop32(uint32_t val)
|
|||
*/
|
||||
static inline int ctpop64(uint64_t val)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(3, 4)
|
||||
return __builtin_popcountll(val);
|
||||
#else
|
||||
val = (val & 0x5555555555555555ULL) + ((val >> 1) & 0x5555555555555555ULL);
|
||||
val = (val & 0x3333333333333333ULL) + ((val >> 2) & 0x3333333333333333ULL);
|
||||
val = (val + (val >> 4)) & 0x0f0f0f0f0f0f0f0fULL;
|
||||
val = (val * 0x0101010101010101ULL) >> 56;
|
||||
|
||||
return (int)val;
|
||||
#endif
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -131,14 +131,7 @@ enum {
|
|||
|
||||
static inline void flush_icache_range(uintptr_t start, uintptr_t stop)
|
||||
{
|
||||
#if QEMU_GNUC_PREREQ(4, 1)
|
||||
__builtin___clear_cache((char *) start, (char *) stop);
|
||||
#else
|
||||
register uintptr_t _beg __asm("a1") = start;
|
||||
register uintptr_t _end __asm("a2") = stop;
|
||||
register uintptr_t _flg __asm("a3") = 0;
|
||||
__asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg));
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue