diff options
author | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2005-10-03 07:22:20 +0000 |
---|---|---|
committer | François-Xavier Coudert <fxcoudert@gcc.gnu.org> | 2005-10-03 07:22:20 +0000 |
commit | 644cb69f803dc904c271885272e70f032ce56a97 (patch) | |
tree | 8bb857b1bc8bb03e3ba5509a8bba4513942fff4a /gcc/fortran/trans-intrinsic.c | |
parent | 41a182c62d6314c2c3c138ebe358da485691f1b7 (diff) | |
download | gcc-644cb69f803dc904c271885272e70f032ce56a97.zip gcc-644cb69f803dc904c271885272e70f032ce56a97.tar.gz gcc-644cb69f803dc904c271885272e70f032ce56a97.tar.bz2 |
re PR libfortran/19308 (I/O library should support more real and integer kinds)
PR libfortran/19308
PR fortran/20120
PR libfortran/22437
* Makefile.am: Add generated files for large real and integers
kinds. Add a rule to create the kinds.inc c99_protos.inc files.
Use kinds.inc to preprocess Fortran generated files.
* libgfortran.h: Add macro definitions for GFC_INTEGER_16_HUGE,
GFC_REAL_10_HUGE and GFC_REAL_16_HUGE. Add types gfc_array_i16,
gfc_array_r10, gfc_array_r16, gfc_array_c10, gfc_array_c16,
gfc_array_l16.
* mk-kinds-h.sh: Define macros HAVE_GFC_LOGICAL_* and
HAVE_GFC_COMPLEX_* when these types are available.
* intrinsics/ishftc.c (ishftc16): New function for GFC_INTEGER_16.
* m4/all.m4, m4/any.m4, m4/count.m4, m4/cshift1.m4, m4/dotprod.m4,
m4/dotprodc.m4, m4/dotprodl.m4, m4/eoshift1.m4, m4/eoshift3.m4,
m4/exponent.m4, m4/fraction.m4, m4/in_pack.m4, m4/in_unpack.m4,
m4/matmul.m4, m4/matmull.m4, m4/maxloc0.m4, m4/maxloc1.m4,
m4/maxval.m4, m4/minloc0.m4, m4/minloc1.m4, m4/minval.m4, m4/mtype.m4,
m4/nearest.m4, m4/pow.m4, m4/product.m4, m4/reshape.m4,
m4/set_exponent.m4, m4/shape.m4, m4/specific.m4, m4/specific2.m4,
m4/sum.m4, m4/transpose.m4: Protect generated functions with
appropriate "#if defined (HAVE_GFC_type_kind)" preprocessor directives.
* Makefile.in: Regenerate.
* all files in generated/: Regenerate.
* f95-lang.c (DO_DEFINE_MATH_BUILTIN): Add support for long
double builtin function.
(gfc_init_builtin_functions): Add mfunc_longdouble,
mfunc_clongdouble and func_clongdouble_longdouble trees. Build
them for round, trunc, cabs, copysign and pow functions.
* iresolve.c (gfc_resolve_reshape, gfc_resolve_transpose): Add
case for kind 10 and 16.
* trans-decl.c: Add trees for cpowl10, cpowl16, ishftc16,
exponent10 and exponent16.
(gfc_build_intrinsic_function_decls): Build nodes for int16,
real10, real16, complex10 and complex16 types. Build all possible
combinations for function _gfortran_pow_?n_?n. Build function
calls cpowl10, cpowl16, ishftc16, exponent10 and exponent16.
* trans-expr.c (gfc_conv_power_op): Add case for integer(16),
real(10) and real(16).
* trans-intrinsic.c: Add suppport for long double builtin
functions in BUILT_IN_FUNCTION, LIBM_FUNCTION and LIBF_FUNCTION
macros.
(gfc_conv_intrinsic_aint): Add case for integer(16), real(10) and
real(16) kinds.
(gfc_build_intrinsic_lib_fndecls): Add support for real10_decl
and real16_decl in library functions.
(gfc_get_intrinsic_lib_fndecl): Add cases for real and complex
kinds 10 and 16.
(gfc_conv_intrinsic_exponent): Add cases for real(10) and real(16)
kinds.
(gfc_conv_intrinsic_sign): Likewise.
(gfc_conv_intrinsic_ishftc): Add case for integer(16) kind.
* trans-types.c (gfc_get_int_type, gfc_get_real_type,
gfc_get_complex_type, gfc_get_logical_type): Doesn't error out in
the case of kinds not available.
* trans.h: Declare trees for cpowl10, cpowl16, ishftc16,
exponent10 and exponent16.
* gfortran.dg/large_real_kind_2.F90: New test.
* gfortran.dg/large_integer_kind_2.f90: New test.
From-SVN: r104889
Diffstat (limited to 'gcc/fortran/trans-intrinsic.c')
-rw-r--r-- | gcc/fortran/trans-intrinsic.c | 115 |
1 files changed, 90 insertions, 25 deletions
diff --git a/gcc/fortran/trans-intrinsic.c b/gcc/fortran/trans-intrinsic.c index d498717..1d958e1 100644 --- a/gcc/fortran/trans-intrinsic.c +++ b/gcc/fortran/trans-intrinsic.c @@ -52,14 +52,18 @@ typedef struct gfc_intrinsic_map_t GTY(()) /* Enum value from the "language-independent", aka C-centric, part of gcc, or END_BUILTINS of no such value set. */ - /* ??? There are now complex variants in builtins.def, though we - don't currently do anything with them. */ - enum built_in_function code4; - enum built_in_function code8; + enum built_in_function code_r4; + enum built_in_function code_r8; + enum built_in_function code_r10; + enum built_in_function code_r16; + enum built_in_function code_c4; + enum built_in_function code_c8; + enum built_in_function code_c10; + enum built_in_function code_c16; /* True if the naming pattern is to prepend "c" for complex and append "f" for kind=4. False if the naming pattern is to - prepend "_gfortran_" and append "[rc][48]". */ + prepend "_gfortran_" and append "[rc](4|8|10|16)". */ bool libm_name; /* True if a complex version of the function exists. */ @@ -74,32 +78,42 @@ typedef struct gfc_intrinsic_map_t GTY(()) /* Cache decls created for the various operand types. */ tree real4_decl; tree real8_decl; + tree real10_decl; + tree real16_decl; tree complex4_decl; tree complex8_decl; + tree complex10_decl; + tree complex16_decl; } gfc_intrinsic_map_t; /* ??? The NARGS==1 hack here is based on the fact that (c99 at least) defines complex variants of all of the entries in mathbuiltins.def except for atan2. */ -#define BUILT_IN_FUNCTION(ID, NAME, HAVE_COMPLEX) \ - { GFC_ISYM_ ## ID, BUILT_IN_ ## ID ## F, BUILT_IN_ ## ID, true, \ - HAVE_COMPLEX, true, NAME, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE}, - -#define DEFINE_MATH_BUILTIN(id, name, argtype) \ - BUILT_IN_FUNCTION (id, name, false) - -/* TODO: Use builtin function for complex intrinsics. */ -#define DEFINE_MATH_BUILTIN_C(id, name, argtype) \ - BUILT_IN_FUNCTION (id, name, true) +#define DEFINE_MATH_BUILTIN(ID, NAME, ARGTYPE) \ + { GFC_ISYM_ ## ID, BUILT_IN_ ## ID ## F, BUILT_IN_ ## ID, \ + BUILT_IN_ ## ID ## L, BUILT_IN_ ## ID ## L, 0, 0, 0, 0, true, \ + false, true, NAME, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, \ + NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE}, + +#define DEFINE_MATH_BUILTIN_C(ID, NAME, ARGTYPE) \ + { GFC_ISYM_ ## ID, BUILT_IN_ ## ID ## F, BUILT_IN_ ## ID, \ + BUILT_IN_ ## ID ## L, BUILT_IN_ ## ID ## L, BUILT_IN_C ## ID ## F, \ + BUILT_IN_C ## ID, BUILT_IN_C ## ID ## L, BUILT_IN_C ## ID ## L, true, \ + true, true, NAME, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, \ + NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE}, #define LIBM_FUNCTION(ID, NAME, HAVE_COMPLEX) \ - { GFC_ISYM_ ## ID, END_BUILTINS, END_BUILTINS, true, HAVE_COMPLEX, true, \ - NAME, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE } + { GFC_ISYM_ ## ID, END_BUILTINS, END_BUILTINS, END_BUILTINS, END_BUILTINS, \ + END_BUILTINS, END_BUILTINS, END_BUILTINS, END_BUILTINS, \ + true, HAVE_COMPLEX, true, NAME, NULL_TREE, NULL_TREE, NULL_TREE, \ + NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE } #define LIBF_FUNCTION(ID, NAME, HAVE_COMPLEX) \ - { GFC_ISYM_ ## ID, END_BUILTINS, END_BUILTINS, false, HAVE_COMPLEX, true, \ - NAME, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE } + { GFC_ISYM_ ## ID, END_BUILTINS, END_BUILTINS, END_BUILTINS, END_BUILTINS, \ + END_BUILTINS, END_BUILTINS, END_BUILTINS, END_BUILTINS, \ + false, HAVE_COMPLEX, true, NAME, NULL_TREE, NULL_TREE, NULL_TREE, \ + NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE } static GTY(()) gfc_intrinsic_map_t gfc_intrinsic_map[] = { @@ -122,7 +136,6 @@ static GTY(()) gfc_intrinsic_map_t gfc_intrinsic_map[] = }; #undef DEFINE_MATH_BUILTIN #undef DEFINE_MATH_BUILTIN_C -#undef BUILT_IN_FUNCTION #undef LIBM_FUNCTION #undef LIBF_FUNCTION @@ -336,6 +349,11 @@ gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, enum tree_code op) case 8: n = BUILT_IN_ROUND; break; + + case 10: + case 16: + n = BUILT_IN_ROUNDL; + break; } break; @@ -349,6 +367,11 @@ gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, enum tree_code op) case 8: n = BUILT_IN_TRUNC; break; + + case 10: + case 16: + n = BUILT_IN_TRUNCL; + break; } break; @@ -469,10 +492,22 @@ gfc_build_intrinsic_lib_fndecls (void) /* Add GCC builtin functions. */ for (m = gfc_intrinsic_map; m->id != GFC_ISYM_NONE; m++) { - if (m->code4 != END_BUILTINS) - m->real4_decl = built_in_decls[m->code4]; - if (m->code8 != END_BUILTINS) - m->real8_decl = built_in_decls[m->code8]; + if (m->code_r4 != END_BUILTINS) + m->real4_decl = built_in_decls[m->code_r4]; + if (m->code_r8 != END_BUILTINS) + m->real8_decl = built_in_decls[m->code_r8]; + if (m->code_r10 != END_BUILTINS) + m->real10_decl = built_in_decls[m->code_r10]; + if (m->code_r16 != END_BUILTINS) + m->real16_decl = built_in_decls[m->code_r16]; + if (m->code_c4 != END_BUILTINS) + m->complex4_decl = built_in_decls[m->code_c4]; + if (m->code_c8 != END_BUILTINS) + m->complex8_decl = built_in_decls[m->code_c8]; + if (m->code_c10 != END_BUILTINS) + m->complex10_decl = built_in_decls[m->code_c10]; + if (m->code_c16 != END_BUILTINS) + m->complex16_decl = built_in_decls[m->code_c16]; } } @@ -501,6 +536,12 @@ gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr) case 8: pdecl = &m->real8_decl; break; + case 10: + pdecl = &m->real10_decl; + break; + case 16: + pdecl = &m->real16_decl; + break; default: gcc_unreachable (); } @@ -517,6 +558,12 @@ gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr) case 8: pdecl = &m->complex8_decl; break; + case 10: + pdecl = &m->complex10_decl; + break; + case 16: + pdecl = &m->complex16_decl; + break; default: gcc_unreachable (); } @@ -529,7 +576,8 @@ gfc_get_intrinsic_lib_fndecl (gfc_intrinsic_map_t * m, gfc_expr * expr) if (m->libm_name) { - gcc_assert (ts->kind == 4 || ts->kind == 8); + gcc_assert (ts->kind == 4 || ts->kind == 8 || ts->kind == 10 + || ts->kind == 16); snprintf (name, sizeof (name), "%s%s%s", ts->type == BT_COMPLEX ? "c" : "", m->name, @@ -615,6 +663,12 @@ gfc_conv_intrinsic_exponent (gfc_se * se, gfc_expr * expr) case 8: fndecl = gfor_fndecl_math_exponent8; break; + case 10: + fndecl = gfor_fndecl_math_exponent10; + break; + case 16: + fndecl = gfor_fndecl_math_exponent16; + break; default: gcc_unreachable (); } @@ -734,6 +788,10 @@ gfc_conv_intrinsic_abs (gfc_se * se, gfc_expr * expr) case 8: n = BUILT_IN_CABS; break; + case 10: + case 16: + n = BUILT_IN_CABSL; + break; default: gcc_unreachable (); } @@ -896,6 +954,10 @@ gfc_conv_intrinsic_sign (gfc_se * se, gfc_expr * expr) case 8: tmp = built_in_decls[BUILT_IN_COPYSIGN]; break; + case 10: + case 16: + tmp = built_in_decls[BUILT_IN_COPYSIGNL]; + break; default: gcc_unreachable (); } @@ -1861,6 +1923,9 @@ gfc_conv_intrinsic_ishftc (gfc_se * se, gfc_expr * expr) case 8: tmp = gfor_fndecl_math_ishftc8; break; + case 16: + tmp = gfor_fndecl_math_ishftc16; + break; default: gcc_unreachable (); } |