summaryrefslogtreecommitdiff
path: root/src/recompiler/host-utils.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/recompiler/host-utils.h')
-rw-r--r--src/recompiler/host-utils.h110
1 files changed, 31 insertions, 79 deletions
diff --git a/src/recompiler/host-utils.h b/src/recompiler/host-utils.h
index eb83cd260..0ddc17658 100644
--- a/src/recompiler/host-utils.h
+++ b/src/recompiler/host-utils.h
@@ -27,16 +27,16 @@
#if defined(__x86_64__)
#define __HAVE_FAST_MULU64__
-static always_inline void mulu64 (uint64_t *plow, uint64_t *phigh,
- uint64_t a, uint64_t b)
+static inline void mulu64(uint64_t *plow, uint64_t *phigh,
+ uint64_t a, uint64_t b)
{
__asm__ ("mul %0\n\t"
: "=d" (*phigh), "=a" (*plow)
: "a" (a), "0" (b));
}
#define __HAVE_FAST_MULS64__
-static always_inline void muls64 (uint64_t *plow, uint64_t *phigh,
- int64_t a, int64_t b)
+static inline void muls64(uint64_t *plow, uint64_t *phigh,
+ int64_t a, int64_t b)
{
__asm__ ("imul %0\n\t"
: "=d" (*phigh), "=a" (*plow)
@@ -49,11 +49,7 @@ void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b);
/* Binary search for leading zeros. */
-#ifndef VBOX
-static always_inline int clz32(uint32_t val)
-#else
-DECLALWAYSINLINE(int) clz32(uint32_t val)
-#endif
+static inline int clz32(uint32_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
@@ -90,20 +86,12 @@ DECLALWAYSINLINE(int) clz32(uint32_t val)
#endif
}
-#ifndef VBOX
-static always_inline int clo32(uint32_t val)
-#else
-DECLALWAYSINLINE(int) clo32(uint32_t val)
-#endif
+static inline int clo32(uint32_t val)
{
return clz32(~val);
}
-#ifndef VBOX
-static always_inline int clz64(uint64_t val)
-#else
-DECLALWAYSINLINE(int) clz64(uint64_t val)
-#endif
+static inline int clz64(uint64_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
@@ -123,20 +111,12 @@ DECLALWAYSINLINE(int) clz64(uint64_t val)
#endif
}
-#ifndef VBOX
-static always_inline int clo64(uint64_t val)
-#else
-DECLALWAYSINLINE(int) clo64(uint64_t val)
-#endif
+static inline int clo64(uint64_t val)
{
return clz64(~val);
}
-#ifndef VBOX
-static always_inline int ctz32 (uint32_t val)
-#else
-DECLALWAYSINLINE(int) ctz32 (uint32_t val)
-#endif
+static inline int ctz32(uint32_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
@@ -148,51 +128,43 @@ DECLALWAYSINLINE(int) ctz32 (uint32_t val)
cnt = 0;
if (!(val & 0x0000FFFFUL)) {
- cnt += 16;
+ cnt += 16;
val >>= 16;
- }
+ }
if (!(val & 0x000000FFUL)) {
- cnt += 8;
+ cnt += 8;
val >>= 8;
- }
+ }
if (!(val & 0x0000000FUL)) {
- cnt += 4;
+ cnt += 4;
val >>= 4;
- }
+ }
if (!(val & 0x00000003UL)) {
- cnt += 2;
+ cnt += 2;
val >>= 2;
- }
+ }
if (!(val & 0x00000001UL)) {
- cnt++;
+ cnt++;
val >>= 1;
- }
+ }
if (!(val & 0x00000001UL)) {
- cnt++;
- }
+ cnt++;
+ }
- return cnt;
+ return cnt;
#endif
- }
+}
-#ifndef VBOX
-static always_inline int cto32 (uint32_t val)
-#else
-DECLALWAYSINLINE(int) cto32 (uint32_t val)
-#endif
+static inline int cto32(uint32_t val)
{
return ctz32(~val);
}
-#ifndef VBOX
-static always_inline int ctz64 (uint64_t val)
-#else
-DECLALWAYSINLINE(int) ctz64 (uint64_t val)
-#endif
+static inline int ctz64(uint64_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
if (val)
- return __builtin_ctz(val);
+ return __builtin_ctzll(val);
else
return 64;
#else
@@ -208,20 +180,12 @@ DECLALWAYSINLINE(int) ctz64 (uint64_t val)
#endif
}
-#ifndef VBOX
-static always_inline int cto64 (uint64_t val)
-#else
-DECLALWAYSINLINE(int) cto64 (uint64_t val)
-#endif
+static inline int cto64(uint64_t val)
{
return ctz64(~val);
}
-#ifndef VBOX
-static always_inline int ctpop8 (uint8_t val)
-#else
-DECLALWAYSINLINE(int) ctpop8 (uint8_t val)
-#endif
+static inline int ctpop8(uint8_t val)
{
val = (val & 0x55) + ((val >> 1) & 0x55);
val = (val & 0x33) + ((val >> 2) & 0x33);
@@ -230,11 +194,7 @@ DECLALWAYSINLINE(int) ctpop8 (uint8_t val)
return val;
}
-#ifndef VBOX
-static always_inline int ctpop16 (uint16_t val)
-#else
-DECLALWAYSINLINE(int) ctpop16 (uint16_t val)
-#endif
+static inline int ctpop16(uint16_t val)
{
val = (val & 0x5555) + ((val >> 1) & 0x5555);
val = (val & 0x3333) + ((val >> 2) & 0x3333);
@@ -244,11 +204,7 @@ DECLALWAYSINLINE(int) ctpop16 (uint16_t val)
return val;
}
-#ifndef VBOX
-static always_inline int ctpop32 (uint32_t val)
-#else
-DECLALWAYSINLINE(int) ctpop32 (uint32_t val)
-#endif
+static inline int ctpop32(uint32_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_popcount(val);
@@ -263,11 +219,7 @@ DECLALWAYSINLINE(int) ctpop32 (uint32_t val)
#endif
}
-#ifndef VBOX
-static always_inline int ctpop64 (uint64_t val)
-#else
-DECLALWAYSINLINE(int) ctpop64 (uint64_t val)
-#endif
+static inline int ctpop64(uint64_t val)
{
#if QEMU_GNUC_PREREQ(3, 4)
return __builtin_popcountll(val);