This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
abs/fabs/labs not builtin in C++
- To: egcs at cygnus dot com
- Subject: abs/fabs/labs not builtin in C++
- From: Andreas Schwab <schwab at issan dot informatik dot uni-dortmund dot de>
- Date: 10 Dec 1997 11:15:01 +0100
- Reply-To: egcs at cygnus dot com
Why are abs, labs and fabs not builtins in C++? A comment in cp/decl.c
claims they don't work with libg++, but i could not find any problems
after enabling them, and libg++ is obsolete anyway.
1997-12-09 Andreas Schwab <schwab@issan.informatik.uni-dortmund.de>
* 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.
*** egcs-971207/gcc/cp/call.c.~1~ Tue Dec 9 00:33:39 1997
--- egcs-971207/gcc/cp/call.c Tue Dec 9 11:24:31 1997
*************** build_over_call (fn, convs, args, flags)
*** 5591,5596 ****
--- 5591,5613 ----
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;
*** egcs-971207/gcc/cp/decl.c.~1~ Tue Dec 9 00:33:58 1997
--- egcs-971207/gcc/cp/decl.c Tue Dec 9 11:23:39 1997
*************** init_decl_processing ()
*** 5263,5273 ****
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);
--- 5263,5271 ----