builtin-types.def (BT_FN_FLOAT_FLOAT_FLOAT): New built-in type.

* builtin-types.def (BT_FN_FLOAT_FLOAT_FLOAT): New built-in type.
	(BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE): Likewise.
	(BT_FN_DOUBLE_DOUBLE_DOUBLE): Likewise.
	* builtins.def: Define pow, powf, powl, atan2, atan2f and atan2l
	builtin functions (and their __builtin_* variants).
	* builtins.c (mathfn_built_in): Handle missing log{,f,l} cases.
	(expand_builtin): Don't expand log{,f,l}, pow{,f,l} or atan2{,f,l}
	when not optimizing.

	* doc/extend.texi: Document new pow and atan2 builtins, and
	their float and long double variants.  Realphabetize builtins.

	* testsuite/gcc.dg/builtins-4.c: New test case.

From-SVN: r62551
This commit is contained in:
Roger Sayle 2003-02-07 22:37:57 +00:00 committed by Roger Sayle
parent c48d6750f4
commit 46847aa6e7
7 changed files with 138 additions and 17 deletions

View File

@ -1,3 +1,17 @@
2003-02-07 Roger Sayle <roger@eyesopen.com>
* builtin-types.def (BT_FN_FLOAT_FLOAT_FLOAT): New built-in type.
(BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE): Likewise.
(BT_FN_DOUBLE_DOUBLE_DOUBLE): Likewise.
* builtins.def: Define pow, powf, powl, atan2, atan2f and atan2l
builtin functions (and their __builtin_* variants).
* builtins.c (mathfn_built_in): Handle missing log{,f,l} cases.
(expand_builtin): Don't expand log{,f,l}, pow{,f,l} or atan2{,f,l}
when not optimizing.
* doc/extend.texi: Document new pow and atan2 builtins, and
their float and long double variants. Realphabetize builtins.
Fri Feb 7 23:24:28 CET 2003 Jan Hubicka <jh@suse.cz>
* i386.md (sse2_nandv2di3): Fix.

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2001, 2002 Free Software Foundation, Inc.
/* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GCC.
@ -149,6 +149,12 @@ DEF_FUNCTION_TYPE_2 (BT_FN_INT_PTR_CONST_STRING,
BT_INT, BT_PTR, BT_CONST_STRING)
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_SIZE,
BT_VOID, BT_PTR, BT_SIZE)
DEF_FUNCTION_TYPE_2 (BT_FN_FLOAT_FLOAT_FLOAT,
BT_FLOAT, BT_FLOAT, BT_FLOAT)
DEF_FUNCTION_TYPE_2 (BT_FN_DOUBLE_DOUBLE_DOUBLE,
BT_DOUBLE, BT_DOUBLE, BT_DOUBLE)
DEF_FUNCTION_TYPE_2 (BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
BT_LONG_DOUBLE, BT_LONG_DOUBLE, BT_LONG_DOUBLE)
DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE,
BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE)

View File

@ -1507,6 +1507,11 @@ mathfn_built_in (type, fn)
case BUILT_IN_EXPL:
fcode = BUILT_IN_EXP;
break;
case BUILT_IN_LOG:
case BUILT_IN_LOGF:
case BUILT_IN_LOGL:
fcode = BUILT_IN_LOG;
break;
case BUILT_IN_FLOOR:
case BUILT_IN_FLOORF:
case BUILT_IN_FLOORL:
@ -1558,6 +1563,11 @@ mathfn_built_in (type, fn)
case BUILT_IN_EXPL:
fcode = BUILT_IN_EXPF;
break;
case BUILT_IN_LOG:
case BUILT_IN_LOGF:
case BUILT_IN_LOGL:
fcode = BUILT_IN_LOGF;
break;
case BUILT_IN_FLOOR:
case BUILT_IN_FLOORF:
case BUILT_IN_FLOORL:
@ -1609,6 +1619,11 @@ mathfn_built_in (type, fn)
case BUILT_IN_EXPL:
fcode = BUILT_IN_EXPL;
break;
case BUILT_IN_LOG:
case BUILT_IN_LOGF:
case BUILT_IN_LOGL:
fcode = BUILT_IN_LOGL;
break;
case BUILT_IN_FLOOR:
case BUILT_IN_FLOORF:
case BUILT_IN_FLOORL:
@ -3905,6 +3920,15 @@ expand_builtin (exp, target, subtarget, mode, ignore)
case BUILT_IN_EXP:
case BUILT_IN_EXPF:
case BUILT_IN_EXPL:
case BUILT_IN_LOG:
case BUILT_IN_LOGF:
case BUILT_IN_LOGL:
case BUILT_IN_POW:
case BUILT_IN_POWF:
case BUILT_IN_POWL:
case BUILT_IN_ATAN2:
case BUILT_IN_ATAN2F:
case BUILT_IN_ATAN2L:
case BUILT_IN_MEMSET:
case BUILT_IN_MEMCPY:
case BUILT_IN_MEMCMP:

View File

@ -1,6 +1,6 @@
/* This file contains the definitions and documentation for the
builtins used in the GNU compiler.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GCC.
@ -487,6 +487,20 @@ DEF_LIB_BUILTIN(BUILT_IN_LOG,
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_LIB_BUILTIN(BUILT_IN_POW,
"__builtin_pow",
BT_FN_DOUBLE_DOUBLE_DOUBLE,
flag_errno_math ? ATTR_NOTHROW_LIST
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_LIB_BUILTIN(BUILT_IN_ATAN2,
"__builtin_atan2",
BT_FN_DOUBLE_DOUBLE_DOUBLE,
flag_errno_math ? ATTR_NOTHROW_LIST
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_C99_C90RES_BUILTIN(BUILT_IN_SQRTF,
"__builtin_sqrtf",
BT_FN_FLOAT_FLOAT,
@ -518,6 +532,20 @@ DEF_C99_C90RES_BUILTIN(BUILT_IN_LOGF,
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_C99_C90RES_BUILTIN(BUILT_IN_POWF,
"__builtin_powf",
BT_FN_FLOAT_FLOAT_FLOAT,
flag_errno_math ? ATTR_NOTHROW_LIST
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_C99_C90RES_BUILTIN(BUILT_IN_ATAN2F,
"__builtin_atan2f",
BT_FN_FLOAT_FLOAT_FLOAT,
flag_errno_math ? ATTR_NOTHROW_LIST
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_C99_C90RES_BUILTIN(BUILT_IN_SQRTL,
"__builtin_sqrtl",
BT_FN_LONG_DOUBLE_LONG_DOUBLE,
@ -549,6 +577,20 @@ DEF_C99_C90RES_BUILTIN(BUILT_IN_LOGL,
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_C99_C90RES_BUILTIN(BUILT_IN_POWL,
"__builtin_powl",
BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
flag_errno_math ? ATTR_NOTHROW_LIST
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_C99_C90RES_BUILTIN(BUILT_IN_ATAN2L,
"__builtin_atan2l",
BT_FN_LONG_DOUBLE_LONG_DOUBLE_LONG_DOUBLE,
flag_errno_math ? ATTR_NOTHROW_LIST
: (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_NOTHROW_LIST))
DEF_GCC_BUILTIN(BUILT_IN_INF,
"__builtin_inf",

View File

@ -4527,6 +4527,9 @@ v4si f (v4si a, v4si b, v4si c)
@findex abort
@findex abs
@findex alloca
@findex atan2
@findex atan2f
@findex atan2l
@findex bcmp
@findex bzero
@findex cimag
@ -4565,6 +4568,9 @@ v4si f (v4si a, v4si b, v4si c)
@findex memcmp
@findex memcpy
@findex memset
@findex pow
@findex powf
@findex powl
@findex printf
@findex printf_unlocked
@findex rindex
@ -4639,26 +4645,30 @@ mode.
The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal},
@code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl},
@code{llabs}, @code{imaxabs}, @code{round}, @code{trunc}, @code{nearbyint},
@code{roundf}, @code{truncf}, @code{nearbyintf}, @code{roundl}, @code{truncl} and
@code{nearbyintl} are handled as built-in functions except in strict ISO C90 mode.
There are also built-in versions of the ISO C99 functions @code{cosf},
@code{cosl}, @code{expf}, @code{expl}, @code{fabsf}, @code{fabsl}, @code{logf},
@code{logl}, @code{sinf}, @code{sinl}, @code{sqrtf}, @code{sqrtl},
@code{ceilf}, @code{ceill}, @code{floorf} and @code{floorl} that are recognized
in any mode since ISO C90 reserves these names for the purpose to which ISO C99
puts them. All these functions have corresponding versions prefixed with
@code{__builtin_}.
@code{llabs}, @code{imaxabs}, @code{round}, @code{roundf}, @code{roundl},
@code{trunc}, @code{truncf}, @code{truncl}, @code{nearbyint},
@code{nearbyintf} and @code{nearbyintl} are handled as built-in functions
except in strict ISO C90 mode.
The ISO C90 functions @code{abs}, @code{cos}, @code{exp}, @code{fabs},
@code{fprintf}, @code{fputs}, @code{labs}, @code{log}, @code{floor},
@code{ceil} @code{memcmp}, @code{memcpy}, @code{memset}, @code{printf},
There are also built-in versions of the ISO C99 functions @code{atan2f},
@code{atan2l}, @code{ceilf}, @code{ceill}, @code{cosf}, @code{cosl},
@code{expf}, @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf},
@code{floorl}, @code{logf}, @code{logl}, @code{powf}, @code{powl},
@code{sinf}, @code{sinl}, @code{sqrtf} and @code{sqrtl}
that are recognized in any mode since ISO C90 reserves these names for
the purpose to which ISO C99 puts them. All these functions have
corresponding versions prefixed with @code{__builtin_}.
The ISO C90 functions @code{abs}, @code{atan2}, @code{ceil}, @code{cos},
@code{exp}, @code{fabs}, @code{floor},
@code{fprintf}, @code{fputs}, @code{labs}, @code{log},
@code{memcmp}, @code{memcpy}, @code{memset}, @code{pow}, @code{printf},
@code{sin}, @code{sqrt}, @code{strcat}, @code{strchr}, @code{strcmp},
@code{strcpy}, @code{strcspn}, @code{strlen}, @code{strncat}, @code{strncmp},
@code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, and
@code{strstr} are all recognized as built-in functions unless
@option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}} is
specified for an individual function). All of these functions have
@option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
is specified for an individual function). All of these functions have
corresponding versions prefixed with @code{__builtin_}.
GCC provides built-in versions of the ISO C99 floating point comparison

View File

@ -1,3 +1,7 @@
2003-02-07 Roger Sayle <roger@eyesopen.com>
* testsuite/gcc.dg/builtins-4.c: New test case.
2003-02-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/20020430-1.c: Fix dg command typos.

View File

@ -0,0 +1,21 @@
/* Copyright (C) 2003 Free Software Foundation.
Verify that all the binary __builtin_ math functions are
recognized by the compiler.
Written by Roger Sayle, 6th February 2002. */
/* { dg-do compile } */
/* { dg-final { scan-assembler-not "__builtin_" } } */
double test1(double x, double y) { return __builtin_pow(x,y); }
double test2(double x, double y) { return __builtin_atan2(x,y); }
float test1f(float x, float y) { return __builtin_powf(x,y); }
float test2f(float x, float y) { return __builtin_atan2f(x,y); }
long double test1l(long double x, long double y)
{ return __builtin_powl(x,y); }
long double test2l(long double x, long double y)
{ return __builtin_atan2l(x,y); }