From 387c47a3801e961f6fa0d7688f2db225a490fe86 Mon Sep 17 00:00:00 2001 From: Andreas Schwab Date: Fri, 13 Feb 1998 02:26:35 +0000 Subject: [PATCH] call.c (build_over_call): Convert builtin abs, labs and fabs to tree-codes. * call.c (build_over_call): Convert builtin abs, labs and fabs to tree-codes. * decl.c (init_decl_processing): Reenable abs, labs and fabs as builtins. From-SVN: r17900 --- gcc/cp/ChangeLog | 7 +++++++ gcc/cp/call.c | 17 +++++++++++++++++ gcc/cp/decl.c | 2 -- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog index 0054db6cf61..2f1f6f0a077 100644 --- a/gcc/cp/ChangeLog +++ b/gcc/cp/ChangeLog @@ -1,3 +1,10 @@ +Fri Feb 13 02:26:10 1998 Andreas Schwab + + * call.c (build_over_call): Convert builtin abs, labs and fabs to + tree-codes. + * decl.c (init_decl_processing): Reenable abs, labs and fabs as + builtins. + Fri Feb 13 01:36:42 1998 Jason Merrill * call.c (standard_conversion): A BASE_CONV replaces an RVALUE_CONV. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 299e0a4257e..424bfd5fbcb 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -5656,6 +5656,23 @@ build_over_call (fn, convs, args, flags) else fn = build_addr_func (fn); + /* Recognize certain built-in functions so we can make tree-codes + other than CALL_EXPR. We do this when it enables fold-const.c + to do something useful. */ + + if (TREE_CODE (fn) == ADDR_EXPR + && TREE_CODE (TREE_OPERAND (fn, 0)) == FUNCTION_DECL + && DECL_BUILT_IN (TREE_OPERAND (fn, 0))) + switch (DECL_FUNCTION_CODE (TREE_OPERAND (fn, 0))) + { + case BUILT_IN_ABS: + case BUILT_IN_LABS: + case BUILT_IN_FABS: + if (converted_args == 0) + return integer_zero_node; + return build_unary_op (ABS_EXPR, TREE_VALUE (converted_args), 0); + } + fn = build_call (fn, TREE_TYPE (TREE_TYPE (TREE_TYPE (fn))), converted_args); if (TREE_TYPE (fn) == void_type_node) return fn; diff --git a/gcc/cp/decl.c b/gcc/cp/decl.c index e378f4a3d65..c9eaeb8e519 100644 --- a/gcc/cp/decl.c +++ b/gcc/cp/decl.c @@ -5333,11 +5333,9 @@ init_decl_processing () if (!flag_no_builtin) { -#if 0 /* These do not work well with libg++. */ builtin_function ("abs", int_ftype_int, BUILT_IN_ABS, NULL_PTR); builtin_function ("fabs", double_ftype_double, BUILT_IN_FABS, NULL_PTR); builtin_function ("labs", long_ftype_long, BUILT_IN_LABS, NULL_PTR); -#endif builtin_function ("fabsf", float_ftype_float, BUILT_IN_FABS, NULL_PTR); builtin_function ("fabsl", ldouble_ftype_ldouble, BUILT_IN_FABS, NULL_PTR); -- 2.30.2