guile-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Guile-commits] 148/437: Add better ppc support code, but still not func


From: Andy Wingo
Subject: [Guile-commits] 148/437: Add better ppc support code, but still not functional.
Date: Mon, 2 Jul 2018 05:14:06 -0400 (EDT)

wingo pushed a commit to branch lightning
in repository guile.

commit 7e3d863767300bc65ad8742eb9494e700dcebf19
Author: pcpa <address@hidden>
Date:   Tue Dec 11 02:16:51 2012 -0200

    Add better ppc support code, but still not functional.
    
        * configure.ac: Only default to using the builtin disassembler
        if on GNU/Linux. This should be temporary, due to requiring
        /proc/self/exe.
          Correctly check $target_cpu for powerpc.
    
        * include/lightning/jit_ppc.h: Correctly implement jit_v_num.
    
        * include/lightning/jit_private.h: Declare proper prototype
        for jit_init_debug and jit_finish_debug.
    
        * lib/jit_ppc-cpu.c: Remove code to save/restore callee save
        float registers, as it is not required since those float
        registers are not usable currently.
          Change prolog and epilog generation to, at least comparing
        code, match what gcc generates in "gcc -O0", but it is still
        failing in Darwin PPC, apparently due to the __clear_cache
        call not being enough, as frequently it will also fail to
        execute, and the code buffer is all zeroes.
    
        * lib/lightning.c: Do not fail in jit_regset_scan1 calls due
        to passing 64 as argument on computers with 64 registers.
---
 ChangeLog                       | 24 +++++++++++++++++++++++
 configure.ac                    |  7 +++++--
 include/lightning/jit_ppc.h     |  2 +-
 include/lightning/jit_private.h |  4 ++--
 lib/jit_ppc-cpu.c               | 42 +++++++++++++++--------------------------
 lib/lightning.c                 | 12 ++++++++----
 6 files changed, 55 insertions(+), 36 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index cbfbafd..0a4b573 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2012-12-11 Paulo Andrade <address@hidden>
+
+       * configure.ac: Only default to using the builtin disassembler
+       if on GNU/Linux. This should be temporary, due to requiring
+       /proc/self/exe.
+         Correctly check $target_cpu for powerpc.
+
+       * include/lightning/jit_ppc.h: Correctly implement jit_v_num.
+
+       * include/lightning/jit_private.h: Declare proper prototype
+       for jit_init_debug and jit_finish_debug.
+
+       * lib/jit_ppc-cpu.c: Remove code to save/restore callee save
+       float registers, as it is not required since those float
+       registers are not usable currently.
+         Change prolog and epilog generation to, at least comparing
+       code, match what gcc generates in "gcc -O0", but it is still
+       failing in Darwin PPC, apparently due to the __clear_cache
+       call not being enough, as frequently it will also fail to
+       execute, and the code buffer is all zeroes.
+
+       * lib/lightning.c: Do not fail in jit_regset_scan1 calls due
+       to passing 64 as argument on computers with 64 registers.
+
 2012-12-10 Paulo Andrade <address@hidden>
 
        * lib/jit_mips-cpu.c: Correct all current test cases.
diff --git a/configure.ac b/configure.ac
index e7051c7..920feed 100644
--- a/configure.ac
+++ b/configure.ac
@@ -53,7 +53,10 @@ if test "x$DISASSEMBLER" != "xno"; then
 fi
 AM_CONDITIONAL(with_disassembler, [test "x$DISASSEMBLER" != "xno"])
 if test "x$DISASSEMBLER" != "xno"; then
-    LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"
+    case "$target_os" in
+       *linux*) LIGHTNING_CFLAGS="$LIGHTNING_CFLAGS -DDISASSEMBLER=1"  ;;
+       *)                                                              ;;
+    esac
 fi
 
 cpu=
@@ -61,7 +64,7 @@ case "$target_cpu" in
     i?86|x86_64)       cpu=x86         ;;
     *arm*)             cpu=arm         ;;
     *mips*)            cpu=mips        ;;
-    *ppc*)             cpu=ppc         ;;
+    *powerpc*)         cpu=ppc         ;;
     *)                                 ;;
 esac
 if test x$cpu = x; then
diff --git a/include/lightning/jit_ppc.h b/include/lightning/jit_ppc.h
index 52111c8..d42b8cc 100644
--- a/include/lightning/jit_ppc.h
+++ b/include/lightning/jit_ppc.h
@@ -29,7 +29,7 @@ typedef enum {
 #define jit_r(i)               (_R11 + (i))
 #define jit_r_num()            3
 #define jit_v(i)               (_R30 - (i))
-#define jit_r_num()            17
+#define jit_v_num()            17
 #define jit_arg_f_reg_p(i)     ((i) >= 0 && (i) < 8)
 #define jit_f(i)               (_F0 + (i))
 #define jit_f_num()            6
diff --git a/include/lightning/jit_private.h b/include/lightning/jit_private.h
index d2db6c2..6107ffa 100644
--- a/include/lightning/jit_private.h
+++ b/include/lightning/jit_private.h
@@ -369,8 +369,8 @@ _emit_ldxi_d(jit_state_t*, jit_int32_t, jit_int32_t, 
jit_word_t);
 extern void
 _emit_stxi_d(jit_state_t*, jit_word_t, jit_int32_t, jit_int32_t);
 
-extern void jit_init_debug();
-extern void jit_finish_debug();
+extern void jit_init_debug(void);
+extern void jit_finish_debug(void);
 
 /*
  * Externs
diff --git a/lib/jit_ppc-cpu.c b/lib/jit_ppc-cpu.c
index 4cfa561..729d275 100644
--- a/lib/jit_ppc-cpu.c
+++ b/lib/jit_ppc-cpu.c
@@ -16,10 +16,7 @@
  */
 
 #if PROTO
-/* quite a lot of space for fixed computation of possible stack arguments
- * this currently is done mostly to keep it simple, as the vm has only
- * one function */
-#  define stack_framesize              224
+#  define stack_framesize              80
 #  define ii(i)                                *_jit->pc.ui++ = i
 #  define can_sign_extend_short_p(im)  ((im) >= -32768 && (im) <= 32767)
 #  define can_zero_extend_short_p(im)  ((im) >= 0 && (im) <= 65535)
@@ -2209,46 +2206,37 @@ _calli_p(jit_state_t *_jit, jit_word_t i0)
 static void
 _prolog(jit_state_t *_jit, jit_node_t *node)
 {
-    unsigned long       regno;
+    unsigned long      regno;
 
-    subi(_SP_REGNO, _SP_REGNO, stack_framesize);
     /* return address */
     MFLR(_R0_REGNO);
-    stxi(0, _SP_REGNO, _R0_REGNO);
 
-    /* save any clobbered  callee save fpr register */
-    /* FIXME actually, no "clean" interface to use these registers */
-    for (regno = _F31; regno >= _F14; regno--) {
-       if (jit_regset_tstbit(_jit->function->regset, regno))
-           stxi_d(stack_framesize - rn(regno) * 8, _SP_REGNO, regno);
-    }
     /* save any clobbered callee save gpr register */
     regno = jit_regset_scan1(_jit->function->regset, _R14);
     if (regno == ULONG_MAX || regno > _R31)
        regno = _R31;   /* aka _FP_REGNO */
-    STMW(regno, _SP_REGNO, rn(regno) * 4 + 8);
-    movr(_FP_REGNO, _SP_REGNO);
-    /* alloca and/or space for excess parameters */
-    subi(_SP_REGNO, _SP_REGNO, _jit->function->stack);
+    STMW(rn(regno), _SP_REGNO, -(32 * 4) + rn(regno) * 4);
+
+    stxi(8, _SP_REGNO, _R0_REGNO);
+    STWU(_SP_REGNO, _SP_REGNO, -(stack_framesize + _jit->function->stack + 
16));
+    addi(_FP_REGNO, _SP_REGNO, _jit->function->stack + 16);
 }
 
 static void
 _epilog(jit_state_t *_jit, jit_node_t *node)
 {
-    unsigned long       regno;
+    unsigned long      regno;
+
+    //ldxi(_SP_REGNO, _SP_REGNO, 0);
+    LWZ(_SP_REGNO, _SP_REGNO, 0);
+    ldxi(_R0_REGNO, _SP_REGNO, 8);
+
+    MTLR(_R0_REGNO);
 
-    movr(_SP_REGNO, _FP_REGNO);
-    for (regno = _F31; regno >= _F14; regno--) {
-       if (jit_regset_tstbit(_jit->function->regset, regno))
-           ldxi_d(regno, _SP_REGNO, stack_framesize - rn(regno) * 8);
-    }
     regno = jit_regset_scan1(_jit->function->regset, _R14);
     if (regno == ULONG_MAX || regno > _R31)
        regno = _R31;   /* aka _FP_REGNO */
-    LMW(rn(regno), _SP_REGNO, regno * 4 + 8);
-    ldxi(_R0_REGNO, _SP_REGNO, 0);
-    addi(_SP_REGNO, _SP_REGNO, stack_framesize);
-    MTLR(_R0_REGNO);
+    LMW(rn(regno), _SP_REGNO, -(32 * 4) + rn(regno) * 4);
     BLR();
 }
 
diff --git a/lib/lightning.c b/lib/lightning.c
index 69abeeb..7bef394 100644
--- a/lib/lightning.c
+++ b/lib/lightning.c
@@ -1221,8 +1221,10 @@ _jit_setup(jit_state_t *_jit, jit_block_t *block)
                    jit_regset_setbit(reglive, node->u.w);
                }
            case jit_code_calli:
-               for (value = jit_regset_scan1(regmask, 0); value != ULONG_MAX;
-                    value = jit_regset_scan1(regmask, value + 1)) {
+               for (value = 0; value < _jit->reglen; ++value) {
+                   value = jit_regset_scan1(regmask, value);
+                   if (value >= _jit->reglen)
+                       break;
                    spec = jit_class(_rvs[value].spec);
                    if (!(spec & jit_class_sav))
                        jit_regset_clrbit(regmask, value);
@@ -1349,8 +1351,10 @@ _jit_update(jit_state_t *_jit, jit_bool_t setup, 
jit_node_t *node,
                    jit_regset_clrbit(*mask, JIT_FRET);
                }
 #endif
-               for (value = jit_regset_scan1(*mask, 0); value != ULONG_MAX;
-                    value = jit_regset_scan1(*mask, value + 1)) {
+               for (value = 0; value < _jit->reglen; ++value) {
+                   value = jit_regset_scan1(*mask, value);
+                   if (value >= _jit->reglen)
+                       break;
                    spec = jit_class(_rvs[value].spec);
                    if (!(spec & jit_class_sav))
                        jit_regset_clrbit(*mask, value);



reply via email to

[Prev in Thread] Current Thread [Next in Thread]