* abs/fabs/labs not builtin in C++
@ 1997-12-10 2:27 Andreas Schwab
1997-12-10 10:30 ` Richard Henderson
1997-12-10 10:58 ` Joe Buck
0 siblings, 2 replies; 3+ messages in thread
From: Andreas Schwab @ 1997-12-10 2:27 UTC (permalink / raw)
To: egcs
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 ----
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: abs/fabs/labs not builtin in C++
1997-12-10 2:27 abs/fabs/labs not builtin in C++ Andreas Schwab
@ 1997-12-10 10:30 ` Richard Henderson
1997-12-10 10:58 ` Joe Buck
1 sibling, 0 replies; 3+ messages in thread
From: Richard Henderson @ 1997-12-10 10:30 UTC (permalink / raw)
To: egcs
On Wed, Dec 10, 1997 at 11:15:01AM +0100, Andreas Schwab wrote:
> Why are abs, labs and fabs not builtins in C++?
Don't know about labs/fabs, but I believe the std c++ library
overloads abs. That's not to say that we can't define the
overloads as builtins as well, but...
r~
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: abs/fabs/labs not builtin in C++
1997-12-10 2:27 abs/fabs/labs not builtin in C++ Andreas Schwab
1997-12-10 10:30 ` Richard Henderson
@ 1997-12-10 10:58 ` Joe Buck
1 sibling, 0 replies; 3+ messages in thread
From: Joe Buck @ 1997-12-10 10:58 UTC (permalink / raw)
To: egcs
> 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.
If this is done, we need to make sure to provide all the proper overloads.
Essentially there should be an abs() for every builtin numeric type.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~1997-12-10 10:58 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-10 2:27 abs/fabs/labs not builtin in C++ Andreas Schwab
1997-12-10 10:30 ` Richard Henderson
1997-12-10 10:58 ` Joe Buck
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).