Changeset 20 for trunk/src


Ignore:
Timestamp:
Jan 17, 2008, 7:05:52 AM (11 years ago)
Author:
cameron
Message:

simplified BYTE_ORDER dependencies

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/engine.c

    r19 r20  
    3333#endif
    3434#ifdef OPTIMIZE_SHORT_SCAN
    35   BitBlock sentinel_value = bitblock_sfli(simd_const_1(1), 8*sizeof(unsigned long));
     35  BitBlock sentinel_value = sisd_sfli(simd_const_1(1), 8*sizeof(unsigned long));
    3636#endif
    3737  for (int j = MarkupStart; j < LexicalItemCount; j++) {
  • trunk/src/multiliteral.h

    r19 r20  
    11/*  multiliteral.h - XML Multicharacter Recognizers.
    2     Copyright (c) 2007, Robert D. Cameron. 
     2    Copyright (c) 2007, 2008, Robert D. Cameron. 
    33    Licensed to the public under the Open Software License 3.0.
    44    Licensed to International Characters, Inc., under the Academic
     
    99compared as 16 bit integers, sequences of length 3 or 4 are compared
    1010as 32 bit integers and other sequences of length up to 8 are compared as
    11 64 bit integers.
     1164 bit integers.  The integer value for each XML multicharacter sequence
     12is determined as a compile-time constant for optimal efficiency.
    1213
    1314All functions are declared inline; there is no corresponding multiliteral.c
     
    2122#include "charsets/ASCII_EBCDIC.h"
    2223
     24#if BYTE_ORDER == BIG_ENDIAN
     25const int LOW_BYTE_SHIFT = 8;
     26const int HIGH_BYTE_SHIFT = 0;
     27#endif
     28#if BYTE_ORDER == LITTLE_ENDIAN
     29const int LOW_BYTE_SHIFT = 0;
     30const int HIGH_BYTE_SHIFT = 8;
     31#endif
     32
    2333/*
    24 Helper functions.  Given 2, 4 or 8 characters comprising a sequence,
     34Helper metafunctions.  Given 2, 4 or 8 characters comprising a sequence,
    2535the c2int16, c4int32, and c8int64 functions determine the corresponding
    26 16, 32 or 64 bit integer value.   These functions are intended to be called
    27 with constant arguments and hence to be applied at compile time.
    28 This is achieved using template metaprogramming.
     3616, 32 or 64 bit integer value.   These are template metafunctions that
     37must be instantiated with constant arguments to be applied at compile time.
     38The functions may be instantiated for ASCII or EBCDIC based byte
     39sequences.
     40For example, c2int16<ASCII, '<', '/'>::value produces the compile
     41time constant for the 16-bit value of an ASCII-based byte sequence
     42of the XML end tag opening delimiter.
    2943*/
    3044
     
    3246struct c2int16 {
    3347  static uint16_t const value =
    34 #if BYTE_ORDER == BIG_ENDIAN
    35     (((uint16_t) Ord<C,c1>::value) << 8) + (uint16_t) Ord<C,c2>::value;
    36 #endif
    37 #if BYTE_ORDER == LITTLE_ENDIAN
    38     (uint16_t) Ord<C,c1>::value + (((uint16_t) Ord<C,c2>::value) << 8);
    39 #endif
     48    (((uint16_t) Ord<C,c1>::value) << LOW_BYTE_SHIFT) +
     49    (((uint16_t) Ord<C,c2>::value) << HIGH_BYTE_SHIFT);
    4050};
    4151
     
    4454struct c4int32 {
    4555  static uint32_t const value =
    46 #if BYTE_ORDER == BIG_ENDIAN
    47     (((uint16_t) c2int16<C,c1,c2>::value) << 16) + (uint16_t) c2int16<C,c3,c4>::value;
    48 #endif
    49 #if BYTE_ORDER == LITTLE_ENDIAN
    50     (uint16_t) c2int16<C,c1,c2>::value + (((uint16_t) c2int16<C,c3,c4>::value) << 16);
    51 #endif
     56    (((uint32_t) c2int16<C,c1,c2>::value) << (2 * LOW_BYTE_SHIFT)) +
     57    (((uint32_t) c2int16<C,c3,c4>::value) << (2 * HIGH_BYTE_SHIFT));
    5258};
    5359
     
    5864struct c8int64 {
    5965  static uint64_t const value =
    60 #if BYTE_ORDER == BIG_ENDIAN
    61     (((uint64_t) c4int32<C, c1, c2, c3, c4>::value) << 32) +
    62      (uint64_t) c4int32<C, c5, c6, c7, c8>::value;
    63 #endif
    64 #if BYTE_ORDER == LITTLE_ENDIAN
    65     ((uint64_t) c4int32<C, c1, c2, c3, c4>::value) +
    66     (((uint64_t) c4int32<C, c5, c6, c7, c8>::value) << 32);
    67 #endif
     66    (((uint64_t) c4int32<C, c1, c2, c3, c4>::value) << (4 * LOW_BYTE_SHIFT)) +
     67    (((uint64_t) c4int32<C, c5, c6, c7, c8>::value) << (4 * HIGH_BYTE_SHIFT));
    6868};
    6969
     
    118118
    119119static inline uint32_t s3int32(unsigned char s[]) {
    120   return s4int32(s) & c3int32<Native, 0xFF, 0xFF, 0xFF>::value;
     120  return s4int32(s) & (0xFFFFFF << LOW_BYTE_SHIFT);
    121121}
    122122
    123123static inline uint64_t s5int64(unsigned char s[]) {
    124   return s8int64(s) & c5int64<Native, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF>::value;
     124  return s8int64(s) & (0xFFFFFFFFFFULL << (3 * LOW_BYTE_SHIFT));
    125125}
    126126
    127127static inline uint64_t s6int64(unsigned char s[]) {
    128   return s8int64(s) & c6int64<Native, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF>::value;
     128  return s8int64(s) & (0xFFFFFFFFFFFFULL << (2 * LOW_BYTE_SHIFT));
    129129}
    130130
    131131static inline uint64_t s7int64(unsigned char s[]) {
    132   return s8int64(s) & c7int64<Native, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF>::value;
     132  return s8int64(s) & (0xFFFFFFFFFFFFFFULL << LOW_BYTE_SHIFT);
    133133}
    134134
Note: See TracChangeset for help on using the changeset viewer.