builtins.def (BUILT_IN_CABS, [...]): New builtins representing ISO C99's cabs, cabsf and cabsl.
* builtins.def (BUILT_IN_CABS, BUILT_IN_CABSF, BUILT_IN_CABSL): New builtins representing ISO C99's cabs, cabsf and cabsl. * builtins.c (expand_builtin_fabs): New function. (expand_builtin_cabs): New function. (expand_builtin): Expand BUILT_IN_FABS{,F,L} and BUILT_IN_CABS{,F,L} using expand_builtin_fabs and expand_builtin_cabs respectively. * doc/extend.texi: Document new cabs, cabsf and cabsl builtins. * gcc.dg/builtins-16.c: New test case. From-SVN: r67368
This commit is contained in:
parent
ded9bf77e3
commit
075ec276a0
@ -1,3 +1,14 @@
|
||||
2003-06-03 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
* builtins.def (BUILT_IN_CABS, BUILT_IN_CABSF, BUILT_IN_CABSL):
|
||||
New builtins representing ISO C99's cabs, cabsf and cabsl.
|
||||
* builtins.c (expand_builtin_fabs): New function.
|
||||
(expand_builtin_cabs): New function.
|
||||
(expand_builtin): Expand BUILT_IN_FABS{,F,L} and BUILT_IN_CABS{,F,L}
|
||||
using expand_builtin_fabs and expand_builtin_cabs respectively.
|
||||
|
||||
* doc/extend.texi: Document new cabs, cabsf and cabsl builtins.
|
||||
|
||||
2003-06-03 Aldy Hernandez <aldyh@redhat.com>
|
||||
|
||||
* function.c (assign_parms): Split complex arguments.
|
||||
|
@ -169,6 +169,8 @@ static tree fold_builtin_nan PARAMS ((tree, tree, int));
|
||||
static int validate_arglist PARAMS ((tree, ...));
|
||||
static tree fold_trunc_transparent_mathfn PARAMS ((tree));
|
||||
static bool readonly_data_expr PARAMS ((tree));
|
||||
static rtx expand_builtin_fabs PARAMS ((tree, rtx, rtx));
|
||||
static rtx expand_builtin_cabs PARAMS ((tree, rtx));
|
||||
|
||||
/* Return the alignment in bits of EXP, a pointer valued expression.
|
||||
But don't return more than MAX_ALIGN no matter what.
|
||||
@ -4306,6 +4308,57 @@ expand_builtin_trap ()
|
||||
emit_library_call (abort_libfunc, LCT_NORETURN, VOIDmode, 0);
|
||||
emit_barrier ();
|
||||
}
|
||||
|
||||
/* Expand a call to fabs, fabsf or fabsl with arguments ARGLIST.
|
||||
Return 0 if a normal call should be emitted rather than expanding
|
||||
the function inline. If convenient, the result should be placed
|
||||
in TARGET. SUBTARGET may be used as the target for computing
|
||||
the operand. */
|
||||
|
||||
static rtx
|
||||
expand_builtin_fabs (arglist, target, subtarget)
|
||||
tree arglist;
|
||||
rtx target, subtarget;
|
||||
{
|
||||
enum machine_mode mode;
|
||||
tree arg;
|
||||
rtx op0;
|
||||
|
||||
if (!validate_arglist (arglist, REAL_TYPE, VOID_TYPE))
|
||||
return 0;
|
||||
|
||||
arg = TREE_VALUE (arglist);
|
||||
mode = TYPE_MODE (TREE_TYPE (arg));
|
||||
op0 = expand_expr (arg, subtarget, VOIDmode, 0);
|
||||
return expand_abs (mode, op0, target, 0, safe_from_p (target, arg, 1));
|
||||
}
|
||||
|
||||
/* Expand a call to cabs, cabsf or cabsl with arguments ARGLIST.
|
||||
Return 0 if a normal call should be emitted rather than expanding
|
||||
the function inline. If convenient, the result should be placed
|
||||
in target. */
|
||||
|
||||
static rtx
|
||||
expand_builtin_cabs (arglist, target)
|
||||
tree arglist;
|
||||
rtx target;
|
||||
{
|
||||
enum machine_mode mode;
|
||||
tree arg;
|
||||
rtx op0;
|
||||
|
||||
if (arglist == 0 || TREE_CHAIN (arglist))
|
||||
return 0;
|
||||
arg = TREE_VALUE (arglist);
|
||||
if (TREE_CODE (TREE_TYPE (arg)) != COMPLEX_TYPE
|
||||
|| TREE_CODE (TREE_TYPE (TREE_TYPE (arg))) != REAL_TYPE)
|
||||
return 0;
|
||||
|
||||
mode = TYPE_MODE (TREE_TYPE (arg));
|
||||
op0 = expand_expr (arg, NULL_RTX, VOIDmode, 0);
|
||||
return expand_complex_abs (mode, op0, target, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Expand an expression EXP that calls a built-in function,
|
||||
with result going to TARGET if that's convenient
|
||||
@ -4458,11 +4511,27 @@ expand_builtin (exp, target, subtarget, mode, ignore)
|
||||
case BUILT_IN_LABS:
|
||||
case BUILT_IN_LLABS:
|
||||
case BUILT_IN_IMAXABS:
|
||||
/* build_function_call changes these into ABS_EXPR. */
|
||||
abort ();
|
||||
|
||||
case BUILT_IN_FABS:
|
||||
case BUILT_IN_FABSF:
|
||||
case BUILT_IN_FABSL:
|
||||
/* build_function_call changes these into ABS_EXPR. */
|
||||
abort ();
|
||||
target = expand_builtin_fabs (arglist, target, subtarget);
|
||||
if (target)
|
||||
return target;
|
||||
break;
|
||||
|
||||
case BUILT_IN_CABS:
|
||||
case BUILT_IN_CABSF:
|
||||
case BUILT_IN_CABSL:
|
||||
if (flag_unsafe_math_optimizations)
|
||||
{
|
||||
target = expand_builtin_cabs (arglist, target);
|
||||
if (target)
|
||||
return target;
|
||||
}
|
||||
break;
|
||||
|
||||
case BUILT_IN_CONJ:
|
||||
case BUILT_IN_CONJF:
|
||||
|
@ -285,6 +285,18 @@ DEF_C99_BUILTIN(BUILT_IN_CIMAGL,
|
||||
"__builtin_cimagl",
|
||||
BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE,
|
||||
ATTR_CONST_NOTHROW_LIST)
|
||||
DEF_C99_BUILTIN(BUILT_IN_CABS,
|
||||
"__builtin_cabs",
|
||||
BT_FN_DOUBLE_COMPLEX_DOUBLE,
|
||||
ATTR_CONST_NOTHROW_LIST)
|
||||
DEF_C99_BUILTIN(BUILT_IN_CABSF,
|
||||
"__builtin_cabsf",
|
||||
BT_FN_FLOAT_COMPLEX_FLOAT,
|
||||
ATTR_CONST_NOTHROW_LIST)
|
||||
DEF_C99_BUILTIN(BUILT_IN_CABSL,
|
||||
"__builtin_cabsl",
|
||||
BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE,
|
||||
ATTR_CONST_NOTHROW_LIST)
|
||||
|
||||
/* The system prototypes for `bzero', 'bcopy' and `bcmp' functions
|
||||
have many variations, so don't specify parameters to avoid
|
||||
|
@ -4598,6 +4598,9 @@ v4si f (v4si a, v4si b, v4si c)
|
||||
@findex atanl
|
||||
@findex bcmp
|
||||
@findex bzero
|
||||
@findex cabs
|
||||
@findex cabsf
|
||||
@findex cabsl
|
||||
@findex calloc
|
||||
@findex ceil
|
||||
@findex ceilf
|
||||
@ -4726,8 +4729,11 @@ All these functions have corresponding versions
|
||||
prefixed with @code{__builtin_}, which may be used even in strict C89
|
||||
mode.
|
||||
|
||||
The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal},
|
||||
@code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl},
|
||||
The ISO C99 functions
|
||||
@code{cabs}, @code{cabsf}, @code{cabsl},
|
||||
@code{conj}, @code{conjf}, @code{conjl},
|
||||
@code{creal}, @code{crealf}, @code{creall},
|
||||
@code{cimag}, @code{cimagf}, @code{cimagl},
|
||||
@code{_Exit}, @code{imaxabs}, @code{llabs},
|
||||
@code{nearbyint}, @code{nearbyintf}, @code{nearbyintl},
|
||||
@code{round}, @code{roundf}, @code{roundl}, @code{snprintf},
|
||||
|
@ -1,3 +1,7 @@
|
||||
2003-06-03 Roger Sayle <roger@eyesopen.com>
|
||||
|
||||
* gcc.dg/builtins-16.c: New test case.
|
||||
|
||||
2003-06-03 Jakub Jelinek <jakub@redhat.com>
|
||||
|
||||
* gcc.c-torture/execute/builtins/string-4.c (main_test): Remove
|
||||
|
28
gcc/testsuite/gcc.dg/builtins-16.c
Normal file
28
gcc/testsuite/gcc.dg/builtins-16.c
Normal file
@ -0,0 +1,28 @@
|
||||
/* Copyright (C) 2003 Free Software Foundation.
|
||||
|
||||
Verify that all the __builtin_cabs? functions are recognized
|
||||
by the compiler. Complex numbers are not supported with the
|
||||
gcc.dg default "-pedantic-errors" option, so the dg-options
|
||||
overrides this.
|
||||
|
||||
Written by Roger Sayle, 1st June 2003. */
|
||||
|
||||
/* { dg-do compile } */
|
||||
/* { dg-options "-O -ansi" } */
|
||||
/* { dg-final { scan-assembler-not "__builtin_" } } */
|
||||
|
||||
double test(__complex__ double x)
|
||||
{
|
||||
return __builtin_cabs (x);
|
||||
}
|
||||
|
||||
float testf(__complex__ float x)
|
||||
{
|
||||
return __builtin_cabsf (x);
|
||||
}
|
||||
|
||||
long double testl(__complex__ long double x)
|
||||
{
|
||||
return __builtin_cabsl (x);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user