This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran 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][fortran] Handle c99 builtins via .def mechanism


This adds another file with builtin definitions, c99builtins.def,
where C99 builtins used by the middle-end or for optimization
purposes can be put.

Build and tested on x86_64-unknown-linux-gnu.

Ok for mainline?

Richard.


2005-12-06  Richard Guenther  <rguenther@suse.de>

	* f95-lang.c (gfc_init_builtin_functions): Remove special
	handling of round, trunc, copysign and pow.  Include
	c99builtins.def.
	* c99builtins.def: New file.
	* Make-lang.in (fortran/f95-lang.o): Add c99builtins.def
	dependency.

Index: fortran/f95-lang.c
===================================================================
--- fortran/f95-lang.c	(revision 108015)
+++ fortran/f95-lang.c	(working copy)
@@ -819,45 +819,15 @@
     build_function_type (long_double_type_node, tmp);
 
 #include "mathbuiltins.def"
+#include "c99builtins.def"
 
-  /* We define these separately as the fortran versions have different
-     semantics (they return an integer type) */
-  gfc_define_builtin ("__builtin_roundl", mfunc_longdouble[0], 
-		      BUILT_IN_ROUNDL, "roundl", true);
-  gfc_define_builtin ("__builtin_round", mfunc_double[0], 
-		      BUILT_IN_ROUND, "round", true);
-  gfc_define_builtin ("__builtin_roundf", mfunc_float[0], 
-		      BUILT_IN_ROUNDF, "roundf", true);
-
-  gfc_define_builtin ("__builtin_truncl", mfunc_longdouble[0],
-		      BUILT_IN_TRUNCL, "truncl", true);
-  gfc_define_builtin ("__builtin_trunc", mfunc_double[0],
-                      BUILT_IN_TRUNC, "trunc", true);
-  gfc_define_builtin ("__builtin_truncf", mfunc_float[0],
-                      BUILT_IN_TRUNCF, "truncf", true);
-
   gfc_define_builtin ("__builtin_cabsl", func_clongdouble_longdouble, 
 		      BUILT_IN_CABSL, "cabsl", true);
   gfc_define_builtin ("__builtin_cabs", func_cdouble_double, 
 		      BUILT_IN_CABS, "cabs", true);
   gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, 
 		      BUILT_IN_CABSF, "cabsf", true);
- 
-  gfc_define_builtin ("__builtin_copysignl", mfunc_longdouble[1], 
-		      BUILT_IN_COPYSIGNL, "copysignl", true);
-  gfc_define_builtin ("__builtin_copysign", mfunc_double[1], 
-		      BUILT_IN_COPYSIGN, "copysign", true);
-  gfc_define_builtin ("__builtin_copysignf", mfunc_float[1], 
-		      BUILT_IN_COPYSIGNF, "copysignf", true);
 
-  /* These are used to implement the ** operator.  */
-  gfc_define_builtin ("__builtin_powl", mfunc_longdouble[1], 
-		      BUILT_IN_POWL, "powl", true);
-  gfc_define_builtin ("__builtin_pow", mfunc_double[1], 
-		      BUILT_IN_POW, "pow", true);
-  gfc_define_builtin ("__builtin_powf", mfunc_float[1], 
-		      BUILT_IN_POWF, "powf", true);
-
   /* Other builtin functions we use.  */
 
   tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node);
Index: fortran/c99builtins.def
===================================================================
--- fortran/c99builtins.def	(revision 0)
+++ fortran/c99builtins.def	(revision 0)
@@ -0,0 +1,14 @@
+/* DEFINE_MATH_BUILTIN (CODE, NAME, ARGTYPE)
+   NAME	  The name of the builtin
+   SNAME  The name of the builtin as a string
+   ARGTYPE The type of the arguments.  See f95-lang.c
+
+   Use DEFINE_MATH_BUILTIN_C if the complex versions of the builtin are
+   also available.
+
+   This list is for C99 builtins used by the middle-end that do
+   not have a corresponding intrinsic in the fortran frontend.  */
+DEFINE_MATH_BUILTIN   (COPYSIGN, "copysign", 1)
+DEFINE_MATH_BUILTIN   (POW,   "pow",    1)
+DEFINE_MATH_BUILTIN   (ROUND, "round",  0)
+DEFINE_MATH_BUILTIN   (TRUNC, "trunc",  0)
Index: fortran/Make-lang.in
===================================================================
--- fortran/Make-lang.in	(revision 108015)
+++ fortran/Make-lang.in	(working copy)
@@ -276,7 +276,8 @@
     $(CONFIG_H) $(SYSTEM_H) $(TREE_H) $(TM_H) coretypes.h $(GGC_H)
 
 fortran/f95-lang.o: $(GFORTRAN_TRANS_DEPS) fortran/mathbuiltins.def \
-  gt-fortran-f95-lang.h gtype-fortran.h cgraph.h $(TARGET_H)
+  fortran/c99builtins.def gt-fortran-f95-lang.h gtype-fortran.h cgraph.h \
+  $(TARGET_H)
 fortran/convert.o: $(GFORTRAN_TRANS_DEPS)
 fortran/trans.o: $(GFORTRAN_TRANS_DEPS)
 fortran/trans-decl.o: $(GFORTRAN_TRANS_DEPS) gt-fortran-trans-decl.h \


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