* gcc/config/rs6000/rs6000.c (rs6000_override_options)
authorHartmut Penner <hpenner@de.ibm.com>
Wed, 11 Feb 2004 09:00:08 +0000 (09:00 +0000)
committerHartmut Penner <hpenner@gcc.gnu.org>
Wed, 11 Feb 2004 09:00:08 +0000 (09:00 +0000)
       Set AltiVec ABI and vrsave as default for ppc64 linux.
       (init_cumulative_args): Post error, if try to return
       value in AltiVec register without enable AltiVec.
       (function_arg_advance): Ditto for passing arguments.

From-SVN: r77642

gcc/ChangeLog
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/ppc64-abi-3.c [new file with mode: 0644]

index 6a6d685..ea05ce0 100644 (file)
@@ -1,3 +1,11 @@
+2004-02-11  Hartmut Penner  <hpenner@de.ibm.com>
+
+       * gcc/config/rs6000/rs6000.c (rs6000_override_options)
+       Set AltiVec ABI and vrsave as default for ppc64 linux.
+       (init_cumulative_args): Post error, if try to return
+       value in AltiVec register without enable AltiVec.
+       (function_arg_advance): Ditto for passing arguments. 
+
 2004-02-11  Richard Sandiford  <rsandifo@redhat.com>
 
        * emit-rtl.c (mark_label_nuses): Check that a LABEL_REF refers to
index f0bdd74..59cd623 100644 (file)
@@ -836,6 +836,13 @@ rs6000_override_options (const char *default_cpu)
        rs6000_long_double_type_size = size;
     }
 
+  /* Set Altivec ABI as default for powerpc64 linux.  */
+  if (TARGET_ELF && TARGET_64BIT)
+    {
+      rs6000_altivec_abi = 1;
+      rs6000_altivec_vrsave = 1;
+    }
+
   /* Handle -mabi= options.  */
   rs6000_parse_abi_options ();
 
@@ -3836,6 +3843,16 @@ init_cumulative_args (CUMULATIVE_ARGS *cum, tree fntype,
       fprintf (stderr, " proto = %d, nargs = %d\n",
               cum->prototype, cum->nargs_prototype);
     }
+  
+    if (fntype 
+       && !TARGET_ALTIVEC 
+       && TARGET_ALTIVEC_ABI
+        && ALTIVEC_VECTOR_MODE (TYPE_MODE (TREE_TYPE (fntype))))
+      {
+       error ("Cannot return value in vector register because"
+              " altivec instructions are disabled, use -maltivec"
+              " to enable them.");
+      }
 }
 \f
 /* If defined, a C expression which determines whether, and in which
@@ -3928,8 +3945,13 @@ function_arg_advance (CUMULATIVE_ARGS *cum, enum machine_mode mode,
   if (TARGET_ALTIVEC_ABI && ALTIVEC_VECTOR_MODE (mode))
     {
       if (USE_ALTIVEC_FOR_ARG_P (cum, mode, type, named))
-       cum->vregno++;
-      
+        {
+         cum->vregno++;
+         if (!TARGET_ALTIVEC)
+           error ("Cannot pass argument in vector register because"
+                  " altivec instructions are disabled, use -maltivec"
+                  " to enable them.");
+       }
       /* PowerPC64 Linux and AIX allocates GPRs for a vector argument
         even if it is going to be passed in a vector register.  
         Darwin does the same for variable-argument functions.  */
index a22f644..d49569a 100644 (file)
@@ -1,3 +1,7 @@
+2004-02-11  Hartmut Penner  <hpenner@de.ibm.com>
+
+        * gcc.dg/ppc64-abi-3.c: New test.
+
 2004-02-10  Paolo Bonzini  <bonzini@gnu.org>
 
        PR c/14092
diff --git a/gcc/testsuite/gcc.dg/ppc64-abi-3.c b/gcc/testsuite/gcc.dg/ppc64-abi-3.c
new file mode 100644 (file)
index 0000000..58f161d
--- /dev/null
@@ -0,0 +1,28 @@
+/* { dg-do compile { target powerpc64-*-linux* } } */
+/* { dg-options "-Wall" } */
+/* Testcase to check for ABI compliance of parameter passing
+   for the PowerPC64 ABI.  */
+
+typedef int __attribute__((mode(V4SI))) v4si;
+typedef int __attribute__((mode(V2SI))) v2si;
+
+v4si 
+f(v4si v)
+{ /* { dg-error "altivec instructions are disabled" } */
+    return v;
+}
+
+v2si 
+g(v2si v)
+{
+    return v;
+}
+
+int 
+main()
+{
+    v4si v;
+    v2si w;
+    v = f (v); /* { dg-error "altivec instructions are disabled" } */
+    w = g (w);
+}