source: trunk/lib/bitblock.hpp @ 1753

Last change on this file since 1753 was 1753, checked in by ksherdy, 7 years ago

Added 128 bit specific p2s, s2p. Added 256 bit headers as placeholders.

File size: 1.8 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#include "s2p128.hpp"
27#include "p2s128.hpp"
28#endif
29
30/*  BLOCK_SIZE 256 for AVX */
31#if (BLOCK_SIZE == 256)
32#include "bitblock256.hpp"
33#include "s2p256.hpp"
34#include "p2s256.hpp"
35#endif
36
37template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(block_t s);
38template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(block_t s);
39template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long>(unsigned long s) {return cfzl(s);}
40template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long long>(unsigned long long s) {return cfzll(s);}
41template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long>(unsigned long s) {return cbzl(s);}
42template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long long>(unsigned long long s) {return cbzll(s);}
43
44template <class T> void print_register(const char * var_name, T v);
45template <class T>
46void print_register(const char * var_name, T v) {
47        unsigned char c;
48        printf("%20s = ", var_name);
49        for(int i=sizeof(T)-1; i>=0; i--) {
50                c = *(((unsigned char *)&v)+i);
51                printf("%02X ", c);
52        }
53        printf("\n");
54}
55
56#endif /* BITBLOCK_HPP */
57
58
Note: See TracBrowser for help on using the repository browser.