Fix APCS violation.
authorRichard Earnshaw <rearnsha@arm.com>
Tue, 19 Oct 1999 14:27:00 +0000 (14:27 +0000)
committerNick Clifton <nickc@gcc.gnu.org>
Tue, 19 Oct 1999 14:27:00 +0000 (14:27 +0000)
From-SVN: r30087

gcc/ChangeLog
gcc/config/arm/arm.c

index fa012f66d06026a006368213d4e5df62c9bf62cc..a183c593791ab1d357f7cb26b9f610725f17787b 100644 (file)
@@ -1,3 +1,8 @@
+Tue Oct 19 15:26:11 1999  Richard Earnshaw  (rearnsha@arm.com)
+
+       * arm.c (arm_return_in_memory): APCS rules state that the elements
+       of a structure returned in a register must be 'integer-like'.
+
 1999-10-19  Bruce Korb  <autogen@linuxbox.com>
 
         * fixinc/Makefile.in: Change the generation rules to run `genfixes'
index 8509eaa6078edec09366f4dddec7325ce28f6f07..2e6e969828f25e9730f9e430c3e767d2d33175b5 100644 (file)
@@ -1404,12 +1404,12 @@ arm_return_in_memory (type)
     {
       tree field;
 
-      /* For a struct the APCS says that we must return in a register if
-        every addressable element has an offset of zero.  For practical
-        purposes this means that the structure can have at most one non
-        bit-field element and that this element must be the first one in
-        the structure.  */
-
+      /* For a struct the APCS says that we only return in a register
+        if the type is 'integer like' and every addressable element
+        has an offset of zero.  For practical purposes this means
+        that the structure can have at most one non bit-field element
+        and that this element must be the first one in the structure.  */
+      
       /* Find the first field, ignoring non FIELD_DECL things which will
         have been created by C++.  */
       for (field = TYPE_FIELDS (type);
@@ -1420,7 +1420,19 @@ arm_return_in_memory (type)
       if (field == NULL)
        return 0; /* An empty structure.  Allowed by an extension to ANSI C. */
 
-      /* Now check the remaining fields, if any. */
+      /* Check that the first field is valid for returning in a register...  */
+
+      /* ... Floats are not allowed */
+      if (FLOAT_TYPE_P (TREE_TYPE (field)))
+       return 1;
+
+      /* ... Aggregates that are not themselves valid for returning in
+        a register are not allowed.  */
+      if (RETURN_IN_MEMORY (TREE_TYPE (field)))
+       return 1;
+
+      /* Now check the remaining fields, if any.  Only bitfields are allowed,
+        since they are not addressable.  */
       for (field = TREE_CHAIN (field);
           field;
           field = TREE_CHAIN (field))