]> git.ipfire.org Git - thirdparty/vectorscan.git/commitdiff
fix IA32 build, as we need minimum SSSE3 support for compilation to succeed 5/head
authorKonstantinos Margaritis <markos@freevec.org>
Wed, 30 Dec 2020 17:57:44 +0000 (19:57 +0200)
committerKonstantinos Margaritis <markos@freevec.org>
Wed, 30 Dec 2020 17:57:44 +0000 (19:57 +0200)
CMakeLists.txt
src/dispatcher.c
src/hs.cpp
src/hs_valid_platform.c
src/util/arch/x86/simd_utils.h
util/CMakeLists.txt

index 5595438447cc101a806ad36c57c110882842dc92..11415c8040cd41f1a2d7204e07111ccc5243d3d2 100644 (file)
@@ -30,7 +30,7 @@ else()
     message(STATUS "Build type ${CMAKE_BUILD_TYPE}")
 endif()
 
-if(CMAKE_BUILD_TYPE MATCHES RELEASE|RELWITHDEBINFO|MINSIZEREL)
+if(CMAKE_BUILD_TYPE MATCHES NONE|RELEASE|RELWITHDEBINFO|MINSIZEREL)
     message(STATUS "using release build")
     set(RELEASE_BUILD TRUE)
 else()
@@ -1193,6 +1193,9 @@ if (NOT FAT_RUNTIME)
         set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
 
         add_library(hs_compile OBJECT ${hs_compile_SRCS})
+       if (ARCH_IA32)
+            set_target_properties(hs_compile PROPERTIES COMPILE_FLAGS "-mssse3")
+        endif (ARCH_IA32)
 
         add_library(hs STATIC
             src/hs_version.c
@@ -1259,7 +1262,11 @@ else (FAT_RUNTIME)
            $<TARGET_OBJECTS:hs_exec_common>
            ${RUNTIME_LIBS})
        set_target_properties(hs_runtime PROPERTIES LINKER_LANGUAGE C)
-        add_library(hs_compile OBJECT ${hs_compile_SRCS})
+       add_library(hs_compile OBJECT ${hs_compile_SRCS})
+       if (ARCH_IA32)
+           set_target_properties(hs_exec_common PROPERTIES COMPILE_FLAGS "-mssse3")
+           set_target_properties(hs_compile PROPERTIES COMPILE_FLAGS "-mssse3")
+       endif (ARCH_IA32)
 
        # we want the static lib for testing
        add_library(hs STATIC src/hs_version.c src/hs_valid_platform.c
index 76ed37a155493021eff78af2c5336c3daab963f1..46fdb7d519927b2f909da509b41b41f4367721cc 100644 (file)
@@ -30,7 +30,7 @@
 #include "hs_common.h"
 #include "hs_runtime.h"
 #include "ue2common.h"
-#if defined(ARCH_X86_64)
+#if defined(ARCH_IA32) || defined(ARCH_X86_64)
 #include "util/arch/x86/cpuid_inline.h"
 #endif
 #include "util/join.h"
index 7898cf4675fe25d937eba70863b8ed14e278a1c9..b128572a67a038204d360e188ba4056406005031 100644 (file)
@@ -45,7 +45,7 @@
 #include "parser/unsupported.h"
 #include "util/compile_error.h"
 #include "util/arch/common/cpuid_flags.h"
-#if defined(ARCH_X86_64)
+#if defined(ARCH_IA32) || defined(ARCH_X86_64)
 #include "util/arch/x86/cpuid_inline.h"
 #elif defined(ARCH_ARM32) || defined(ARCH_AARCH64)
 #endif
index b187090bb91d9dcc6c64398dc93b514efefe5401..8323f343eae23c9b3e0bb315f33379cc04fa7ded 100644 (file)
@@ -29,7 +29,7 @@
 #include "config.h"
 #include "hs_common.h"
 #include "ue2common.h"
-#if defined(ARCH_X86_64)
+#if defined(ARCH_IA32) || defined(ARCH_X86_64)
 #include "util/arch/x86/cpuid_inline.h"
 #endif
 
index 9555bf6c42e18c50dd1e31103f75d1cf89362e91..5270808a9b6ad39151e9b67d38540586bef1e434 100644 (file)
@@ -44,7 +44,7 @@
 static really_inline m128 ones128(void) {
 #if defined(__GNUC__) || defined(__INTEL_COMPILER)
     /* gcc gets this right */
-    return _mm_set1_epi8(0xFF);
+    return (m128) _mm_set1_epi8(0xFF);
 #else
     /* trick from Intel's optimization guide to generate all-ones.
      * ICC converts this to the single cmpeq instruction */
@@ -53,12 +53,12 @@ static really_inline m128 ones128(void) {
 }
 
 static really_inline m128 zeroes128(void) {
-    return _mm_setzero_si128();
+    return (m128) _mm_setzero_si128();
 }
 
 /** \brief Bitwise not for m128*/
 static really_inline m128 not128(m128 a) {
-    return _mm_xor_si128(a, ones128());
+    return (m128) _mm_xor_si128(a, ones128());
 }
 
 /** \brief Return 1 if a and b are different otherwise 0 */
@@ -125,7 +125,13 @@ static really_inline u32 movd(const m128 in) {
 }
 
 static really_inline u64a movq(const m128 in) {
+#if defined(ARCH_X86_64)
     return _mm_cvtsi128_si64(in);
+#else // 32-bit - this is horrific
+    u32 lo = movd(in);
+    u32 hi = movd(_mm_srli_epi64(in, 32));
+    return (u64a)hi << 32 | lo;
+#endif
 }
 
 /* another form of movq */
index ea942ef1a5ced1871d5029e31588f106d9cd434b..861f2f085a89072f6a7e9528de9ade2724b72f67 100644 (file)
@@ -33,6 +33,9 @@ SET(corpusomatic_SRCS
     ng_find_matches.cpp
 )
 add_library(corpusomatic STATIC ${corpusomatic_SRCS})
+if (ARCH_IA32)
+    set_target_properties(corpusomatic PROPERTIES COMPILE_FLAGS "-mssse3")
+endif (ARCH_IA32)
 
 set(databaseutil_SRCS
     database_util.cpp