From mail Fri Apr 27 12:04 EDT 1990
Received: from dg-rtp.dg.com (dg-rtp) by bigbird.rtp.dg.com (4.20/rtp-s01)
	id AA05617; Fri, 27 Apr 90 12:04:19 edt
Received: from MCC.COM by dg-rtp.dg.com (4.20/4.7)
	id AA07433; Fri, 27 Apr 90 12:03:12 edt via SMTP
Received: from pasillo.aca.mcc.com by MCC.COM with TCP/SMTP; Fri 27 Apr 90 11:03:32-CDT
Date: Fri, 27 Apr 90 11:02:48 CDT
From: lk@mcc.com (Larry Ketcham)
Posted-Date: Fri, 27 Apr 90 11:02:48 CDT
Message-Id: <9004271602.AA14366@pasillo.aca.mcc.com>
Received: by pasillo.aca.mcc.com (4.0/ACAv4.0i) 
	id AA14366; Fri, 27 Apr 90 11:02:48 CDT
To: hassey@DG-RTP.DG.COM, wood@DG-RTP.DG.COM
Subject: params in stack not registers
Status: R

Using Tom's GCC with 1.37.1 and 1.37.2 patches as a
base for G++ with John's 1.37.1.1 kit, I've successfully
built an 88k G++ cross-compiler that hosts on Sun3.
In the process, I developed a patch that is necessary
for the heterogeneous object-oriented environment that 
we support with our ES-Kit kernel.  

Our kernel supports a distributed processing environment
that can be composed of heterogeneous processor nodes.
For example, one of our typical configurations includes
Sun3 workstations linked with m88k processors.  Because 
the kernel enables method calls to occur between objects
that may be executing on different processor types, we
had to choose a method of parameter passing that is
not dependent upon register conventions.  For that reason,
we pass parameters in the stack rather than in registers
when a "remote" method call is compiled.  We distinguish
"remote" method calls via a base class for which the
method call operator is overloaded.

Given that rather terse explanation, here's the patch I've
developed to modify parameter passing to meet our needs.
I've guarded the changes with `#ifdef ESKIT' to prevent
interference with non-ESKIT users.  I would appreciate it
if you could merge this patch into your m88k kits (and thus
it should eventually make its way into the mainstream FSF
releases).

(Tiemann already has several instances of `#ifdef ESKIT' code
in his G++ releases, so don't worry, I'm not asking you to 
establish a new precedent.)

If you see a better way to accomplish this enhancement, or if
you want to put it under control of a compilation option, I'm 
certainly open to suggestions.

Thanks
--Larry Ketcham   MCC/ES-Kit   lk@mcc.com


----------------------------cut here---------------------------
*** config/out-m88k.c~	Tue Apr  3 13:46:09 1990
--- config/out-m88k.c	Thu Apr  5 15:20:02 1990
***************
*** 2881,2886 ****
    bytes = (mode != BLKmode) ? GET_MODE_SIZE (mode) : int_size_in_bytes (type);
    words = (bytes + 3) / 4;
    if (args_so_far->num + words > 8)
!     return (rtx) 0;
  
    else if (mode == BLKmode && (TYPE_ALIGN (type) != 32 || bytes != 4))
--- 2881,2892 ----
    bytes = (mode != BLKmode) ? GET_MODE_SIZE (mode) : int_size_in_bytes (type);
    words = (bytes + 3) / 4;
+ 
+ #ifdef ESKIT
+   if (no_reg_params)
+     return (rtx) 0;             /* don't put args in registers */
+ #endif
+ 
    if (args_so_far->num + words > 8)
!     return (rtx) 0;             /* args have exhausted registers */
  
    else if (mode == BLKmode && (TYPE_ALIGN (type) != 32 || bytes != 4))
***************
*** 2931,2934 ****
--- 2937,2945 ----
  	  || (type != 0 && TYPE_ALIGN (type) > 32)))
      args_so_far->num++;
+ 
+ #ifdef ESKIT
+   if (no_reg_params)
+     return (rtx) 0;             /* don't put args in registers */
+ #endif
  
    if (args_so_far->num >= 8)
*** cplus-decl.c~	Tue Apr  3 13:47:00 1990
--- cplus-decl.c	Thu Apr  5 13:43:45 1990
***************
*** 7408,7411 ****
--- 7408,7415 ----
    tree nonparms = 0;
  
+ #ifdef ESKIT
+   int save_no_reg_params = no_reg_params;
+ #endif
+ 
    if (current_binding_level == global_binding_level)
      fatal ("parse errors have confused me too much");
***************
*** 7414,7417 ****
--- 7418,7435 ----
    init_function_start (fndecl);
  
+ #ifdef ESKIT
+   /* If method call operator is overloaded,
+      prevent passing parameters in registers.  */
+   no_reg_params = 0;
+   if (fndecl)
+       if (DECL_CONTEXT (fndecl))
+ 	  if ((DECL_VIRTUAL_P (fndecl) || (flag_all_virtual == 1))
+ 		  && (TREE_HAS_METHOD_CALL_OVERLOADED (DECL_CONTEXT (fndecl))
+ 		      || TREE_NEEDS_WRAPPER (DECL_CONTEXT (fndecl)))
+ 		  && (! TREE_IS_CONSTRUCTOR (fndecl))
+                   && (DECL_FUNCTION_CODE (fndecl) == NOT_BUILT_IN))
+ 	      no_reg_params = 1;
+ #endif
+ 
    /* Create a binding level for the parms.  */
    expand_start_bindings (0);
***************
*** 7524,7527 ****
--- 7542,7549 ----
      expand_expr (build_function_call (lookup_name (get_identifier ("__main")), NULL_TREE),
  		 0, VOIDmode, 0);
+ 
+ #ifdef ESKIT
+   no_reg_params = save_no_reg_params;
+ #endif
  }
  
*** expr.c~	Tue Apr  3 13:47:32 1990
--- expr.c	Thu Apr  5 14:27:41 1990
***************
*** 32,35 ****
--- 32,40 ----
  #include "cplus-tree.h"
  
+ #ifdef ESKIT
+ int no_reg_params = 0;    /* Set if method call operator is overloaded
+                              for function being called.  */
+ #endif
+ 
  /* Decide whether a function's arguments should be processed
     from first to last or from last to first.  */
***************
*** 1521,1524 ****
--- 1526,1536 ----
    rtx use_insns;
  
+ #ifdef ESKIT
+   int save_no_reg_params = no_reg_params;
+ 
+   /* Allow parameters to be passed in registers for library call.  */ 
+   no_reg_params = 0;
+ #endif
+ 
    va_start (p);
    orgfun = fun = va_arg (p, rtx);
***************
*** 1679,1682 ****
--- 1691,1699 ----
  	       old_inhibit_defer_pop + 1, use_insns);
    OK_DEFER_POP;
+ 
+ #ifdef ESKIT
+   /* Restore potential to push parameters into stack.  */
+   no_reg_params = save_no_reg_params;
+ #endif
  }
  
***************
*** 3693,3696 ****
--- 3710,3720 ----
    rtx op0;
  
+ #ifdef ESKIT
+   int save_no_reg_params = no_reg_params;
+ 
+   /* Allow parameters to be passed in registers for builtin functions.  */
+   no_reg_params = 0;    
+ #endif
+ 
   again:
    switch (DECL_FUNCTION_CODE (fndecl))
***************
*** 4126,4129 ****
--- 4150,4158 ----
  #endif
      }
+ 
+ #ifdef ESKIT
+   /* Restore potential to push parameters into stack.  */
+   no_reg_params = save_no_reg_params;
+ #endif
  }
  
***************
*** 4637,4640 ****
--- 4666,4673 ----
    register int i;
  
+ #ifdef ESKIT
+   int save_no_reg_params = no_reg_params;
+ #endif
+ 
    /* See if we can find a DECL-node for the actual function.
       As a result, decide whether this is a call to an integrable function.  */
***************
*** 4674,4677 ****
--- 4707,4732 ----
      }
  
+ #ifdef ESKIT
+   /* If method call operator is overloaded,
+      prevent passing parameters in registers.  */
+   no_reg_params = 0;
+   if (fndecl)
+     {
+       if (DECL_CONTEXT (fndecl))
+           if ((DECL_VIRTUAL_P (DECL_CONTEXT (fndecl)) 
+ 	       || (flag_all_virtual == 1))
+ 	      && (TREE_HAS_METHOD_CALL_OVERLOADED (DECL_CONTEXT (fndecl))
+ 		  || TREE_NEEDS_WRAPPER (DECL_CONTEXT (fndecl)))
+ 	      && (! TREE_IS_CONSTRUCTOR (fndecl))
+ 	      && (DECL_FUNCTION_CODE (fndecl) == NOT_BUILT_IN))
+             no_reg_params = 1;
+     }
+   else
+     {
+       if (TREE_CODE (p) == COMPONENT_REF)
+ 	  no_reg_params = 1;
+     }
+ #endif
+ 
    /* When calling a const function, we must pop the stack args right away,
       so that the pop is deleted or moved with the call.  */
***************
*** 5495,5498 ****
--- 5550,5557 ----
  	}
      }
+ 
+ #ifdef ESKIT
+   no_reg_params = save_no_reg_params;
+ #endif
  
    return target;
*** flags.h~	Tue Apr  3 13:47:33 1990
--- flags.h	Thu Apr  5 13:54:59 1990
***************
*** 119,122 ****
--- 119,129 ----
  extern int flag_force_addr;
  
+ #ifdef ESKIT
+ /* Nonzero means don't pass parameters in registers.  Set this flag when
+    the method call operator is overloaded for the function being called.  */
+ 
+ extern int no_reg_params;
+ #endif
+ 
  /* Nonzero for -fstore-reg-params: force all parameters which are passed
     in registers to be saved into local stack slots assigned to hold these
----------------------------cut here---------------------------

