mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
Add sharable clz/clo inline functions and use them for the mips target.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3455 c046a42c-6fe2-441c-8c8c-71466251a162
This commit is contained in:
parent
5592a750b9
commit
05f778c8bd
4 changed files with 137 additions and 49 deletions
|
@ -70,6 +70,8 @@ void do_dsllv (void);
|
|||
void do_dsrav (void);
|
||||
void do_dsrlv (void);
|
||||
void do_drotrv (void);
|
||||
void do_dclo (void);
|
||||
void do_dclz (void);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
|
||||
#include "config.h"
|
||||
#include "exec.h"
|
||||
#include "host-utils.h"
|
||||
|
||||
#ifndef CALL_FROM_TB0
|
||||
#define CALL_FROM_TB0(func) func()
|
||||
|
@ -537,35 +538,13 @@ void op_rotrv (void)
|
|||
|
||||
void op_clo (void)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (T0 == ~((target_ulong)0)) {
|
||||
T0 = 32;
|
||||
} else {
|
||||
for (n = 0; n < 32; n++) {
|
||||
if (!(((int32_t)T0) & (1 << 31)))
|
||||
break;
|
||||
T0 <<= 1;
|
||||
}
|
||||
T0 = n;
|
||||
}
|
||||
T0 = clo32(T0);
|
||||
RETURN();
|
||||
}
|
||||
|
||||
void op_clz (void)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (T0 == 0) {
|
||||
T0 = 32;
|
||||
} else {
|
||||
for (n = 0; n < 32; n++) {
|
||||
if (T0 & (1 << 31))
|
||||
break;
|
||||
T0 <<= 1;
|
||||
}
|
||||
T0 = n;
|
||||
}
|
||||
T0 = clz32(T0);
|
||||
RETURN();
|
||||
}
|
||||
|
||||
|
@ -645,6 +624,18 @@ void op_drotrv (void)
|
|||
RETURN();
|
||||
}
|
||||
|
||||
void op_dclo (void)
|
||||
{
|
||||
CALL_FROM_TB0(do_dclo);
|
||||
RETURN();
|
||||
}
|
||||
|
||||
void op_dclz (void)
|
||||
{
|
||||
CALL_FROM_TB0(do_dclz);
|
||||
RETURN();
|
||||
}
|
||||
|
||||
#else /* TARGET_LONG_BITS > HOST_LONG_BITS */
|
||||
|
||||
void op_dsll (void)
|
||||
|
@ -735,41 +726,19 @@ void op_drotrv (void)
|
|||
T0 = T1;
|
||||
RETURN();
|
||||
}
|
||||
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
|
||||
|
||||
void op_dclo (void)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (T0 == ~((target_ulong)0)) {
|
||||
T0 = 64;
|
||||
} else {
|
||||
for (n = 0; n < 64; n++) {
|
||||
if (!(T0 & (1ULL << 63)))
|
||||
break;
|
||||
T0 <<= 1;
|
||||
}
|
||||
T0 = n;
|
||||
}
|
||||
T0 = clo64(T0);
|
||||
RETURN();
|
||||
}
|
||||
|
||||
void op_dclz (void)
|
||||
{
|
||||
int n;
|
||||
|
||||
if (T0 == 0) {
|
||||
T0 = 64;
|
||||
} else {
|
||||
for (n = 0; n < 64; n++) {
|
||||
if (T0 & (1ULL << 63))
|
||||
break;
|
||||
T0 <<= 1;
|
||||
}
|
||||
T0 = n;
|
||||
}
|
||||
T0 = clz64(T0);
|
||||
RETURN();
|
||||
}
|
||||
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
|
||||
#endif /* TARGET_MIPSN32 || TARGET_MIPS64 */
|
||||
|
||||
/* 64 bits arithmetic */
|
||||
|
|
|
@ -20,6 +20,8 @@
|
|||
#include <stdlib.h>
|
||||
#include "exec.h"
|
||||
|
||||
#include "host-utils.h"
|
||||
|
||||
#define GETPC() (__builtin_return_address(0))
|
||||
|
||||
/*****************************************************************************/
|
||||
|
@ -141,6 +143,17 @@ void do_drotrv (void)
|
|||
} else
|
||||
T0 = T1;
|
||||
}
|
||||
|
||||
void do_dclo (void)
|
||||
{
|
||||
T0 = clo64(T0);
|
||||
}
|
||||
|
||||
void do_dclz (void)
|
||||
{
|
||||
T0 = clz64(T0);
|
||||
}
|
||||
|
||||
#endif /* TARGET_LONG_BITS > HOST_LONG_BITS */
|
||||
#endif /* TARGET_MIPSN32 || TARGET_MIPS64 */
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue