Changeset 179 for trunk/src/bitlex.c


Ignore:
Timestamp:
Jul 9, 2008, 12:17:19 PM (11 years ago)
Author:
lindanl
Message:

Templated SIMD Library - initial version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bitlex.c

    r169 r179  
    2828        x8basis = (BitBlockBasis *) simd_new(BUFFER_SIZE/PACKSIZE);
    2929        validation_stream = (BitBlock *) simd_new(BUFFER_BLOCKS+SENTINEL_BLOCKS);
     30#ifdef TEMPLATED_SIMD_LIB
     31        validation_stream[BUFFER_BLOCKS] = simd_const<1,1>();
     32#endif
     33#ifndef TEMPLATED_SIMD_LIB
    3034        validation_stream[BUFFER_BLOCKS] = simd_const_1(1);
     35#endif
    3136};
    3237
     
    161166        BitBlock temp1 = simd_or(bit[0], bit[1]);
    162167        BitBlock temp2 = simd_or(temp1, bit[2]);
     168#ifdef TEMPLATED_SIMD_LIB
     169        Control = simd_andc(simd_const<1,1>(), temp2);
     170#endif
     171#ifndef TEMPLATED_SIMD_LIB
    163172        Control = simd_andc(simd_const_1(1), temp2);
     173#endif
    164174        BitBlock temp3 = simd_or(bit[2], bit[3]);
    165175        BitBlock temp4 = simd_or(temp1, temp3);
     
    212222        BitBlock temp26 = simd_or(bit[5], temp9);
    213223        BitBlock temp27 = simd_and(bit[4], temp26);
     224#ifdef TEMPLATED_SIMD_LIB
     225        BitBlock temp28 = simd_andc(simd_const<1,1>(), temp4);
     226#endif
     227#ifndef TEMPLATED_SIMD_LIB
    214228        BitBlock temp28 = simd_andc(simd_const_1(1), temp4);
     229#endif
    215230        BitBlock temp29 = simd_if(bit[3], temp27, temp28);
    216231        BitBlock temp30 = simd_andc(temp29, temp25);
     
    234249        BitBlock temp48 = simd_and(temp21, temp15);
    235250        BitBlock temp49 = simd_andc(temp47, temp48);
     251#ifdef TEMPLATED_SIMD_LIB
     252        Control = simd_andc(simd_const<1,1>(), temp49);
     253#endif
     254#ifndef TEMPLATED_SIMD_LIB
    236255        Control = simd_andc(simd_const_1(1), temp49);
     256#endif
    237257        BitBlock temp50 = simd_andc(bit[7], bit[6]);
    238258        BitBlock temp51 = simd_and(temp15, temp50);
     
    321341  BitBlock temp35 = simd_or(temp31, temp34);
    322342  BitBlock temp36 = simd_and(temp17, bit[4]);
     343#ifdef TEMPLATED_SIMD_LIB
     344  BitBlock temp37 = simd_andc(simd_const<1,1>(), temp20);
     345#endif
     346#ifndef TEMPLATED_SIMD_LIB
    323347  BitBlock temp37 = simd_andc(simd_const_1(1), temp20);
     348#endif
    324349  BitBlock temp38 = simd_if(bit[5], temp37, temp20);
    325350  BitBlock temp39 = simd_and(temp36, temp38);
     
    554579            However, at the beginning of the buffer, no suffixes
    555580            are expected, so this value is initialized to zeroes. */
     581#ifdef TEMPLATED_SIMD_LIB
     582        BitBlock prefix_pending = simd_const<1,0>();
     583        /*  If a suffix is pending, then it may involve one of
     584            the special case prefixes E0, ED. F0, F4, or the
     585            EF prefix or EF_BF combination for FFFF/FFFE detection.*/
     586        BitBlock E0ED_pending = simd_const<1,0>();
     587        BitBlock F0F4_pending = simd_const<1,0>();
     588        BitBlock bit5_pending = simd_const<1,0>();
     589        BitBlock EF_pending = simd_const<1,0>();
     590        BitBlock EF_BF_pending = simd_const<1,0>();
     591#endif
     592#ifndef TEMPLATED_SIMD_LIB
    556593        BitBlock prefix_pending = simd_const_1(0);
    557594        /*  If a suffix is pending, then it may involve one of
     
    563600        BitBlock EF_pending = simd_const_1(0);
    564601        BitBlock EF_BF_pending = simd_const_1(0);
    565 
     602#endif
    566603        /* Temporary variables used within the block. */
    567604        BitBlock suffix_required_scope;
     
    571608
    572609        for (int i = 0; i < buffer_blocks; i++) {
     610#ifdef TEMPLATED_SIMD_LIB
     611                validation_stream[i] = simd_const<1,0>();
     612#endif
     613#ifndef TEMPLATED_SIMD_LIB
    573614                validation_stream[i] = simd_const_1(0);
     615#endif
    574616                /* If there is no pending suffix and no bit 0, then there
    575617                   are no possible validation issues for this block. */
     
    598640
    599641                /* Default values of pending variables for next iteration. */
     642#ifdef TEMPLATED_SIMD_LIB
     643                E0ED_pending = simd_const<1,0>();
     644                F0F4_pending = simd_const<1,0>();
     645                bit5_pending = simd_const<1,0>();
     646                EF_pending = simd_const<1,0>();
     647                EF_BF_pending = simd_const<1,0>();
     648#endif
     649#ifndef TEMPLATED_SIMD_LIB
    600650                E0ED_pending = simd_const_1(0);
    601651                F0F4_pending = simd_const_1(0);
     
    603653                EF_pending = simd_const_1(0);
    604654                EF_BF_pending = simd_const_1(0);
     655#endif
    605656
    606657                X111x = simd_and(simd_and(x8basis[i].bit[4], x8basis[i].bit[5]), x8basis[i].bit[6]);
     
    693744        /* Nothing required for most charsets - but perhaps should have tables. */
    694745        for (int i = 0; i < buffer_blocks; i++) {
     746#ifdef TEMPLATED_SIMD_LIB
     747                validation_stream[i] = simd_const<1,0>();
     748#endif
     749#ifndef TEMPLATED_SIMD_LIB
    695750                validation_stream[i] = simd_const_1(0);
     751#endif
    696752        }
    697753};
     
    713769        /* Nothing required for most cases - but perhaps should have tables. */
    714770        for (int i = 0; i < buffer_blocks; i++) {
     771#ifdef TEMPLATED_SIMD_LIB
     772                validation_stream[i] = simd_const<1,0>();
     773#endif
     774#ifndef TEMPLATED_SIMD_LIB
    715775                validation_stream[i] = simd_const_1(0);
     776#endif
    716777        }
    717778}
     
    739800        BitBlock temp10 = simd_andc(temp2, temp9);
    740801        BitBlock temp11 = simd_andc(temp10, bit[0]);
     802#ifdef TEMPLATED_SIMD_LIB
     803        Control = simd_andc(simd_const<1,1>(), temp11);
     804#endif
     805#ifndef TEMPLATED_SIMD_LIB
    741806        Control = simd_andc(simd_const_1(1), temp11);
     807#endif
    742808        BitBlock temp12 = simd_or(bit[2], bit[3]);
    743809        BitBlock temp13 = simd_or(temp1, temp12);
     
    784850        BitBlock temp12 = simd_andc(temp11, bit[2]);
    785851        BitBlock temp13 = simd_andc(temp10, temp12);
     852#ifdef TEMPLATED_SIMD_LIB
     853        Control = simd_andc(simd_const<1,1>(), temp13);
     854#endif
     855#ifndef TEMPLATED_SIMD_LIB
    786856        Control = simd_andc(simd_const_1(1), temp13);
     857#endif
    787858        BitBlock temp14 = simd_or(bit[2], bit[3]);
    788859        BitBlock temp15 = simd_or(temp1, temp14);
     
    840911        BitBlock temp8 = simd_and(temp4, temp7);
    841912        BitBlock temp9 = simd_andc(temp1, temp8);
     913#ifdef TEMPLATED_SIMD_LIB
     914        Control = simd_andc(simd_const<1,1>(), temp9);
     915#endif
     916#ifndef TEMPLATED_SIMD_LIB
    842917        Control = simd_andc(simd_const_1(1), temp9);
     918#endif
    843919        BitBlock temp10 = simd_or(bit[2], bit[3]);
    844920        BitBlock temp11 = simd_or(temp1, temp10);
     
    9341010
    9351011        if (buffer_units < BUFFER_SIZE) {
     1012#ifdef TEMPLATED_SIMD_LIB
     1013                BitBlock final_block_mask =
     1014                        sisd_sfl(simd_const<1,1>(), sisd_from_int(buffer_units % BLOCKSIZE));
     1015#endif
     1016#ifndef TEMPLATED_SIMD_LIB
    9361017                BitBlock final_block_mask =
    9371018                        sisd_sfl(simd_const_1(1), sisd_from_int(buffer_units % BLOCKSIZE));
     1019#endif
    9381020                int lastblk = buffer_units/BLOCKSIZE;
    9391021                for (int j = minLexicalItem; j < LexicalItemCount; j++) {
Note: See TracChangeset for help on using the changeset viewer.