Commit 7a51ad822f533472cab908d2622578d51eb97dc6

Authored by j_mayer
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
exec-all.h
@@ -91,9 +91,6 @@ void optimize_flags_init(void); @@ -91,9 +91,6 @@ void optimize_flags_init(void);
91 extern FILE *logfile; 91 extern FILE *logfile;
92 extern int loglevel; 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 int gen_intermediate_code(CPUState *env, struct TranslationBlock *tb); 94 int gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
98 int gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb); 95 int gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
99 void dump_ops(const uint16_t *opc_buf, const uint32_t *opparam_buf); 96 void dump_ops(const uint16_t *opc_buf, const uint32_t *opparam_buf);
host-utils.c
@@ -28,6 +28,7 @@ @@ -28,6 +28,7 @@
28 //#define DEBUG_MULDIV 28 //#define DEBUG_MULDIV
29 29
30 /* Long integer helpers */ 30 /* Long integer helpers */
  31 +#if !defined(__x86_64__)
31 static void add128 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) 32 static void add128 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b)
32 { 33 {
33 *plow += a; 34 *plow += a;
@@ -69,17 +70,10 @@ static void mul64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) @@ -69,17 +70,10 @@ static void mul64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b)
69 *phigh += v; 70 *phigh += v;
70 } 71 }
71 72
72 -  
73 /* Unsigned 64x64 -> 128 multiplication */ 73 /* Unsigned 64x64 -> 128 multiplication */
74 void mulu64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) 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 mul64(plow, phigh, a, b); 76 mul64(plow, phigh, a, b);
82 -#endif  
83 #if defined(DEBUG_MULDIV) 77 #if defined(DEBUG_MULDIV)
84 printf("mulu64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n", 78 printf("mulu64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n",
85 a, b, *phigh, *plow); 79 a, b, *phigh, *plow);
@@ -89,11 +83,6 @@ void mulu64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b) @@ -89,11 +83,6 @@ void mulu64 (uint64_t *plow, uint64_t *phigh, uint64_t a, uint64_t b)
89 /* Signed 64x64 -> 128 multiplication */ 83 /* Signed 64x64 -> 128 multiplication */
90 void muls64 (uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b) 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 int sa, sb; 86 int sa, sb;
98 87
99 sa = (a < 0); 88 sa = (a < 0);
@@ -106,9 +95,9 @@ void muls64 (uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b) @@ -106,9 +95,9 @@ void muls64 (uint64_t *plow, uint64_t *phigh, int64_t a, int64_t b)
106 if (sa ^ sb) { 95 if (sa ^ sb) {
107 neg128(plow, phigh); 96 neg128(plow, phigh);
108 } 97 }
109 -#endif  
110 #if defined(DEBUG_MULDIV) 98 #if defined(DEBUG_MULDIV)
111 printf("muls64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n", 99 printf("muls64: 0x%016llx * 0x%016llx = 0x%016llx%016llx\n",
112 a, b, *phigh, *plow); 100 a, b, *phigh, *plow);
113 #endif 101 #endif
114 } 102 }
  103 +#endif /* !defined(__x86_64__) */
host-utils.h
@@ -23,6 +23,28 @@ @@ -23,6 +23,28 @@
23 * THE SOFTWARE. 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 /* Note that some of those functions may end up calling libgcc functions, 48 /* Note that some of those functions may end up calling libgcc functions,
27 depending on the host machine. It is up to the target emulation to 49 depending on the host machine. It is up to the target emulation to
28 cope with that. */ 50 cope with that. */
@@ -68,34 +90,13 @@ static always_inline int clz64(uint64_t val) @@ -68,34 +90,13 @@ static always_inline int clz64(uint64_t val)
68 { 90 {
69 int cnt = 0; 91 int cnt = 0;
70 92
71 - if (!(val & 0xFFFFFFFF00000000ULL)) { 93 + if (!(val >> 32)) {
72 cnt += 32; 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 static always_inline int clo64(uint64_t val) 102 static always_inline int clo64(uint64_t val)
target-alpha/op.c
@@ -22,6 +22,7 @@ @@ -22,6 +22,7 @@
22 22
23 #include "config.h" 23 #include "config.h"
24 #include "exec.h" 24 #include "exec.h"
  25 +#include "host-utils.h"
25 26
26 #include "op_helper.h" 27 #include "op_helper.h"
27 28
target-i386/helper.c
@@ -18,6 +18,7 @@ @@ -18,6 +18,7 @@
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */ 19 */
20 #include "exec.h" 20 #include "exec.h"
  21 +#include "host-utils.h"
21 22
22 //#define DEBUG_PCALL 23 //#define DEBUG_PCALL
23 24