Changeset 1617 for trunk


Ignore:
Timestamp:
Oct 31, 2011, 3:44:18 AM (8 years ago)
Author:
ksherdy
Message:

Added overloaded count_forward_zeroes on unsigned long, unsigned long long.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock.hpp

    r1616 r1617  
    11/*
    22    IDISA Library Import - Generic
    3     Copyright (C) 2011, Robert D. Cameron
     3    Copyright (C) 2011, Robert D. Cameron, Kenneth S. Herdy
    44    Licensed to the public under the Open Software License 3.0.
    55    Licensed to International Characters Inc.
     
    1212#include <stdio.h>
    1313#include "config.hpp"
     14#include "builtins.hpp"
    1415#include "idisa.hpp"
    1516
     
    1718#define BLOCK_SIZE 128
    1819#endif
     20
     21template<class T> void print_register(const char * var_name, T v);
    1922
    2023/*  Default BLOCK_SIZE is 128, compatible with SSE, Altivec, SPU */
     
    2831#endif
    2932
    30 /* Wrapper Declarations */
    31 /*
    32 #define sisd_sll(blk, n) simd<128>::sll(blk, n)         // TODO - Deprecate 'sisd_f(x,y)'. bitblock_f(x,y) Migrate to simd<sizeof(BitBlock)*8>::f(x,y) or simd<bitblock128_t, 128>::f(x,y)
    33 #define sisd_srl(blk, n) simd<128>::srl(blk, n)
    34 #define sisd_slli(blk, n) simd<128>::slli<n>(blk)
    35 #define sisd_srli(blk, n) simd<128>::srli<n>(blk)
    36 #define sisd_sfl(blk, n) sisd_sll(blk, n)                       // TODO - Remove forward (f) and backward (b) do not make sense in a little endian based library, just left and right in a register representation
    37 #define sisd_sbl(blk, n) sisd_srl(blk, n)
    38 #define sisd_sfli(blk, n) sisd_slli(blk, n)
    39 #define sisd_sbli(blk, n) sisd_srli(blk, n)
    40 #define sb_op(x, n) ((x)>>(n))
    41 #define sf_op(x, n) ((x)<<(n))
     33/* Template specialization is slightly slower, but may be required to differentiate on integer types unsigned long and unsigned long long.
     34//template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(block_t s);
     35//template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(block_t s);
     36template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long>(unsigned long s) {return cfzl(s);}
     37template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long long>(unsigned long long s) {return cfzll(s);}
     38template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long>(unsigned long s) {return cbzl(s);}
     39template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long long>(unsigned long long s) {return cbzll(s);}
    4240*/
    4341
    44 template<class T> void print_register(const char * var_name, T v);      // print integer types as array of unsigned char
     42static IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(unsigned long v) { return cfzl(v);}
     43static IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(unsigned long long v) { return cfzll(v);}
     44static IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(unsigned long s) {return cbzl(s);}
     45static IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(unsigned long long s) {return cbzll(s);}
    4546
    46 /* Debug */
    4747template <class T>
    4848void print_register(const char * var_name, T v) {
Note: See TracChangeset for help on using the changeset viewer.