Revision 603fccce target-ppc/op_helper.c

b/target-ppc/op_helper.c
18 18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 19
 */
20 20
#include "exec.h"
21
#include "host-utils.h"
21 22

  
22 23
#include "helper_regs.h"
23 24
#include "op_helper.h"
......
381 382
}
382 383
#endif
383 384

  
385
void do_cntlzw (void)
386
{
387
    T0 = clz32(T0);
388
}
389

  
390
#if defined(TARGET_PPC64)
391
void do_cntlzd (void)
392
{
393
    T0 = clz64(T0);
394
}
395
#endif
396

  
384 397
/* shift right arithmetic helper */
385 398
void do_sraw (void)
386 399
{
......
438 451
}
439 452
#endif
440 453

  
441
static always_inline int popcnt (uint32_t val)
442
{
443
    int i;
444

  
445
    for (i = 0; val != 0;)
446
        val = val ^ (val - 1);
447

  
448
    return i;
449
}
450

  
451 454
void do_popcntb (void)
452 455
{
453 456
    uint32_t ret;
......
455 458

  
456 459
    ret = 0;
457 460
    for (i = 0; i < 32; i += 8)
458
        ret |= popcnt((T0 >> i) & 0xFF) << i;
461
        ret |= ctpop8((T0 >> i) & 0xFF) << i;
459 462
    T0 = ret;
460 463
}
461 464

  
......
467 470

  
468 471
    ret = 0;
469 472
    for (i = 0; i < 64; i += 8)
470
        ret |= popcnt((T0 >> i) & 0xFF) << i;
473
        ret |= ctpop8((T0 >> i) & 0xFF) << i;
471 474
    T0 = ret;
472 475
}
473 476
#endif
......
1924 1927
static always_inline int _do_ecntlsw (uint32_t val)
1925 1928
{
1926 1929
    if (val & 0x80000000)
1927
        return _do_cntlzw(~val);
1930
        return clz32(~val);
1928 1931
    else
1929
        return _do_cntlzw(val);
1932
        return clz32(val);
1930 1933
}
1931 1934

  
1932 1935
static always_inline int _do_ecntlzw (uint32_t val)
1933 1936
{
1934
    return _do_cntlzw(val);
1937
    return clz32(val);
1935 1938
}
1936 1939

  
1937 1940
static always_inline uint32_t _do_eneg (uint32_t val)

Also available in: Unified diff