[Pcre-svn] [995] code/trunk: IBM AIX OS support for PPC

Top Page
Delete this message
Author: Subversion repository
Date:  
To: pcre-svn
Subject: [Pcre-svn] [995] code/trunk: IBM AIX OS support for PPC
Revision: 995
          http://vcs.pcre.org/viewvc?view=rev&revision=995
Author:   zherczeg
Date:     2012-07-11 12:05:30 +0100 (Wed, 11 Jul 2012)


Log Message:
-----------
IBM AIX OS support for PPC

Modified Paths:
--------------
    code/trunk/pcre_jit_compile.c
    code/trunk/pcre_jit_test.c
    code/trunk/sljit/sljitConfigInternal.h
    code/trunk/sljit/sljitLir.c
    code/trunk/sljit/sljitNativePPC_64.c
    code/trunk/sljit/sljitNativePPC_common.c


Modified: code/trunk/pcre_jit_compile.c
===================================================================
--- code/trunk/pcre_jit_compile.c    2012-07-10 14:29:26 UTC (rev 994)
+++ code/trunk/pcre_jit_compile.c    2012-07-11 11:05:30 UTC (rev 995)
@@ -2420,7 +2420,6 @@
   /* Search for the end of the first line. */
   SLJIT_ASSERT(common->first_line_end != 0);
   OP1(SLJIT_MOV, TMP3, 0, STR_PTR, 0);
-  OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, STR_END, 0);


   if (common->nltype == NLTYPE_FIXED && common->newline > 255)
     {
@@ -2431,6 +2430,7 @@
     OP1(MOV_UCHAR, TMP2, 0, SLJIT_MEM1(STR_PTR), IN_UCHARS(0));
     CMPTO(SLJIT_C_NOT_EQUAL, TMP1, 0, SLJIT_IMM, (common->newline >> 8) & 0xff, mainloop);
     CMPTO(SLJIT_C_NOT_EQUAL, TMP2, 0, SLJIT_IMM, common->newline & 0xff, mainloop);
+    JUMPHERE(end);
     OP2(SLJIT_SUB, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, STR_PTR, 0, SLJIT_IMM, IN_UCHARS(1));
     }
   else
@@ -2442,11 +2442,11 @@
     read_char(common);
     check_newlinechar(common, common->nltype, &newline, TRUE);
     CMPTO(SLJIT_C_LESS, STR_PTR, 0, STR_END, 0, mainloop);
+    JUMPHERE(end);
     OP1(SLJIT_MOV, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end, STR_PTR, 0);
     set_jumps(newline, LABEL());
     }


- JUMPHERE(end);
OP1(SLJIT_MOV, STR_PTR, 0, TMP3, 0);
}

@@ -2861,7 +2861,7 @@
if (firstline)
{
SLJIT_ASSERT(common->first_line_end != 0);
- OP1(SLJIT_MOV, TMP3, 0, STR_END, 0);
+ OP1(SLJIT_MOV, RETURN_ADDR, 0, STR_END, 0);
OP1(SLJIT_MOV, STR_END, 0, SLJIT_MEM1(SLJIT_LOCALS_REG), common->first_line_end);
}

@@ -2913,7 +2913,7 @@
JUMPHERE(quit);

if (firstline)
- OP1(SLJIT_MOV, STR_END, 0, TMP3, 0);
+ OP1(SLJIT_MOV, STR_END, 0, RETURN_ADDR, 0);
}

 static SLJIT_INLINE struct sljit_jump *search_requested_char(compiler_common *common, pcre_uchar req_char, BOOL caseless, BOOL has_firstchar)
@@ -4396,7 +4396,7 @@
     }
   OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, c);
   COND_VALUE(SLJIT_MOV, TMP2, 0, SLJIT_C_EQUAL);
-  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, char_othercase(common, c));
+  OP2(SLJIT_SUB | SLJIT_SET_E, SLJIT_UNUSED, 0, TMP1, 0, SLJIT_IMM, oc);
   COND_VALUE(SLJIT_OR | SLJIT_SET_E, TMP2, 0, SLJIT_C_EQUAL);
   add_jump(compiler, backtracks, JUMP(SLJIT_C_ZERO));
   return cc + length;


Modified: code/trunk/pcre_jit_test.c
===================================================================
--- code/trunk/pcre_jit_test.c    2012-07-10 14:29:26 UTC (rev 994)
+++ code/trunk/pcre_jit_test.c    2012-07-11 11:05:30 UTC (rev 995)
@@ -583,6 +583,7 @@
     { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "[abc]", "\na" },
     { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^a", "\na" },
     { MUA | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^(?<=\n)", "\na" },
+    { MUA | PCRE_FIRSTLINE, 0, "\xf0\x90\x90\x80", "\xf0\x90\x90\x80" },
     { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\xc2\x85#" },
     { PCRE_MULTILINE | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "#", "\x85#" },
     { PCRE_MULTILINE | PCRE_UTF8 | PCRE_NEWLINE_ANY | PCRE_FIRSTLINE, 0 | F_NOMATCH, "^#", "\xe2\x80\xa8#" },


Modified: code/trunk/sljit/sljitConfigInternal.h
===================================================================
--- code/trunk/sljit/sljitConfigInternal.h    2012-07-10 14:29:26 UTC (rev 994)
+++ code/trunk/sljit/sljitConfigInternal.h    2012-07-11 11:05:30 UTC (rev 995)
@@ -95,7 +95,7 @@
 #endif
 #elif defined(__ppc64__) || defined(__powerpc64__) || defined(_ARCH_PPC64)
 #define SLJIT_CONFIG_PPC_64 1
-#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC)
+#elif defined(__ppc__) || defined(__powerpc__) || defined(_ARCH_PPC) || defined(_POWER)
 #define SLJIT_CONFIG_PPC_32 1
 #elif defined(__mips__)
 #define SLJIT_CONFIG_MIPS_32 1
@@ -335,9 +335,9 @@
 #error "Exactly one endianness must be selected"
 #endif


-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-/* It seems ppc64 compilers use an indirect addressing for functions.
- It makes things really complicated. */
+#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64) || (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32 && defined _AIX)
+/* It seems certain ppc compilers use an indirect addressing for functions
+ which makes things complicated. */
#define SLJIT_INDIRECT_CALL 1
#endif


Modified: code/trunk/sljit/sljitLir.c
===================================================================
--- code/trunk/sljit/sljitLir.c    2012-07-10 14:29:26 UTC (rev 994)
+++ code/trunk/sljit/sljitLir.c    2012-07-11 11:05:30 UTC (rev 995)
@@ -186,12 +186,16 @@


#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
+#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
+#else
#define FIXED_LOCALS_OFFSET (2 * sizeof(sljit_w))
#endif
+#endif

#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
#define SLJIT_HAS_FIXED_LOCALS_OFFSET 1
-#define FIXED_LOCALS_OFFSET ((7 + 8) * sizeof(sljit_w))
+#define FIXED_LOCALS_OFFSET ((6 + 8) * sizeof(sljit_w))
#endif

 #if (defined SLJIT_HAS_VARIABLE_LOCALS_OFFSET && SLJIT_HAS_VARIABLE_LOCALS_OFFSET)
@@ -336,7 +340,7 @@
     /* Remove thumb mode flag. */
     SLJIT_FREE_EXEC((void*)((sljit_uw)code & ~0x1));
 }
-#elif (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
+#elif (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
 SLJIT_API_FUNC_ATTRIBUTE void sljit_free_code(void* code)
 {
     /* Resolve indirection. */


Modified: code/trunk/sljit/sljitNativePPC_64.c
===================================================================
--- code/trunk/sljit/sljitNativePPC_64.c    2012-07-10 14:29:26 UTC (rev 994)
+++ code/trunk/sljit/sljitNativePPC_64.c    2012-07-11 11:05:30 UTC (rev 995)
@@ -417,14 +417,3 @@
     inst[4] = (inst[4] & 0xffff0000) | (new_constant & 0xffff);
     SLJIT_CACHE_FLUSH(inst, inst + 5);
 }
-
-SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func)
-{
-    sljit_w* ptrs;
-    if (func_ptr)
-        *func_ptr = (void*)context;
-    ptrs = (sljit_w*)func;
-    context->addr = addr ? addr : ptrs[0];
-    context->r2 = ptrs[1];
-    context->r11 = ptrs[2];
-}


Modified: code/trunk/sljit/sljitNativePPC_common.c
===================================================================
--- code/trunk/sljit/sljitNativePPC_common.c    2012-07-10 14:29:26 UTC (rev 994)
+++ code/trunk/sljit/sljitNativePPC_common.c    2012-07-11 11:05:30 UTC (rev 995)
@@ -37,7 +37,11 @@
 {
     while (from < to) {
 #if defined(__GNUC__) || (defined(__IBM_GCC_ASM) && __IBM_GCC_ASM)
+#ifdef _POWER
+        __asm__ volatile ( "clf 0, %0" : : "r"(from) );
+#else
         __asm__ volatile ( "icbi 0, %0" : : "r"(from) );
+#endif
 #ifdef __xlc__
 #warning "This file may fail to compile if -qfuncsect is used"
 #endif
@@ -176,6 +180,19 @@
   0, 3, 4, 5, 6, 7, 30, 29, 28, 27, 26, 1, 8, 9, 10, 31
 };


+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
+SLJIT_API_FUNC_ATTRIBUTE void sljit_set_function_context(void** func_ptr, struct sljit_function_context* context, sljit_w addr, void* func)
+{
+    sljit_w* ptrs;
+    if (func_ptr)
+        *func_ptr = (void*)context;
+    ptrs = (sljit_w*)func;
+    context->addr = addr ? addr : ptrs[0];
+    context->r2 = ptrs[1];
+    context->r11 = ptrs[2];
+}
+#endif
+
 static int push_inst(struct sljit_compiler *compiler, sljit_ins ins)
 {
     sljit_ins *ptr = (sljit_ins*)ensure_buf(compiler, sizeof(sljit_ins));
@@ -242,9 +259,13 @@
     check_sljit_generate_code(compiler);
     reverse_buf(compiler);


+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
     compiler->size += (compiler->size & 0x1) + (sizeof(struct sljit_function_context) / sizeof(sljit_ins));
+#else
+    compiler->size += (sizeof(struct sljit_function_context) / sizeof(sljit_ins));
 #endif
+#endif
     code = (sljit_ins*)SLJIT_MALLOC_EXEC(compiler->size * sizeof(sljit_ins));
     PTR_FAIL_WITH_EXEC_IF(code);
     buf = compiler->buf;
@@ -307,8 +328,8 @@
     SLJIT_ASSERT(!label);
     SLJIT_ASSERT(!jump);
     SLJIT_ASSERT(!const_);
-#if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
-    SLJIT_ASSERT(code_ptr - code <= (int)compiler->size - ((compiler->size & 0x1) ? 3 : 2));
+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
+    SLJIT_ASSERT(code_ptr - code <= (int)compiler->size - (sizeof(struct sljit_function_context) / sizeof(sljit_ins)));
 #else
     SLJIT_ASSERT(code_ptr - code <= (int)compiler->size);
 #endif
@@ -363,12 +384,17 @@
     compiler->error = SLJIT_ERR_COMPILED;
     compiler->executable_size = compiler->size * sizeof(sljit_ins);


+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
 #if (defined SLJIT_CONFIG_PPC_64 && SLJIT_CONFIG_PPC_64)
     if (((sljit_w)code_ptr) & 0x4)
         code_ptr++;
     sljit_set_function_context(NULL, (struct sljit_function_context*)code_ptr, (sljit_w)code, (void*)sljit_generate_code);
     return code_ptr;
 #else
+    sljit_set_function_context(NULL, (struct sljit_function_context*)code_ptr, (sljit_w)code, (void*)sljit_generate_code);
+    return code_ptr;
+#endif
+#else
     return code;
 #endif
 }
@@ -468,10 +494,10 @@
     if (args >= 3)
         FAIL_IF(push_inst(compiler, OR | S(SLJIT_TEMPORARY_REG3) | A(SLJIT_SAVED_REG3) | B(SLJIT_TEMPORARY_REG3)));


-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
+    compiler->local_size = (1 + saveds + 6 + 8) * sizeof(sljit_w) + local_size;
+#else
     compiler->local_size = (1 + saveds + 2) * sizeof(sljit_w) + local_size;
-#else
-    compiler->local_size = (1 + saveds + 7 + 8) * sizeof(sljit_w) + local_size;
 #endif
     compiler->local_size = (compiler->local_size + 15) & ~0xf;


@@ -505,10 +531,10 @@
     compiler->logical_local_size = local_size;
 #endif


-#if (defined SLJIT_CONFIG_PPC_32 && SLJIT_CONFIG_PPC_32)
+#if (defined SLJIT_INDIRECT_CALL && SLJIT_INDIRECT_CALL)
+    compiler->local_size = (1 + saveds + 6 + 8) * sizeof(sljit_w) + local_size;
+#else
     compiler->local_size = (1 + saveds + 2) * sizeof(sljit_w) + local_size;
-#else
-    compiler->local_size = (1 + saveds + 7 + 8) * sizeof(sljit_w) + local_size;
 #endif
     compiler->local_size = (compiler->local_size + 15) & ~0xf;
 }