[Pcre-svn] [884] code/trunk: JIT test prints cpu info

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [884] code/trunk: JIT test prints cpu info
Revision: 884
          http://vcs.pcre.org/viewvc?view=rev&revision=884
Author:   zherczeg
Date:     2012-01-17 11:52:43 +0000 (Tue, 17 Jan 2012)


Log Message:
-----------
JIT test prints cpu info

Modified Paths:
--------------
    code/trunk/pcre.h.in
    code/trunk/pcre_config.c
    code/trunk/pcre_internal.h
    code/trunk/pcre_jit_compile.c
    code/trunk/pcre_jit_test.c
    code/trunk/sljit/sljitLir.c
    code/trunk/sljit/sljitNativeARM_Thumb2.c
    code/trunk/sljit/sljitNativeARM_v5.c
    code/trunk/sljit/sljitNativeMIPS_common.c
    code/trunk/sljit/sljitNativePPC_common.c
    code/trunk/sljit/sljitNativeX86_common.c


Modified: code/trunk/pcre.h.in
===================================================================
--- code/trunk/pcre.h.in    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/pcre.h.in    2012-01-17 11:52:43 UTC (rev 884)
@@ -249,6 +249,7 @@
 #define PCRE_CONFIG_BSR                     8
 #define PCRE_CONFIG_JIT                     9
 #define PCRE_CONFIG_UTF16                  10
+#define PCRE_CONFIG_JITTARGET              11


/* Request types for pcre_study(). Do not re-arrange, in order to remain
compatible. */

Modified: code/trunk/pcre_config.c
===================================================================
--- code/trunk/pcre_config.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/pcre_config.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -117,6 +117,14 @@
 #endif
   break;


+ case PCRE_CONFIG_JITTARGET:
+#ifdef SUPPORT_JIT
+ *((const char **)where) = PRIV(jit_get_target)();
+#else
+ *((const char **)where) = NULL;
+#endif
+ break;
+
case PCRE_CONFIG_NEWLINE:
*((int *)where) = NEWLINE;
break;

Modified: code/trunk/pcre_internal.h
===================================================================
--- code/trunk/pcre_internal.h    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/pcre_internal.h    2012-01-17 11:52:43 UTC (rev 884)
@@ -2285,6 +2285,7 @@
                            const pcre_uchar *, int, int, int, int, int *, int);
 extern void              PRIV(jit_free)(void *);
 extern int               PRIV(jit_get_size)(void *);
+extern const char*       PRIV(jit_get_target)(void);
 #endif


/* Unicode character database (UCD) */

Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/pcre_jit_compile.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -6814,6 +6814,12 @@
 return ((executable_function*)executable_func)->executable_size;
 }


+const char*
+PRIV(jit_get_target)(void)
+{
+return sljit_get_platform_name();
+}
+
#ifdef COMPILE_PCRE8
PCRE_EXP_DECL pcre_jit_stack *
pcre_jit_stack_alloc(int startsize, int maxsize)

Modified: code/trunk/pcre_jit_test.c
===================================================================
--- code/trunk/pcre_jit_test.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/pcre_jit_test.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -860,6 +860,7 @@
 {
     struct regression_test_case *current = regression_test_cases;
     const char *error;
+    const char *cpu_info;
     int i, err_offs;
     int is_successful, is_ascii_pattern, is_ascii_input;
     int total = 0;
@@ -889,8 +890,15 @@
     utf or ucp may make tests fail, if the pcre_exec result is the SAME, it is
     still considered successful from pcre_jit_test point of view. */


-    printf("Running JIT regression\n");
+#ifdef SUPPORT_PCRE8
+    pcre_config(PCRE_CONFIG_JITTARGET, &cpu_info);
+#else
+    pcre16_config(PCRE_CONFIG_JITTARGET, &cpu_info);
+#endif


+    printf("Running JIT regression tests\n");
+    printf("  target CPU of SLJIT compiler: %s\n", cpu_info);
+
 #ifdef SUPPORT_PCRE8
     pcre_config(PCRE_CONFIG_UTF8, &utf8);
     pcre_config(PCRE_CONFIG_UNICODE_PROPERTIES, &ucp8);
@@ -898,7 +906,7 @@
         disabled_flags8 |= PCRE_UTF8;
     if (!ucp8)
         disabled_flags8 |= PCRE_UCP;
-    printf(" in  8 bit mode with utf8  %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled");
+    printf("  in  8 bit mode with utf8  %s and ucp %s:\n", utf8 ? "enabled" : "disabled", ucp8 ? "enabled" : "disabled");
 #endif
 #ifdef SUPPORT_PCRE16
     pcre16_config(PCRE_CONFIG_UTF16, &utf16);
@@ -907,7 +915,7 @@
         disabled_flags16 |= PCRE_UTF8;
     if (!ucp16)
         disabled_flags16 |= PCRE_UCP;
-    printf(" in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled");
+    printf("  in 16 bit mode with utf16 %s and ucp %s:\n", utf16 ? "enabled" : "disabled", ucp16 ? "enabled" : "disabled");
 #endif


     while (current->pattern) {


Modified: code/trunk/sljit/sljitLir.c
===================================================================
--- code/trunk/sljit/sljitLir.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/sljit/sljitLir.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -1153,6 +1153,32 @@
     return sljit_emit_op1(compiler, op, SLJIT_RETURN_REG, 0, src, srcw);
 }


+/* CPU description section */
+
+#if (defined SLJIT_32BIT_ARCHITECTURE && SLJIT_32BIT_ARCHITECTURE)
+#define SLJIT_CPUINFO_PART1 " 32bit ("
+#elif (defined SLJIT_64BIT_ARCHITECTURE && SLJIT_64BIT_ARCHITECTURE)
+#define SLJIT_CPUINFO_PART1 " 64bit ("
+#else
+#error "Internal error: CPU type info missing"
+#endif
+
+#if (defined SLJIT_LITTLE_ENDIAN && SLJIT_LITTLE_ENDIAN)
+#define SLJIT_CPUINFO_PART2 "little endian + "
+#elif (defined SLJIT_BIG_ENDIAN && SLJIT_BIG_ENDIAN)
+#define SLJIT_CPUINFO_PART2 "big endian + "
+#else
+#error "Internal error: CPU type info missing"
+#endif
+
+#if (defined SLJIT_UNALIGNED && SLJIT_UNALIGNED)
+#define SLJIT_CPUINFO_PART3 "unaligned)"
+#else
+#define SLJIT_CPUINFO_PART3 "aligned)"
+#endif
+
+#define SLJIT_CPUINFO SLJIT_CPUINFO_PART1 SLJIT_CPUINFO_PART2 SLJIT_CPUINFO_PART3
+
 #if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
     #include "sljitNativeX86_common.c"
 #elif (defined SLJIT_CONFIG_X86_64 && SLJIT_CONFIG_X86_64)


Modified: code/trunk/sljit/sljitNativeARM_Thumb2.c
===================================================================
--- code/trunk/sljit/sljitNativeARM_Thumb2.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/sljit/sljitNativeARM_Thumb2.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -26,7 +26,7 @@


 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name()
 {
-    return "arm-thumb2";
+    return "ARM-Thumb2" SLJIT_CPUINFO;
 }


/* Last register + 1. */

Modified: code/trunk/sljit/sljitNativeARM_v5.c
===================================================================
--- code/trunk/sljit/sljitNativeARM_v5.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/sljit/sljitNativeARM_v5.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -27,9 +27,9 @@
 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name()
 {
 #if (defined SLJIT_CONFIG_ARM_V7 && SLJIT_CONFIG_ARM_V7)
-    return "arm-v7";
+    return "ARMv7" SLJIT_CPUINFO;
 #elif (defined SLJIT_CONFIG_ARM_V5 && SLJIT_CONFIG_ARM_V5)
-    return "arm-v5";
+    return "ARMv5" SLJIT_CPUINFO;
 #else
 #error "Internal error: Unknown ARM architecture"
 #endif


Modified: code/trunk/sljit/sljitNativeMIPS_common.c
===================================================================
--- code/trunk/sljit/sljitNativeMIPS_common.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/sljit/sljitNativeMIPS_common.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -26,11 +26,7 @@


 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name()
 {
-#if (defined SLJIT_CONFIG_MIPS_32 && SLJIT_CONFIG_MIPS_32)
-    return "mips-32";
-#else
-#error "mips-64 is not yet supported"
-#endif
+    return "MIPS" SLJIT_CPUINFO;
 }


/* Latest MIPS architecture. */

Modified: code/trunk/sljit/sljitNativePPC_common.c
===================================================================
--- code/trunk/sljit/sljitNativePPC_common.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/sljit/sljitNativePPC_common.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -26,11 +26,7 @@


 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name()
 {
-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
-    return "ppc-32";
-#else
-    return "ppc-64";
-#endif
+    return "PowerPC" SLJIT_CPUINFO;
 }


/* Length of an instruction word.

Modified: code/trunk/sljit/sljitNativeX86_common.c
===================================================================
--- code/trunk/sljit/sljitNativeX86_common.c    2012-01-16 08:35:42 UTC (rev 883)
+++ code/trunk/sljit/sljitNativeX86_common.c    2012-01-17 11:52:43 UTC (rev 884)
@@ -26,11 +26,7 @@


 SLJIT_API_FUNC_ATTRIBUTE SLJIT_CONST char* sljit_get_platform_name()
 {
-#if (defined SLJIT_CONFIG_X86_32 && SLJIT_CONFIG_X86_32)
-    return "x86-32";
-#else
-    return "x86-64";
-#endif
+    return "x86" SLJIT_CPUINFO;
 }


/*