aboutsummaryrefslogtreecommitdiff
path: root/target-cris/op_helper.c
diff options
context:
space:
mode:
authoredgar_igl <edgar_igl@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-07 13:11:22 +0000
committeredgar_igl <edgar_igl@c046a42c-6fe2-441c-8c8c-71466251a162>2009-01-07 13:11:22 +0000
commitabd5c94ee110d4a5187eca3e2dff91cb3e9e5606 (patch)
tree3df2562604d2442d8d464a6dcf85eec312ca7576 /target-cris/op_helper.c
parent4a1e6beab60d9d105fcc56f3d568044390ef7e9e (diff)
downloadqemu-abd5c94ee110d4a5187eca3e2dff91cb3e9e5606.zip
qemu-abd5c94ee110d4a5187eca3e2dff91cb3e9e5606.tar.gz
qemu-abd5c94ee110d4a5187eca3e2dff91cb3e9e5606.tar.bz2
CRIS: Speedup btst by using a helper.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6203 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'target-cris/op_helper.c')
-rw-r--r--target-cris/op_helper.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/target-cris/op_helper.c b/target-cris/op_helper.c
index 51323a2..6b23980 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;