Commit 7a51ad822f533472cab908d2622578d51eb97dc6
1 parent
077fc206
For consistency, move muls64 / mulu64 prototypes to host-utils.h
Make x86_64 optimized versions inline. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3523 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
5 changed files
with
31 additions
and
42 deletions
exec-all.h
... | ... | @@ -91,9 +91,6 @@ void optimize_flags_init(void); |
91 | 91 | extern FILE *logfile; |
92 | 92 | extern int loglevel; |
93 | 93 | |
94 | -void muls64(int64_t *phigh, int64_t *plow, int64_t a, int64_t b); | |
95 | -void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); | |
96 | - | |
97 | 94 | int gen_intermediate_code(CPUState *env, struct TranslationBlock *tb); |
98 | 95 | int gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb); |
99 | 96 | void dump_ops(const uint16_t *opc_buf, const uint32_t *opparam_buf); | ... | ... |
host-utils.c
... | ... | @@ -28,6 +28,7 @@ |
28 | 28 | //#define DEBUG_MULDIV |
29 | 29 | |
30 | 30 | /* Long integer helpers */ |
31 | +#if !defined(__x86_64__) | |
31 | 32 | static void add128 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) |
32 | 33 | { |
33 | 34 | *plow += a; |
... | ... | @@ -69,17 +70,10 @@ static void mul64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) |
69 | 70 | *phigh += v; |
70 | 71 | } |
71 | 72 | |
72 | - | |
73 | 73 | /* Unsigned 64x64 -> 128 multiplication */ |
74 | 74 | void mulu64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) |
75 | 75 | { |
76 | -#if defined(__x86_64__) | |
77 | - __asm__ ("mul %0\n\t" | |
78 | - : "=d" (*phigh), "=a" (*plow) | |
79 | - : "a" (a), "0" (b)); | |
80 | -#else | |
81 | 76 | mul64(plow, phigh, a, b); |
82 | -#endif | |
83 | 77 | #if defined(DEBUG_MULDIV) |
84 | 78 | printf("mulu64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n", |
85 | 79 | a, b, *phigh, *plow); |
... | ... | @@ -89,11 +83,6 @@ void mulu64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) |
89 | 83 | /* Signed 64x64 -> 128 multiplication */ |
90 | 84 | void muls64 (uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b) |
91 | 85 | { |
92 | -#if defined(__x86_64__) | |
93 | - __asm__ ("imul %0\n\t" | |
94 | - : "=d" (*phigh), "=a" (*plow) | |
95 | - : "a" (a), "0" (b)); | |
96 | -#else | |
97 | 86 | int sa, sb; |
98 | 87 | |
99 | 88 | sa = (a < 0); |
... | ... | @@ -106,9 +95,9 @@ void muls64 (uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b) |
106 | 95 | if (sa ^ sb) { |
107 | 96 | neg128(plow, phigh); |
108 | 97 | } |
109 | -#endif | |
110 | 98 | #if defined(DEBUG_MULDIV) |
111 | 99 | printf("muls64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n", |
112 | 100 | a, b, *phigh, *plow); |
113 | 101 | #endif |
114 | 102 | } |
103 | +#endif /* !defined(__x86_64__) */ | ... | ... |
host-utils.h
... | ... | @@ -23,6 +23,28 @@ |
23 | 23 | * THE SOFTWARE. |
24 | 24 | */ |
25 | 25 | |
26 | +#if defined(__x86_64__) | |
27 | +#define __HAVE_FAST_MULU64__ | |
28 | +static always_inline void mulu64 (uint64_t *plow, uint64_t *phigh, | |
29 | + uint64_t a, uint64_t b) | |
30 | +{ | |
31 | + __asm__ ("mul %0\n\t" | |
32 | + : "=d" (*phigh), "=a" (*plow) | |
33 | + : "a" (a), "0" (b)); | |
34 | +} | |
35 | +#define __HAVE_FAST_MULS64__ | |
36 | +static always_inline void muls64 (uint64_t *plow, uint64_t *phigh, | |
37 | + int64_t a, int64_t b) | |
38 | +{ | |
39 | + __asm__ ("imul %0\n\t" | |
40 | + : "=d" (*phigh), "=a" (*plow) | |
41 | + : "a" (a), "0" (b)); | |
42 | +} | |
43 | +#else | |
44 | +void muls64(int64_t *phigh, int64_t *plow, int64_t a, int64_t b); | |
45 | +void mulu64(uint64_t *phigh, uint64_t *plow, uint64_t a, uint64_t b); | |
46 | +#endif | |
47 | + | |
26 | 48 | /* Note that some of those functions may end up calling libgcc functions, |
27 | 49 | depending on the host machine. It is up to the target emulation to |
28 | 50 | cope with that. */ |
... | ... | @@ -68,34 +90,13 @@ static always_inline int clz64(uint64_t val) |
68 | 90 | { |
69 | 91 | int cnt = 0; |
70 | 92 | |
71 | - if (!(val & 0xFFFFFFFF00000000ULL)) { | |
93 | + if (!(val >> 32)) { | |
72 | 94 | cnt += 32; |
73 | - val <<= 32; | |
74 | - } | |
75 | - if (!(val & 0xFFFF000000000000ULL)) { | |
76 | - cnt += 16; | |
77 | - val <<= 16; | |
78 | - } | |
79 | - if (!(val & 0xFF00000000000000ULL)) { | |
80 | - cnt += 8; | |
81 | - val <<= 8; | |
82 | - } | |
83 | - if (!(val & 0xF000000000000000ULL)) { | |
84 | - cnt += 4; | |
85 | - val <<= 4; | |
86 | - } | |
87 | - if (!(val & 0xC000000000000000ULL)) { | |
88 | - cnt += 2; | |
89 | - val <<= 2; | |
90 | - } | |
91 | - if (!(val & 0x8000000000000000ULL)) { | |
92 | - cnt++; | |
93 | - val <<= 1; | |
94 | - } | |
95 | - if (!(val & 0x8000000000000000ULL)) { | |
96 | - cnt++; | |
95 | + } else { | |
96 | + val >>= 32; | |
97 | 97 | } |
98 | - return cnt; | |
98 | + | |
99 | + return cnt + clz32(val); | |
99 | 100 | } |
100 | 101 | |
101 | 102 | static always_inline int clo64(uint64_t val) | ... | ... |
target-alpha/op.c