mirror of
https://github.com/xemu-project/xemu.git
synced 2024-11-27 13:30:52 +00:00
target/ppc: Implement cfuged instruction
Signed-off-by: Matheus Ferst <matheus.ferst@eldorado.org.br> Message-Id: <20210601193528.2533031-12-matheus.ferst@eldorado.org.br> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
parent
9a14365eeb
commit
89ccd7dc3f
@ -46,6 +46,7 @@ DEF_HELPER_4(divwe, tl, env, tl, tl, i32)
|
||||
DEF_HELPER_FLAGS_1(popcntb, TCG_CALL_NO_RWG_SE, tl, tl)
|
||||
DEF_HELPER_FLAGS_2(cmpb, TCG_CALL_NO_RWG_SE, tl, tl, tl)
|
||||
DEF_HELPER_3(sraw, tl, env, tl, tl)
|
||||
DEF_HELPER_FLAGS_2(cfuged, TCG_CALL_NO_RWG_SE, i64, i64, i64)
|
||||
#if defined(TARGET_PPC64)
|
||||
DEF_HELPER_FLAGS_2(cmpeqb, TCG_CALL_NO_RWG_SE, i32, tl, tl)
|
||||
DEF_HELPER_FLAGS_1(popcntw, TCG_CALL_NO_RWG_SE, tl, tl)
|
||||
|
@ -87,6 +87,10 @@ STDUX 011111 ..... ..... ..... 0010110101 - @X
|
||||
ADDI 001110 ..... ..... ................ @D
|
||||
ADDIS 001111 ..... ..... ................ @D
|
||||
|
||||
## Fixed-Point Logical Instructions
|
||||
|
||||
CFUGED 011111 ..... ..... ..... 0011011100 - @X
|
||||
|
||||
### Move To/From System Register Instructions
|
||||
|
||||
SETBC 011111 ..... ..... ----- 0110000000 - @X_bi
|
||||
|
@ -320,6 +320,68 @@ target_ulong helper_popcntb(target_ulong val)
|
||||
}
|
||||
#endif
|
||||
|
||||
uint64_t helper_cfuged(uint64_t src, uint64_t mask)
|
||||
{
|
||||
/*
|
||||
* Instead of processing the mask bit-by-bit from the most significant to
|
||||
* the least significant bit, as described in PowerISA, we'll handle it in
|
||||
* blocks of 'n' zeros/ones from LSB to MSB. To avoid the decision to use
|
||||
* ctz or cto, we negate the mask at the end of the loop.
|
||||
*/
|
||||
target_ulong m, left = 0, right = 0;
|
||||
unsigned int n, i = 64;
|
||||
bool bit = false; /* tracks if we are processing zeros or ones */
|
||||
|
||||
if (mask == 0 || mask == -1) {
|
||||
return src;
|
||||
}
|
||||
|
||||
/* Processes the mask in blocks, from LSB to MSB */
|
||||
while (i) {
|
||||
/* Find how many bits we should take */
|
||||
n = ctz64(mask);
|
||||
if (n > i) {
|
||||
n = i;
|
||||
}
|
||||
|
||||
/*
|
||||
* Extracts 'n' trailing bits of src and put them on the leading 'n'
|
||||
* bits of 'right' or 'left', pushing down the previously extracted
|
||||
* values.
|
||||
*/
|
||||
m = (1ll << n) - 1;
|
||||
if (bit) {
|
||||
right = ror64(right | (src & m), n);
|
||||
} else {
|
||||
left = ror64(left | (src & m), n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Discards the processed bits from 'src' and 'mask'. Note that we are
|
||||
* removing 'n' trailing zeros from 'mask', but the logical shift will
|
||||
* add 'n' leading zeros back, so the population count of 'mask' is kept
|
||||
* the same.
|
||||
*/
|
||||
src >>= n;
|
||||
mask >>= n;
|
||||
i -= n;
|
||||
bit = !bit;
|
||||
mask = ~mask;
|
||||
}
|
||||
|
||||
/*
|
||||
* At the end, right was ror'ed ctpop(mask) times. To put it back in place,
|
||||
* we'll shift it more 64-ctpop(mask) times.
|
||||
*/
|
||||
if (bit) {
|
||||
n = ctpop64(mask);
|
||||
} else {
|
||||
n = 64 - ctpop64(mask);
|
||||
}
|
||||
|
||||
return left | (right >> n);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
/* PowerPC 601 specific instructions (POWER bridge) */
|
||||
target_ulong helper_div(CPUPPCState *env, target_ulong arg1, target_ulong arg2)
|
||||
|
@ -227,3 +227,15 @@ TRANS(SETBC, do_set_bool_cond, false, false)
|
||||
TRANS(SETBCR, do_set_bool_cond, false, true)
|
||||
TRANS(SETNBC, do_set_bool_cond, true, false)
|
||||
TRANS(SETNBCR, do_set_bool_cond, true, true)
|
||||
|
||||
static bool trans_CFUGED(DisasContext *ctx, arg_X *a)
|
||||
{
|
||||
REQUIRE_64BIT(ctx);
|
||||
REQUIRE_INSNS_FLAGS2(ctx, ISA310);
|
||||
#if defined(TARGET_PPC64)
|
||||
gen_helper_cfuged(cpu_gpr[a->ra], cpu_gpr[a->rt], cpu_gpr[a->rb]);
|
||||
#else
|
||||
qemu_build_not_reached();
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user