source: proto/SymbolTable/symtab_common_functions.h @ 4373

Last change on this file since 4373 was 1721, checked in by vla24, 8 years ago

SymbolTable?: completed dictionary implementation and refactored templates

File size: 1.9 KB
Line 
1#ifndef SYMTAB_COMMON_FUNCTIONS_H
2#define SYMTAB_COMMON_FUNCTIONS_H
3
4#ifdef USE_LS_SYMBOL_TABLE
5static inline void print_GIDS(LSSymbolTable ls_symbol_table);
6#else
7static inline void print_GIDS(vector<int> gids);
8#endif
9
10static inline int compute_hash_value (int lgth, int start, BytePack* hashvalues);
11static inline int ScanBackwardPos(BitBlock * block, int pos, int previous_block_last_elem_start);
12static inline int ScanForwardPos(BitBlock * block, int pos);
13
14#ifdef USE_LS_SYMBOL_TABLE
15static inline void print_GIDS(LSSymbolTable ls_symbol_table)
16{
17    ls_symbol_table.display_flattened_symbol_values();
18    ls_symbol_table.display_flattened_gids();
19}
20#else
21static inline void print_GIDS(vector<int> gids)
22{
23    int span_count = gids.size();
24    for(int i=0;i<span_count;i++) {
25             cout << gids[i] << " ";
26    }
27    cout << endl;
28}
29#endif
30
31static inline int compute_hash_value (int lgth, int start, BytePack* hashvalues)
32{
33    unsigned int offset_bit = start + 128;
34    uint64_t stream = *((uint64_t*)(((uint32_t*)hashvalues)+(offset_bit>>5)));
35    return stream >> (offset_bit & 0x1F) & ~(~0 << lgth);
36}
37
38static inline int ScanBackwardPos(BitBlock * block, int pos, int previous_block_last_elem_start)
39{
40    BitBlock s = block[0];
41    BitBlock temp = simd_and( s, simd_not(simd<128>::sll(simd<2>::constant<3>(), convert(pos))) );
42
43    if (bitblock_has_bit(temp))
44    {
45        // sizeof (BitBlock)*8 - cbzl( s & ~(~0 << pos)) - 1;
46        return BLOCK_SIZE - count_reverse_zeroes (temp) - 1;
47    }
48    else
49    {
50        //handle boundary case
51        return previous_block_last_elem_start - 1;
52    }
53}
54
55static inline int ScanForwardPos(BitBlock * block, int pos)
56{
57    BitBlock s = block[0];
58    BitBlock temp = simd_and(s, simd<128>::sll(simd<2>::constant<3>(), convert(pos)));
59
60    if (bitblock_has_bit(temp))
61    {
62        return count_forward_zeroes (temp);
63    }
64
65    return 0;
66}
67
68#endif // SYMTAB_COMMON_FUNCTIONS_H
Note: See TracBrowser for help on using the repository browser.