From abd5c94ee110d4a5187eca3e2dff91cb3e9e5606 Mon Sep 17 00:00:00 2001 From: edgar_igl Date: Wed, 7 Jan 2009 13:11:22 +0000 Subject: CRIS: Speedup btst by using a helper. Signed-off-by: Edgar E. Iglesias git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6203 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-cris/op_helper.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'target-cris/op_helper.c') diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c index 51323a2a5c..6b23980740 100644 --- a/target-cris/op_helper.c +++ b/target-cris/op_helper.c @@ -243,6 +243,32 @@ void helper_rfn(void) env->pregs[PR_CCS] |= M_FLAG; } +uint32_t helper_btst(uint32_t t0, uint32_t t1, uint32_t ccs) +{ + /* FIXME: clean this up. */ + + /* des ref: + The N flag is set according to the selected bit in the dest reg. + The Z flag is set if the selected bit and all bits to the right are + zero. + The X flag is cleared. + Other flags are left untouched. + The destination reg is not affected.*/ + unsigned int fz, sbit, bset, mask, masked_t0; + + sbit = t1 & 31; + bset = !!(t0 & (1 << sbit)); + mask = sbit == 31 ? -1 : (1 << (sbit + 1)) - 1; + masked_t0 = t0 & mask; + fz = !(masked_t0 | bset); + + /* Clear the X, N and Z flags. */ + ccs = ccs & ~(X_FLAG | N_FLAG | Z_FLAG); + /* Set the N and Z flags accordingly. */ + ccs |= (bset << 3) | (fz << 2); + return ccs; +} + static void evaluate_flags_writeback(uint32_t flags) { unsigned int x, z, mask; -- cgit v1.2.1