Changeset 1670


Ignore:
Timestamp:
Nov 7, 2011, 8:00:09 PM (7 years ago)
Author:
vla24
Message:

SymbolTable?: Updated identity grouping template to use BitstreamForwardIterator?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/SymbolTable/symtab_pbgs_identity_template.cpp

    r1667 r1670  
    5252static inline int compute_hash_value (int lgth, int start);
    5353template <int L> static inline int ElemEnd_grouping(int pos);
    54 template <int L> static inline int StreamScanLengthGrouping(ScanBlock * stream, int blk_count);
     54template <int L> static inline void validate_block_length_grouping(BitBlockForwardIterator & start, int block_base);
    5555
    5656int main(int argc, char * argv[]) {
     
    142142template <int L>
    143143static inline int ElemEnd_grouping(int pos) {
    144     int end = block_base + pos;
     144    int end = pos;
    145145    int start = end - L;
    146146    int hashvalue = compute_hash_value(L, start - block_base);
     
    159159template<>
    160160inline int ElemEnd_grouping<17>(int pos) {
    161     int end = block_base + pos;
    162     int start = ScanBackwardPos (&elem_starts, pos) + block_base;
     161    int end = pos;
     162    int start = ScanBackwardPos (&elem_starts, pos - block_base) + block_base;
    163163    int lgth = end - start;
    164164    int hashvalue = compute_hash_value(lgth, start - block_base);
     
    180180    printf ("%s | start: %i[%i] | end: %i[%i] | lgth: %i | hashvalue: %i | gid: %i | symbol: %s\n", __FUNCTION__, start, start - block_base, end, end - block_base, lgth, hashvalue, gid, symbol);
    181181#endif
    182     return 0;
    183 }
    184 
    185 template <int L>
    186 static inline int StreamScanLengthGrouping(ScanBlock * stream, int blk_count) {
    187     int blk;
    188     int block_pos = 0;
    189     for (blk = 0; blk < blk_count; blk++) {
    190         ScanBlock s = stream[blk];
    191         while(s) {
    192             int end_pos = cfzl(s) + block_pos;
    193             ElemEnd_grouping<L>(end_pos);
    194             s = s & (s-1);  // clear rightmost bit.
    195         }
    196         block_pos += 8 * sizeof(ScanBlock);
    197     }
    198182    return 0;
    199183}
     
    447431}
    448432
     433template <int L>
     434static inline void validate_block_length_grouping(BitBlockForwardIterator & start, int block_base) {
     435
     436    BitBlockForwardIterator end;
     437    int block_pos;
     438
     439    while(start != end) {
     440        ElemEnd_grouping<L>(end_pos);
     441        block_pos = block_base + *start;
     442
     443        start++;
     444    }
     445}
     446
    449447static inline void validate_block(BitBlockForwardIterator & start, int block_base, int is_valid(int)) {
    450448
     
    491489
    492490static inline void postprocess_do_block(Lex & lex, CtCDPI_Callouts & ctCDPI_Callouts, Ref_Callouts & ref_Callouts, Check_streams & check_streams, Tag_Callouts & tag_Callouts, Hash_data & hash_data, int chars_avail){
    493             tracker.StoreNewlines(lex.LF);
    494 
    495             elem_starts = tag_Callouts.ElemName_starts;
    496             hashvalues[1] = hash_data.Hash_value;
    497 
    498             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_1) )
    499             {
    500                 StreamScanLengthGrouping<1>((ScanBlock *) &tag_Callouts.ElemName_ends_1, sizeof(BitBlock)/sizeof(ScanBlock));
    501             }
    502 
    503             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_2) )
    504             {
    505                 StreamScanLengthGrouping<2>((ScanBlock *) &tag_Callouts.ElemName_ends_2, sizeof(BitBlock)/sizeof(ScanBlock));
    506             }
    507 
    508             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_3) )
    509             {
    510                 StreamScanLengthGrouping<3>((ScanBlock *) &tag_Callouts.ElemName_ends_3, sizeof(BitBlock)/sizeof(ScanBlock));
    511             }
    512 
    513             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_4) )
    514             {
    515                 StreamScanLengthGrouping<4>((ScanBlock *) &tag_Callouts.ElemName_ends_4, sizeof(BitBlock)/sizeof(ScanBlock));
    516             }
    517 
    518             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_5) )
    519             {
    520                 StreamScanLengthGrouping<5>((ScanBlock *) &tag_Callouts.ElemName_ends_5, sizeof(BitBlock)/sizeof(ScanBlock));
    521             }
    522 
    523             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_6) )
    524             {
    525                 StreamScanLengthGrouping<6>((ScanBlock *) &tag_Callouts.ElemName_ends_6, sizeof(BitBlock)/sizeof(ScanBlock));
    526             }
    527 
    528             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_7) )
    529             {
    530                 StreamScanLengthGrouping<7>((ScanBlock *) &tag_Callouts.ElemName_ends_7, sizeof(BitBlock)/sizeof(ScanBlock));
    531             }
    532 
    533             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_8) )
    534             {
    535                 StreamScanLengthGrouping<8>((ScanBlock *) &tag_Callouts.ElemName_ends_8, sizeof(BitBlock)/sizeof(ScanBlock));
    536             }
    537 
    538             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_9) )
    539             {
    540                 StreamScanLengthGrouping<9>((ScanBlock *) &tag_Callouts.ElemName_ends_9, sizeof(BitBlock)/sizeof(ScanBlock));
    541             }
    542 
    543             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_10) )
    544             {
    545                 StreamScanLengthGrouping<10>((ScanBlock *) &tag_Callouts.ElemName_ends_10, sizeof(BitBlock)/sizeof(ScanBlock));
    546             }
    547 
    548             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_11) )
    549             {
    550                 StreamScanLengthGrouping<11>((ScanBlock *) &tag_Callouts.ElemName_ends_11, sizeof(BitBlock)/sizeof(ScanBlock));
    551             }
    552 
    553             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_12) )
    554             {
    555                 StreamScanLengthGrouping<12>((ScanBlock *) &tag_Callouts.ElemName_ends_12, sizeof(BitBlock)/sizeof(ScanBlock));
    556             }
    557 
    558             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_13) )
    559             {
    560                 StreamScanLengthGrouping<13>((ScanBlock *) &tag_Callouts.ElemName_ends_13, sizeof(BitBlock)/sizeof(ScanBlock));
    561             }
    562 
    563             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_14) )
    564             {
    565                 StreamScanLengthGrouping<14>((ScanBlock *) &tag_Callouts.ElemName_ends_14, sizeof(BitBlock)/sizeof(ScanBlock));
    566             }
    567 
    568             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_15) )
    569             {
    570                 StreamScanLengthGrouping<15>((ScanBlock *) &tag_Callouts.ElemName_ends_15, sizeof(BitBlock)/sizeof(ScanBlock));
    571             }
    572 
    573             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_16) )
    574             {
    575                 StreamScanLengthGrouping<16>((ScanBlock *) &tag_Callouts.ElemName_ends_16, sizeof(BitBlock)/sizeof(ScanBlock));
    576             }
    577 
    578             if ( bitblock_has_bit(tag_Callouts.ElemName_ends_17_and_longer) )
    579             {
    580                 StreamScanLengthGrouping<17>((ScanBlock *) &tag_Callouts.ElemName_ends_17_and_longer, sizeof(BitBlock)/sizeof(ScanBlock));
    581             }
    582 
    583             // Store the last starting position in case we hit boundary case
    584             previous_block_last_elem_start = - count_reverse_zeroes (elem_starts);
    585 
    586             //copy current hash value data as previous one.
    587             memmove (&hashvalues[0], &hashvalues[1], 16);
     491    tracker.StoreNewlines(lex.LF);
     492
     493    elem_starts = tag_Callouts.ElemName_starts;
     494    hashvalues[1] = hash_data.Hash_value;
     495
     496    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_1) )
     497    {
     498        BitBlockForwardIterator iter_length_grouping_1(&tag_Callouts.ElemName_ends_1);
     499        validate_block_length_grouping<1>(iter_length_grouping_1, block_base);
     500    }
     501
     502    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_2) )
     503    {
     504        BitBlockForwardIterator iter_length_grouping_2(&tag_Callouts.ElemName_ends_2);
     505        validate_block_length_grouping<2>(iter_length_grouping_2, block_base);
     506    }
     507
     508    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_3) )
     509    {
     510        BitBlockForwardIterator iter_length_grouping_3(&tag_Callouts.ElemName_ends_3);
     511        validate_block_length_grouping<3>(iter_length_grouping_3, block_base);
     512    }
     513
     514    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_4) )
     515    {
     516        BitBlockForwardIterator iter_length_grouping_4(&tag_Callouts.ElemName_ends_4);
     517        validate_block_length_grouping<4>(iter_length_grouping_4, block_base);
     518    }
     519
     520    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_5) )
     521    {
     522        BitBlockForwardIterator iter_length_grouping_5(&tag_Callouts.ElemName_ends_5);
     523        validate_block_length_grouping<5>(iter_length_grouping_5, block_base);
     524    }
     525
     526    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_6) )
     527    {
     528        BitBlockForwardIterator iter_length_grouping_6(&tag_Callouts.ElemName_ends_6);
     529        validate_block_length_grouping<6>(iter_length_grouping_6, block_base);
     530    }
     531
     532    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_7) )
     533    {
     534        BitBlockForwardIterator iter_length_grouping_7(&tag_Callouts.ElemName_ends_7);
     535        validate_block_length_grouping<7>(iter_length_grouping_7, block_base);
     536    }
     537
     538    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_8) )
     539    {
     540        BitBlockForwardIterator iter_length_grouping_8(&tag_Callouts.ElemName_ends_8);
     541        validate_block_length_grouping<8>(iter_length_grouping_8, block_base);
     542    }
     543
     544    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_9) )
     545    {
     546        BitBlockForwardIterator iter_length_grouping_9(&tag_Callouts.ElemName_ends_9);
     547        validate_block_length_grouping<9>(iter_length_grouping_9, block_base);
     548    }
     549
     550    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_10) )
     551    {
     552        BitBlockForwardIterator iter_length_grouping_10(&tag_Callouts.ElemName_ends_10);
     553        validate_block_length_grouping<10>(iter_length_grouping_10, block_base);
     554    }
     555
     556    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_11) )
     557    {
     558        BitBlockForwardIterator iter_length_grouping_11(&tag_Callouts.ElemName_ends_11);
     559        validate_block_length_grouping<11>(iter_length_grouping_11, block_base);
     560    }
     561
     562    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_12) )
     563    {
     564        BitBlockForwardIterator iter_length_grouping_12(&tag_Callouts.ElemName_ends_12);
     565        validate_block_length_grouping<12>(iter_length_grouping_12, block_base);
     566    }
     567
     568    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_13) )
     569    {
     570        BitBlockForwardIterator iter_length_grouping_13(&tag_Callouts.ElemName_ends_13);
     571        validate_block_length_grouping<13>(iter_length_grouping_13, block_base);
     572    }
     573
     574    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_14) )
     575    {
     576        BitBlockForwardIterator iter_length_grouping_14(&tag_Callouts.ElemName_ends_14);
     577        validate_block_length_grouping<14>(iter_length_grouping_14, block_base);
     578    }
     579
     580    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_15) )
     581    {
     582        BitBlockForwardIterator iter_length_grouping_15(&tag_Callouts.ElemName_ends_15);
     583        validate_block_length_grouping<15>(iter_length_grouping_15, block_base);
     584    }
     585
     586    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_16) )
     587    {
     588        BitBlockForwardIterator iter_length_grouping_16(&tag_Callouts.ElemName_ends_16);
     589        validate_block_length_grouping<16>(iter_length_grouping_16, block_base);
     590    }
     591
     592    if ( bitblock_has_bit(tag_Callouts.ElemName_ends_17_and_longer) )
     593    {
     594        BitBlockForwardIterator iter_length_grouping_remaining(&tag_Callouts.ElemName_ends_17_and_longer);
     595        validate_block_length_grouping<17>(iter_length_grouping_remaining, block_base);
     596    }
     597
     598    // Store the last starting position in case we hit boundary case
     599    previous_block_last_elem_start = - count_reverse_zeroes (elem_starts);
     600
     601    //copy current hash value data as previous one.
     602    memmove (&hashvalues[0], &hashvalues[1], 16);
    588603
    589604#ifdef STREAMSCAN
     
    671686    tracker.AdvanceBlock();
    672687#else
    673             if (bitblock_has_bit(simd_or(check_streams.non_ascii_name_starts, check_streams.non_ascii_names))) {
    674                 BitBlockForwardIterator iter_NameStrt_check(&check_streams.non_ascii_name_starts);
    675                 validate_block(iter_NameStrt_check, block_base, NameStrt_check);
    676                 BitBlockForwardIterator iter_Name_check(&check_streams.non_ascii_names);
    677                 validate_block(iter_Name_check, block_base, Name_check);
    678             }
    679             if (bitblock_has_bit(ctCDPI_Callouts.PI_name_starts)){
    680                 BitBlockForwardIterator iter_PI_name_starts(&(ctCDPI_Callouts.PI_name_starts));
    681                 validate_block(iter_PI_name_starts, block_base, buffer_base, PIName_check);
    682             }
    683             if (bitblock_has_bit(ctCDPI_Callouts.CD_starts)){
    684                 BitBlockForwardIterator iter_CD_check(&ctCDPI_Callouts.CD_starts);
    685                 validate_block(iter_CD_check, block_base, CD_check);
    686             }
    687             if(bitblock_has_bit(ref_Callouts.GenRef_starts)){
    688                 BitBlockForwardIterator iter_GenRef_check(&ref_Callouts.GenRef_starts);
    689                 validate_block(iter_GenRef_check, block_base, GenRef_check);
    690             }
    691             if(bitblock_has_bit(ref_Callouts.DecRef_starts)){
    692                 BitBlockForwardIterator iter_DecRef_check(&ref_Callouts.DecRef_starts);
    693                 validate_block(iter_DecRef_check, block_base, DecRef_check);
    694             }
    695             if(bitblock_has_bit(ref_Callouts.HexRef_starts)){
    696                 BitBlockForwardIterator iter_HexRef_check(&ref_Callouts.HexRef_starts);
    697                 validate_block(iter_HexRef_check, block_base, HexRef_check);
    698             }
    699             if(bitblock_has_bit(check_streams.att_refs)){
    700                 BitBlockForwardIterator iter_AttRef_check(&check_streams.att_refs);
    701                 validate_block(iter_AttRef_check, block_base, AttRef_check);
    702             }
    703 
    704             if(error_tracker.Has_Noted_Error()){
    705                     int error_line, error_column;
    706                     tracker.get_Line_and_Column(error_tracker.Noted_Pos_In_Block(), error_line, error_column);
    707                     ReportError(error_tracker.Noted_Error_Msg(), error_line, error_column);
    708                     exit(-1);
    709             }
    710 
    711             matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
    712             tracker.AdvanceBlock();
     688    if (bitblock_has_bit(simd_or(check_streams.non_ascii_name_starts, check_streams.non_ascii_names))) {
     689        BitBlockForwardIterator iter_NameStrt_check(&check_streams.non_ascii_name_starts);
     690        validate_block(iter_NameStrt_check, block_base, NameStrt_check);
     691        BitBlockForwardIterator iter_Name_check(&check_streams.non_ascii_names);
     692        validate_block(iter_Name_check, block_base, Name_check);
     693    }
     694    if (bitblock_has_bit(ctCDPI_Callouts.PI_name_starts)){
     695        BitBlockForwardIterator iter_PI_name_starts(&(ctCDPI_Callouts.PI_name_starts));
     696        validate_block(iter_PI_name_starts, block_base, buffer_base, PIName_check);
     697    }
     698    if (bitblock_has_bit(ctCDPI_Callouts.CD_starts)){
     699        BitBlockForwardIterator iter_CD_check(&ctCDPI_Callouts.CD_starts);
     700        validate_block(iter_CD_check, block_base, CD_check);
     701    }
     702    if(bitblock_has_bit(ref_Callouts.GenRef_starts)){
     703        BitBlockForwardIterator iter_GenRef_check(&ref_Callouts.GenRef_starts);
     704        validate_block(iter_GenRef_check, block_base, GenRef_check);
     705    }
     706    if(bitblock_has_bit(ref_Callouts.DecRef_starts)){
     707        BitBlockForwardIterator iter_DecRef_check(&ref_Callouts.DecRef_starts);
     708        validate_block(iter_DecRef_check, block_base, DecRef_check);
     709    }
     710    if(bitblock_has_bit(ref_Callouts.HexRef_starts)){
     711        BitBlockForwardIterator iter_HexRef_check(&ref_Callouts.HexRef_starts);
     712        validate_block(iter_HexRef_check, block_base, HexRef_check);
     713    }
     714    if(bitblock_has_bit(check_streams.att_refs)){
     715        BitBlockForwardIterator iter_AttRef_check(&check_streams.att_refs);
     716        validate_block(iter_AttRef_check, block_base, AttRef_check);
     717    }
     718
     719    if(error_tracker.Has_Noted_Error()){
     720            int error_line, error_column;
     721            tracker.get_Line_and_Column(error_tracker.Noted_Pos_In_Block(), error_line, error_column);
     722            ReportError(error_tracker.Noted_Error_Msg(), error_line, error_column);
     723            exit(-1);
     724    }
     725
     726    matcher.store_streams(check_streams.tag_marks, check_streams.name_follows, check_streams.misc_mask, chars_avail);
     727    tracker.AdvanceBlock();
    713728
    714729
Note: See TracChangeset for help on using the changeset viewer.