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] Vector return on ARM


Hi,

This patch corrects returning vectors from functions on ARM, both with the classic APCS and the new AAPCS. Vectors of word-size or less are returned in r0, and larger vectors are returned in memory. Previously, vector values were always returned in registers, which sometimes caused wrong code (on arm-none-elf) and sometimes ICEd on both arm-none-elf and arm-none-eabi.

Tested on arm-none-elf and arm-none-eabi, with the following improved results:

Tests that now work, but didn't before:

gcc.dg/compat/vector-2 c_compat_x_tst.o compile
gcc.dg/compat/vector-2 c_compat_y_tst.o compile

New tests that PASS:

gcc.dg/compat/vector-2 c_compat_x_tst.o-c_compat_y_tst.o execute
gcc.dg/compat/vector-2 c_compat_x_tst.o-c_compat_y_tst.o link

And on arm-none-elf only (these worked before on arm-none-eabi),

Tests that now work, but didn't before:

g++.dg/ext/attribute-test-1.C execution test
g++.dg/ext/attribute-test-2.C execution test

OK to apply?

ChangeLog:

* config/arm/arm.c (arm_return_in_memory): Handle vector return.
diff -urp ../gcc-nopatch/gcc/config/arm/arm.c ./gcc/config/arm/arm.c
--- ../gcc-nopatch/gcc/config/arm/arm.c	2005-05-11 00:10:51.000000000 +0100
+++ ./gcc/config/arm/arm.c	2005-05-10 19:23:39.000000000 +0100
@@ -2467,7 +2467,8 @@ arm_return_in_memory (tree type)
   HOST_WIDE_INT size;
 
   if (!AGGREGATE_TYPE_P (type) &&
-      !(TARGET_AAPCS_BASED && TREE_CODE (type) == COMPLEX_TYPE))
+      !(TARGET_AAPCS_BASED && TREE_CODE (type) == COMPLEX_TYPE) &&
+      TREE_CODE (type) != VECTOR_TYPE)
     /* All simple types are returned in registers.
        For AAPCS, complex types are treated the same as aggregates.  */
     return 0;
@@ -2491,6 +2492,10 @@ arm_return_in_memory (tree type)
   if (size < 0 || size > UNITS_PER_WORD)
     return 1;
 
+  /* Return vector types smaller than a word in registers.  */
+  if (TREE_CODE (type) == VECTOR_TYPE && size <= UNITS_PER_WORD)
+    return 0;
+
   if (TREE_CODE (type) == RECORD_TYPE)
     {
       tree field;

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