Changeset 471 for proto/u16u8


Ignore:
Timestamp:
Jul 12, 2010, 10:35:37 AM (9 years ago)
Author:
cameron
Message:

Update u16u8 template and generated u16u8.c

Location:
proto/u16u8
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • proto/u16u8/src/u16u8.c

    r470 r471  
    66#include <sys/types.h>
    77#include <sys/stat.h>
    8 #include "lib/lib_simd.h"
    9 #define min(x,y) ((x) <(y) ?(x) :(y) )  \
     8
     9#include "../lib/lib_simd.h"
     10#include "../lib/block_carry.h"
    1011
    1112typedef SIMD_type BytePack;
     
    1415
    1516// Profiling
     17#define BUFFER_PROFILING
     18#include "../lib/perflib/perfsec.h"
    1619
    1720#ifdef BUFFER_PROFILING
    18 #include "../Profiling/BOM_Profiler.c"
    1921BOM_Table * transcode_timer;
    2022#endif
     
    192194}
    193195
    194 #define double_int64_adc(x1, x2, y1, y2, rslt1, rslt2, carry) \
    195   __asm__  ("sahf\n\t" \
    196         "adc %[e1], %[z1]\n\t" \
    197         "adc %[e2], %[z2]\n\t" \
    198         "lahf\n\t" \
    199      : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    200          : "[z1]" (x1), "[z2]" (x2), \
    201            [e1] "r" (y1), [e2] "r" (y2), \
    202            "[carryflag]" (carry) \
    203          : "cc")
    204 
    205 #define adc128(first, second, carry, sum) \
    206 do\
    207 {\
    208   union {__m128i bitblock;\
    209          uint64_t int64[2];} rslt;\
    210 \
    211   union {__m128i bitblock;\
    212          uint64_t int64[2];} x;\
    213 \
    214   union {__m128i bitblock;\
    215          uint64_t int64[2];} y;\
    216 \
    217   x.bitblock = first;\
    218   y.bitblock = second;\
    219 \
    220   double_int64_adc(x.int64[0], x.int64[1], y.int64[0], y.int64[1], rslt.int64[0], rslt.int64[1], carry);\
    221   sum = rslt.bitblock;\
    222 }while(0)
    223 
    224 #define double_int64_sbb(x1, x2, y1, y2, rslt1, rslt2, carry) \
    225   __asm__  ("sahf\n\t" \
    226         "sbb %[e1], %[z1]\n\t" \
    227         "sbb %[e2], %[z2]\n\t" \
    228         "lahf\n\t" \
    229      : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    230          : "[z1]" (x1), "[z2]" (x2), \
    231            [e1] "r" (y1), [e2] "r" (y2), \
    232            "[carryflag]" (carry) \
    233          : "cc")
    234 
    235 
    236 #define sbb128(first, second, carry, sum) \
    237 do\
    238 { union {__m128i bitblock;\
    239          uint64_t int64[2];} rslt;\
    240 \
    241   union {__m128i bitblock;\
    242          uint64_t int64[2];} x;\
    243 \
    244   union {__m128i bitblock;\
    245          uint64_t int64[2];} y;\
    246 \
    247   x.bitblock = first;\
    248   y.bitblock = second;\
    249 \
    250   double_int64_sbb(x.int64[0], x.int64[1], y.int64[0], y.int64[1], \
    251                    rslt.int64[0], rslt.int64[1], carry);\
    252   sum = rslt.bitblock;\
    253 }while(0)
    254196
    255197
     
    258200void u16u8(char ** targetbuf, const char * targetlimit, const UChar ** srcbuf, const UChar * srclimit, UErrorCode * err){
    259201
    260   int carry1=0;
    261 int carry0=0;
    262 int carry2=0;
    263 BitBlock hcarry;
     202  BitBlock hcarry;
    264203BitBlock array_u16l__4_;
    265204BitBlock array_u16h__4_;
     
    357296BitBlock Temp9;
    358297BitBlock Temp8;
     298CarryType carry1 = Carry0;
     299CarryType carry0 = Carry0;
     300CarryType carry2 = Carry0;
    359301
    360302
     
    378320  int pos = 0;
    379321
    380   int  units_read  = 0;
     322  intptr_t  units_remaining  = 0;
     323  intptr_t  units_read  = 0;
    381324
    382325  bool error_found = false;
    383326  int err_pos;
    384327
    385 
     328 
    386329
    387330  do {
    388331
    389332    U16 = (BytePack *)(*srcbuf);
    390     units_read = min(srclimit-(*srcbuf),BLOCK_SIZE);
    391 
    392     if(units_read < BLOCK_SIZE){
    393         endmask = sisd_sll(simd_const_1(1),sisd_from_int(units_read));
     333    units_remaining = srclimit-(*srcbuf);
     334
     335    if(units_remaining < BLOCK_SIZE){
     336        endmask = sisd_sll(simd_const_1(1),sisd_from_int((int) units_remaining));
     337        units_read = units_remaining;
     338
    394339//      ((uint16_t *) U16)[units_read/2] = 0;
    395340    }
    396     else endmask = simd_const_1(0);
    397 
     341    else {
     342        endmask = simd_const_1(0);
     343        units_read = BLOCK_SIZE;
     344    }
    398345
    399346    for (int i=0; i< 8; i++){
     
    444391strct_u16__utf8_2_ = simd_andc(above_0x7F,above_0x7FF);
    445392strct_u16__ASCII_ = simd_andc(AllOne,above_0x7F);
    446 adc128(strct_u16__hsurrogate_, strct_u16__hsurrogate_, carry0, Temp10);
     393advance_with_carry(strct_u16__hsurrogate_, carry0, Temp10);
    447394strct_u16__error_ = simd_xor(Temp10,strct_u16__lsurrogate_);
    448395efghi_i = simd_andc(AllOne,array_u16l__1_);
     
    478425Temp23 = simd_and(strct_u16__utf8_3_,array_u16h__4_);
    479426Temp24 = simd_or(strct_u16__hsurrogate_,Temp23);
    480 adc128(array_u16l__6_, array_u16l__6_, carry1, Temp25);
     427advance_with_carry(array_u16l__6_, carry1, Temp25);
    481428Temp26 = simd_and(strct_u16__lsurrogate_,Temp25);
    482429array_u8_butlast__2_ = simd_or(Temp24,Temp26);
    483430Temp27 = simd_and(u8_2or3,array_u16h__5_);
    484431Temp28 = simd_or(strct_u16__hsurrogate_,Temp27);
    485 adc128(array_u16l__7_, array_u16l__7_, carry2, Temp29);
     432advance_with_carry(array_u16l__7_, carry2, Temp29);
    486433Temp30 = simd_and(strct_u16__lsurrogate_,Temp29);
    487434array_u8_butlast__3_ = simd_or(Temp28,Temp30);
     
    671618        }
    672619
    673 //      fclose(infile);
    674 //      fclose(outfile);
     620        fclose(outfile);
    675621
    676622
  • proto/u16u8/template.c

    r464 r471  
    99#include "../lib/lib_simd.h"
    1010#include "../lib/block_carry.h"
    11 
    12 
    13 #define min(x,y) ((x) <(y) ?(x) :(y) )  \
    1411
    1512typedef SIMD_type BytePack;
     
    224221  int pos = 0;
    225222
    226   int  units_read  = 0;
     223  intptr_t  units_remaining  = 0;
     224  intptr_t  units_read  = 0;
    227225
    228226  bool error_found = false;
     
    234232
    235233    U16 = (BytePack *)(*srcbuf);
    236     units_read = min(srclimit-(*srcbuf),BLOCK_SIZE);
    237 
    238     if(units_read < BLOCK_SIZE){
    239         endmask = sisd_sll(simd_const_1(1),sisd_from_int(units_read));
     234    units_remaining = srclimit-(*srcbuf);
     235
     236    if(units_remaining < BLOCK_SIZE){
     237        endmask = sisd_sll(simd_const_1(1),sisd_from_int((int) units_remaining));
     238        units_read = units_remaining;
     239
    240240//      ((uint16_t *) U16)[units_read/2] = 0;
    241241    }
    242     else endmask = simd_const_1(0);
    243 
     242    else {
     243        endmask = simd_const_1(0);
     244        units_read = BLOCK_SIZE;
     245    }
    244246
    245247    for (int i=0; i< 8; i++){
     
    439441        }
    440442
    441 //      fclose(infile);
    442 //      fclose(outfile);
     443        fclose(outfile);
    443444
    444445
Note: See TracChangeset for help on using the changeset viewer.