aboutsummaryrefslogtreecommitdiff
path: root/gcc/fortran/trans-decl.c
diff options
context:
space:
mode:
authorFeng Wang <fengwang@nudt.edu.cn>2004-05-19 00:34:59 +0000
committerPaul Brook <pbrook@gcc.gnu.org>2004-05-19 00:34:59 +0000
commit5b200ac2c7278c022c23a684589df1b31a40a153 (patch)
tree6d5551f77f0b03649dcf0b885fe4be35ce373a23 /gcc/fortran/trans-decl.c
parent933520b9beeea22009be7637b3186c61679266b0 (diff)
downloadgcc-5b200ac2c7278c022c23a684589df1b31a40a153.zip
gcc-5b200ac2c7278c022c23a684589df1b31a40a153.tar.gz
gcc-5b200ac2c7278c022c23a684589df1b31a40a153.tar.bz2
f95-lang.c (gfc_init_builtin_functions): Use vold_list_node.
* f95-lang.c (gfc_init_builtin_functions): Use vold_list_node. Create decls for __builtin_pow{,f}. * gfortran.h (PREFIX_LEN): Define. * trans-decl.c (gfor_fndecl_math_powi): Add. (gfor_fndecl_math_powf, gfor_fndecl_math_pow): Remove. (gfc_build_intrinsic_function_decls): Create decls for powi. * trans-expr.c (powi_table): Add. (gfc_conv_integer_power): Remove. (gfc_conv_powi): New function. (gfc_conv_cst_int_power): New function. (gfc_conv_power_op): Use new powi routines. * trans.h (struct gfc_powdecl_list): Add. (gfor_fndecl_math_powi): Add. (gfor_fndecl_math_powf, gfor_fndecl_math_pow): Remove. testsuite/ * gfortran.fortran-torture/execute/power.f90: Test constant integers. libgfortran/ * Makefile.am (i_pow_c): Set it. Add build rule. (gfor_built_src): Use it. (m4_files): add m4/pow.m4. * Makefile.in: Regenerate. * m4/pow.m4: New file. * generated/pow_*.c: Regenerate. From-SVN: r82014
Diffstat (limited to 'gcc/fortran/trans-decl.c')
-rw-r--r--gcc/fortran/trans-decl.c45
1 files changed, 35 insertions, 10 deletions
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index b5f3508..8708bea 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -93,8 +93,7 @@ tree gfor_fndecl_associated;
/* Math functions. Many other math functions are handled in
trans-intrinsic.c. */
-tree gfor_fndecl_math_powf;
-tree gfor_fndecl_math_pow;
+gfc_powdecl_list gfor_fndecl_math_powi[3][2];
tree gfor_fndecl_math_cpowf;
tree gfor_fndecl_math_cpow;
tree gfor_fndecl_math_cabsf;
@@ -1398,14 +1397,40 @@ gfc_build_intrinsic_function_decls (void)
/* Power functions. */
- gfor_fndecl_math_powf =
- gfc_build_library_function_decl (get_identifier ("powf"),
- gfc_real4_type_node,
- 1, gfc_real4_type_node);
- gfor_fndecl_math_pow =
- gfc_build_library_function_decl (get_identifier ("pow"),
- gfc_real8_type_node,
- 1, gfc_real8_type_node);
+ {
+ tree type;
+ tree itype;
+ int kind;
+ int ikind;
+ static int kinds[2] = {4, 8};
+ char name[PREFIX_LEN + 10]; /* _gfortran_pow_?n_?n */
+
+ for (ikind=0; ikind < 2; ikind++)
+ {
+ itype = gfc_get_int_type (kinds[ikind]);
+ for (kind = 0; kind < 2; kind ++)
+ {
+ type = gfc_get_int_type (kinds[kind]);
+ sprintf(name, PREFIX("pow_i%d_i%d"), kinds[kind], kinds[ikind]);
+ gfor_fndecl_math_powi[kind][ikind].integer =
+ gfc_build_library_function_decl (get_identifier (name),
+ type, 2, type, itype);
+
+ type = gfc_get_real_type (kinds[kind]);
+ sprintf(name, PREFIX("pow_r%d_i%d"), kinds[kind], kinds[ikind]);
+ gfor_fndecl_math_powi[kind][ikind].real =
+ gfc_build_library_function_decl (get_identifier (name),
+ type, 2, type, itype);
+
+ type = gfc_get_complex_type (kinds[kind]);
+ sprintf(name, PREFIX("pow_c%d_i%d"), kinds[kind], kinds[ikind]);
+ gfor_fndecl_math_powi[kind][ikind].cmplx =
+ gfc_build_library_function_decl (get_identifier (name),
+ type, 2, type, itype);
+ }
+ }
+ }
+
gfor_fndecl_math_cpowf =
gfc_build_library_function_decl (get_identifier ("cpowf"),
gfc_complex4_type_node,