Commit 46847aa6 by Roger Sayle Committed by Roger Sayle

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
parent c48d6750
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> Fri Feb 7 23:24:28 CET 2003 Jan Hubicka <jh@suse.cz>
* i386.md (sse2_nandv2di3): Fix. * i386.md (sse2_nandv2di3): Fix.
......
/* Copyright (C) 2001, 2002 Free Software Foundation, Inc. /* Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
This file is part of GCC. This file is part of GCC.
...@@ -149,6 +149,12 @@ DEF_FUNCTION_TYPE_2 (BT_FN_INT_PTR_CONST_STRING, ...@@ -149,6 +149,12 @@ DEF_FUNCTION_TYPE_2 (BT_FN_INT_PTR_CONST_STRING,
BT_INT, BT_PTR, BT_CONST_STRING) BT_INT, BT_PTR, BT_CONST_STRING)
DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_SIZE, DEF_FUNCTION_TYPE_2 (BT_FN_VOID_PTR_SIZE,
BT_VOID, BT_PTR, BT_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, DEF_FUNCTION_TYPE_3 (BT_FN_STRING_STRING_CONST_STRING_SIZE,
BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE) BT_STRING, BT_STRING, BT_CONST_STRING, BT_SIZE)
......
...@@ -1507,6 +1507,11 @@ mathfn_built_in (type, fn) ...@@ -1507,6 +1507,11 @@ mathfn_built_in (type, fn)
case BUILT_IN_EXPL: case BUILT_IN_EXPL:
fcode = BUILT_IN_EXP; fcode = BUILT_IN_EXP;
break; 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_FLOOR:
case BUILT_IN_FLOORF: case BUILT_IN_FLOORF:
case BUILT_IN_FLOORL: case BUILT_IN_FLOORL:
...@@ -1558,6 +1563,11 @@ mathfn_built_in (type, fn) ...@@ -1558,6 +1563,11 @@ mathfn_built_in (type, fn)
case BUILT_IN_EXPL: case BUILT_IN_EXPL:
fcode = BUILT_IN_EXPF; fcode = BUILT_IN_EXPF;
break; 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_FLOOR:
case BUILT_IN_FLOORF: case BUILT_IN_FLOORF:
case BUILT_IN_FLOORL: case BUILT_IN_FLOORL:
...@@ -1609,6 +1619,11 @@ mathfn_built_in (type, fn) ...@@ -1609,6 +1619,11 @@ mathfn_built_in (type, fn)
case BUILT_IN_EXPL: case BUILT_IN_EXPL:
fcode = BUILT_IN_EXPL; fcode = BUILT_IN_EXPL;
break; 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_FLOOR:
case BUILT_IN_FLOORF: case BUILT_IN_FLOORF:
case BUILT_IN_FLOORL: case BUILT_IN_FLOORL:
...@@ -3905,6 +3920,15 @@ expand_builtin (exp, target, subtarget, mode, ignore) ...@@ -3905,6 +3920,15 @@ expand_builtin (exp, target, subtarget, mode, ignore)
case BUILT_IN_EXP: case BUILT_IN_EXP:
case BUILT_IN_EXPF: case BUILT_IN_EXPF:
case BUILT_IN_EXPL: 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_MEMSET:
case BUILT_IN_MEMCPY: case BUILT_IN_MEMCPY:
case BUILT_IN_MEMCMP: case BUILT_IN_MEMCMP:
......
/* This file contains the definitions and documentation for the /* This file contains the definitions and documentation for the
builtins used in the GNU compiler. 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. This file is part of GCC.
...@@ -487,6 +487,20 @@ DEF_LIB_BUILTIN(BUILT_IN_LOG, ...@@ -487,6 +487,20 @@ DEF_LIB_BUILTIN(BUILT_IN_LOG,
: (flag_unsafe_math_optimizations : (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST ? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_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, DEF_C99_C90RES_BUILTIN(BUILT_IN_SQRTF,
"__builtin_sqrtf", "__builtin_sqrtf",
BT_FN_FLOAT_FLOAT, BT_FN_FLOAT_FLOAT,
...@@ -518,6 +532,20 @@ DEF_C99_C90RES_BUILTIN(BUILT_IN_LOGF, ...@@ -518,6 +532,20 @@ DEF_C99_C90RES_BUILTIN(BUILT_IN_LOGF,
: (flag_unsafe_math_optimizations : (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST ? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_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, DEF_C99_C90RES_BUILTIN(BUILT_IN_SQRTL,
"__builtin_sqrtl", "__builtin_sqrtl",
BT_FN_LONG_DOUBLE_LONG_DOUBLE, BT_FN_LONG_DOUBLE_LONG_DOUBLE,
...@@ -549,6 +577,20 @@ DEF_C99_C90RES_BUILTIN(BUILT_IN_LOGL, ...@@ -549,6 +577,20 @@ DEF_C99_C90RES_BUILTIN(BUILT_IN_LOGL,
: (flag_unsafe_math_optimizations : (flag_unsafe_math_optimizations
? ATTR_CONST_NOTHROW_LIST ? ATTR_CONST_NOTHROW_LIST
: ATTR_PURE_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, DEF_GCC_BUILTIN(BUILT_IN_INF,
"__builtin_inf", "__builtin_inf",
......
...@@ -4527,6 +4527,9 @@ v4si f (v4si a, v4si b, v4si c) ...@@ -4527,6 +4527,9 @@ v4si f (v4si a, v4si b, v4si c)
@findex abort @findex abort
@findex abs @findex abs
@findex alloca @findex alloca
@findex atan2
@findex atan2f
@findex atan2l
@findex bcmp @findex bcmp
@findex bzero @findex bzero
@findex cimag @findex cimag
...@@ -4565,6 +4568,9 @@ v4si f (v4si a, v4si b, v4si c) ...@@ -4565,6 +4568,9 @@ v4si f (v4si a, v4si b, v4si c)
@findex memcmp @findex memcmp
@findex memcpy @findex memcpy
@findex memset @findex memset
@findex pow
@findex powf
@findex powl
@findex printf @findex printf
@findex printf_unlocked @findex printf_unlocked
@findex rindex @findex rindex
...@@ -4639,26 +4645,30 @@ mode. ...@@ -4639,26 +4645,30 @@ mode.
The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal}, The ISO C99 functions @code{conj}, @code{conjf}, @code{conjl}, @code{creal},
@code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl}, @code{crealf}, @code{creall}, @code{cimag}, @code{cimagf}, @code{cimagl},
@code{llabs}, @code{imaxabs}, @code{round}, @code{trunc}, @code{nearbyint}, @code{llabs}, @code{imaxabs}, @code{round}, @code{roundf}, @code{roundl},
@code{roundf}, @code{truncf}, @code{nearbyintf}, @code{roundl}, @code{truncl} and @code{trunc}, @code{truncf}, @code{truncl}, @code{nearbyint},
@code{nearbyintl} are handled as built-in functions except in strict ISO C90 mode. @code{nearbyintf} and @code{nearbyintl} are handled as built-in functions
There are also built-in versions of the ISO C99 functions @code{cosf}, except in strict ISO C90 mode.
@code{cosl}, @code{expf}, @code{expl}, @code{fabsf}, @code{fabsl}, @code{logf},
@code{logl}, @code{sinf}, @code{sinl}, @code{sqrtf}, @code{sqrtl}, There are also built-in versions of the ISO C99 functions @code{atan2f},
@code{ceilf}, @code{ceill}, @code{floorf} and @code{floorl} that are recognized @code{atan2l}, @code{ceilf}, @code{ceill}, @code{cosf}, @code{cosl},
in any mode since ISO C90 reserves these names for the purpose to which ISO C99 @code{expf}, @code{expl}, @code{fabsf}, @code{fabsl}, @code{floorf},
puts them. All these functions have corresponding versions prefixed with @code{floorl}, @code{logf}, @code{logl}, @code{powf}, @code{powl},
@code{__builtin_}. @code{sinf}, @code{sinl}, @code{sqrtf} and @code{sqrtl}
that are recognized in any mode since ISO C90 reserves these names for
The ISO C90 functions @code{abs}, @code{cos}, @code{exp}, @code{fabs}, the purpose to which ISO C99 puts them. All these functions have
@code{fprintf}, @code{fputs}, @code{labs}, @code{log}, @code{floor}, corresponding versions prefixed with @code{__builtin_}.
@code{ceil} @code{memcmp}, @code{memcpy}, @code{memset}, @code{printf},
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{sin}, @code{sqrt}, @code{strcat}, @code{strchr}, @code{strcmp},
@code{strcpy}, @code{strcspn}, @code{strlen}, @code{strncat}, @code{strncmp}, @code{strcpy}, @code{strcspn}, @code{strlen}, @code{strncat}, @code{strncmp},
@code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, and @code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn}, and
@code{strstr} are all recognized as built-in functions unless @code{strstr} are all recognized as built-in functions unless
@option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}} is @option{-fno-builtin} is specified (or @option{-fno-builtin-@var{function}}
specified for an individual function). All of these functions have is specified for an individual function). All of these functions have
corresponding versions prefixed with @code{__builtin_}. corresponding versions prefixed with @code{__builtin_}.
GCC provides built-in versions of the ISO C99 floating point comparison GCC provides built-in versions of the ISO C99 floating point comparison
......
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> 2003-02-06 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/20020430-1.c: Fix dg command typos. * gcc.dg/20020430-1.c: Fix dg command typos.
......
/* 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); }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment