Commit e743d142 by Tobias Schlüter Committed by Tobias Schlüter

f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC and…

f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC and BUILT_IN_TRUNCF instead of BUILT_IN_FLOOR and...

	* f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC
	and BUILT_IN_TRUNCF instead of BUILT_IN_FLOOR and BUILT_IN_FLOORF.
	* trans-intrinsic.c (build_fix_expr): Change 'op' argument
	to correct enum type.
	(gfc_conv_intrinsic_aint): Likewise.  Clarify comment in front of
	function.  Add default case to switch, deal with FIX_TRUNC_EXPR
	instead of FIX_FLOOR_EXPR.

From-SVN: r99900
parent 33af9c08
2005-05-18 Tobias Schl"uter <tobias.schlueter@physik.uni-muenchen.de>
* f95-lang.c (gfc_init_builtin_functions): Define BUILT_IN_TRUNC
and BUILT_IN_TRUNCF instead of BUILT_IN_FLOOR and BUILT_IN_FLOORF.
* trans-intrinsic.c (build_fix_expr): Change 'op' argument
to correct enum type.
(gfc_conv_intrinsic_aint): Likewise. Clarify comment in front of
function. Add default case to switch, deal with FIX_TRUNC_EXPR
instead of FIX_FLOOR_EXPR.
2005-05-18 Feng Wang <fengwang@nudt.edu.cn> 2005-05-18 Feng Wang <fengwang@nudt.edu.cn>
PR fortran/20954 PR fortran/20954
......
...@@ -790,15 +790,15 @@ gfc_init_builtin_functions (void) ...@@ -790,15 +790,15 @@ gfc_init_builtin_functions (void)
/* We define these separately as the fortran versions have different /* We define these separately as the fortran versions have different
semantics (they return an integer type) */ semantics (they return an integer type) */
gfc_define_builtin ("__builtin_floor", mfunc_double[0],
BUILT_IN_FLOOR, "floor", true);
gfc_define_builtin ("__builtin_floorf", mfunc_float[0],
BUILT_IN_FLOORF, "floorf", true);
gfc_define_builtin ("__builtin_round", mfunc_double[0], gfc_define_builtin ("__builtin_round", mfunc_double[0],
BUILT_IN_ROUND, "round", true); BUILT_IN_ROUND, "round", true);
gfc_define_builtin ("__builtin_roundf", mfunc_float[0], gfc_define_builtin ("__builtin_roundf", mfunc_float[0],
BUILT_IN_ROUNDF, "roundf", true); BUILT_IN_ROUNDF, "roundf", 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_cabs", func_cdouble_double, gfc_define_builtin ("__builtin_cabs", func_cdouble_double,
BUILT_IN_CABS, "cabs", true); BUILT_IN_CABS, "cabs", true);
gfc_define_builtin ("__builtin_cabsf", func_cfloat_float, gfc_define_builtin ("__builtin_cabsf", func_cfloat_float,
......
...@@ -277,7 +277,8 @@ build_round_expr (stmtblock_t * pblock, tree arg, tree type) ...@@ -277,7 +277,8 @@ build_round_expr (stmtblock_t * pblock, tree arg, tree type)
however the RTL expander only actually supports FIX_TRUNC_EXPR. */ however the RTL expander only actually supports FIX_TRUNC_EXPR. */
static tree static tree
build_fix_expr (stmtblock_t * pblock, tree arg, tree type, int op) build_fix_expr (stmtblock_t * pblock, tree arg, tree type,
enum tree_code op)
{ {
switch (op) switch (op)
{ {
...@@ -300,14 +301,15 @@ build_fix_expr (stmtblock_t * pblock, tree arg, tree type, int op) ...@@ -300,14 +301,15 @@ build_fix_expr (stmtblock_t * pblock, tree arg, tree type, int op)
/* Round a real value using the specified rounding mode. /* Round a real value using the specified rounding mode.
We use a temporary integer of that same kind size as the result. We use a temporary integer of that same kind size as the result.
Values larger than can be represented by this kind are unchanged, as Values larger than those that can be represented by this kind are
will not be accurate enough to represent the rounding. unchanged, as thay will not be accurate enough to represent the
rounding.
huge = HUGE (KIND (a)) huge = HUGE (KIND (a))
aint (a) = ((a > huge) || (a < -huge)) ? a : (real)(int)a aint (a) = ((a > huge) || (a < -huge)) ? a : (real)(int)a
*/ */
static void static void
gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, int op) gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, enum tree_code op)
{ {
tree type; tree type;
tree itype; tree itype;
...@@ -337,17 +339,21 @@ gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, int op) ...@@ -337,17 +339,21 @@ gfc_conv_intrinsic_aint (gfc_se * se, gfc_expr * expr, int op)
} }
break; break;
case FIX_FLOOR_EXPR: case FIX_TRUNC_EXPR:
switch (kind) switch (kind)
{ {
case 4: case 4:
n = BUILT_IN_FLOORF; n = BUILT_IN_TRUNCF;
break; break;
case 8: case 8:
n = BUILT_IN_FLOOR; n = BUILT_IN_TRUNC;
break; break;
} }
break;
default:
gcc_unreachable ();
} }
/* Evaluate the argument. */ /* Evaluate the argument. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment