X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=turbopfor.cpp;h=2c7ef58c6589ad9d94e8ef4f50d69df58c78dd10;hb=3e8b0c34103a4de4190ba270060ef5135ad9d8bc;hp=8deebd94d10f4d435f8e5bf0260930d0b7899c73;hpb=bbd966c25ca270651d335d9b81ba35e63ddf77b3;p=plocate diff --git a/turbopfor.cpp b/turbopfor.cpp index 8deebd9..2c7ef58 100644 --- a/turbopfor.cpp +++ b/turbopfor.cpp @@ -1,13 +1,17 @@ +#include #include #include #include #include #include -#include #if defined(__i386__) || defined(__x86_64__) #define COULD_HAVE_SSE2 #include +#define TARGET_DEFAULT __attribute__((target("default"))) +#else +// Function multiversioning is x86-only. +#define TARGET_DEFAULT #endif #include "turbopfor-common.h" @@ -17,13 +21,13 @@ // Forward declarations to declare to the template code below that they exist. // (These must seemingly be non-templates for function multiversioning to work.) -__attribute__((target("default"))) +TARGET_DEFAULT const unsigned char * decode_for_interleaved_128_32(const unsigned char *in, uint32_t *out); -__attribute__((target("default"))) +TARGET_DEFAULT const unsigned char * decode_pfor_bitmap_interleaved_128_32(const unsigned char *in, uint32_t *out); -__attribute__((target("default"))) +TARGET_DEFAULT const unsigned char * decode_pfor_vb_interleaved_128_32(const unsigned char *in, uint32_t *out); @@ -74,6 +78,12 @@ const unsigned char *read_baseval(const unsigned char *in, Docid *out) (uint32_t(in[2]) << 8) | (uint32_t(in[1]))) & 0x1fffff; return in + 3; + } else if (*in < 240) { + *out = ((uint32_t(in[0]) << 24) | + (uint32_t(in[1]) << 16) | + (uint32_t(in[2]) << 8) | + (uint32_t(in[3]))) & 0xfffffff; + return in + 4; } else { assert(false); // Not implemented. } @@ -411,7 +421,7 @@ const unsigned char *decode_for_interleaved(const unsigned char *in, Docid *out) } // Does not read past the end of the input. -__attribute__((target("default"))) +TARGET_DEFAULT const unsigned char * decode_for_interleaved_128_32(const unsigned char *in, uint32_t *out) { @@ -533,7 +543,7 @@ const unsigned char *decode_pfor_bitmap_interleaved(const unsigned char *in, Doc } } -__attribute__((target("default"))) +TARGET_DEFAULT const unsigned char * decode_pfor_bitmap_interleaved_128_32(const unsigned char *in, uint32_t *out) { @@ -683,13 +693,14 @@ const unsigned char *decode_pfor_vb_interleaved(const unsigned char *in, Docid * } } -__attribute__((target("default"))) +TARGET_DEFAULT const unsigned char * decode_pfor_vb_interleaved_128_32(const unsigned char *in, uint32_t *out) { return decode_pfor_vb_interleaved_generic<128>(in, out); } +#ifdef COULD_HAVE_SSE2 // Specialized version for SSE2. // Can read 16 bytes past the end of the input (inherit from decode_bitmap_sse2()). __attribute__((target("sse2"))) @@ -729,6 +740,7 @@ decode_pfor_vb_interleaved_128_32(const unsigned char *in, uint32_t *out) return in; } +#endif // Can read 16 bytes past the end of the input (inherit from several functions). template