rs6000-protos.h (rs6000_builtin_is_supported_p): New prototype.
authorKelvin Nilsen <kelvin@gcc.gnu.org>
Tue, 17 Apr 2018 18:58:08 +0000 (18:58 +0000)
committerKelvin Nilsen <kelvin@gcc.gnu.org>
Tue, 17 Apr 2018 18:58:08 +0000 (18:58 +0000)
gcc/ChangeLog:

2018-04-13  Kelvin Nilsen  <kelvin@gcc.gnu.org>

* config/rs6000/rs6000-protos.h (rs6000_builtin_is_supported_p):
New prototype.
* config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
Add note to error message to explain internal mapping of overloaded
built-in function name to non-overloaded built-in function name.
* config/rs6000/rs6000.c (rs6000_builtin_is_supported_p): New
function.

gcc/testsuite/ChangeLog:

2018-04-13  Kelvin Nilsen  <kelvin@gcc.gnu.org>

* gcc.target/powerpc/bfp/scalar-extract-sig-5.c: Simplify to
prevent cascading of errors and change expected error message.
* gcc.target/powerpc/bfp/scalar-test-neg-4.c: Restrict this test
to 64-bit targets.
* gcc.target/powerpc/bfp/scalar-test-data-class-8.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-data-class-9.c: Likewise.
* gcc.target/powerpc/bfp/scalar-test-data-class-10.c: Likewise.
* gcc.target/powerpc/bfp/scalar-insert-exp-11.c: Change expected
error message.
* gcc.target/powerpc/bfp/scalar-extract-exp-5.c: Likewise.

From-SVN: r259442

12 files changed:
gcc/ChangeLog
gcc/config/rs6000/rs6000-c.c
gcc/config/rs6000/rs6000-protos.h
gcc/config/rs6000/rs6000.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/bfp/scalar-extract-exp-5.c
gcc/testsuite/gcc.target/powerpc/bfp/scalar-extract-sig-5.c
gcc/testsuite/gcc.target/powerpc/bfp/scalar-insert-exp-11.c
gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-data-class-10.c
gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-data-class-8.c
gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-data-class-9.c
gcc/testsuite/gcc.target/powerpc/bfp/scalar-test-neg-4.c

index 54dfb4ff35164b30a73c890e8200173d770df18b..a136e541e13f576531bcbd5d87ccfd2db7a5ec54 100644 (file)
@@ -1,3 +1,13 @@
+2018-04-17  Kelvin Nilsen  <kelvin@gcc.gnu.org>
+
+       * config/rs6000/rs6000-protos.h (rs6000_builtin_is_supported_p):
+       New prototype.
+       * config/rs6000/rs6000-c.c (altivec_resolve_overloaded_builtin):
+       Add note to error message to explain internal mapping of overloaded
+       built-in function name to non-overloaded built-in function name.
+       * config/rs6000/rs6000.c (rs6000_builtin_is_supported_p): New
+       function.
+
 2018-04-17  Michael Meissner  <meissner@linux.vnet.ibm.com>
 
        PR target/85424
index bdf6405557e1abbdd324d3c048cbec423b7c1a90..8ed22011b1800236765dfa683b59ed138277e965 100644 (file)
@@ -6894,6 +6894,8 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
 
   {
     bool unsupported_builtin = false;
+    enum rs6000_builtins overloaded_code;
+    tree result = NULL;
     for (desc = altivec_overloaded_builtins;
         desc->code && desc->code != fcode; desc++)
       continue;
@@ -6906,7 +6908,6 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
        discrimination between the desired forms of the function.  */
     if (fcode == P6_OV_BUILTIN_CMPB)
       {
-       int overloaded_code;
        machine_mode arg1_mode = TYPE_MODE (types[0]);
        machine_mode arg2_mode = TYPE_MODE (types[1]);
 
@@ -6941,14 +6942,20 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
            && rs6000_builtin_type_compatible (types[1], desc->op2))
          {
            if (rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
-             return altivec_build_resolved_builtin (args, n, desc);
+             {
+               result = altivec_build_resolved_builtin (args, n, desc);
+               /* overloaded_code is set above */
+               if (!rs6000_builtin_is_supported_p (overloaded_code))
+                 unsupported_builtin = true;
+               else
+                 return result;
+             }
            else
              unsupported_builtin = true;
          }
       }
     else if (fcode == P9V_BUILTIN_VEC_VSIEDP)
       {
-       int overloaded_code;
        machine_mode arg1_mode = TYPE_MODE (types[0]);
 
        if (nargs != 2)
@@ -6983,12 +6990,20 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
        while (desc->code && desc->code == fcode
               && desc->overloaded_code != overloaded_code)
          desc++;
+
        if (desc->code && (desc->code == fcode)
            && rs6000_builtin_type_compatible (types[0], desc->op1)
            && rs6000_builtin_type_compatible (types[1], desc->op2))
          {
            if (rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
-             return altivec_build_resolved_builtin (args, n, desc);
+             {
+               result = altivec_build_resolved_builtin (args, n, desc);
+               /* overloaded_code is set above.  */
+               if (!rs6000_builtin_is_supported_p (overloaded_code))
+                 unsupported_builtin = true;
+               else
+                 return result;
+             }
            else
              unsupported_builtin = true;
          }
@@ -7007,7 +7022,18 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
                    || rs6000_builtin_type_compatible (types[2], desc->op3)))
              {
                if (rs6000_builtin_decls[desc->overloaded_code] != NULL_TREE)
-                 return altivec_build_resolved_builtin (args, n, desc);
+                 {
+                   result = altivec_build_resolved_builtin (args, n, desc);
+                   if (!rs6000_builtin_is_supported_p (desc->overloaded_code))
+                     {
+                       /* Allow loop to continue in case a different
+                          definition is supported.  */
+                       overloaded_code = desc->overloaded_code;
+                       unsupported_builtin = true;
+                     }
+                   else
+                     return result;
+                 }
                else
                  unsupported_builtin = true;
              }
@@ -7017,9 +7043,23 @@ altivec_resolve_overloaded_builtin (location_t loc, tree fndecl,
     if (unsupported_builtin)
       {
        const char *name = rs6000_overloaded_builtin_name (fcode);
-       error ("builtin function %qs not supported in this compiler "
-              "configuration", name);
-       return error_mark_node;
+       if (result != NULL)
+         {
+           const char *internal_name
+             = rs6000_overloaded_builtin_name (overloaded_code);
+           /* An error message making reference to the name of the
+              non-overloaded function has already been issued.  Add
+              clarification of the previous message.  */
+           rich_location richloc (line_table, input_location);
+           inform (&richloc, "builtin %qs requires builtin %qs",
+                   name, internal_name);
+         }
+       else
+         error ("builtin function %qs not supported in this compiler "
+                "configuration", name);
+       /* If an error-representing  result tree was returned from
+          altivec_build_resolved_builtin above, use it.  */
+       return (result != NULL) ? result : error_mark_node;
       }
   }
  bad:
index b1e8cf66c540662aa3ee1958ae1a6411fe174c02..d22486037532c38b313a9ac951d1a0c336f66f7f 100644 (file)
@@ -212,6 +212,7 @@ extern void rs6000_sibcall_aix (rtx, rtx, rtx, rtx);
 extern void rs6000_aix_asm_output_dwarf_table_ref (char *);
 extern void get_ppc476_thunk_name (char name[32]);
 extern bool rs6000_overloaded_builtin_p (enum rs6000_builtins);
+extern bool rs6000_builtin_is_supported_p (enum rs6000_builtins);
 extern const char *rs6000_overloaded_builtin_name (enum rs6000_builtins);
 extern int rs6000_store_data_bypass_p (rtx_insn *, rtx_insn *);
 extern HOST_WIDE_INT rs6000_builtin_mask_calculate (void);
index c74e2a39d80dcb9649876f683f434cbb5c4c3070..fd11407367e6474dbae51e7891466925cc0367eb 100644 (file)
@@ -15905,6 +15905,18 @@ paired_expand_predicate_builtin (enum insn_code icode, tree exp, rtx target)
   return target;
 }
 
+/* Check whether a builtin function is supported in this target
+   configuration.  */
+bool
+rs6000_builtin_is_supported_p (enum rs6000_builtins fncode)
+{
+  HOST_WIDE_INT fnmask = rs6000_builtin_info[fncode].mask;
+  if ((fnmask & rs6000_builtin_mask) != fnmask)
+    return false;
+  else
+    return true;
+}
+
 /* Raise an error message for a builtin function that is called without the
    appropriate target options being set.  */
 
index f0d6035123ea5786154709a9affd903331176e14..b07c42a75d070c1192cb3dbab055ec11fba8a2b6 100644 (file)
@@ -1,3 +1,16 @@
+2018-04-13  Kelvin Nilsen  <kelvin@gcc.gnu.org>
+
+       * gcc.target/powerpc/bfp/scalar-extract-sig-5.c: Simplify to
+       prevent cascading of errors and change expected error message.
+       * gcc.target/powerpc/bfp/scalar-test-neg-4.c: Restrict this test
+       to 64-bit targets.
+       * gcc.target/powerpc/bfp/scalar-test-data-class-8.c: Likewise.
+       * gcc.target/powerpc/bfp/scalar-test-data-class-9.c: Likewise.
+       * gcc.target/powerpc/bfp/scalar-test-data-class-10.c: Likewise.
+       * gcc.target/powerpc/bfp/scalar-insert-exp-11.c: Change expected
+       error message.
+       * gcc.target/powerpc/bfp/scalar-extract-exp-5.c: Likewise.
+
 2018-04-17  Jakub Jelinek  <jakub@redhat.com>
 
        PR target/85430
index 739ccc7a6b184f7c223da254cb435e208b739a81..0f9f952a971ca5a09e238f9c9a01fc22d26f4a43 100644 (file)
@@ -15,7 +15,7 @@ get_exponent (__ieee128 *p)
 {
   __ieee128 source = *p;
 
-  return scalar_extract_exp (source);  /* { dg-error "builtin function '__builtin_vec_scalar_extract_exp' not supported in this compiler configuration" } */
+  return scalar_extract_exp (source);  /* { dg-error "requires ISA 3.0 IEEE 128-bit floating point" } */
 }
 
 
index f82bbe0262d5b75e1eddad5a19beddbf30f7daa3..e2f091b88bae32462964bb3e30c6110a5f9a6157 100644 (file)
@@ -8,10 +8,10 @@
    error because the builtin requires 64 bits.  */
 #include <altivec.h>
 
-unsigned __int128 /* { dg-error "'__int128' is not supported on this target" } */
+unsigned long long int
 get_significand (__ieee128 *p)
 {
   __ieee128 source = *p;
 
-  return __builtin_vec_scalar_extract_sig (source); /* { dg-error "builtin function '__builtin_vec_scalar_extract_sig' not supported in this compiler configuration" } */
+  return (long long int) __builtin_vec_scalar_extract_sig (source); /* { dg-error "requires ISA 3.0 IEEE 128-bit floating point" } */
 }
index 3e47a69a0f44df63d1a8d0b585487f9156b4de6a..8c8255ac5c053dd12ed58093a52d158dce242558 100644 (file)
@@ -17,5 +17,5 @@ insert_exponent (__ieee128 *significand_p,
   __ieee128 significand = *significand_p;
   unsigned long long int exponent = *exponent_p;
 
-  return scalar_insert_exp (significand, exponent); /* { dg-error "builtin function '__builtin_vec_scalar_insert_exp' not supported in this compiler configuration" } */
+  return scalar_insert_exp (significand, exponent); /* { dg-error "requires ISA 3.0 IEEE 128-bit floating point" } */
 }
index 32fd8b1deeeff957c8613b6492d7133014d4c4fb..c125988eaabc0ec7ab0547ccc35d891285fbf766 100644 (file)
@@ -1,5 +1,8 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* Require 64-bit target to select expected error message below.  32-bit
+   target produces different error message.  */
+/* { dg-require-effective-target lp64 } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-options "-mcpu=power9" } */
 
index 25192506992c2ddb0413975796a397e04e4fa3b6..e7cf68e74648ffea2d076898265669ebe00afe14 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target lp64 } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-options "-mcpu=power9" } */
 
@@ -11,6 +12,8 @@ test_data_class (__ieee128 *p)
 {
   __ieee128 source = *p;
 
+  /* IEEE 128-bit floating point operations are only supported
+     on 64-bit targets.  */
   return scalar_test_data_class (source, 3);
 }
 
index 28c1e090ce5c3994df5c5e77252f1105f8e421f1..27e62bd8fef3e54a67758a7b883896039db73939 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target lp64 } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-options "-mcpu=power9" } */
 
@@ -11,6 +12,8 @@ test_data_class (__ieee128 *p)
 {
   __ieee128 source = *p;
 
+  /* IEEE 128-bit floating point operations are only supported
+     on 64-bit targets.  */
   return scalar_test_data_class (source, 256); /* { dg-error "argument 2 must be a 7-bit unsigned literal" } */
 }
 
index 13fee32cdf8f120d747526fe2152b7b17c4299fa..535bf60ae6ecd3d38c71752a5fee10be4719fe39 100644 (file)
@@ -1,5 +1,6 @@
 /* { dg-do compile { target { powerpc*-*-* } } } */
 /* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { "-mcpu=power9" } } */
+/* { dg-require-effective-target lp64 } */
 /* { dg-require-effective-target powerpc_p9vector_ok } */
 /* { dg-options "-mcpu=power9" } */
 
@@ -11,6 +12,8 @@ test_neg (__ieee128 *p)
 {
   __ieee128 source = *p;
 
+  /* IEEE 128-bit floating point operations are only supported
+     on 64-bit targets.  */
   return scalar_test_neg (source);
 }