Patch for COMPLEX support (part 3)

Weiwen Liu weiwen.liu@yale.edu
Thu Jan 15 16:30:00 GMT 1998


This patch fixes the problem for COMPLEX support on x86.
Part 1 and 2 should be applied before this patch.

Wed Jan 14 22:56:00 1998  Weiwen Liu <liu@hepunix.physics.yale.edu>

	* reg-stack.c (mark_regs_pat): Calculate the number of
          registers needed for COMPLEX mode.
	  (subst_stack_regs_pat): Likewise.
	  (convert_regs): Likewise.

	* calls.c (store_one_arg): If a COMPLEX argument is passed on
	  the stack, use emit_push_insn.

--- reg-stack.c.orig	Sun Nov  2 16:17:53 1997
+++ reg-stack.c	Wed Jan 14 21:26:56 1998
@@ -292,8 +292,11 @@ mark_regs_pat (pat, set)
   else
      regno = REGNO (pat), mode = GET_MODE (pat);
 
-  for (count = HARD_REGNO_NREGS (regno, mode);
-       count; count--, regno++)
+  if (!COMPLEX_MODE_P (mode))
+    count = HARD_REGNO_NREGS (regno, mode);
+  else
+    count = 2 * HARD_REGNO_NREGS (regno, COMPLEX_SUBMODE (mode));
+  for (; count; count--, regno++)
      SET_HARD_REG_BIT (*set, regno);
 }
 
@@ -2141,8 +2144,12 @@ subst_stack_regs_pat (insn, regstack, pa
       case CALL:
 	 {
 	   int count;
-	   for (count = HARD_REGNO_NREGS (REGNO (*dest), GET_MODE (*dest));
-              --count >= 0;)
+	   if (! COMPLEX_MODE_P (GET_MODE (*dest)))
+	     count = HARD_REGNO_NREGS (REGNO (*dest), GET_MODE (*dest));
+	   else
+	     count = 2 * HARD_REGNO_NREGS (REGNO (*dest),
+					   COMPLEX_SUBMODE (GET_MODE (*dest)));
+	   for (; --count >= 0;)
 	    {
 	      regstack->reg[++regstack->top] = REGNO (*dest) + count;
 	      SET_HARD_REG_BIT (regstack->reg_set, REGNO (*dest) + count);
@@ -3133,8 +3140,14 @@ convert_regs ()
         if (retvalue = stack_result (current_function_decl))
 	 {
 	   value_reg_low = REGNO (retvalue);
-	   value_reg_high = value_reg_low +
-	    HARD_REGNO_NREGS (value_reg_low, GET_MODE (retvalue)) - 1;
+	   if (!COMPLEX_MODE_P (GET_MODE (retvalue)))
+	     value_reg_high = value_reg_low +
+	       HARD_REGNO_NREGS (value_reg_low, GET_MODE (retvalue)) - 1;
+	   else
+	     value_reg_high = value_reg_low +
+	       2 * HARD_REGNO_NREGS (value_reg_low,
+				     COMPLEX_SUBMODE (GET_MODE (retvalue)))
+	       - 1;
 	 }
 
       }
--- calls.c.orig	Wed Jan  7 19:32:02 1998
+++ calls.c	Sun Jan 11 08:15:47 1998
@@ -3874,7 +3874,8 @@ store_one_arg (arg, argblock, may_be_all
 
       /* This isn't already where we want it on the stack, so put it there.
 	 This can either be done with push or copy insns.  */
-      if (! COMPLEX_MODE_P (arg->mode))
+      if (! COMPLEX_MODE_P (arg->mode)
+	  || (COMPLEX_MODE_P (arg->mode) && arg->reg == 0))
 	emit_push_insn (arg->value, arg->mode, type, NULL_RTX,
 			0, partial, reg, used - size,
 			argblock, ARGS_SIZE_RTX (arg->offset));






More information about the Gcc mailing list