re PR target/25477 (builtin functions should use $LDBL128 suffix on darwin when appro...
authorFrancois-Xavier Coudert <coudert@clipper.ens.fr>
Sat, 23 Feb 2008 18:42:04 +0000 (19:42 +0100)
committerFrançois-Xavier Coudert <fxcoudert@gcc.gnu.org>
Sat, 23 Feb 2008 18:42:04 +0000 (18:42 +0000)
PR target/25477

* config/darwin-protos.h: Add darwin_patch_builtins prototype.
* config/darwin-ppc-ldouble-patch.def: New file.
* config/rs6000/darwin.h (SUBTARGET_INIT_BUILTINS): New macro.
* config/rs6000/rs6000.c (rs6000_init_builtins): Call
SUBTARGET_INIT_BUILTINS if defined.
* config/darwin.c (darwin_patch_builtin,
darwin_patch_builtins): New functions.

* trans-expr.c (gfc_conv_power_op): Use BUILT_IN_CPOW{F,,L}.
* f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_CPOW{F,,L}.
* trans.h (gfor_fndecl_math_cpow, gfor_fndecl_math_cpowf,
gfor_fndecl_math_cpowl10, gfor_fndecl_math_cpowl16): Remove.
* trans-decl.c: Likewise.

* gfortran.dg/large_real_kind_2.F90: Split testing of ERF and
ERFC into gfortran.dg/large_real_kind_3.F90.
* gfortran.dg/large_real_kind_3.F90: New test.

From-SVN: r132576

14 files changed:
gcc/ChangeLog
gcc/config/darwin-ppc-ldouble-patch.def [new file with mode: 0644]
gcc/config/darwin-protos.h
gcc/config/darwin.c
gcc/config/rs6000/darwin.h
gcc/config/rs6000/rs6000.c
gcc/fortran/ChangeLog
gcc/fortran/f95-lang.c
gcc/fortran/trans-decl.c
gcc/fortran/trans-expr.c
gcc/fortran/trans.h
gcc/testsuite/ChangeLog
gcc/testsuite/gfortran.dg/large_real_kind_2.F90
gcc/testsuite/gfortran.dg/large_real_kind_3.F90 [new file with mode: 0644]

index 9bf9a9d915a1603ae4f50d736494e52cb0f30579..e4af96d6371acb18138727a05bf0878068179fd8 100644 (file)
@@ -1,3 +1,14 @@
+2008-02-23  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR target/25477
+       * config/darwin-protos.h: Add darwin_patch_builtins prototype.
+       * config/darwin-ppc-ldouble-patch.def: New file.
+       * config/rs6000/darwin.h (SUBTARGET_INIT_BUILTINS): New macro.
+       * config/rs6000/rs6000.c (rs6000_init_builtins): Call
+       SUBTARGET_INIT_BUILTINS if defined.
+       * config/darwin.c (darwin_patch_builtin,
+       darwin_patch_builtins): New functions.
+
 2008-02-23  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR rtl-opt/33512
diff --git a/gcc/config/darwin-ppc-ldouble-patch.def b/gcc/config/darwin-ppc-ldouble-patch.def
new file mode 100644 (file)
index 0000000..0d09221
--- /dev/null
@@ -0,0 +1,95 @@
+PATCH_BUILTIN (BUILT_IN_ACOSHL)
+PATCH_BUILTIN (BUILT_IN_ACOSL)
+PATCH_BUILTIN (BUILT_IN_ASINHL)
+PATCH_BUILTIN (BUILT_IN_ASINL)
+PATCH_BUILTIN (BUILT_IN_ATAN2L)
+PATCH_BUILTIN (BUILT_IN_ATANHL)
+PATCH_BUILTIN (BUILT_IN_ATANL)
+PATCH_BUILTIN (BUILT_IN_CABSL)
+PATCH_BUILTIN (BUILT_IN_CACOSHL)
+PATCH_BUILTIN (BUILT_IN_CACOSL)
+PATCH_BUILTIN (BUILT_IN_CARGL)
+PATCH_BUILTIN (BUILT_IN_CASINHL)
+PATCH_BUILTIN (BUILT_IN_CASINL)
+PATCH_BUILTIN (BUILT_IN_CATANHL)
+PATCH_BUILTIN (BUILT_IN_CATANL)
+PATCH_BUILTIN (BUILT_IN_CBRTL)
+PATCH_BUILTIN (BUILT_IN_CCOSHL)
+PATCH_BUILTIN (BUILT_IN_CCOSL)
+PATCH_BUILTIN (BUILT_IN_CEILL)
+PATCH_BUILTIN (BUILT_IN_CEXPL)
+PATCH_BUILTIN (BUILT_IN_CIMAGL)
+PATCH_BUILTIN (BUILT_IN_CLOGL)
+PATCH_BUILTIN (BUILT_IN_CONJL)
+PATCH_BUILTIN (BUILT_IN_COPYSIGNL)
+PATCH_BUILTIN (BUILT_IN_COSHL)
+PATCH_BUILTIN (BUILT_IN_COSL)
+PATCH_BUILTIN (BUILT_IN_CPOWL)
+PATCH_BUILTIN (BUILT_IN_CPROJL)
+PATCH_BUILTIN (BUILT_IN_CREALL)
+PATCH_BUILTIN (BUILT_IN_CSINHL)
+PATCH_BUILTIN (BUILT_IN_CSINL)
+PATCH_BUILTIN (BUILT_IN_CSQRTL)
+PATCH_BUILTIN (BUILT_IN_CTANHL)
+PATCH_BUILTIN (BUILT_IN_CTANL)
+PATCH_BUILTIN (BUILT_IN_ERFCL)
+PATCH_BUILTIN (BUILT_IN_ERFL)
+PATCH_BUILTIN (BUILT_IN_EXP2L)
+PATCH_BUILTIN (BUILT_IN_EXPL)
+PATCH_BUILTIN (BUILT_IN_EXPM1L)
+PATCH_BUILTIN (BUILT_IN_FABSL)
+PATCH_BUILTIN (BUILT_IN_FDIML)
+PATCH_BUILTIN (BUILT_IN_FLOORL)
+PATCH_BUILTIN (BUILT_IN_FMAL)
+PATCH_BUILTIN (BUILT_IN_FMAXL)
+PATCH_BUILTIN (BUILT_IN_FMINL)
+PATCH_BUILTIN (BUILT_IN_FMODL)
+PATCH_BUILTIN (BUILT_IN_FREXPL)
+PATCH_BUILTIN (BUILT_IN_HYPOTL)
+PATCH_BUILTIN (BUILT_IN_ILOGBL)
+PATCH_BUILTIN (BUILT_IN_LDEXPL)
+PATCH_BUILTIN (BUILT_IN_LGAMMAL)
+PATCH_BUILTIN (BUILT_IN_LLRINTL)
+PATCH_BUILTIN (BUILT_IN_LLROUNDL)
+PATCH_BUILTIN (BUILT_IN_LOG10L)
+PATCH_BUILTIN (BUILT_IN_LOG1PL)
+PATCH_BUILTIN (BUILT_IN_LOG2L)
+PATCH_BUILTIN (BUILT_IN_LOGBL)
+PATCH_BUILTIN (BUILT_IN_LOGL)
+PATCH_BUILTIN (BUILT_IN_LRINTL)
+PATCH_BUILTIN (BUILT_IN_LROUNDL)
+PATCH_BUILTIN (BUILT_IN_MODFL)
+PATCH_BUILTIN (BUILT_IN_NEARBYINTL)
+PATCH_BUILTIN (BUILT_IN_NEXTAFTERL)
+PATCH_BUILTIN (BUILT_IN_NEXTTOWARD)
+PATCH_BUILTIN (BUILT_IN_NEXTTOWARDF)
+PATCH_BUILTIN (BUILT_IN_NEXTTOWARDL)
+PATCH_BUILTIN (BUILT_IN_POWL)
+PATCH_BUILTIN (BUILT_IN_REMAINDERL)
+PATCH_BUILTIN (BUILT_IN_REMQUOL)
+PATCH_BUILTIN (BUILT_IN_RINTL)
+PATCH_BUILTIN (BUILT_IN_ROUNDL)
+PATCH_BUILTIN (BUILT_IN_SCALBLNL)
+PATCH_BUILTIN (BUILT_IN_SCALBNL)
+PATCH_BUILTIN (BUILT_IN_SINHL)
+PATCH_BUILTIN (BUILT_IN_SINL)
+PATCH_BUILTIN (BUILT_IN_SQRTL)
+PATCH_BUILTIN (BUILT_IN_TANHL)
+PATCH_BUILTIN (BUILT_IN_TANL)
+PATCH_BUILTIN (BUILT_IN_TGAMMAL)
+PATCH_BUILTIN (BUILT_IN_TRUNCL)
+PATCH_BUILTIN_NO64 (BUILT_IN_VFPRINTF)
+PATCH_BUILTIN_NO64 (BUILT_IN_VFSCANF)
+PATCH_BUILTIN_NO64 (BUILT_IN_VPRINTF)
+PATCH_BUILTIN_NO64 (BUILT_IN_VSCANF)
+PATCH_BUILTIN_NO64 (BUILT_IN_VSNPRINTF)
+PATCH_BUILTIN_NO64 (BUILT_IN_VSPRINTF)
+PATCH_BUILTIN_NO64 (BUILT_IN_VSSCANF)
+
+PATCH_BUILTIN_VARIADIC (BUILT_IN_FPRINTF)
+PATCH_BUILTIN_VARIADIC (BUILT_IN_FSCANF)
+PATCH_BUILTIN_VARIADIC (BUILT_IN_PRINTF)
+PATCH_BUILTIN_VARIADIC (BUILT_IN_SCANF)
+PATCH_BUILTIN_VARIADIC (BUILT_IN_SNPRINTF)
+PATCH_BUILTIN_VARIADIC (BUILT_IN_SPRINTF)
+PATCH_BUILTIN_VARIADIC (BUILT_IN_SSCANF)
index a8ce17c01110a1d3f80723e5a17bf7a14374ceb8..c894bf051047ff57bf29b30fae20c4ceff3196fb 100644 (file)
@@ -89,3 +89,4 @@ extern void darwin_cpp_builtins (struct cpp_reader *);
 extern void darwin_asm_output_anchor (rtx symbol);
 extern bool darwin_kextabi_p (void);
 extern void darwin_override_options (void);
+extern void darwin_patch_builtins (void);
index 307698d095f71b1e76191477f136d13b0d5bfd9a..13aa021f4c676fca487d447737fc21380a9d1a3e 100644 (file)
@@ -1735,4 +1735,52 @@ darwin_override_options (void)
     flag_var_tracking_uninit = 1;
 }
 
+/* Add $LDBL128 suffix to long double builtins.  */
+
+static void
+darwin_patch_builtin (int fncode)
+{
+  tree fn = built_in_decls[fncode];
+  tree sym;
+  char *newname;
+
+  if (!fn)
+    return;
+
+  sym = DECL_ASSEMBLER_NAME (fn);
+  newname = alloca (IDENTIFIER_LENGTH (sym) + 10);
+  strcpy (newname, "_");
+  strcat (newname, IDENTIFIER_POINTER (sym));
+  strcat (newname, "$LDBL128");
+  set_user_assembler_name (fn, newname);
+  /*sym = get_identifier (newname);
+  SET_DECL_ASSEMBLER_NAME (fn, sym);*/
+
+  fn = implicit_built_in_decls[fncode];
+  if (fn)
+    set_user_assembler_name (fn, newname);
+    /*SET_DECL_ASSEMBLER_NAME (fn, sym);*/
+}
+
+void
+darwin_patch_builtins (void)
+{
+  if (LONG_DOUBLE_TYPE_SIZE != 128)
+    return;
+
+#define PATCH_BUILTIN(fncode) darwin_patch_builtin (fncode);
+#define PATCH_BUILTIN_NO64(fncode) \
+  if (!TARGET_64BIT) \
+    darwin_patch_builtin (fncode);
+#define PATCH_BUILTIN_VARIADIC(fncode) \
+  if (!TARGET_64BIT \
+      && (strverscmp (darwin_macosx_version_min, "10.3.9") >= 0)) \
+    darwin_patch_builtin (fncode);
+#include "darwin-ppc-ldouble-patch.def"
+#undef PATCH_BUILTIN
+#undef PATCH_BUILTIN_NO64
+#undef PATCH_BUILTIN_VARIADIC
+}
+
+
 #include "gt-darwin.h"
index 6c88757d24e9c4149047adabf2647457d5919a85..f6c9ee3c2e252aaac03d971d6294523024f1e923 100644 (file)
 /* When generating kernel code or kexts, we don't use Altivec by
    default, as kernel code doesn't save/restore those registers.  */
 #define OS_MISSING_ALTIVEC (flag_mkernel || flag_apple_kext)
+
+/* Darwin has to rename some of the long double builtins.  */
+#define SUBTARGET_INIT_BUILTINS darwin_patch_builtins ()
index fb6aa19659ad8426b4736cd4c48b8fd0c726343b..00a7bc590636c9f769a3f329e007cfee3d46c373 100644 (file)
@@ -9187,6 +9187,10 @@ rs6000_init_builtins (void)
   if (built_in_decls [BUILT_IN_CLOG])
     set_user_assembler_name (built_in_decls [BUILT_IN_CLOG], "__clog");
 #endif
+
+#ifdef SUBTARGET_INIT_BUILTINS
+  SUBTARGET_INIT_BUILTINS;
+#endif
 }
 
 /* Search through a set of builtins and enable the mask bits.
index 0273000265fe6c9ed57457ca0e8ee50491bb3274..89766c62d914c7e7a3d60df126ed5293852ce962 100644 (file)
@@ -1,3 +1,12 @@
+2008-02-23  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       PR target/25477
+       * trans-expr.c (gfc_conv_power_op): Use BUILT_IN_CPOW{F,,L}.
+       * f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_CPOW{F,,L}.
+       * trans.h (gfor_fndecl_math_cpow, gfor_fndecl_math_cpowf,
+       gfor_fndecl_math_cpowl10, gfor_fndecl_math_cpowl16): Remove.
+       * trans-decl.c: Likewise.
+
 2008-02-20  Jerry DeLisle  <jvdelisle@gcc.gnu.org>
 
        PR fortran/34907
index dcc64b9c38d82dd9bc943da3f7f4b45201ccfc98..3056fdb5b5f25bc2abf53931b310f8e1d73619cd 100644 (file)
@@ -942,6 +942,12 @@ gfc_init_builtin_functions (void)
                      BUILT_IN_POW, "pow", true);
   gfc_define_builtin ("__builtin_powf", mfunc_float[1], 
                      BUILT_IN_POWF, "powf", true);
+  gfc_define_builtin ("__builtin_cpowl", mfunc_clongdouble[1], 
+                     BUILT_IN_CPOWL, "cpowl", true);
+  gfc_define_builtin ("__builtin_cpow", mfunc_cdouble[1], 
+                     BUILT_IN_CPOW, "cpow", true);
+  gfc_define_builtin ("__builtin_cpowf", mfunc_cfloat[1], 
+                     BUILT_IN_CPOWF, "cpowf", true);
   gfc_define_builtin ("__builtin_powil", mfunc_longdouble[2], 
                      BUILT_IN_POWIL, "powil", true);
   gfc_define_builtin ("__builtin_powi", mfunc_double[2], 
index 79a3e8b8c316021de76ea5524cd3fc2bf8816e2e..8ca4d430e9870b102b98c872002cc6f1da253ecf 100644 (file)
@@ -99,10 +99,6 @@ tree gfor_fndecl_associated;
    trans-intrinsic.c.  */
 
 gfc_powdecl_list gfor_fndecl_math_powi[4][3];
-tree gfor_fndecl_math_cpowf;
-tree gfor_fndecl_math_cpow;
-tree gfor_fndecl_math_cpowl10;
-tree gfor_fndecl_math_cpowl16;
 tree gfor_fndecl_math_ishftc4;
 tree gfor_fndecl_math_ishftc8;
 tree gfor_fndecl_math_ishftc16;
@@ -2024,10 +2020,6 @@ gfc_build_intrinsic_function_decls (void)
   tree gfc_real8_type_node = gfc_get_real_type (8);
   tree gfc_real10_type_node = gfc_get_real_type (10);
   tree gfc_real16_type_node = gfc_get_real_type (16);
-  tree gfc_complex4_type_node = gfc_get_complex_type (4);
-  tree gfc_complex8_type_node = gfc_get_complex_type (8);
-  tree gfc_complex10_type_node = gfc_get_complex_type (10);
-  tree gfc_complex16_type_node = gfc_get_complex_type (16);
 
   /* String functions.  */
   gfor_fndecl_compare_string =
@@ -2195,25 +2187,6 @@ gfc_build_intrinsic_function_decls (void)
 #undef NRKINDS
   }
 
-  gfor_fndecl_math_cpowf =
-    gfc_build_library_function_decl (get_identifier ("cpowf"),
-                                    gfc_complex4_type_node,
-                                    1, gfc_complex4_type_node);
-  gfor_fndecl_math_cpow =
-    gfc_build_library_function_decl (get_identifier ("cpow"),
-                                    gfc_complex8_type_node,
-                                    1, gfc_complex8_type_node);
-  if (gfc_complex10_type_node)
-    gfor_fndecl_math_cpowl10 =
-      gfc_build_library_function_decl (get_identifier ("cpowl"),
-                                      gfc_complex10_type_node, 1,
-                                      gfc_complex10_type_node);
-  if (gfc_complex16_type_node)
-    gfor_fndecl_math_cpowl16 =
-      gfc_build_library_function_decl (get_identifier ("cpowl"),
-                                      gfc_complex16_type_node, 1,
-                                      gfc_complex16_type_node);
-
   gfor_fndecl_math_ishftc4 =
     gfc_build_library_function_decl (get_identifier (PREFIX("ishftc4")),
                                     gfc_int4_type_node,
index 8d0392fd34756240881531f154d8040ecd6c3d90..37fc7282f1a429b347838e63e44d516aab0fe0f7 100644 (file)
@@ -935,16 +935,14 @@ gfc_conv_power_op (gfc_se * se, gfc_expr * expr)
       switch (kind)
        {
        case 4:
-         fndecl = gfor_fndecl_math_cpowf;
+         fndecl = built_in_decls[BUILT_IN_CPOWF];
          break;
        case 8:
-         fndecl = gfor_fndecl_math_cpow;
+         fndecl = built_in_decls[BUILT_IN_CPOW];
          break;
        case 10:
-         fndecl = gfor_fndecl_math_cpowl10;
-         break;
        case 16:
-         fndecl = gfor_fndecl_math_cpowl16;
+         fndecl = built_in_decls[BUILT_IN_CPOWL];
          break;
        default:
          gcc_unreachable ();
index 9ccf5713bee38342dfbe90e877a475aed3a5fe74..72476888e6b67599e48a1a00daf7b001409d0228 100644 (file)
@@ -526,10 +526,6 @@ typedef struct gfc_powdecl_list GTY(())
 gfc_powdecl_list;
 
 extern GTY(()) gfc_powdecl_list gfor_fndecl_math_powi[4][3];
-extern GTY(()) tree gfor_fndecl_math_cpowf;
-extern GTY(()) tree gfor_fndecl_math_cpow;
-extern GTY(()) tree gfor_fndecl_math_cpowl10;
-extern GTY(()) tree gfor_fndecl_math_cpowl16;
 extern GTY(()) tree gfor_fndecl_math_ishftc4;
 extern GTY(()) tree gfor_fndecl_math_ishftc8;
 extern GTY(()) tree gfor_fndecl_math_ishftc16;
index e53852be3e6427bcb5e96fbb1c51e643fc0a325d..345387349842893f2a42600ee0ec2660f9d42424 100644 (file)
@@ -1,3 +1,9 @@
+2008-02-23  Francois-Xavier Coudert  <coudert@clipper.ens.fr>
+
+       * gfortran.dg/large_real_kind_2.F90: Split testing of ERF and
+       ERFC into gfortran.dg/large_real_kind_3.F90.
+       * gfortran.dg/large_real_kind_3.F90: New test.
+
 2008-02-23  Andrew Pinski  <andrew_pinski@playstation.sony.com>
 
        PR rtl-opt/33512
index 7719cafed4d39ad7af3b6999917191c8f1dfd8a0..2e3891b2ffd16fa9c84ce2837f2a7f0233fe7bc8 100644 (file)
@@ -43,8 +43,6 @@
  TEST_FUNCTION(log,0.00178914)
  TEST_FUNCTION(log10,123789.123)
  TEST_FUNCTION(sqrt,789.1356)
- TEST_FUNCTION(erf,1.45123231)
- TEST_FUNCTION(erfc,-0.123789)
 
  CTEST_FUNCTION(cos,(17.456,-1.123))
  CTEST_FUNCTION(sin,(17.456,-7.6))
diff --git a/gcc/testsuite/gfortran.dg/large_real_kind_3.F90 b/gcc/testsuite/gfortran.dg/large_real_kind_3.F90
new file mode 100644 (file)
index 0000000..0660b49
--- /dev/null
@@ -0,0 +1,24 @@
+! { dg-do run }
+! { dg-require-effective-target fortran_large_real }
+! { dg-xfail-if "" { "*-*-freebsd*" } { "*" }  { "" } }
+
+! Testing erf and erfc library calls on large real kinds (larger than kind=8)
+  implicit none
+
+  integer,parameter :: k = selected_real_kind (precision (0.0_8) + 1)
+  real(8),parameter :: eps = 1e-8
+
+  real(kind=k) :: x
+  real(8) :: y
+
+#define TEST_FUNCTION(func,val) \
+ x = val ;\
+ y = x ;\
+ x = func (x) ;\
+ y = func (y) ;\
+ if (abs((y - x) / y) > eps) call abort
+  
+ TEST_FUNCTION(erf,1.45123231)
+ TEST_FUNCTION(erfc,-0.123789)
+end