Enable GroupVarint on PPC64
authorGustavo Serra Scalet <gustavo.scalet@eldorado.org.br>
Tue, 5 Jan 2016 20:18:23 +0000 (12:18 -0800)
committerfacebook-github-bot-1 <folly-bot@fb.com>
Tue, 5 Jan 2016 21:20:23 +0000 (13:20 -0800)
Summary:
This PR is necessary for both Folly and HHVM to compile on PPC64 (https://github.com/PPC64/hhvm) and other platforms that are not compatible with SSE instructions.

It also removes GroupVarint32 tables generator dependency on x86 platform.
Closes https://github.com/facebook/folly/pull/339

Reviewed By: mxw

Differential Revision: D2760156

fb-gh-sync-id: b4e93b54b62d6f68ccf684d34840678f677bf276

folly/GroupVarint.h
folly/build/generate_varint_tables.py

index 4e8657a6ba60176237d17af51c40b0dd1ae2ad4a..fb99ac8738fe998dbcf1077c87eaf33d93f04a55 100644 (file)
@@ -23,7 +23,7 @@
 
 #include <folly/Portability.h>
 
-#if FOLLY_X64 || defined(__i386__)
+#if FOLLY_X64 || defined(__i386__) || FOLLY_PPC64
 #define HAVE_GROUP_VARINT 1
 
 #include <cstdint>
@@ -617,5 +617,5 @@ typedef GroupVarintDecoder<uint64_t> GroupVarint64Decoder;
 
 }  // namespace folly
 
-#endif /* FOLLY_X64 || defined(__i386__) */
+#endif /* FOLLY_X64 || defined(__i386__) || FOLLY_PPC64 */
 #endif /* FOLLY_GROUPVARINT_H_ */
index c2c9dbf7432a289de3036f00de86cfff7b9da555..96bfd1d13d080237e522fd6e9ee36bc759172419 100755 (executable)
@@ -54,13 +54,16 @@ def generate(f):
     f.write("""
 #include <folly/Portability.h>
 
-#if (FOLLY_X64 || defined(__i386__)) && (FOLLY_SSE >= 2)
 #include <stdint.h>
+
+#if (FOLLY_X64 || defined(__i386__)) && (FOLLY_SSE >= 2)
 #include <x86intrin.h>
+#endif
 
 namespace folly {
 namespace detail {
 
+#if (FOLLY_X64 || defined(__i386__)) && (FOLLY_SSE >= 2)
 extern const __m128i groupVarintSSEMasks[] = {
 """)
 
@@ -82,8 +85,9 @@ extern const __m128i groupVarintSSEMasks[] = {
             "static_cast<int64_t>(0x{3:08x}{2:08x})}},\n".format(*vals))
 
     f.write("};\n"
-            "\n"
-            "extern const uint8_t groupVarintLengths[] = {\n")
+        "#endif /*#if (FOLLY_X64 || defined(__i386__)) && (FOLLY_SSE >= 2)*/\n"
+        "\n"
+        "extern const uint8_t groupVarintLengths[] = {\n")
 
     # Also compute total encoded lengths, including key byte
     for i in range(0, 256):
@@ -98,7 +102,6 @@ extern const __m128i groupVarintSSEMasks[] = {
 
 }  // namespace detail
 }  // namespace folly
-#endif /* (FOLLY_X64 || defined(__i386__)) && (FOLLY_SSE >= 2) */
 """)
 
 def main():