Changeset 1519


Ignore:
Timestamp:
Oct 8, 2011, 7:01:50 AM (8 years ago)
Author:
cameron
Message:

Eliminate SAHFLAHF strategy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lib/block_carry.h

    r1073 r1519  
    3636#define SIMD_CARRY_STRATEGY 1
    3737#define ADC64_STRATEGY 2
    38 #define ADC64_SAHF_STRATEGY 3
    3938
    4039#ifdef ADC64
    41 #ifdef SAHFLAHF
    42 #define CARRY_STRATEGY ADC64_SAHF_STRATEGY
    43 #else
    4440#define CARRY_STRATEGY ADC64_STRATEGY
    45 #endif
    46 #else
    47 #ifdef SAHFLAHF
    48 #define CARRY_STRATEGY ADC64_SAHF_STRATEGY
    4941#else
    5042#define CARRY_STRATEGY SIMD_CARRY_STRATEGY
    51 #endif
    5243#endif
    5344
     
    152143#endif
    153144
    154 #if (CARRY_STRATEGY == ADC64_SAHF_STRATEGY)
    155 typedef uint64_t CarryType;
    156 
    157 #define Carry0 0
    158 
    159 #define test_carry(x) (((x)&256) > 0)
    160 
    161 #define carry_flip(c) ((c)^256)
    162 
    163 #define carry_or(carry1, carry2) (carry1 | carry2)
    164 
    165 #define double_int64_adc(x1, x2, y1, y2, rslt1, rslt2, carry) \
    166   __asm__  ("sahf\n\t" \
    167         "adc %[e1], %[z1]\n\t" \
    168         "adc %[e2], %[z2]\n\t" \
    169         "lahf\n\t" \
    170      : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    171          : "[z1]" (x1), "[z2]" (x2), \
    172            [e1] "r" (y1), [e2] "r" (y2), \
    173            "[carryflag]" (carry) \
    174          : "cc")
    175 
    176 #define adc128(first, second, carry, sum) \
    177 do {\
    178   BitBlock_int64 rslt, x, y;\
    179   x.bitblock = first;\
    180   y.bitblock = second;\
    181   double_int64_adc(x.int64[0], x.int64[1], y.int64[0], y.int64[1], rslt.int64[0], rslt.int64[1], carry);\
    182   sum = rslt.bitblock;\
    183 }while(0)
    184 
    185 
    186 
    187 #define double_int64_advance(x1, x2, rslt1, rslt2, carry) \
    188   __asm__  ("sahf\n\t" \
    189         "adc %[z1], %[z1]\n\t" \
    190         "adc %[z2], %[z2]\n\t" \
    191         "lahf\n\t" \
    192      : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    193          : "[z1]" (x1), "[z2]" (x2), \
    194            "[carryflag]" (carry) \
    195          : "cc")
    196 
    197 
    198 #define advance_with_carry(cursor, carry, rslt)\
    199 do {\
    200   BitBlock_int64 x, z;\
    201   x.bitblock = cursor;\
    202   double_int64_advance(x.int64[0], x.int64[1], z.int64[0], z.int64[1], carry);\
    203   rslt = z.bitblock;\
    204 } while(0)
    205 
    206 
    207 
    208 
    209 #define double_int64_sbb(x1, x2, y1, y2, rslt1, rslt2, carry) \
    210   __asm__  ("sahf\n\t" \
    211         "sbb %[e1], %[z1]\n\t" \
    212         "sbb %[e2], %[z2]\n\t" \
    213         "lahf\n\t" \
    214      : [z1] "=r" (rslt1), [z2] "=r" (rslt2), [carryflag] "=a" (carry) \
    215          : "[z1]" (x1), "[z2]" (x2), \
    216            [e1] "r" (y1), [e2] "r" (y2), \
    217            "[carryflag]" (carry) \
    218          : "cc")
    219 
    220 #define sbb128(first, second, borrow, diff) \
    221 do {\
    222   BitBlock_int64 rslt, x, y;\
    223   x.bitblock = first;\
    224   y.bitblock = second;\
    225   double_int64_sbb(x.int64[0], x.int64[1], y.int64[0], y.int64[1], \
    226                    rslt.int64[0], rslt.int64[1], borrow);\
    227   diff = rslt.bitblock;\
    228 }while(0)
    229 
    230 #endif
    231 
    232145
    233146
Note: See TracChangeset for help on using the changeset viewer.