source: trunk/lib/bitblock.hpp @ 1542

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

Prefer static function overloading on bitblock128_t types for performance. Methods templated on BitBlock? type do not inline efficiently.

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