From 603fcccece43303c623df2561f85ab2baba95e5f Mon Sep 17 00:00:00 2001 From: j_mayer Date: Sun, 28 Oct 2007 12:54:53 +0000 Subject: Make Alpha and PowerPC targets use shared helpers for clz, clo, ctz, cto and ctpop. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3466 c046a42c-6fe2-441c-8c8c-71466251a162 --- target-alpha/op_helper.c | 77 +++--------------------------------------------- 1 file changed, 4 insertions(+), 73 deletions(-) (limited to 'target-alpha/op_helper.c') diff --git a/target-alpha/op_helper.c b/target-alpha/op_helper.c index f9390c8..ae8470b 100644 --- a/target-alpha/op_helper.c +++ b/target-alpha/op_helper.c @@ -19,6 +19,7 @@ */ #include "exec.h" +#include "host-utils.h" #include "softfloat.h" #include "op_helper.h" @@ -211,87 +212,17 @@ void helper_mulqv () void helper_ctpop (void) { - int n; - - for (n = 0; T0 != 0; n++) - T0 = T0 ^ (T0 - 1); - T0 = n; + T0 = ctpop64(T0); } void helper_ctlz (void) { - uint32_t op32; - int n; - - n = 0; - if (!(T0 & 0xFFFFFFFF00000000ULL)) { - n += 32; - T0 <<= 32; - } - /* Make it easier for 32 bits hosts */ - op32 = T0 >> 32; - if (!(op32 & 0xFFFF0000UL)) { - n += 16; - op32 <<= 16; - } - if (!(op32 & 0xFF000000UL)) { - n += 8; - op32 <<= 8; - } - if (!(op32 & 0xF0000000UL)) { - n += 4; - op32 <<= 4; - } - if (!(op32 & 0xC0000000UL)) { - n += 2; - op32 <<= 2; - } - if (!(op32 & 0x80000000UL)) { - n++; - op32 <<= 1; - } - if (!(op32 & 0x80000000UL)) { - n++; - } - T0 = n; + T0 = clz64(T0); } void helper_cttz (void) { - uint32_t op32; - int n; - - n = 0; - if (!(T0 & 0x00000000FFFFFFFFULL)) { - n += 32; - T0 >>= 32; - } - /* Make it easier for 32 bits hosts */ - op32 = T0; - if (!(op32 & 0x0000FFFFUL)) { - n += 16; - op32 >>= 16; - } - if (!(op32 & 0x000000FFUL)) { - n += 8; - op32 >>= 8; - } - if (!(op32 & 0x0000000FUL)) { - n += 4; - op32 >>= 4; - } - if (!(op32 & 0x00000003UL)) { - n += 2; - op32 >>= 2; - } - if (!(op32 & 0x00000001UL)) { - n++; - op32 >>= 1; - } - if (!(op32 & 0x00000001UL)) { - n++; - } - T0 = n; + T0 = ctz64(T0); } static always_inline uint64_t byte_zap (uint64_t op, uint8_t mskb) -- cgit v1.1