source: trunk/lib/bitblock.hpp @ 1760

Last change on this file since 1760 was 1760, checked in by ksherdy, 8 years ago

Revert s2p, p2s, 128, 256-bit specific versions.

File size: 1.7 KB
Line 
1/*
2    IDISA Library Import - Generic
3    Copyright (C) 2011, Robert D. Cameron, Kenneth S. Herdy
4    Licensed to the public under the Open Software License 3.0.
5    Licensed to International Characters Inc.
6       under the Academic Free License version 3.0.
7*/
8#ifndef BITBLOCK_HPP
9#define BITBLOCK_HPP
10
11#include <stdint.h>
12#include <stdio.h>
13#include "config.hpp"
14#include "builtins.hpp"
15#include "idisa.hpp"
16
17#ifndef BLOCK_SIZE
18#define BLOCK_SIZE 128
19#endif
20
21template<class T> void print_register(const char * var_name, T v);
22
23/*  Default BLOCK_SIZE is 128, compatible with SSE, Altivec, SPU */
24#if (BLOCK_SIZE == 128)
25#include "bitblock128.hpp"
26#endif
27
28/*  BLOCK_SIZE 256 for AVX */
29#if (BLOCK_SIZE == 256)
30#include "bitblock256.hpp"
31#endif
32
33template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(block_t s);
34template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(block_t s);
35template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long>(unsigned long s) {return cfzl(s);}
36template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long long>(unsigned long long s) {return cfzll(s);}
37template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long>(unsigned long s) {return cbzl(s);}
38template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long long>(unsigned long long s) {return cbzll(s);}
39
40template <class T> void print_register(const char * var_name, T v);
41template <class T>
42void print_register(const char * var_name, T v) {
43        unsigned char c;
44        printf("%20s = ", var_name);
45        for(int i=sizeof(T)-1; i>=0; i--) {
46                c = *(((unsigned char *)&v)+i);
47                printf("%02X ", c);
48        }
49        printf("\n");
50}
51
52#endif /* BITBLOCK_HPP */
53
54
Note: See TracBrowser for help on using the repository browser.