summaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorsayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-07 22:37:57 +0000
committersayle <sayle@138bc75d-0d04-0410-961f-82ee72b054a4>2003-02-07 22:37:57 +0000
commitfa426235d6507241e779257cae6776a616e03fb7 (patch)
tree5831f8d64256959cde2af68fd1808297950ca51d /gcc
parent51482831f2b68c6d167f4e24147e8a678b2c2d1f (diff)
downloadgcc-fa426235d6507241e779257cae6776a616e03fb7.tar.gz
* 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. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@62551 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog14
-rw-r--r--gcc/builtin-types.def8
-rw-r--r--gcc/builtins.c24
-rw-r--r--gcc/builtins.def44
-rw-r--r--gcc/doc/extend.texi42
-rw-r--r--gcc/testsuite/ChangeLog4
-rw-r--r--gcc/testsuite/gcc.dg/builtins-4.c21
7 files changed, 139 insertions, 18 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index 38f40353e45..bb4d4db4c05 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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.
diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def
index b8b9b29929b..9fa0f4e6f2c 100644
--- a/gcc/builtin-types.def
+++ b/gcc/builtin-types.def
@@ -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)
diff --git a/gcc/builtins.c b/gcc/builtins.c
index 47d93e21cee..e2ad1e8af08 100644
--- a/gcc/builtins.c
+++ b/gcc/builtins.c
@@ -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:
diff --git a/gcc/builtins.def b/gcc/builtins.def
index 60a962a9abd..268696edb8f 100644
--- a/gcc/builtins.def
+++ b/gcc/builtins.def
@@ -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",
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 5544c5c9cc8..eb5935954ee 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -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_}.
-
-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},
+@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.
+
+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
diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog
index 9b89f7a7adb..c701328315b 100644
--- a/gcc/testsuite/ChangeLog
+++ b/gcc/testsuite/ChangeLog
@@ -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.
diff --git a/gcc/testsuite/gcc.dg/builtins-4.c b/gcc/testsuite/gcc.dg/builtins-4.c
new file mode 100644
index 00000000000..95a1917533d
--- /dev/null
+++ b/gcc/testsuite/gcc.dg/builtins-4.c
@@ -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); }
+