This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix one-sized FP arrays returning on MIPS


Hi,

This is a regression present on 3.4 branch and mainline (n32 ABI).  The 
compiler ICEs when trying to convert between SFmode and SImode for the 
following procedure:

 type index is (first);

 type my_array is array (index) of Float;

 procedure f (i: in Integer; a : out my_array);

The 'a' parameter is turned by the Ada front-end into the return value of the 
function 'f'.  Then mips_return_in_msb accepts it and the back-end decides 
to return it in $2.


The proposed fix is to teach mips_fpr_return_fields to accept one-sized 
arrays of floating-point type.  I also renamed it into mips_return_in_fpr 
since it is not mandatory for it to populate the 'fields' parameter anymore.

Tested C, C++, Ada on mips-sgi-irix6.5 (3.4 branch).  OK for mainline and 3.4 
branch?


2004-06-11  Eric Botcazou  <ebotcazou@act-europe.fr>

	* config/mips/mips.c (mips_fpr_return_fields): Rename into
	mips_return_in_fpr.  Return 1 for one-sized arrays of FP type.
	(mips_return_in_msb): Adjust call to previous function.
	(mips_function_value): Likewise.


-- 
Eric Botcazou
Index: config/mips/mips.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/mips/mips.c,v
retrieving revision 1.417
diff -u -p -r1.417 mips.c
--- config/mips/mips.c	4 Jun 2004 00:37:56 -0000	1.417
+++ config/mips/mips.c	11 Jun 2004 06:25:06 -0000
@@ -235,7 +235,7 @@ static void mips_select_rtx_section (enu
 static void mips_select_section (tree, int, unsigned HOST_WIDE_INT)
 				  ATTRIBUTE_UNUSED;
 static bool mips_in_small_data_p (tree);
-static int mips_fpr_return_fields (tree, tree *);
+static int mips_return_in_fpr (tree, tree *);
 static bool mips_return_in_msb (tree);
 static rtx mips_return_fpr_pair (enum machine_mode mode,
 				 enum machine_mode mode1, HOST_WIDE_INT,
@@ -7313,17 +7313,18 @@ mips_in_small_data_p (tree decl)
   return (size > 0 && size <= mips_section_threshold);
 }
 
-/* See whether VALTYPE is a record whose fields should be returned in
-   floating-point registers.  If so, return the number of fields and
-   list them in FIELDS (which should have two elements).  Return 0
-   otherwise.
+/* See whether VALTYPE is an aggregate that should be returned in
+   floating-point registers.  If so, return 1 if the aggregate has
+   only one field, otherwise return the number of fields and list
+   them in FIELDS (which should have two elements).  Return 0 if the
+   aggregate should not be passed in floating-point registers.
 
    For n32 & n64, a structure with one or two fields is returned in
    floating-point registers as long as every field has a floating-point
    type.  */
 
 static int
-mips_fpr_return_fields (tree valtype, tree *fields)
+mips_return_in_fpr (tree valtype, tree *fields)
 {
   tree field;
   int i;
@@ -7331,6 +7332,12 @@ mips_fpr_return_fields (tree valtype, tr
   if (!TARGET_NEWABI)
     return 0;
 
+  /* Accept one-sized arrays of FP type.  */
+  if (TREE_CODE (valtype) == ARRAY_TYPE
+      && TREE_CODE (TREE_TYPE (valtype)) == REAL_TYPE
+      && TYPE_MODE (valtype) != BLKmode)
+    return 1;
+
   if (TREE_CODE (valtype) != RECORD_TYPE)
     return 0;
 
@@ -7360,7 +7367,7 @@ mips_fpr_return_fields (tree valtype, tr
       - the value has a structure or union type (we generalize this to
 	cover aggregates from other languages too); and
 
-      - the structure is not returned in floating-point registers.  */
+      - the aggregate is not returned in floating-point registers.  */
 
 static bool
 mips_return_in_msb (tree valtype)
@@ -7370,7 +7377,7 @@ mips_return_in_msb (tree valtype)
   return (TARGET_NEWABI
 	  && TARGET_BIG_ENDIAN
 	  && AGGREGATE_TYPE_P (valtype)
-	  && mips_fpr_return_fields (valtype, fields) == 0);
+	  && mips_return_in_fpr (valtype, fields) == 0);
 }
 
 
@@ -7424,7 +7431,7 @@ mips_function_value (tree valtype, tree 
       mode = promote_mode (valtype, mode, &unsignedp, 1);
 
       /* Handle structures whose fields are returned in $f0/$f2.  */
-      switch (mips_fpr_return_fields (valtype, fields))
+      switch (mips_return_in_fpr (valtype, fields))
 	{
 	case 1:
 	  return gen_rtx_REG (mode, FP_RETURN);
package q_array is

 type index is (first);

 type my_array is array (index) of Float;

 procedure f (i: in Integer; a : out my_array);

end;
with q_array; use q_array;

procedure p_array is

 i : Integer := 0;
 a : my_array;

begin
  f (i,a);
end;

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]