mirror of https://github.com/xqemu/xqemu.git
target-i386: Use clz/ctz for bsf/bsr helpers
And mark the helpers as NO_RWG_SE. Signed-off-by: Richard Henderson <rth@twiddle.net>
This commit is contained in:
parent
cd7f97cafd
commit
f1300734cb
|
@ -195,9 +195,9 @@ DEF_HELPER_3(frstor, void, env, tl, int)
|
||||||
DEF_HELPER_3(fxsave, void, env, tl, int)
|
DEF_HELPER_3(fxsave, void, env, tl, int)
|
||||||
DEF_HELPER_3(fxrstor, void, env, tl, int)
|
DEF_HELPER_3(fxrstor, void, env, tl, int)
|
||||||
|
|
||||||
DEF_HELPER_1(bsf, tl, tl)
|
DEF_HELPER_FLAGS_1(bsf, TCG_CALL_NO_RWG_SE, tl, tl)
|
||||||
DEF_HELPER_1(bsr, tl, tl)
|
DEF_HELPER_FLAGS_1(bsr, TCG_CALL_NO_RWG_SE, tl, tl)
|
||||||
DEF_HELPER_2(lzcnt, tl, tl, int)
|
DEF_HELPER_FLAGS_2(lzcnt, TCG_CALL_NO_RWG_SE, tl, tl, int)
|
||||||
DEF_HELPER_FLAGS_2(pdep, TCG_CALL_NO_RWG_SE, tl, tl, tl)
|
DEF_HELPER_FLAGS_2(pdep, TCG_CALL_NO_RWG_SE, tl, tl, tl)
|
||||||
DEF_HELPER_FLAGS_2(pext, TCG_CALL_NO_RWG_SE, tl, tl, tl)
|
DEF_HELPER_FLAGS_2(pext, TCG_CALL_NO_RWG_SE, tl, tl, tl)
|
||||||
|
|
||||||
|
|
|
@ -447,53 +447,30 @@ void helper_idivq_EAX(CPUX86State *env, target_ulong t0)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if TARGET_LONG_BITS == 32
|
||||||
|
# define ctztl ctz32
|
||||||
|
# define clztl clz32
|
||||||
|
#else
|
||||||
|
# define ctztl ctz64
|
||||||
|
# define clztl clz64
|
||||||
|
#endif
|
||||||
|
|
||||||
/* bit operations */
|
/* bit operations */
|
||||||
target_ulong helper_bsf(target_ulong t0)
|
target_ulong helper_bsf(target_ulong t0)
|
||||||
{
|
{
|
||||||
int count;
|
return ctztl(t0);
|
||||||
target_ulong res;
|
|
||||||
|
|
||||||
res = t0;
|
|
||||||
count = 0;
|
|
||||||
while ((res & 1) == 0) {
|
|
||||||
count++;
|
|
||||||
res >>= 1;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target_ulong helper_lzcnt(target_ulong t0, int wordsize)
|
target_ulong helper_lzcnt(target_ulong t0, int wordsize)
|
||||||
{
|
{
|
||||||
int count;
|
return clztl(t0) - (TARGET_LONG_BITS - wordsize);
|
||||||
target_ulong res, mask;
|
|
||||||
|
|
||||||
if (wordsize > 0 && t0 == 0) {
|
|
||||||
return wordsize;
|
|
||||||
}
|
|
||||||
res = t0;
|
|
||||||
count = TARGET_LONG_BITS - 1;
|
|
||||||
mask = (target_ulong)1 << (TARGET_LONG_BITS - 1);
|
|
||||||
while ((res & mask) == 0) {
|
|
||||||
count--;
|
|
||||||
res <<= 1;
|
|
||||||
}
|
|
||||||
if (wordsize > 0) {
|
|
||||||
return wordsize - 1 - count;
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
target_ulong helper_bsr(target_ulong t0)
|
target_ulong helper_bsr(target_ulong t0)
|
||||||
{
|
{
|
||||||
return helper_lzcnt(t0, 0);
|
return clztl(t0) ^ (TARGET_LONG_BITS - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if TARGET_LONG_BITS == 32
|
|
||||||
# define ctztl ctz32
|
|
||||||
#else
|
|
||||||
# define ctztl ctz64
|
|
||||||
#endif
|
|
||||||
|
|
||||||
target_ulong helper_pdep(target_ulong src, target_ulong mask)
|
target_ulong helper_pdep(target_ulong src, target_ulong mask)
|
||||||
{
|
{
|
||||||
target_ulong dest = 0;
|
target_ulong dest = 0;
|
||||||
|
|
Loading…
Reference in New Issue