[kaffe] CVS kaffe (dalibor): Merged in ppc-jit from JanosVM

Kaffe CVS cvs-commits at kaffe.org
Fri Sep 17 11:52:56 PDT 2004


PatchSet 5178 
Date: 2004/09/17 18:48:38
Author: dalibor
Branch: HEAD
Tag: (none) 
Log:
Merged in ppc-jit from JanosVM

2004-09-17  Michael Franz <mvfranz at gmail.com>,
            Timothy S. Stack <stack at cs.utah.edu>

        * config/powerpc/jit.h:
        merged in from JanOSVM with CIF optimizations removed

        * config/powerpc/jit3-icode.h:
        copy from JanOSVM with HAVE_move_int_const
        & HAVE_move_ref_const removed

        * config/powerpc/jit3-powerpc.def:
        copy from JanOSVM with janosvm/nameSpace.h include removed
        and update LOUT macro usage to conform with current Kaffe
        implementation and removed CIF optimizations.

        * config/powerpc/callmethod_ppc.h,
        config/powerpc/ppc_isa.defs,
        config/powerpc/ppc_isa.h,
        config/powerpc/ppc_macros.h,
        config/powerpc/ppc_stack_frame.h,
        config/powerpc/trampolines.c,
        config/powerpc/darwin/jit3-md.h:
        Merged in from JanosVM.

        2002-07-31 Wednesday 09:08  stack

        * config/powerpc/: jit.h, jit3-icode.h, jit3-powerpc.def,
        ppc_isa.defs: tweaks

        2002-07-31 Wednesday 08:30  stack

        * config/powerpc/ppc_stack_frame.h: add floating point argument
        register count

        2002-07-31 Wednesday 08:29  stack

        * config/powerpc/: ppc_isa.defs, ppc_isa.h: add frsp opcode

        2002-07-31 Wednesday 08:28  stack

        * config/powerpc/jit3-powerpc.def: fixes for floats/doubles and
        argument pushing

        2002-07-31 Wednesday 08:28  stack

        * config/powerpc/jit3-icode.h: define HAVE_div_int

        2002-07-31 Wednesday 08:28  stack

        * config/powerpc/jit.h: define PUSHARG_FORWARDS

        2002-07-27 Saturday 16:17  stack
        * config/powerpc/darwin/: jit3-md.h, md.h: first checkin of ppc
        jitter stuff

        2002-07-27 Saturday 15:51  stack

        * config/powerpc/: jit.h, jit3-icode.h, jit3-powerpc.def,
        ppc_isa.defs, ppc_isa.h, ppc_macros.h, ppc_stack_frame.h,
        trampolines.c: initial checkin of powerpc jitter back end, works a
        bit, but still fails quite a few tests

Members: 
	ChangeLog:1.2733->1.2734 
	config/Makefile.am:1.50->1.51 
	config/Makefile.in:1.158->1.159 
	config/powerpc/callmethod_ppc.h:1.3->1.4 
	config/powerpc/jit.h:INITIAL->1.1 
	config/powerpc/jit3-icode.h:INITIAL->1.1 
	config/powerpc/jit3-powerpc.def:INITIAL->1.1 
	config/powerpc/ppc_isa.defs:INITIAL->1.1 
	config/powerpc/ppc_isa.h:INITIAL->1.1 
	config/powerpc/ppc_macros.h:INITIAL->1.1 
	config/powerpc/ppc_stack_frame.h:INITIAL->1.1 
	config/powerpc/trampolines.c:INITIAL->1.1 
	config/powerpc/darwin/jit3-md.h:INITIAL->1.1 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.2733 kaffe/ChangeLog:1.2734
--- kaffe/ChangeLog:1.2733	Fri Sep 17 08:31:56 2004
+++ kaffe/ChangeLog	Fri Sep 17 18:48:38 2004
@@ -1,3 +1,74 @@
+2004-09-17  Michael Franz <mvfranz at gmail.com>,
+	    Timothy S. Stack <stack at cs.utah.edu>
+
+	* config/powerpc/jit.h:
+	merged in from JanOSVM with CIF optimizations removed
+
+	* config/powerpc/jit3-icode.h:
+	copy from JanOSVM with HAVE_move_int_const 
+	& HAVE_move_ref_const removed 
+
+	* config/powerpc/jit3-powerpc.def:
+	copy from JanOSVM with janosvm/nameSpace.h include removed 
+	and update LOUT macro usage to conform with current Kaffe 
+	implementation and removed CIF optimizations.
+
+	* config/powerpc/callmethod_ppc.h,
+	config/powerpc/ppc_isa.defs,
+	config/powerpc/ppc_isa.h,
+	config/powerpc/ppc_macros.h,
+	config/powerpc/ppc_stack_frame.h,
+	config/powerpc/trampolines.c,
+	config/powerpc/darwin/jit3-md.h:
+	Merged in from JanosVM.
+
+	2002-07-31 Wednesday 09:08  stack
+
+        * config/powerpc/: jit.h, jit3-icode.h, jit3-powerpc.def,
+        ppc_isa.defs: tweaks
+
+	2002-07-31 Wednesday 08:30  stack
+
+        * config/powerpc/ppc_stack_frame.h: add floating point argument
+        register count
+
+	2002-07-31 Wednesday 08:29  stack
+
+        * config/powerpc/: ppc_isa.defs, ppc_isa.h: add frsp opcode
+
+	2002-07-31 Wednesday 08:28  stack
+
+        * config/powerpc/jit3-powerpc.def: fixes for floats/doubles and
+        argument pushing
+
+	2002-07-31 Wednesday 08:28  stack
+
+        * config/powerpc/jit3-icode.h: define HAVE_div_int
+
+	2002-07-31 Wednesday 08:28  stack
+
+        * config/powerpc/jit.h: define PUSHARG_FORWARDS
+
+	2002-07-27 Saturday 16:17  stack
+
+        * config/powerpc/darwin/: jit3-md.h, md.h: first checkin of ppc
+        jitter stuff
+
+	2002-07-27 Saturday 15:51  stack
+
+        * config/powerpc/: jit.h, jit3-icode.h, jit3-powerpc.def,
+        ppc_isa.defs, ppc_isa.h, ppc_macros.h, ppc_stack_frame.h,
+        trampolines.c: initial checkin of powerpc jitter back end, works a
+        bit, but still fails quite a few tests
+
+2004-09-17  Dalibor Topic  <robilad at kaffe.org>
+
+	* config/Makefile.am:
+	(EXTRA_DIST) Added new files.
+
+	* config/Makefile.in:
+	Regenerated.
+
 2004-09-17  Noa Resare  <noa at resare.com>
 	Guilhem Lavaux  <guilhem at kaffe.org>
 
Index: kaffe/config/Makefile.am
diff -u kaffe/config/Makefile.am:1.50 kaffe/config/Makefile.am:1.51
--- kaffe/config/Makefile.am:1.50	Fri Aug 27 12:22:03 2004
+++ kaffe/config/Makefile.am	Fri Sep 17 18:48:40 2004
@@ -294,6 +294,7 @@
 	powerpc/darwin/config.frag \
 	powerpc/darwin/md.c \
 	powerpc/darwin/md.h \
+	powerpc/darwin/jit3-md.h \
 	powerpc/linux/config.frag \
 	powerpc/linux/md.c \
 	powerpc/linux/md.h \
@@ -303,8 +304,17 @@
 	powerpc/netbsd1/config.frag \
 	powerpc/netbsd1/md.c \
 	powerpc/netbsd1/md.h \
+	powerpc/callmethod_ppc.h \
+	powerpc/jit.h \
+	powerpc/jit3-icode.h \
+	powerpc/jit3-powerpc.def \
+	powerpc/ppc_isa.defs \
+	powerpc/ppc_isa.h \
+	powerpc/ppc_macros.h \
+	powerpc/ppc_stack_frame.h \
 	powerpc/sysdepCallMethod.h \
 	powerpc/threads.h \
+	powerpc/trampolines.c \
 	s390/atomicity32.h \
 	s390/atomicity64.h \
 	s390/common.h \
Index: kaffe/config/Makefile.in
diff -u kaffe/config/Makefile.in:1.158 kaffe/config/Makefile.in:1.159
--- kaffe/config/Makefile.in:1.158	Thu Sep 16 21:01:58 2004
+++ kaffe/config/Makefile.in	Fri Sep 17 18:48:40 2004
@@ -622,6 +622,7 @@
 	powerpc/darwin/config.frag \
 	powerpc/darwin/md.c \
 	powerpc/darwin/md.h \
+	powerpc/darwin/jit3-md.h \
 	powerpc/linux/config.frag \
 	powerpc/linux/md.c \
 	powerpc/linux/md.h \
@@ -631,8 +632,17 @@
 	powerpc/netbsd1/config.frag \
 	powerpc/netbsd1/md.c \
 	powerpc/netbsd1/md.h \
+	powerpc/callmethod_ppc.h \
+	powerpc/jit.h \
+	powerpc/jit3-icode.h \
+	powerpc/jit3-powerpc.def \
+	powerpc/ppc_isa.defs \
+	powerpc/ppc_isa.h \
+	powerpc/ppc_macros.h \
+	powerpc/ppc_stack_frame.h \
 	powerpc/sysdepCallMethod.h \
 	powerpc/threads.h \
+	powerpc/trampolines.c \
 	s390/atomicity32.h \
 	s390/atomicity64.h \
 	s390/common.h \
===================================================================
Checking out kaffe/config/powerpc/callmethod_ppc.h
RCS:  /home/cvs/kaffe/kaffe/config/powerpc/callmethod_ppc.h,v
VERS: 1.4
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/powerpc/callmethod_ppc.h	Fri Sep 17 18:52:56 2004
@@ -0,0 +1,224 @@
+/*
+ * sysdepCallMethod_ppc(CALL) implementation for linuxppc
+ *
+ * Copyright (c) 1998
+ *	Kevin B. Hendricks  All rights reserved.
+ * Copyright (c) 2001
+ *	Edouard G. Parmelan.  All rights reserved.
+ *
+ * distributed under the GPL license
+ */
+
+/*
+   This function translates the "Kaffe" calling convention into the "C"
+   calling convention used in native methods. See the files
+   common.h, and support.h for information as to the input parameters
+*/
+
+ 
+
+// #define dbg_mode 1
+
+#if 0
+#include "config.h"
+#include "config-std.h"
+#include "config-mem.h"
+#include "jni.h"
+#include <stdarg.h>
+#include "classMethod.h"
+#include "jtypes.h"
+#include "access.h"
+#include "object.h"
+#include "constants.h"
+#include "baseClasses.h"
+#include "lookup.h"
+#include "errors.h"
+#include "exception.h"
+#include "slots.h"
+#include "machine.h"
+#include "support.h"
+#include "md.h"
+#include "itypes.h"
+#include "external.h"
+#include "thread.h"
+#include "locks.h"
+#endif
+
+void sysdepCallMethod_ppc(
+     callMethodInfo* CALL)  /* pointer to Kaffe callMethodInfo */
+{
+
+  /* Because of the Power PC calling conventions we could be passing
+     parameters in both register types and on the stack. To create the
+     stack parameter area we need we now simply allocate local
+     variable storage param[ssiz] that is the size of the java stack 
+     (more than enough space) which we can overwrite the parameters into.
+
+     Note: This keeps us from having problems with later local variables.
+
+     Note: could require up to  2*argsize words of parameter stack area 
+     if the call has many float parameters (i.e. floats take up only 1 
+     word on the kaffe args but take 2 words in parameter area in the 
+     stack frame .
+
+     The basic idea here is to use gpr[8] as a storage area for
+     the future values of registers r3 to r10 needed for the call, 
+     and similarly fpr[8] as a storage area for the future values
+     of floating point registers f1 to f8, and param to set aside
+     possible stack area needed by the call
+  */
+
+     unsigned long gpr[8];    /* storage for gpregisters, map to r3-r10 */
+     double fpr[8];           /* storage for fpregisters, map to f1-f8 */
+     int n;                   /* number of gprs mapped so far */
+     int f;                   /* number of fprs mapped so far */
+     long *p;                 /* pointer to parameter overflow area */
+     int c;                   /* calltype being processes */
+     int argidx;              /* pointer into kaffe args array */
+     double dret;             /* temporary function return values*/
+     long iret, iret2;
+     unsigned long param[(2*((CALL)->nrargs)+1)];
+
+     /* now begin to load the C function arguments into storage */
+     n = 0;
+     f = 0;
+     argidx = 0;
+
+     /* set up a pointer to the stack parameter area */
+     __asm__ __volatile__ ( "addi %0,1,8" : "=r" (p) : /* no inputs */ );
+
+     /* now loop through each argument and assign it properly to
+        either gpr, fpr, or the param area */
+
+#if defined(dbg_mode)
+     fprintf(stdout,"called with %d args\n",(CALL)->nrargs);
+     fprintf(stdout, "return type %c size %d\n",(CALL)->rettype,
+                 (CALL)->retsize);
+     while (argidx < (CALL)->nrargs) {
+         fprintf(stdout, "arg %d: value: %x size %d type %c\n",
+                argidx, (CALL)->args[argidx].l,(CALL)->callsize[argidx],
+                (CALL)->calltype[argidx]);
+         argidx++;
+     }
+     fflush(stdout);
+     argidx = 0;
+#endif
+
+      while (argidx < (CALL)->nrargs) {
+          c = (int)((CALL)->calltype[argidx]);
+
+       switch (c) {
+
+       case 'D':                   /* type is double */
+            if (f < 8) {
+               fpr[f++] = (CALL)->args[argidx].d;
+	    } else {
+	       if (((long) p) & 4)          
+	          p++;
+              /* into parameter stack */
+               *((double *)p) = (CALL)->args[argidx].d; 
+               p+=2;
+	    }
+            break;
+
+       case 'F':                   /* type is float */
+	   /* floats are store as 32 bit word on Kaffe and passed as
+	      float in parameter stack to C as native method have prototype.
+	      Without prototype, float will be cast to double but this is
+	      not the case here.  */
+	   if (f < 8) {
+	       fpr[f++] = (double) (CALL)->args[argidx].f;
+	   } else {
+	       /* into parameter stack */
+	       *((float *)p) = (CALL)->args[argidx].f;
+	       p++;
+	   }
+	   break;
+
+       case 'J':                /* type is long long */
+            if (n & 1) n++; 	/* note even elements gpr[] will map to odd registers*/
+            if (n <= 6) {
+               *((long long *) (&gpr[n])) = (CALL)->args[argidx].j;
+               n+=2;
+	    } else {
+	       if (((long) p) & 4)          
+	          p++;
+               *((long long *)p) = (CALL)->args[argidx].j; 
+               p+=2;
+	    }
+            break;
+
+       case 'L':		/* type is jref (void*)   */
+     	                /* fall through and handle in gpr*/
+       
+       default:
+            if (n < 8) {
+               gpr[n++] = (unsigned long) (CALL)->args[argidx].i;
+	    } else {
+	      /* place on the stack */
+               *((unsigned long *)p) = (CALL)->args[argidx].i; 
+               p++; 
+	    }
+            break;
+       }
+
+       if (((int)((CALL)->callsize[argidx])) == 2) argidx++;
+       argidx++;
+ }						
+
+
+/* Set up the machine registers and invoke the function */
+
+    __asm__ __volatile__ (
+	"
+		lwz	3,	0(%3)
+		lwz	4,	4(%3)
+		lwz	5,	8(%3)
+		lwz	6,	12(%3)
+		lwz	7,	16(%3)
+		lwz	8,	20(%3)
+		lwz	9,	24(%3)
+		lwz	10,	28(%3)
+		lfd	1,	0(%4)
+		lfd	2,	8(%4)
+		lfd	3,	16(%4)
+		lfd	4,	24(%4)
+		lfd	5,	32(%4)
+		lfd	6,	40(%4)
+		lfd	7,	48(%4)
+		lfd	8,	56(%4)
+		mtctr	%5
+		bctrl
+		mr	%1,	3
+		mr	%2,	4
+		fmr	%0,	1
+	" : "=f" (dret), "=r" (iret), "=r" (iret2)
+	  : "r" (gpr), "r" (fpr), "r" (CALL->function)
+	  : "0", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"
+    );
+
+
+    /* Put the return value in the right place. */
+    c = (int) (CALL)->rettype;
+
+    switch (c) {
+        case 0 :
+	  /* fall through */
+	case 'V':
+	    break;
+	case 'D':
+	    * (double *) (CALL)->ret = dret;
+	    break;
+	case 'F':
+	    * (float *) (CALL)->ret = (float) dret;
+	    break;
+	case 'J':
+	    * (unsigned long *) (CALL)->ret = iret;
+            * (((unsigned long *) (CALL)->ret) + 1) = iret2;
+	    break;
+	default:
+	    * (unsigned long *)(CALL)->ret = iret;
+	    break;
+    }
+}
+
===================================================================
Checking out kaffe/config/powerpc/jit.h
RCS:  /home/cvs/kaffe/kaffe/config/powerpc/jit.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/powerpc/jit.h	Fri Sep 17 18:52:56 2004
@@ -0,0 +1,268 @@
+/*
+ * powerpc/jit.h
+ * Contains the powerpc trampoline and dcache flush macros.
+ *
+ * Copyright (c) 2002 The University of Utah and the Flux Group.
+ * All rights reserved.
+ *
+ * @JANOSVM_KAFFE_JANOSVM_LICENSE@
+ */
+
+#ifndef __powerpc_jit_h
+#define __powerpc_jit_h
+
+#include "ppc_isa.h"
+#include "ppc_macros.h"
+#include "ppc_stack_frame.h"
+
+extern void powerpc_do_fixup_trampoline(void);
+
+/*
+ * The PowerPC trampoline structure.
+ *
+ * code - The trampoline code.
+ * meth - The method the trampoline interposes on.
+ * where - A pointer to the pointer that refers to this trampoline.
+ */
+typedef struct _methodTrampoline {
+	ppc_code_t code[6];
+	struct _methods *meth;
+	void **where;
+} methodTrampoline;
+
+/*
+ * The trampoline comprises six instructions. The first two of them load into
+ * r0 (the function prologue scratch register) the address of our fixup
+ * routine.  We do it in two steps: first we load the high nibble into r0 and
+ * then or in the lower nibble.
+ *
+ *	code[0]		lis   r0, hi(powerpc_do_fixup_trampoline)
+ *	code[1]		ori   r0, r0, lo(powerpc_do_fixup_trampoline)
+ *
+ * Afterwards we copy that address from r0 into ctr, so that later on
+ * we can jump to it:
+ *
+ *	code[2]		mtctr r0
+ *
+ * Next, we save the current lr value since we are going to use it to tell the
+ * powerpc_do_fixup_trampoline() function about this trampoline.
+ *
+ *	code[3]		mflr r0
+ *	code[4]		stw  r0, <lr offset in frame>(sp)
+ *
+ * And finally we update the link register and branch to the fixup function.
+ * The fixup function can then use the link register value to find the meth
+ * and where values in this trampoline.
+ *
+ *	code[5]		bctrl
+ *
+ * This is the simplest way of jumping to a generic 32-bit address
+ * that I can think of.  Simplifications are welcome :-)
+ *
+ *
+ * NOTES:
+ *
+ *   1. I think we need to avoid any registers except r0 since they might
+ *   contain arguments/saved state.
+ */
+#define FILL_IN_TRAMPOLINE(t, m, w) \
+do { \
+	(t)->code[0] = ppc_op_lis(PPC_R0, \
+				  ppc_hi16(powerpc_do_fixup_trampoline)); \
+	(t)->code[1] = ppc_op_ori(PPC_R0, \
+				  PPC_R0, \
+				  ppc_lo16(powerpc_do_fixup_trampoline)); \
+	(t)->code[2] = ppc_op_mtctr(PPC_R0); \
+	(t)->code[3] = ppc_op_mflr(PPC_R0); \
+	(t)->code[4] = ppc_op_stw(PPC_R0, \
+				  PPC_RSP, \
+				  PPC_FRAME_LR); \
+	(t)->code[5] = ppc_op_bctrl(); \
+	(t)->meth = (m); \
+	(t)->where = (w); \
+} while(0)
+
+/*
+ * PowerPC stores return address in register LR, not in the stack. Therefore,
+ * we use 'Method *_meth' and 'meth = _meth' instead of 'Method **_pmeth' and
+ * 'meth = *_pmeth'
+ */
+#define FIXUP_TRAMPOLINE_DECL Method *_meth, void *_where
+#define FIXUP_TRAMPOLINE_INIT meth = _meth; where = _where;
+
+/*
+ * Call a jitted java exception handler.
+ */
+#define CALL_KAFFE_EXCEPTION(frame, handler, object) \
+	asm volatile ("mr r1, %0\n" \
+		      "\tmr r3, %1\n" \
+		      "\tmtctr %2\n" \
+		      "\tbctr\n" \
+		      : : "r" (frame), "r" (object), "r" (handler) : "r3")
+
+/*
+ * Call a JanosVM catastrophe handler.
+ * XXX implement me.
+ */
+#define CALL_KAFFE_C_EXCEPTION(F, P, H, O)
+
+/* Extra label types. */
+
+/* 26 bit displacement */
+#define Llong26  (Larchdepend + 0)
+/* 16 bit displacement */
+#define Llong16  (Larchdepend + 1)
+/* 16 bit displacement, no alignment restrictions.  */
+#define Llong16noalign  (Larchdepend + 2)
+/* 32 bit displacement broken into two instructions. */
+#define Llong16x16 (Larchdepend + 3)
+/* XXX not very different from Lnegframe... */
+#define Lsavedregs (Larchdepend + 4)
+/* Update the source register in a stmw. */
+#define Lreg_s (Larchdepend + 5)
+
+#define FILL_LABEL_Llong16x16(P, V, L) \
+{ \
+	ppc_code_t *_code = (ppc_code_t *)(P); \
+	ppc_code_t _disp = (V); \
+\
+	_code[0] |= ppc_lo16(_disp); \
+	_code[1] |= ppc_ha16(_disp); \
+	/* \
+	 *                 ^^^^^^^^^^^^ Need to clear out the high order bits \
+	 * if the offset is negative. \
+	 */ \
+}
+
+#define FILL_LABEL_Llong26(P, V, L) \
+{ \
+	ppc_code_t *_code = (ppc_code_t *)(P); \
+	ppc_code_t _disp = (V); \
+\
+	assert(((_disp & ~PPC_LI_MASK) == 0x00000000) || \
+	       ((_disp & ~PPC_LI_MASK) == 0xFC000000)); \
+\
+	_code[0] |= (_disp & PPC_LI_MASK); \
+	/* \
+	 *                 ^^^^^^^^^^^^ Need to clear out the high order bits \
+	 * if the offset is negative. \
+	 */ \
+}
+
+#define FILL_LABEL_Llong16(P, V, L) \
+{ \
+	ppc_code_t *_code = (ppc_code_t *)(P); \
+	ppc_code_t _disp = (V); \
+\
+	assert(((_disp & ~PPC_BD_MASK) == 0x00000000) || \
+	       ((_disp & ~PPC_BD_MASK) == 0xFFFF0000)); \
+\
+	_code[0] |= (_disp & PPC_BD_MASK); \
+}
+
+#define FILL_LABEL_Llong16noalign(P, V, L) \
+{ \
+	ppc_code_t *_code = (ppc_code_t *)(P); \
+	int _disp = (V); \
+\
+	assert(((_disp & ~PPC_D_MASK) == 0x00000000) || \
+	       ((_disp & ~PPC_D_MASK) == ~PPC_D_MASK)); \
+\
+	_code[0] |= (_disp & PPC_D_MASK); \
+}
+
+#define FILL_LABEL_Lsavedregs(P, V, L) \
+{ \
+	int frame_size, saved_registers; \
+\
+	saved_registers = (maxLocal + maxStack + maxTemp) - \
+		PPC_ARG_REGISTER_COUNT; \
+	if( saved_registers < 0 ) \
+		saved_registers = 0; \
+	if( (firstConst != currConst) || maxLocal || maxTemp ) \
+	{ \
+		saved_registers += 1; /* r31 */ \
+	} \
+	frame_size = -SLOTSIZE * saved_registers; \
+	if( ((L)->type & Lfrommask) == Lrelative ) \
+	{ \
+		frame_size += (L)->from; \
+	} \
+	FILL_LABEL_Llong16noalign(P, frame_size, L); \
+}
+
+#define FILL_LABEL_Lframe(P, V, L, neg) \
+{ \
+	int frame_size = 0; \
+\
+	if( (firstConst != currConst) || maxLocal || maxTemp ) \
+	{ \
+		frame_size += SLOTSIZE; /* r31 */ \
+	} \
+	if( ((L)->type & Lfrommask) == Lrelative ) \
+		frame_size += (L)->from; \
+	if( neg ) \
+		frame_size = -frame_size; \
+	FILL_LABEL_Llong16noalign(P, frame_size, L); \
+}
+
+#define FILL_LABEL_Lreg_s(P, V, L) \
+{ \
+	ppc_code_t *_code = (ppc_code_t *)(P); \
+	int saved_registers; \
+\
+	saved_registers = (maxLocal + maxStack + maxTemp) - \
+		PPC_ARG_REGISTER_COUNT; \
+	if( saved_registers < 0 ) \
+		saved_registers = 0; \
+	if( (firstConst != currConst) || maxLocal || maxTemp ) \
+	{ \
+		saved_registers += 1; /* r31 */ \
+	} \
+	_code[0] |= PPC_SET_RS((32 - saved_registers)); \
+}
+
+#define EXTRA_LABELS(P, V, L) \
+	case Lframe: \
+		FILL_LABEL_Lframe(P, V, L, 0); \
+		break; \
+	case Lnegframe: \
+		FILL_LABEL_Lframe(P, V, L, 1); \
+		break; \
+	case Llong26: \
+		FILL_LABEL_Llong26(P, V, L); \
+		break; \
+	case Llong16: \
+		FILL_LABEL_Llong16(P, V, L); \
+		break; \
+	case Llong16noalign: \
+		FILL_LABEL_Llong16noalign(P, V, L); \
+		break; \
+	case Llong16x16: \
+		FILL_LABEL_Llong16x16(P, V, L); \
+		break; \
+	case Lsavedregs: \
+		FILL_LABEL_Lsavedregs(P, V, L); \
+		break; \
+	case Lreg_s: \
+		FILL_LABEL_Lreg_s(P, V, L); \
+		break;
+
+#define SLOTSIZE 4
+
+/* XXX */
+#define NR_ARGUMENTS 8
+
+#define REGISTERS_SAVED 21
+
+#define SLOT2LOCALOFFSET(N) \
+	(-(SLOTSIZE * ((N) + 2)))
+
+#define SLOT2ARGOFFSET(N) \
+	(unsigned long)(&((ppc_stack_frame_t *)0)->args[(N)])
+
+#define KAFFEJIT_TO_NATIVE(M)
+
+#define PUSHARG_FORWARDS
+
+#endif
===================================================================
Checking out kaffe/config/powerpc/jit3-icode.h
RCS:  /home/cvs/kaffe/kaffe/config/powerpc/jit3-icode.h,v
VERS: 1.1
***************
--- /dev/null	Sun Aug  4 19:57:58 2002
+++ kaffe/config/powerpc/jit3-icode.h	Fri Sep 17 18:52:56 2004
@@ -0,0 +1,334 @@
+/* ppc/jit-icode.h
+ * Define the instructions which are present on the PPC.
+ *
+ * Copyright (c) 2002 The University of Utah and the Flux Group.
+ * All rights reserved.
+ *
+ * @JANOSVM_KAFFE_JANOSVM_LICENSE@
+ */
+
+#ifndef __icode_h
+#define __icode_h
+
+/*
+ * Size of long's compared to references.
+ */
+#define pusharg_long_idx_inc            2
+
+/*
+ * Define the range checking macros.
+ */
+#define	__anyvalue_rangecheck(v)	(1)
+
+//
+// Shifts
+//
+#define	__U5const_rangecheck(v)		((v) >= 0 && (v) < 32)
+
+#define __I26const_rangecheck(x) ((((x) & 0xfc000000) == 0xffc000000) || (((x) & 0xffc000000) == 0))
+
+#define __S16const_rangecheck(v) ((-32768 <= (v)) && ((v) <= 32767))
+
+#define HAVE_ashr_int_const_rangecheck(x) __U5const_rangecheck(x)
+#define HAVE_lshr_int_const_rangecheck(x) __U5const_rangecheck(x)
+
+/*
+ * These must be defined for any architecture.
+ */
+#define	HAVE_spill_int			spill_Rxx
+#define	HAVE_reload_int			reload_Rxx
+#define	HAVE_spill_ref			spill_Rxx
+#define	HAVE_reload_ref			reload_Rxx
+
+#define	HAVE_move_register_int		movereg_RR
+#define	HAVE_move_register_ref		movereg_RR
+#define	HAVE_move_register_float	fmovereg_RR
+#define	HAVE_move_register_double	fmovereg_RR
+
+#define	HAVE_prologue			prologue_xxx
+#define	HAVE_epilogue			epilogue_xxx
+#define	HAVE_exception_prologue		eprologue_xxx
+
+/*#define	HAVE_move_int_const		move_RxC*/
+#define	HAVE_move_int_const_incode	move_RxC
+/*#define	HAVE_move_ref_const		move_RxC*/
+
+#define	HAVE_move_int_const_rangecheck(v)	__moveable_constant_rangecheck(v)
+#define	HAVE_move_int_const_incode_rangecheck(v)	__anyvalue_rangecheck(v)
+#define	HAVE_move_ref_const_rangecheck(v)	__moveable_constant_rangecheck((int)v)
+
+#define	HAVE_move_int			move_RxR
+
+#define	HAVE_move_label_const		move_RxL
+
+#define	HAVE_load_constpool_ref		ld_RxL
+#define	HAVE_load_constpool_int		ld_RxL
+
+#define	HAVE_move_ref			move_RxR
+#define	HAVE_move_any			move_RxR
+
+#define HAVE_neg_int			neg_RxR
+#define	HAVE_add_int			add_RRR
+#define	HAVE_sub_int			sub_RRR
+#define	HAVE_mul_int			mul_RRR
+#define	HAVE_div_int			div_RRR
+#undef	HAVE_rem_int
+#define	HAVE_and_int			and_RRR
+#define	HAVE_or_int			or_RRR
+#define	HAVE_xor_int			xor_RRR
+#define	HAVE_ashr_int			ashr_RRR
+#define	HAVE_lshr_int			lshr_RRR
+#define	HAVE_lshl_int			lshl_RRR
+#define	HAVE_ashr_int_const		ashr_RRC
+#define	HAVE_lshr_int_const		lshr_RRC
+
+#define	HAVE_load_int			load_RxR
+#define	HAVE_store_int			store_xRR
+#define	HAVE_load_ref			load_RxR
+#define	HAVE_store_ref			store_xRR
+
+#define	HAVE_pusharg_int		push_xRC
+#define	HAVE_pusharg_ref		push_xRC
+#define	HAVE_popargs			popargs_xxC
+
+#define	HAVE_cmp_int			cmp_xRR
+#define	HAVE_cmpl_int			cmpl_xRR
+// #define HAVE_cmp_offset_int		cmpl_xRRC
+
+//
+// Ref's are just int's
+//
+#define	HAVE_cmp_ref		cmp_xRR
+#define	HAVE_add_ref		add_RRR
+#define	HAVE_add_ref_const	add_RRC
+#define	HAVE_cmp_ref_const	cmp_xRC
+
+
+#ifdef I_THINK_THESE_DO_NOT_WORK_ALTHOUGH_I_DEFINED_THE_CODE_CORRECTLY
+#  define	HAVE_add_ref_const	addref_RRC
+#  define	HAVE_cmp_ref_const	cmpref_xRC
+#endif
+
+
+#define HAVE_branch			branch_xCC
+#define HAVE_branch_and_link		branchl_xCC
+
+//
+// It's problematic to implement call_ref using relative branches.
+//
+#define	HAVE_call_ref			call_xCC
+#define	HAVE_call_ref_rangecheck(v)	__I26const_rangecheck(v)
+#undef HAVE_call_ref
+
+#define	HAVE_call			call_xRC
+#define	HAVE_branch_indirect		branch_indirect_xRC
+#define	HAVE_return_int			return_Rxx
+#define	HAVE_return_long		returnl_Rxx
+#define	HAVE_return_ref			return_Rxx
+#define	HAVE_returnarg_int		returnarg_xxR
+#define	HAVE_returnarg_long		returnargl_xxR
+#define	HAVE_returnarg_ref		returnarg_xxR
+
+#define	HAVE_set_label			set_label_xxC
+#define	HAVE_build_key			set_word_xxC
+#define	HAVE_build_code_ref		set_wordpc_xxC
+#undef	HAVE_build_const_ref
+
+/*
+ * These are sometimes optional (if long operators are defined)
+ */
+#define	HAVE_adc_int			adc_RRR
+#define	HAVE_sbc_int			sbc_RRR
+
+/*
+ * These are optional but help to optimise the code generated.
+ */
+#define	HAVE_add_int_const	add_RRC
+#define	HAVE_cmp_int_const	cmp_xRC
+#define	HAVE_sub_int_const	sub_RRC
+#define	HAVE_and_int_const	and_RRC
+
+
+#define	HAVE_load_offset_int	load_RRC
+#define	HAVE_store_offset_int	store_RRC
+#define	HAVE_load_offset_ref	load_RRC
+#define	HAVE_store_offset_ref	store_RRC
+
+#define HAVE_load_offset_int_rangecheck(v)  __S16const_rangecheck(v)
+#define HAVE_store_offset_int_rangecheck(v) __S16const_rangecheck(v)
+#define HAVE_load_offset_ref_rangecheck(v)  __S16const_rangecheck(v)
+#define HAVE_store_offset_ref_rangecheck(v) __S16const_rangecheck(v)
+
+#define	HAVE_lshl_int_const	lshl_RRC
+#define HAVE_lshl_int_const_rangecheck(v)	__U5const_rangecheck(v)
+
+
+#undef	HAVE_pusharg_int_const
+
+
+//
+// We handle a signed value in the add/sub form
+// by flipping the operator
+//
+#define	HAVE_add_int_const_rangecheck(v)	__S16const_rangecheck(v)
+#define	HAVE_sub_int_const_rangecheck(v)	__S16const_rangecheck(v)
+#define	HAVE_add_ref_const_rangecheck(v)	HAVE_add_int_const_rangecheck(v)
+
+#define	HAVE_cmp_int_const_rangecheck(v)	__S16const_rangecheck(v)
+#define	HAVE_cmp_ref_const_rangecheck(v)	__S16const_rangecheck(v)
+#define	HAVE_pusharg_int_const_rangecheck(v)	__S16const_rangecheck(v)
+#define	HAVE_and_int_const_rangecheck(v)	__S16const_rangecheck(v)
+
+#define	HAVE_load_byte			loadb_RxR
+#define	HAVE_load_char			loadc_RxR
+#define	HAVE_load_short			loads_RxR
+#define	HAVE_store_byte			storeb_xRR
+#define	HAVE_store_char			stores_xRR
+#define	HAVE_store_short		stores_xRR
+
+#define HAVE_load_offset_byte	loadb_RRC
+#define HAVE_load_offset_byte_rangecheck(x) __S16const_rangecheck(x)
+#define HAVE_load_offset_short	loads_RRC
+#define HAVE_load_offset_short_rangecheck(x) __S16const_rangecheck(x)
+#define HAVE_load_offset_char	loads_RRC
+#define HAVE_load_offset_char_rangecheck(x) __S16const_rangecheck(x)
+
+#define HAVE_store_offset_byte	storeb_RRC
+#define HAVE_store_offset_byte_rangecheck(x) __S16const_rangecheck(x)
+#define HAVE_store_offset_short	stores_RRC
+#define HAVE_store_offset_short_rangecheck(x) __S16const_rangecheck(x)
+#define HAVE_store_offset_char	stores_RRC
+#define HAVE_store_offset_char_rangecheck(x) __S16const_rangecheck(x)
+
+#define HAVE_load_offset_float	fload_RRC
+#define HAVE_load_offset_float_rangecheck(x) __S16const_rangecheck(x)
+#define HAVE_load_offset_double	floadl_RRC
+#define HAVE_load_offset_double_rangecheck(x) __S16const_rangecheck(x)
+
+#define HAVE_store_offset_float	fstore_RRC
+#define HAVE_store_offset_float_rangecheck(x) __S16const_rangecheck(x)
+#define HAVE_store_offset_double	fstorel_RRC
+#define HAVE_store_offset_double_rangecheck(x) __S16const_rangecheck(x)
+
+/*
+ * These are optional if the architecture supports them.
+ */
+#undef	HAVE_mul_int_const
+#undef	HAVE_swap_int
+
+#undef	HAVE_move_long_const
+#undef	HAVE_move_long
+
+#undef	HAVE_add_long
+#undef	HAVE_sub_long
+#undef	HAVE_mul_long
+#undef	HAVE_div_long
+#undef	HAVE_rem_long
+#undef	HAVE_neg_long
+#undef	HAVE_and_long
+#undef	HAVE_or_long
+#undef	HAVE_xor_long
+#undef	HAVE_ashr_long
+#undef	HAVE_lshl_long
+#undef	HAVE_lshr_long
+
+#undef	HAVE_load_long
+#undef	HAVE_store_long
+
+#undef	HAVE_pusharg_long
+
+#undef	HAVE_cmp_long
+
+#undef	HAVE_cvt_int_long
+#undef	HAVE_cvt_int_byte
+#undef	HAVE_cvt_int_char
+#undef	HAVE_cvt_int_short
+#undef	HAVE_cvt_long_int
+
+#undef	HAVE_call_indirect_const
+
+#define	HAVE_fakecall			fakecall_xCC
+
+#if defined(STACK_LIMIT)
+#define	HAVE_check_stack_limit_constpool check_stack_limit_xRC
+#endif
+
+#if !defined(HAVE_NO_FLOATING_POINT)
+/*
+ * We only include these operations if we actually support floating point.
+ */
+

*** Patch too long, truncated ***




More information about the kaffe mailing list