Changeset 390 for proto/Compiler


Ignore:
Timestamp:
Apr 30, 2010, 6:12:01 PM (9 years ago)
Author:
eamiri
Message:

adc128 changed

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/template.c

    r365 r390  
    5050#define double_int64_adc(x1, x2, y1, y2, rslt1, rslt2, carry) \
    5151  __asm__  ("sahf\n\t" \
    52             "adc %[e1], %[z1]\n\t" \
    53             "adc %[e2], %[z2]\n\t" \
    54             "lahf\n\t" \
    55          : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carry] "=a" (carry) \
     52        "adc %[e1], %[z1]\n\t" \
     53        "adc %[e2], %[z2]\n\t" \
     54        "lahf\n\t" \
     55     : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    5656         : "[z1]" (x1), "[z2]" (x2), \
    5757           [e1] "r" (y1), [e2] "r" (y2), \
    58            "[carry]" (carry) \
     58           "[carryflag]" (carry) \
    5959         : "cc")
    6060
    61 static inline BitBlock adc128(BitBlock first, BitBlock second, int &carry)
    62 {
    63   union {__m128i bitblock;
    64          uint64_t int64[2];} rslt;
    65 
    66   union {__m128i bitblock;
    67          uint64_t int64[2];} x;
    68 
    69   union {__m128i bitblock;
    70          uint64_t int64[2];} y;
    71 
    72   x.bitblock = first;
    73   y.bitblock = second;
    74 
    75   double_int64_adc(x.int64[0], x.int64[1], y.int64[0], y.int64[1],
    76                    rslt.int64[0], rslt.int64[1], carry);
    77 
    78   return rslt.bitblock;
    79 }
     61#define adc128(first, second, carry, sum) \
     62do\
     63{\
     64  union {__m128i bitblock;\
     65         uint64_t int64[2];} rslt;\
     66\
     67  union {__m128i bitblock;\
     68         uint64_t int64[2];} x;\
     69\
     70  union {__m128i bitblock;\
     71         uint64_t int64[2];} y;\
     72\
     73  x.bitblock = first;\
     74  y.bitblock = second;\
     75\
     76  double_int64_adc(x.int64[0], x.int64[1], y.int64[0], y.int64[1], rslt.int64[0], rslt.int64[1], carry);\
     77  sum = rslt.bitblock;\
     78}while(0)
    8079
    8180
    82                      
     81
    8382#define double_int64_sbb(x1, x2, y1, y2, rslt1, rslt2, carry) \
    8483  __asm__  ("sahf\n\t" \
    85             "sbb %[e1], %[z1]\n\t" \
    86             "sbb %[e2], %[z2]\n\t" \
    87             "lahf\n\t" \
    88          : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carry] "=a" (carry) \
     84        "sbb %[e1], %[z1]\n\t" \
     85        "sbb %[e2], %[z2]\n\t" \
     86        "lahf\n\t" \
     87     : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    8988         : "[z1]" (x1), "[z2]" (x2), \
    9089           [e1] "r" (y1), [e2] "r" (y2), \
    91            "[carry]" (carry) \
     90           "[carryflag]" (carry) \
    9291         : "cc")
    9392
    94 static inline BitBlock sbb128(BitBlock first, BitBlock second, int &carry)
    95 {
    96   union {__m128i bitblock;
    97          uint64_t int64[2];} rslt;
    98 
    99   union {__m128i bitblock;
    100          uint64_t int64[2];} x;
    101 
    102   union {__m128i bitblock;
    103          uint64_t int64[2];} y;
    104 
    105   x.bitblock = first;
    106   y.bitblock = second;
    107 
    108   double_int64_sbb(x.int64[0], x.int64[1], y.int64[0], y.int64[1],
    109                    rslt.int64[0], rslt.int64[1], carry);
    110 
    111   return rslt.bitblock;
    112 }
    113 
     93#define sbb128(first, second, carry, sum) \
     94do\
     95{ union {__m128i bitblock;\
     96         uint64_t int64[2];} rslt;\
     97\
     98  union {__m128i bitblock;\
     99         uint64_t int64[2];} x;\
     100\
     101  union {__m128i bitblock;\
     102         uint64_t int64[2];} y;\
     103\
     104  x.bitblock = first;\
     105  y.bitblock = second;\
     106\
     107  double_int64_sbb(x.int64[0], x.int64[1], y.int64[0], y.int64[1], \
     108                   rslt.int64[0], rslt.int64[1], carry);\
     109  sum = rslt.bitblock;\
     110}while(0)
    114111
    115112       
Note: See TracChangeset for help on using the changeset viewer.