diff options
author | Steven G. Kargl <kargls@comcast.net> | 2004-08-29 15:58:16 +0000 |
---|---|---|
committer | Paul Brook <pbrook@gcc.gnu.org> | 2004-08-29 15:58:16 +0000 |
commit | e8525382d986350f38193ca20504631bfadc43ba (patch) | |
tree | 764a8802dba0b681b9c0d6f4248a2b2513c2b2fc /gcc/fortran/f95-lang.c | |
parent | 766ff1b11748f66da98c901b9498a90e72698c05 (diff) | |
download | gcc-e8525382d986350f38193ca20504631bfadc43ba.zip gcc-e8525382d986350f38193ca20504631bfadc43ba.tar.gz gcc-e8525382d986350f38193ca20504631bfadc43ba.tar.bz2 |
check.c (gfc_check_besn, [...]): New functions.
2004-08-29 Steven G. Kargl <kargls@comcast.net>
Paul Brook <paul@codesourcery.com>
* check.c (gfc_check_besn, gfc_check_g77_math1): New functions.
* f95-lang.c (DO_DEFINE_MATH_BUILTIN): Define.
(DEFINE_MATH_BUILTIN, DEFINE_MATH_BUILTIN_C): Use it.
(build_builtin_fntypes): New function.
(gfc_init_builtin_functions): Use it.
* gfortran.h (enum gfc_generic_isym_id): Add GFC_ISYM_{J,Y}{0,1,N}
and GFC_ISYM_ERF{,C}.
(gfc_c_int_kind): Declare.
* intrinsic.c (add_functions): Add [d]bes* and [d]erf*.
* intrinsic.h (gfc_check_besn, gfc_check_g77_math1, gfc_resolve_besn,
gfc_resolve_g77_math1): Add prototypes.
* resolve.c (gfc_resolve_besn, gfc_resolve_g77_math1): New functions.
* mathbuiltins.def: Add comment. Change third argument. Use
DEFINE_MATH_BUILTIN_C. Add bessel and error functions.
* trans-intrinsic.c (BUILT_IN_FUNCTION): Define.
(DEFINE_MATH_BUILTIN, DEFINE_MATH_BUILTIN_C): Use it.
* trans-types.c (gfc_c_int_kind): Declare.
(gfc_init_kinds): Set it.
testsuite/
* gfortran.dg/g77/README: Update.
* gfortran.dg/g77/erfc.f: Copy from g77.f-torture.
* gfortran.dg/g77/intrinsic-unix-bessel.f: Ditto.
* gfortran.dg/g77/intrinsic-unix-erf.f: Ditto.
libgfortran/
* intrinsics/bessel.c: New file.
* intrinsics/erf.c: New file.
* Makefie.am: Add intrinsics/bessel.c and intrinsics/erf.c.
* configure.ac: Test for C99 Bessel and Error functions.
* Makefile.in: Regenerate.
* config.h.in: Regenerate.
* configure: Regenerate.
Co-Authored-By: Paul Brook <paul@codesourcery.com>
From-SVN: r86727
Diffstat (limited to 'gcc/fortran/f95-lang.c')
-rw-r--r-- | gcc/fortran/f95-lang.c | 61 |
1 files changed, 44 insertions, 17 deletions
diff --git a/gcc/fortran/f95-lang.c b/gcc/fortran/f95-lang.c index 673e208..b822a89 100644 --- a/gcc/fortran/f95-lang.c +++ b/gcc/fortran/f95-lang.c @@ -712,38 +712,64 @@ gfc_define_builtin (const char * name, } -#define DEFINE_MATH_BUILTIN(code, name, nargs) \ - gfc_define_builtin ("__builtin_" name, mfunc_double[nargs-1], \ +#define DO_DEFINE_MATH_BUILTIN(code, name, argtype, tbase) \ + gfc_define_builtin ("__builtin_" name, tbase##double[argtype], \ BUILT_IN_ ## code, name, true); \ - gfc_define_builtin ("__builtin_" name "f", mfunc_float[nargs-1], \ + gfc_define_builtin ("__builtin_" name "f", tbase##float[argtype], \ BUILT_IN_ ## code ## F, name "f", true); +#define DEFINE_MATH_BUILTIN(code, name, argtype) \ + DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) + +/* The middle-end is missing builtins for some complex math functions, so + we don't use them yet. */ +#define DEFINE_MATH_BUILTIN_C(code, name, argtype) \ + DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) +/* DO_DEFINE_MATH_BUILTIN (C##code, "c" name, argtype, mfunc_c)*/ + + +/* Create function types for builtin functions. */ + +static void +build_builtin_fntypes (tree * fntype, tree type) +{ + tree tmp; + + /* type (*) (type) */ + tmp = tree_cons (NULL_TREE, float_type_node, void_list_node); + fntype[0] = build_function_type (type, tmp); + /* type (*) (type, type) */ + tmp = tree_cons (NULL_TREE, float_type_node, tmp); + fntype[1] = build_function_type (type, tmp); + /* type (*) (int, type) */ + tmp = tree_cons (NULL_TREE, integer_type_node, void_list_node); + tmp = tree_cons (NULL_TREE, type, tmp); + fntype[2] = build_function_type (type, tmp); +} + + /* Initialisation of builtin function nodes. */ + static void gfc_init_builtin_functions (void) { - tree mfunc_float[2]; - tree mfunc_double[2]; + tree mfunc_float[3]; + tree mfunc_double[3]; + tree mfunc_cfloat[3]; + tree mfunc_cdouble[3]; tree func_cfloat_float; tree func_cdouble_double; tree ftype; tree tmp; - tmp = tree_cons (NULL_TREE, float_type_node, void_list_node); - mfunc_float[0] = build_function_type (float_type_node, tmp); - tmp = tree_cons (NULL_TREE, float_type_node, tmp); - mfunc_float[1] = build_function_type (float_type_node, tmp); - + build_builtin_fntypes (mfunc_float, float_type_node); + build_builtin_fntypes (mfunc_double, double_type_node); + build_builtin_fntypes (mfunc_cfloat, complex_float_type_node); + build_builtin_fntypes (mfunc_cdouble, complex_double_type_node); + 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, double_type_node, void_list_node); - mfunc_double[0] = build_function_type (double_type_node, tmp); - tmp = tree_cons (NULL_TREE, double_type_node, tmp); - mfunc_double[1] = build_function_type (double_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); @@ -835,6 +861,7 @@ gfc_init_builtin_functions (void) "alloca", false); } +#undef DEFINE_MATH_BUILTIN_C #undef DEFINE_MATH_BUILTIN #include "gt-fortran-f95-lang.h" |