source: trunk/lib/bitblock.hpp @ 1808

Last change on this file since 1808 was 1808, checked in by cameron, 7 years ago

Bytepack and ATTRIBUTE_SIMD_ALIGN

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#define BytePack BitBlock
18#ifndef BLOCK_SIZE
19#define BLOCK_SIZE 128
20#endif
21#define ATTRIBUTE_SIMD_ALIGN __attribute__((aligned(sizeof(BitBlock))))
22
23template<class T> void print_register(const char * var_name, T v);
24
25/*  Default BLOCK_SIZE is 128, compatible with SSE, Altivec, SPU */
26#if (BLOCK_SIZE == 128)
27#include "bitblock128.hpp"
28#endif
29
30/*  BLOCK_SIZE 256 for AVX */
31#if (BLOCK_SIZE == 256)
32#include "bitblock256.hpp"
33#endif
34
35template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes(block_t s);
36template<class block_t> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes(block_t s);
37template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long>(unsigned long s) {return cfzl(s);}
38template<> IDISA_ALWAYS_INLINE uint32_t count_forward_zeroes<unsigned long long>(unsigned long long s) {return cfzll(s);}
39template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long>(unsigned long s) {return cbzl(s);}
40template<> IDISA_ALWAYS_INLINE uint32_t count_reverse_zeroes<unsigned long long>(unsigned long long s) {return cbzll(s);}
41
42template <class T> void print_register(const char * var_name, T v);
43template <class T>
44void print_register(const char * var_name, T v) {
45        unsigned char c;
46        printf("%20s = ", var_name);
47        for(int i=sizeof(T)-1; i>=0; i--) {
48                c = *(((unsigned char *)&v)+i);
49                printf("%02X ", c);
50        }
51        printf("\n");
52}
53
54#endif /* BITBLOCK_HPP */
55
56
Note: See TracBrowser for help on using the repository browser.