PatchSet 5672 
Date: 2005/04/11 17:43:41
Author: guilhem
Branch: HEAD
Tag: (none) 
Log:
Integer optimization fix

2005-04-11  Rei Odaira  <[EMAIL PROTECTED]>

        * kaffe/kaffevm/jit3/icode.c
        (div_int_const_optimize): Fixed rounding.

        * test/regression/NegativeDivideConst.java:
        Check the rounding result.

Members: 
        ChangeLog:1.3838->1.3839 
        kaffe/kaffevm/jit3/icode.c:INITIAL->1.52 
        test/regression/NegativeDivideConst.java:1.1->1.2 

Index: kaffe/ChangeLog
diff -u kaffe/ChangeLog:1.3838 kaffe/ChangeLog:1.3839
--- kaffe/ChangeLog:1.3838      Mon Apr 11 14:46:09 2005
+++ kaffe/ChangeLog     Mon Apr 11 17:43:41 2005
@@ -1,3 +1,11 @@
+2005-04-11  Rei Odaira  <[EMAIL PROTECTED]>
+
+       * kaffe/kaffevm/jit3/icode.c
+       (div_int_const_optimize): Fixed rounding.
+
+       * test/regression/NegativeDivideConst.java:
+       Check the rounding result.
+       
 2005-04-11  Guilhem Lavaux  <[EMAIL PROTECTED]>
        Rei Odaira <[EMAIL PROTECTED]>
 
===================================================================
Checking out kaffe/kaffe/kaffevm/jit3/icode.c
RCS:  /home/cvs/kaffe/kaffe/kaffe/kaffevm/jit3/icode.c,v
VERS: 1.52
***************
--- /dev/null   Sun Aug  4 19:57:58 2002
+++ kaffe/kaffe/kaffevm/jit3/icode.c    Mon Apr 11 17:49:58 2005
@@ -0,0 +1,5340 @@
+/* icode.c
+ * Define the instructions.
+ *
+ * Copyright (c) 1996, 1997
+ *     Transvirtual Technologies, Inc.  All rights reserved.
+ *
+ * See the file "license.terms" for information on usage and redistribution
+ * of this file.
+ */
+
+#include "config.h"
+#include "config-std.h"
+#include "config-mem.h"
+#include "gtypes.h"
+#include "slots.h"
+#include "seq.h"
+#include "md.h"
+#include "registers.h"
+#include "basecode.h"
+#include "labels.h"
+#include "constpool.h"
+#include "icode.h"
+#include "soft.h"
+#include "access.h"
+#include "object.h"
+#include "constants.h"
+#include "classMethod.h"
+#include "gc.h"
+#include "itypes.h"
+#include "locks.h"
+#include "machine.h"
+#include "codeproto.h"
+#include "thread.h"
+#include "jthread.h"
+#include "support.h"
+#include "code-analyse.h"
+#include "funcs.h"
+#include "kaffe_jni.h"
+
+#if defined(HAVE_branch_and_link)
+#define blink 0x8000000
+#else
+#define blink 0
+#endif
+
+/*
+ * This flag can turn off array bounds checking.
+ *  - for experimental purposes only.
+ */
+int noArrayBoundsChecks = 0;
+
+#if defined(WORDS_BIGENDIAN)
+#define        LSLOT(_s)       ((_s)+1)
+#define        HSLOT(_s)       (_s)
+#else
+#define        LSLOT(_s)       (_s)
+#define        HSLOT(_s)       ((_s)+1)
+#endif
+
+bool used_ieee_rounding;
+bool used_ieee_division;
+
+sequence* lastSpill;
+
+#define        MAXLABTAB       64
+label* labtab[MAXLABTAB];
+
+static void _call_soft(void *routine, int profiled);
+
+/* ----------------------------------------------------------------------- */
+/* Register loads and spills.                                             */
+/*                                                                        */
+
+#if defined(HAVE_spill_int)
+
+void
+spill_int(SlotData* src)
+{
+       sequence s;
+       seq_dst(&s) = src;
+       seq_value(&s, 1) = slotOffsetNoSpill(src, Rint);
+       HAVE_spill_int(&s);
+}
+#endif
+
+#if defined(HAVE_reload_int)
+
+void
+reload_int(SlotData* dst)
+{
+       sequence s;
+       seq_dst(&s) = dst;
+       seq_value(&s, 1) = slotOffsetNoSpill(dst, Rint);
+       HAVE_reload_int(&s);
+}
+#endif
+
+#if defined(HAVE_spill_ref)
+
+void
+spill_ref(SlotData* src)
+{
+       sequence s;
+       seq_dst(&s) = src;
+       seq_value(&s, 1) = slotOffsetNoSpill(src, Rref);
+       HAVE_spill_ref(&s);
+}
+#endif
+
+#if defined(HAVE_reload_ref)
+
+void
+reload_ref(SlotData* dst)
+{
+       sequence s;
+       seq_dst(&s) = dst;
+       seq_value(&s, 1) = slotOffsetNoSpill(dst, Rref);
+       HAVE_reload_ref(&s);
+}
+#endif
+
+#if defined(HAVE_spill_long)
+
+void
+spill_long(SlotData* src)
+{
+       sequence s;
+       seq_dst(&s) = src;
+       seq_value(&s, 1) = slotOffsetNoSpill(src, Rlong);
+       HAVE_spill_long(&s);
+}
+#endif
+
+#if defined(HAVE_reload_long)
+
+void
+reload_long(SlotData* dst)
+{
+       sequence s;
+       seq_dst(&s) = dst;
+       seq_value(&s, 1) = slotOffsetNoSpill(dst, Rlong);
+       HAVE_reload_long(&s);
+}
+#endif
+
+#if defined(HAVE_spill_float)
+
+void
+spill_float(SlotData* src)
+{
+       sequence s;
+       seq_dst(&s) = src;
+       seq_value(&s, 1) = slotOffsetNoSpill(src, Rfloat);
+       HAVE_spill_float(&s);
+}
+#endif
+
+#if defined(HAVE_reload_float)
+
+void
+reload_float(SlotData* dst)
+{
+       sequence s;
+       seq_dst(&s) = dst;
+       seq_value(&s, 1) = slotOffsetNoSpill(dst, Rfloat);
+       HAVE_reload_float(&s);
+}
+#endif
+
+#if defined(HAVE_spill_double)
+
+void
+spill_double(SlotData* src)
+{
+       sequence s;
+       seq_dst(&s) = src;
+       seq_value(&s, 1) = slotOffsetNoSpill(src, Rdouble);
+       HAVE_spill_double(&s);
+}
+#endif
+
+#if defined(HAVE_reload_double)
+
+void
+reload_double(SlotData* dst)
+{
+       sequence s;
+       seq_dst(&s) = dst;
+       seq_value(&s, 1) = slotOffsetNoSpill(dst, Rdouble);
+       HAVE_reload_double(&s);
+}
+#endif
+
+void
+copyslots(SlotInfo* dst, SlotInfo* src, int type)
+{
+       slot_slot_slot(dst, NULL, src, slotAlias, Tcopy);
+       activeSeq->u[1].value.i = type;
+}
+
+void
+copylslots(SlotInfo* dst, SlotInfo* src, int type)
+{
+       lslot_lslot_lslot(dst, NULL, src, slotAlias, Tcopy);
+       activeSeq->u[1].value.i = type;
+}
+
+/* ----------------------------------------------------------------------- */
+/* Prologues and epilogues.                                               */
+/*                                                                        */
+
+void
+prologue(Method* meth)
+{
+       label* l;
+
+       used_ieee_rounding = false;
+       used_ieee_division = false;
+
+       l = KaffeJIT3_newLabel();
+       l->type = Lnull;
+       l->at = 0;
+       l->to = 0;
+       l->from = 0;
+
+       setupSlotsForBasicBlock();
+       setupGlobalRegisters();
+       setupArgumentRegisters();
+
+       /* Emit prologue code */
+       slot_const_const(NULL, (jword)l, (jword)meth, HAVE_prologue, Tnull);
+        slot_const_const(NULL, (jword)createSpillMask(), SR_START, doReload, 
Tnull);
+       
+#if defined(ENABLE_JVMPI)
+       {
+               SlotInfo *tmp;
+
+               slot_alloctmp(tmp);
+               if( METHOD_IS_STATIC(meth) )
+                       move_ref_const(tmp, NULL);
+               else
+                       move_ref(tmp, local(0));
+               softcall_enter_method(tmp, meth);
+               slot_freetmp(tmp);
+       }
+#endif
+}
+
+void
+check_stack_limit(void)
+{
+#if defined(STACK_LIMIT)
+#if defined(HAVE_check_stack_limit_constpool)
+       label* l;
+       constpool* c;
+
+       l = KaffeJIT3_newLabel();
+       c = KaffeJIT3_newConstant(CPref, soft_stackoverflow);
+       l->type = Lexternal;
+       l->at = 0;
+       l->to = (uintp)c;
+       l->from = 0;
+
+       slot_slot_const(NULL, stack_limit, (jword)l, 
HAVE_check_stack_limit_constpool, Tnull);
+#elif defined(HAVE_check_stack_limit)
+       label* l;
+
+       l = KaffeJIT3_newLabel();
+       l->type = Lexternal;
+       l->at = 0;
+       l->to = (uintp)soft_stackoverflow;
+       l->from = 0;
+
+       slot_slot_const(NULL, stack_limit, (jword)l, HAVE_check_stack_limit, 
Tnull);
+#endif
+#endif /* STACK_LIMIT */
+}
+
+void
+exception_prologue(void)
+{
+       label* l;
+
+       l = KaffeJIT3_newLabel();
+       l->type = Lnull;
+       l->at = 0;
+       l->to = 0;
+       l->from = 0;
+
+       /* Emit exception prologue code */
+       slot_const_const(NULL, (jword)l, 0, HAVE_exception_prologue, Tnull);
+        slot_const_const(NULL, (jword)createSpillMask(), SR_EXCEPTION, 
doReload, Tnull);
+}
+
+void
+epilogue(Method* meth UNUSED)
+{
+       label* l;
+       
+       l = KaffeJIT3_newLabel();
+       l->type = Lnull;        /* Lnegframe|Labsolute|Lgeneral */
+       l->at = 0;
+       l->to = 0;
+       l->from = 0;
+#if defined(TRACE_METHOD_END)
+       if (Kaffe_JavaVMArgs.enableVerboseCall != 0) {
+                begin_func_sync();
+                call_soft(soft_end);
+                popargs();
+                end_func_sync();
+        }
+#endif
+
+       slot_const_const(NULL, (jword)l, 0, HAVE_epilogue, Tnull);
+}
+
+void
+ret(void)
+{
+       label *l;
+
+       l = KaffeJIT3_newLabel();
+       l->at = 0;
+       l->to = 0;
+       l->from = 0;
+
+       /* Jump to epilogue */
+       l->type = Lepilogue;
+       branch (l, ba);
+}
+
+
+/* ----------------------------------------------------------------------- */
+/* Conditional monitor management.                                        */
+/*                                                                        */
+
+void
+mon_enter(methods* meth, SlotInfo* obj)
+{
+       /* Emit monitor entry if required */
+       if ((meth->accflags & ACC_SYNCHRONISED) == 0) {
+               return;
+       }
+#if defined(HAVE_mon_enter)
+       {
+               label* l;
+
+               begin_func_sync();
+               l = KaffeJIT3_newLabel();
+               l->type = Lexternal;
+               l->at = 0;
+               l->to = (uintp)slowLockObject;
+               l->from = 0;
+               if (METHOD_IS_STATIC(meth) == 0) {
+                       meth = NULL;
+               }
+               else {
+                       obj = NULL;
+               }
+               slot_slot_slot_const_const(NULL, NULL, obj, (jword)meth, 
(jword)l, HAVE_mon_enter, Tnull);
+               end_func_sync();
+       }
+#else
+       begin_func_sync();
+       if ((meth->accflags & ACC_STATIC) != 0) {
+               pusharg_class_const(meth->class, 0);
+       }
+       else {
+               pusharg_ref(obj, 0);
+       }
+       call_soft(lockObject);
+       popargs();
+       end_func_sync();
+#endif
+}
+
+void
+mon_exit(methods* meth, SlotInfo* obj)
+{
+       /* Emit monitor entry if required */
+       if ((meth->accflags & ACC_SYNCHRONISED) == 0) {
+               return;
+       }
+#if defined(HAVE_mon_exit)
+       {
+               label* l;
+
+               begin_func_sync();
+               l = KaffeJIT3_newLabel();
+               l->type = Lexternal;
+               l->at = 0;
+               l->to = (uintp)slowUnlockObject;
+               l->from = 0;
+               if (METHOD_IS_STATIC(meth) == 0) {
+                       meth = NULL;
+               }
+               else {
+                       obj = NULL;
+               }
+               slot_slot_slot_const_const(NULL, NULL, obj, (jword)meth, 
(jword)l, HAVE_mon_exit, Tnull);
+               end_func_sync();
+       }
+#else
+       begin_func_sync();
+       if (METHOD_IS_STATIC(meth) != 0) {
+               pusharg_class_const(meth->class, 0);
+       }
+       else {
+               pusharg_ref(obj, 0);
+       }
+       call_soft(unlockObject);
+       popargs();
+       end_func_sync();
+#endif
+}
+
+void
+softcall_monitorenter(SlotInfo* mon)
+{
+#if defined(HAVE_mon_enter)
+       label* l;
+
+       l = KaffeJIT3_newLabel();
+       l->type = Lexternal;
+       l->at = 0;
+       l->to = (uintp)slowLockObject;
+       l->from = 0;
+       slot_slot_slot_const_const(NULL, NULL, mon, 0, (jword)l, 
HAVE_mon_enter, Tnull);
+#else
+       pusharg_ref(mon, 0);
+       call_soft(lockObject);
+       popargs();
+#endif
+}
+
+void
+softcall_monitorexit(SlotInfo* mon)
+{
+#if defined(HAVE_mon_exit)
+       label* l;
+
+       l = KaffeJIT3_newLabel();
+       l->type = Lexternal;
+       l->at = 0;
+       l->to = (uintp)slowUnlockObject;
+       l->from = 0;
+       slot_slot_slot_const_const(NULL, NULL, mon, 0, (jword)l, HAVE_mon_exit, 
Tnull);
+#else
+       pusharg_ref(mon, 0);
+       call_soft(unlockObject);
+       popargs();
+#endif
+}
+
+/* ----------------------------------------------------------------------- */
+/* Basic block and instruction management.                                */
+/*                                                                        */
+
+void
+mark_all_writes(void)
+{
+       int i;
+       SlotData* sd;
+
+       /* We must reference all slots sequence since they may be used */
+       for (i = maxslot - 1; i >= 0; i--) {
+               sd = slotinfo[i].slot;
+               if (sd->wseq != 0) {
+                       sd->wseq->refed = 1;
+               }
+       }
+}
+
+void
+_start_sub_block(void)
+{
+       slot_const_const(NULL, (jword)createSpillMask(), SR_SUBBASIC, doReload, 
Tnull);
+       setupSlotsForBasicBlock();
+}
+
+void
+_start_basic_block(void)
+{
+       slot_const_const(NULL, (jword)createSpillMask(), SR_BASIC, doReload, 
Tnull);
+       setupSlotsForBasicBlock();
+}
+
+void
+_end_sub_block(void)
+{
+       mark_all_writes();
+       slot_const_const(NULL, (jword)createSpillMask(), SR_SUBBASIC, doSpill, 
Tnull);
+}
+
+void
+_end_basic_block(void)
+{
+       mark_all_writes();
+       slot_const_const(NULL, (jword)createSpillMask(), SR_BASIC, doSpill, 
Tnull);
+}
+
+void
+_syncRegisters(uintp stk UNUSED, uintp temp UNUSED)
+{
+       slot_const_const(NULL, (jword)createSpillMask(), SR_SYNC, doSpill, 
Tnull);
+}
+
+void
+_start_instruction(uintp _pc)
+{
+       slot_const_const(NULL, 0, _pc, startInsn, Tnull);
+}
+
+void
+_start_exception_block(uintp stk)
+{
+       /* Exception blocks act like function returns - the return
+        * value is the exception object.
+        */
+       start_basic_block();
+       exception_prologue();
+       return_ref(&localinfo[stk]);
+}
+
+/*
+ * Begin a register/slot syncronization - this is the point we will
+ * store all our cached values back to where they belong.  We don't know
+ * which values to store yet - this is decided at the end_sync point.
+ */
+void
+begin_sync(void)
+{
+       assert(lastSpill == 0);
+       slot_const_const(NULL, 0, SR_BASIC, doSpill, Tnull);
+       lastSpill = activeSeq;
+}
+
+void
+end_sync(void)
+{
+       /* Make sure a sync is in progress */
+       assert(lastSpill != 0);
+       lastSpill->u[1].smask = createSpillMask();
+       lastSpill = NULL;
+       mark_all_writes();
+}
+
+void
+begin_func_sync(void)
+{
+       assert(lastSpill == 0);
+       slot_const_const(NULL, 0, SR_FUNCTION, doSpill, Tnull);
+       lastSpill = activeSeq;
+
+       /* If we might throw and catch and exception we better make everything
+        * is written which should be.
+        */
+       if (canCatch(ANY)) {
+               mark_all_writes();
+       }
+}
+
+void
+end_func_sync(void)
+{
+       SlotData** mask;
+
+       /* Build a mask of the slots to spill and reload */
+       mask = createSpillMask();
+
+       /* Save the slots to spill */
+       assert(lastSpill != 0);
+       lastSpill->u[1].smask = mask;
+       lastSpill = NULL;
+
+       /* Create a reload and save the slots to reload */
+       slot_const_const(NULL, (jword)mask, SR_FUNCTION, doReload, Tnull);
+}
+
+
+/* ----------------------------------------------------------------------- */
+/* Moves.                                                                 */
+/*                                                                        */
+
+void
+move_int_const(SlotInfo* dst, jint val)
+{
+#if defined(HAVE_move_int_const)
+       if (HAVE_move_int_const_rangecheck(val)) {
+               slot_slot_const(dst, NULL, val, HAVE_move_int_const, Tconst);
+       }
+       else
+#endif
+       {
+               constpool *c;
+               label* l;
+
+               c = KaffeJIT3_newConstant(CPint, val);
+               l = KaffeJIT3_newLabel();
+               l->type = Lconstant;
+               l->at = 0;
+               l->to = (uintp)c;
+               l->from = 0;
+
+#if defined(HAVE_load_constpool_int)
+               slot_slot_const(dst, 0, (jword)l, HAVE_load_constpool_int, 
Tnull);
+#else
+               {
+                       SlotInfo* tmp;
+                       slot_alloctmp(tmp);
+                       move_label_const(tmp, l);
+                       load_int(dst, tmp);
+                       slot_freetmp(tmp);
+               }
+#endif
+       }
+}
+
+void
+move_ref_const(SlotInfo* dst, void *val)
+{
+#if defined(HAVE_move_ref_const)
+       if (HAVE_move_ref_const_rangecheck(val)) {
+               slot_slot_const(dst, NULL, (jword)val, HAVE_move_ref_const, 
Tconst);
+       }
+       else
+#endif
+       {
+               constpool *c;
+               label* l;
+
+               c = KaffeJIT3_newConstant(CPref, val);
+               l = KaffeJIT3_newLabel();
+               l->type = Lconstant;
+               l->at = 0;
+               l->to = (uintp)c;
+               l->from = 0;
+
+#if defined(HAVE_load_constpool_ref)
+               slot_slot_const(dst, 0, (jword)l, HAVE_load_constpool_ref, 
Tnull);
+#else
+               {
+                       SlotInfo* tmp;
+                       slot_alloctmp(tmp);
+                       move_label_const(tmp, l);
+                       load_ref(dst, tmp);
+                       slot_freetmp(tmp);
+               }
+#endif
+       }
+}
+
+void
+move_string_const(SlotInfo* dst, void *val)
+{
+#if 1
+       move_ref_const(dst, val);
+#else
+       label* l;
+       constpool *c;
+       SlotInfo* tmp;
+
+       c = KaffeJIT3_newConstant(CPstring, val);
+       l = KaffeJIT3_newLabel();
+       l->type = Lconstant;
+       l->at = 0;
+       l->to = (uintp)c;
+       l->from = 0;
+
+#if defined(HAVE_load_constpool_ref)
+       slot_slot_const(dst, 0, (jword)l, HAVE_load_constpool_ref, Tnull);
+#else
+       slot_alloctmp(tmp);
+       move_label_const(tmp, l);
+       load_ref(dst, tmp);
+       slot_freetmp(tmp);
+#endif
+
+#endif
+}
+
+void
+move_long_const(SlotInfo* dst, jlong val)
+{
+#if defined(HAVE_move_long_const)
+       if (HAVE_move_long_const_rangecheck(val)) {
+               lslot_slot_lconst(dst, 0, val, HAVE_move_long_const, Tconst);
+       }
+       else {
+               constpool *c;
+               label* l;
+               SlotInfo* tmp;
+
+               c = KaffeJIT3_newConstant(CPlong, val);
+               l = KaffeJIT3_newLabel();
+               l->type = Lconstant;
+               l->at = 0;
+               l->to = (uintp)c;
+               l->from = 0;
+
+
+#if defined(HAVE_load_constpool_long)
+               slot_slot_const(dst, 0, (jword)l, HAVE_load_constpool_long, 
Tnull);
+#else
+               slot_alloctmp(tmp);
+               move_label_const(tmp, l);
+               load_long(dst, tmp);
+               slot_freetmp(tmp);
+#endif
+       }
+#else
+
+#if defined(WORDS_BIGENDIAN)
+       /*
+        * Switch the ordering so that we get a better register allocation
+        * ordering and don't have to swap immediately afterwards.  (sigh)
+        */
+       move_int_const(HSLOT(dst), (jint)((val >> 32) & 0xFFFFFFFF));
+       move_int_const(LSLOT(dst), (jint)(val & 0xFFFFFFFF));
+#else
+       move_int_const(LSLOT(dst), (jint)(val & 0xFFFFFFFF));
+       move_int_const(HSLOT(dst), (jint)((val >> 32) & 0xFFFFFFFF));
+#endif
+       
+#endif
+}
+
+void
+move_float_const(SlotInfo* dst, float val)
+{
+#if defined(HAVE_move_float_const)
+       if (HAVE_move_float_const_rangecheck(val)) {
+               slot_slot_fconst(dst, NULL, val, HAVE_move_float_const, Tconst);
+       }
+       else
+#endif
+       {
+               constpool *c;
+               label* l;
+
+               c = KaffeJIT3_newConstant(CPfloat, val);
+               l = KaffeJIT3_newLabel();
+               l->type = Lconstant;
+               l->at = 0;
+               l->to = (uintp)c;
+               l->from = 0;
+
+#if defined(HAVE_load_constpool_float)
+               slot_slot_const(dst, NULL, (jword)l, HAVE_load_constpool_float, 
Tnull);
+#else
+               {
+                       SlotInfo* tmp;
+                       slot_alloctmp(tmp);
+                       move_label_const(tmp, l);
+                       load_float(dst, tmp);
+                       slot_freetmp(tmp);
+               }
+#endif
+       }
+}
+
+void
+move_double_const(SlotInfo* dst, jdouble val)
+{
+#if defined(HAVE_move_double_const)
+       if (HAVE_move_double_const_rangecheck(val)) {
+               lslot_slot_fconst(dst, NULL, val, HAVE_move_double_const, 
Tconst);
+       }
+       else
+#endif
+       {
+               constpool *c;
+               label* l;
+
+               c = KaffeJIT3_newConstant(CPdouble, val);
+               l = KaffeJIT3_newLabel();
+               l->type = Lconstant;
+               l->at = 0;
+               l->to = (uintp)c;
+               l->from = 0;
+
+#if defined(HAVE_load_constpool_double)
+               lslot_lslot_const(dst, 0, (jword)l, HAVE_load_constpool_double, 
Tnull);
+#else
+               {
+                       SlotInfo* tmp;
+                       slot_alloctmp(tmp);
+                       move_label_const(tmp, l);
+                       load_double(dst, tmp);
+                       slot_freetmp(tmp);
+               }
+#endif
+       }
+}
+
+#if defined(HAVE_move_any)
+void
+move_any(SlotInfo* dst, SlotInfo* src)
+{
+       if (dst == src) {
+       }
+       else if (isGlobal(dst->slot)) {
+               slot_slot_slot(dst, NULL, src, HAVE_move_any, Tcopy);
+       }
+       else {
+               copyslots(dst, src, Rref);
+       }
+}
+#endif
+
+#if defined(HAVE_move_int)
+void
+move_int(SlotInfo* dst, SlotInfo* src)
+{
+       if (dst == src) {
+       }
+#if defined(HAVE_move_int_const)
+       else if (slot_type(src) == Tconst) {
+               move_int_const(dst, slot_value(src)->i);
+       }
+#endif
+       else if (isGlobal(dst->slot)) {
+               slot_slot_slot(dst, NULL, src, HAVE_move_int, Tcopy);
+       }
+       else {
+               copyslots(dst, src, Rint);
+       }
+}
+#endif
+
+void
+move_ref(SlotInfo* dst, SlotInfo* src)
+{
+       if (dst == src) {
+       }
+#if defined(HAVE_move_ref_const)
+       else if (slot_type(src) == Tconst) {
+               move_ref_const(dst, slot_value(src)->l);
+       }
+#endif
+       else if (isGlobal(dst->slot)) {
+               slot_slot_slot(dst, NULL, src, HAVE_move_ref, Tcopy);
+       }
+       else {
+               copyslots(dst, src, Rref);
+       }
+}
+
+void
+move_anylong(SlotInfo* dst, SlotInfo* src)
+{
+#if defined(HAVE_move_anylong)
+       lslot_lslot_lslot(dst, 0, src, HAVE_move_anylong, Tcopy);
+#else
+       assert(LSLOT(dst) != HSLOT(src));
+       move_any(LSLOT(dst), LSLOT(src));
+       move_any(HSLOT(dst), HSLOT(src));
+#endif
+}
+
+void
+move_long(SlotInfo* dst, SlotInfo* src)
+{
+#if defined(HAVE_move_long)
+       lslot_lslot_lslot(dst, 0, src, HAVE_move_long, Tcopy);
+#else
+       assert(LSLOT(dst) != HSLOT(src));
+       move_int(LSLOT(dst), LSLOT(src));
+       move_int(HSLOT(dst), HSLOT(src));
+#endif
+}
+
+void
+move_float(SlotInfo* dst, SlotInfo* src)
+{
+       if (dst == src) {
+       }
+#if defined(HAVE_move_float_const)
+       else if (slot_type(src) == Tconst) {
+               move_float_const(dst, slot_value(src)->f);
+       }
+#endif
+       else if (isGlobal(dst->slot)) {
+#if defined(HAVE_move_float)
+               slot_slot_slot(dst, NULL, src, HAVE_move_float, Tcopy);
+#elif defined(HAVE_NO_FLOATING_POINT)
+               move_int(dst, src);
+#else
+       ABORT();
+#endif
+       }
+       else {
+               copyslots(dst, src, Rfloat);
+       }
+}
+
+void
+move_double(SlotInfo* dst, SlotInfo* src)
+{
+       if (dst == src) {
+       }
+#if defined(HAVE_move_double_const)
+       else if (slot_type(src) == Tconst) {
+               move_double_const(dst, slot_value(src)->d);
+       }
+#endif
+       else if (isGlobal(dst->slot)) {
+#if defined(HAVE_move_double)
+               lslot_lslot_lslot(dst, NULL, src, HAVE_move_double, Tcopy);
+#elif defined(HAVE_NO_FLOATING_POINT) || defined(PS2LINUX)
+               move_long(dst, src);
+#else
+               ABORT();
+#endif
+       }
+       else {
+               copylslots(dst, src, Rdouble);
+       }
+}
+
+#if defined(HAVE_move_label_const)
+void
+move_label_const(SlotInfo* dst, label* lab)
+{
+       slot_slot_const(dst, NULL, (jword)lab, HAVE_move_label_const, Tnull);
+}
+#endif
+
+void
+swap_any(SlotInfo* src, SlotInfo* src2)
+{
+#if defined(HAVE_swap_any)
+       slot_slot_slot(src, 0, src2, HAVE_swap_any, Tcomplex);
+#else
+       SlotInfo* tmp;
+       slot_alloctmp(tmp);
+       move_ref(tmp, src);
+       move_ref(src, src2);
+       move_ref(src2, tmp);
+       slot_freetmp(tmp);
+#endif
+}
+
+/* ----------------------------------------------------------------------- */
+/* Arithmetic operators - add, sub, etc.                                  */
+/*                                                                        */
+
+
+#if defined(HAVE_adc_int)
+void
+adc_int(SlotInfo* dst, SlotInfo* src, SlotInfo* src2)
+{
+       slot_slot_slot(dst, src, src2, HAVE_adc_int, Tcomplex);
+}
+#endif

*** Patch too long, truncated ***

_______________________________________________
kaffe mailing list
[email protected]
http://kaffe.org/cgi-bin/mailman/listinfo/kaffe

Reply via email to