[PATCH][fortran] Make sincos, cexpi and cbrt available
Richard Guenther
rguenther@suse.de
Wed Jan 17 21:40:00 GMT 2007
This makes said functions available from the fortran frontend for
use by the middle-end conditional on TARGET_C99_FUNCTIONS and
TARGET_GNU_SINCOS.
Bootstrap and regtest in progress, ok if it passes?
Thanks,
Richard.
2007-01-17 Richard Guenther <rguenther@suse.de>
* f95-lang.c (gfc_init_builtin_functions): Provide cbrt and
cexpi builtins if we have TARGET_C99_FUNCTIONS. Provide
sincos builtins if the target has sincos.
Index: fortran/f95-lang.c
===================================================================
*** fortran/f95-lang.c (revision 120875)
--- fortran/f95-lang.c (working copy)
*************** gfc_init_builtin_functions (void)
*** 852,861 ****
tree mfunc_cfloat[3];
tree mfunc_cdouble[3];
tree mfunc_clongdouble[3];
! tree func_cfloat_float;
! tree func_cdouble_double;
! tree func_clongdouble_longdouble;
! tree ftype;
tree tmp;
tree builtin_types[(int) BT_LAST + 1];
--- 852,864 ----
tree mfunc_cfloat[3];
tree mfunc_cdouble[3];
tree mfunc_clongdouble[3];
! tree func_cfloat_float, func_float_cfloat;
! tree func_cdouble_double, func_double_cdouble;
! tree func_clongdouble_longdouble, func_longdouble_clongdouble;
! tree func_float_floatp_floatp;
! tree func_double_doublep_doublep;
! tree func_longdouble_longdoublep_longdoublep;
! tree ftype, ptype;
tree tmp;
tree builtin_types[(int) BT_LAST + 1];
*************** gfc_init_builtin_functions (void)
*** 869,881 ****
--- 872,915 ----
tmp = tree_cons (NULL_TREE, complex_float_type_node, void_list_node);
func_cfloat_float = build_function_type (float_type_node, tmp);
+ tmp = tree_cons (NULL_TREE, float_type_node, void_list_node);
+ func_float_cfloat = build_function_type (complex_float_type_node, tmp);
+
tmp = tree_cons (NULL_TREE, complex_double_type_node, void_list_node);
func_cdouble_double = build_function_type (double_type_node, tmp);
+ tmp = tree_cons (NULL_TREE, double_type_node, void_list_node);
+ func_double_cdouble = build_function_type (complex_double_type_node, tmp);
+
tmp = tree_cons (NULL_TREE, complex_long_double_type_node, void_list_node);
func_clongdouble_longdouble =
build_function_type (long_double_type_node, tmp);
+ tmp = tree_cons (NULL_TREE, long_double_type_node, void_list_node);
+ func_longdouble_clongdouble =
+ build_function_type (complex_long_double_type_node, tmp);
+
+ ptype = build_pointer_type (float_type_node);
+ tmp = tree_cons (NULL_TREE, float_type_node,
+ tree_cons (NULL_TREE, ptype,
+ build_tree_list (NULL_TREE, ptype)));
+ func_float_floatp_floatp =
+ build_function_type (void_type_node, tmp);
+
+ ptype = build_pointer_type (double_type_node);
+ tmp = tree_cons (NULL_TREE, double_type_node,
+ tree_cons (NULL_TREE, ptype,
+ build_tree_list (NULL_TREE, ptype)));
+ func_double_doublep_doublep =
+ build_function_type (void_type_node, tmp);
+
+ ptype = build_pointer_type (long_double_type_node);
+ tmp = tree_cons (NULL_TREE, long_double_type_node,
+ tree_cons (NULL_TREE, ptype,
+ build_tree_list (NULL_TREE, ptype)));
+ func_longdouble_longdoublep_longdoublep =
+ build_function_type (void_type_node, tmp);
+
#include "mathbuiltins.def"
/* We define these separately as the fortran versions have different
*************** gfc_init_builtin_functions (void)
*** 923,928 ****
--- 957,989 ----
gfc_define_builtin ("__builtin_powf", mfunc_float[1],
BUILT_IN_POWF, "powf", true);
+ if (TARGET_C99_FUNCTIONS)
+ {
+ gfc_define_builtin ("__builtin_cbrtl", mfunc_longdouble[0],
+ BUILT_IN_CBRTL, "cbrtl", true);
+ gfc_define_builtin ("__builtin_cbrt", mfunc_double[0],
+ BUILT_IN_CBRT, "cbrt", true);
+ gfc_define_builtin ("__builtin_cbrtf", mfunc_float[0],
+ BUILT_IN_CBRTF, "cbrtf", true);
+ gfc_define_builtin ("__builtin_cexpil", func_longdouble_clongdouble,
+ BUILT_IN_CEXPIL, "cexpil", true);
+ gfc_define_builtin ("__builtin_cexpi", func_double_cdouble,
+ BUILT_IN_CEXPI, "cexpi", true);
+ gfc_define_builtin ("__builtin_cexpif", func_float_cfloat,
+ BUILT_IN_CEXPIF, "cexpif", true);
+ }
+
+ if (TARGET_GNU_SINCOS)
+ {
+ gfc_define_builtin ("__builtin_sincosl",
+ func_longdouble_longdoublep_longdoublep,
+ BUILT_IN_SINCOSL, "sincosl", false);
+ gfc_define_builtin ("__builtin_sincos", func_double_doublep_doublep,
+ BUILT_IN_SINCOS, "sincos", false);
+ gfc_define_builtin ("__builtin_sincosf", func_float_floatp_floatp,
+ BUILT_IN_SINCOSF, "sincosf", false);
+ }
+
/* Other builtin functions we use. */
tmp = tree_cons (NULL_TREE, long_integer_type_node, void_list_node);
More information about the Gcc-patches
mailing list