source: trunk/lib/bitblock.hpp @ 1613

Last change on this file since 1613 was 1576, checked in by cameron, 8 years ago

Use BLOCK_SIZE instead of BLOCKSIZE

File size: 1.9 KB
Line 
1/*
2    IDISA Library Import - Generic
3    Copyright (C) 2011, Robert D. Cameron
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 "idisa.hpp"
15
16#include <limits>
17#ifndef LONG_BIT
18#if ULONG_MAX == 0xFFFFFFFF
19#define LONG_BIT 32
20#endif
21#if ULONG_MAX == 0xFFFFFFFFFFFFFFFF
22#define LONG_BIT 64
23#endif
24#endif
25
26#ifndef BLOCK_SIZE
27#define BLOCK_SIZE 128
28#endif
29
30/*  Default BLOCK_SIZE is 128, compatible with SSE, Altivec, SPU */
31#if (BLOCK_SIZE == 128)
32#include "bitblock128.hpp"
33#endif
34
35/*  BLOCK_SIZE 256 for AVX */
36#if (BLOCK_SIZE == 256)
37#include "bitblock256.hpp"
38#endif
39
40/* Wrapper Declarations */
41/*
42#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)
43#define sisd_srl(blk, n) simd<128>::srl(blk, n)
44#define sisd_slli(blk, n) simd<128>::slli<n>(blk)
45#define sisd_srli(blk, n) simd<128>::srli<n>(blk)
46#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
47#define sisd_sbl(blk, n) sisd_srl(blk, n)
48#define sisd_sfli(blk, n) sisd_slli(blk, n)
49#define sisd_sbli(blk, n) sisd_srli(blk, n)
50#define sb_op(x, n) ((x)>>(n))
51#define sf_op(x, n) ((x)<<(n))
52*/
53
54template<class T> void print_register(const char * var_name, T v);      // print integer types as array of unsigned char
55
56/* Debug */
57template <class T>
58void print_register(const char * var_name, T v) {
59        unsigned char c;
60        printf("%20s = ", var_name);
61        for(int i=sizeof(T)-1; i>=0; i--) {
62                c = *(((unsigned char *)&v)+i);
63                printf("%02X ", c);
64        }
65        printf("\n");
66}
67
68#endif /* BITBLOCK_HPP */
69
70
Note: See TracBrowser for help on using the repository browser.