Changeset 1527


Ignore:
Timestamp:
Oct 12, 2011, 8:53:36 PM (8 years ago)
Author:
ksherdy
Message:

Refactored functions to use function templates.

Location:
trunk/lib
Files:
2 edited
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/lib/bitblock.hpp

    r1515 r1527  
    77*/
    88
    9 #ifndef IDISA_HPP
    10 #define IDISA_HPP
     9#ifndef BITBLOCK_HPP
     10#define BITBLOCK_HPP
    1111
    1212/*  Default BLOCKSIZE is 128, compatible with SSE, Altivec, SPU */
    13 #ifndef BLOCKSIZE
     13#ifndef BLOCKSIZE                       // TODO - Remove BLOCKSIZE switcher
    1414#define BLOCKSIZE 128
    1515#endif
    1616
    1717#if (BLOCKSIZE == 128)
    18 #include "idisa128.hpp"
    19 typedef bitblock128_t BitBlock;
     18#include "bitblock128.hpp"
    2019#endif
    2120
    2221/*  BLOCKSIZE 256 for AVX */
    23 
    2422#if (BLOCKSIZE == 256)
    25 #include "idisa256.hpp"
    26 typedef bitblock256_t BitBlock;
     23#include "bitblock256.hpp"
    2724#endif
    2825
    29 #endif
     26#include "config.hpp"
     27#include "builtins.hpp"
     28#include <stdio.h>
     29
     30/* Wrapper Declarations */
     31#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)
     32#define sisd_srl(blk, n) simd<128>::srl(blk, n)
     33#define sisd_slli(blk, n) simd<128>::slli<n>(blk)
     34#define sisd_srli(blk, n) simd<128>::srli<n>(blk)
     35#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
     36#define sisd_sbl(blk, n) sisd_srl(blk, n)
     37#define sisd_sfli(blk, n) sisd_slli(blk, n)
     38#define sisd_sbli(blk, n) sisd_srli(blk, n)
     39#define sb_op(x, n) ((x)>>(n))
     40#define sf_op(x, n) ((x)<<(n))
     41
     42/* Utility */
     43template<class T> IDISA_INLINE bool bitblock_has_bit(T arg1);
     44template<class T> IDISA_INLINE uint64_t bitblock_bit_count(T arg1) IDISA_ALWAYS_INLINE;
     45
     46/* Debug */
     47template<class T> void print_register(const char * var_name, T v);      // print integer types as array of unsigned char
     48
     49/* Utility */
     50template<class T>
     51IDISA_INLINE bool bitblock_has_bit(T arg1)
     52{
     53        return bitblock::any(arg1);
     54}
     55
     56template<class T>
     57IDISA_INLINE uint64_t bitblock_bit_count(T arg1)
     58{
     59        return mvmd<64>::extract<0>(simd<sizeof(T) * 8>::popcount(arg1));
     60}
     61
     62/* Debug */
     63template <class T>
     64void print_register(const char * var_name, T v) {
     65        unsigned char c;
     66        printf("%20s = ", var_name);
     67        for(int i=sizeof(T)-1; i>=0; i--) {
     68                c = *(((unsigned char *)&v)+i);
     69                printf("%02X ", c);
     70        }
     71        printf("\n");
     72}
     73
     74#endif /* BITBLOCK_HPP */
    3075
    3176
  • trunk/lib/bitblock128.hpp

    r1516 r1527  
    99
    1010*/
    11 
    1211#ifndef BITBLOCK128_HPP_
    1312#define BITBLOCK128_HPP_
    1413
     14#include "idisa128.hpp"
     15
    1516#endif /* BITBLOCK128_HPP_ */
  • trunk/lib/bitblock256.hpp

    r1516 r1527  
    1313#define BITBLOCK256_HPP_
    1414
     15#include "idisa256.hpp"
     16
    1517#endif /* BITBLOCK256_HPP_ */
Note: See TracChangeset for help on using the changeset viewer.