builtins.def: Add ctype builtins.

* builtins.def: Add ctype builtins.
	* doc/extend.texi: Likewise.
testsuite:
	* gcc.dg/torture/builtin-ctype-1.c: New test.

From-SVN: r79960
This commit is contained in:
Kaveh R. Ghazi 2004-03-25 17:55:13 +00:00 committed by Kaveh Ghazi
parent e19f6bded7
commit 740e5b6f17
5 changed files with 137 additions and 47 deletions

View File

@ -1,3 +1,8 @@
2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.def: Add ctype builtins.
* doc/extend.texi: Likewise.
2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* builtins.c (fold_builtin): Add new builtin optimizations for

View File

@ -491,6 +491,24 @@ DEF_C99_BUILTIN (BUILT_IN_VSNPRINTF, "vsnprintf", BT_FN_INT_STRING_SIZE_C
DEF_LIB_BUILTIN (BUILT_IN_VSPRINTF, "vsprintf", BT_FN_INT_STRING_CONST_STRING_VALIST_ARG, ATTR_FORMAT_PRINTF_2_0)
DEF_C99_BUILTIN (BUILT_IN_VSSCANF, "vsscanf", BT_FN_INT_CONST_STRING_CONST_STRING_VALIST_ARG, ATTR_FORMAT_SCANF_2_0)
/* Category: ctype builtins. */
DEF_LIB_BUILTIN (BUILT_IN_ISALNUM, "isalnum", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISALPHA, "isalpha", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_EXT_LIB_BUILTIN (BUILT_IN_ISASCII, "isascii", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST)
DEF_C99_BUILTIN (BUILT_IN_ISBLANK, "isblank", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISCNTRL, "iscntrl", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISDIGIT, "isdigit", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISGRAPH, "isgraph", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISLOWER, "islower", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISPRINT, "isprint", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISPUNCT, "ispunct", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISSPACE, "isspace", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISUPPER, "isupper", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ISXDIGIT, "isxdigit", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_EXT_LIB_BUILTIN (BUILT_IN_TOASCII, "toascii", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_TOLOWER, "tolower", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_TOUPPER, "toupper", BT_FN_INT_INT, ATTR_PURE_NOTHROW_LIST)
/* Category: miscellaneous builtins. */
DEF_LIB_BUILTIN (BUILT_IN_ABORT, "abort", BT_FN_VOID, ATTR_NORETURN_NOTHROW_LIST)
DEF_LIB_BUILTIN (BUILT_IN_ABS, "abs", BT_FN_INT_INT, ATTR_CONST_NOTHROW_LIST)

View File

@ -4886,6 +4886,19 @@ v4si f (v4si a, v4si b, v4si c)
@findex ilogbl
@findex imaxabs
@findex index
@findex isalnum
@findex isalpha
@findex isascii
@findex isblank
@findex iscntrl
@findex isdigit
@findex isgraph
@findex islower
@findex isprint
@findex ispunct
@findex isspace
@findex isupper
@findex isxdigit
@findex j0
@findex j0f
@findex j0l
@ -5026,6 +5039,9 @@ v4si f (v4si a, v4si b, v4si c)
@findex tgamma
@findex tgammaf
@findex tgammal
@findex toascii
@findex tolower
@findex toupper
@findex trunc
@findex truncf
@findex truncl
@ -5072,15 +5088,16 @@ Outside strict ISO C mode (@option{-ansi}, @option{-std=c89} or
@code{drem}, @code{exp10f}, @code{exp10l}, @code{exp10}, @code{ffsll},
@code{ffsl}, @code{ffs}, @code{fprintf_unlocked}, @code{fputs_unlocked},
@code{gammaf}, @code{gammal}, @code{gamma}, @code{gettext},
@code{index}, @code{j0f}, @code{j0l}, @code{j0}, @code{j1f}, @code{j1l},
@code{j1}, @code{jnf}, @code{jnl}, @code{jn}, @code{mempcpy},
@code{pow10f}, @code{pow10l}, @code{pow10}, @code{printf_unlocked},
@code{rindex}, @code{scalbf}, @code{scalbl}, @code{scalb},
@code{signbit}, @code{signbitf}, @code{signbitl},
@code{index}, @code{isascii}, @code{j0f}, @code{j0l}, @code{j0},
@code{j1f}, @code{j1l}, @code{j1}, @code{jnf}, @code{jnl}, @code{jn},
@code{mempcpy}, @code{pow10f}, @code{pow10l}, @code{pow10},
@code{printf_unlocked}, @code{rindex}, @code{scalbf}, @code{scalbl},
@code{scalb}, @code{signbit}, @code{signbitf}, @code{signbitl},
@code{significandf}, @code{significandl}, @code{significand},
@code{sincosf}, @code{sincosl}, @code{sincos}, @code{stpcpy},
@code{strdup}, @code{strfmon}, @code{y0f}, @code{y0l}, @code{y0},
@code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and @code{yn}
@code{strdup}, @code{strfmon}, @code{toascii}, @code{y0f}, @code{y0l},
@code{y0}, @code{y1f}, @code{y1l}, @code{y1}, @code{ynf}, @code{ynl} and
@code{yn}
may be handled as built-in functions.
All these functions have corresponding versions
prefixed with @code{__builtin_}, which may be used even in strict C89
@ -5097,36 +5114,35 @@ The ISO C99 functions
@code{catanl}, @code{catan}, @code{cbrtf}, @code{cbrtl}, @code{cbrt},
@code{ccosf}, @code{ccoshf}, @code{ccoshl}, @code{ccosh}, @code{ccosl},
@code{ccos}, @code{cexpf}, @code{cexpl}, @code{cexp}, @code{cimagf},
@code{cimagl}, @code{cimag},
@code{conjf}, @code{conjl}, @code{conj}, @code{copysignf},
@code{copysignl}, @code{copysign}, @code{cpowf}, @code{cpowl},
@code{cpow}, @code{cprojf}, @code{cprojl}, @code{cproj}, @code{crealf},
@code{creall}, @code{creal}, @code{csinf}, @code{csinhf}, @code{csinhl},
@code{csinh}, @code{csinl}, @code{csin}, @code{csqrtf}, @code{csqrtl},
@code{csqrt}, @code{ctanf}, @code{ctanhf}, @code{ctanhl}, @code{ctanh},
@code{ctanl}, @code{ctan}, @code{erfcf}, @code{erfcl}, @code{erfc},
@code{erff}, @code{erfl}, @code{erf}, @code{exp2f}, @code{exp2l},
@code{exp2}, @code{expm1f}, @code{expm1l}, @code{expm1}, @code{fdimf},
@code{fdiml}, @code{fdim}, @code{fmaf}, @code{fmal}, @code{fmaxf},
@code{fmaxl}, @code{fmax}, @code{fma}, @code{fminf}, @code{fminl},
@code{fmin}, @code{hypotf}, @code{hypotl}, @code{hypot}, @code{ilogbf},
@code{ilogbl}, @code{ilogb}, @code{imaxabs}, @code{lgammaf},
@code{lgammal}, @code{lgamma}, @code{llabs}, @code{llrintf},
@code{llrintl}, @code{llrint}, @code{llroundf}, @code{llroundl},
@code{llround}, @code{log1pf}, @code{log1pl}, @code{log1p},
@code{log2f}, @code{log2l}, @code{log2}, @code{logbf}, @code{logbl},
@code{logb}, @code{lrintf}, @code{lrintl}, @code{lrint}, @code{lroundf},
@code{lroundl}, @code{lround}, @code{nearbyintf}, @code{nearbyintl},
@code{nearbyint}, @code{nextafterf}, @code{nextafterl},
@code{nextafter}, @code{nexttowardf}, @code{nexttowardl},
@code{nexttoward}, @code{remainderf}, @code{remainderl},
@code{remainder}, @code{remquof}, @code{remquol}, @code{remquo},
@code{rintf}, @code{rintl}, @code{rint}, @code{roundf}, @code{roundl},
@code{round}, @code{scalblnf}, @code{scalblnl}, @code{scalbln},
@code{scalbnf}, @code{scalbnl}, @code{scalbn}, @code{snprintf},
@code{tgammaf}, @code{tgammal}, @code{tgamma}, @code{truncf},
@code{truncl}, @code{trunc}, @code{vfscanf}, @code{vscanf},
@code{vsnprintf} and @code{vsscanf}
@code{cimagl}, @code{cimag}, @code{conjf}, @code{conjl}, @code{conj},
@code{copysignf}, @code{copysignl}, @code{copysign}, @code{cpowf},
@code{cpowl}, @code{cpow}, @code{cprojf}, @code{cprojl}, @code{cproj},
@code{crealf}, @code{creall}, @code{creal}, @code{csinf}, @code{csinhf},
@code{csinhl}, @code{csinh}, @code{csinl}, @code{csin}, @code{csqrtf},
@code{csqrtl}, @code{csqrt}, @code{ctanf}, @code{ctanhf}, @code{ctanhl},
@code{ctanh}, @code{ctanl}, @code{ctan}, @code{erfcf}, @code{erfcl},
@code{erfc}, @code{erff}, @code{erfl}, @code{erf}, @code{exp2f},
@code{exp2l}, @code{exp2}, @code{expm1f}, @code{expm1l}, @code{expm1},
@code{fdimf}, @code{fdiml}, @code{fdim}, @code{fmaf}, @code{fmal},
@code{fmaxf}, @code{fmaxl}, @code{fmax}, @code{fma}, @code{fminf},
@code{fminl}, @code{fmin}, @code{hypotf}, @code{hypotl}, @code{hypot},
@code{ilogbf}, @code{ilogbl}, @code{ilogb}, @code{imaxabs},
@code{isblank}, @code{lgammaf}, @code{lgammal}, @code{lgamma},
@code{llabs}, @code{llrintf}, @code{llrintl}, @code{llrint},
@code{llroundf}, @code{llroundl}, @code{llround}, @code{log1pf},
@code{log1pl}, @code{log1p}, @code{log2f}, @code{log2l}, @code{log2},
@code{logbf}, @code{logbl}, @code{logb}, @code{lrintf}, @code{lrintl},
@code{lrint}, @code{lroundf}, @code{lroundl}, @code{lround},
@code{nearbyintf}, @code{nearbyintl}, @code{nearbyint},
@code{nextafterf}, @code{nextafterl}, @code{nextafter},
@code{nexttowardf}, @code{nexttowardl}, @code{nexttoward},
@code{remainderf}, @code{remainderl}, @code{remainder}, @code{remquof},
@code{remquol}, @code{remquo}, @code{rintf}, @code{rintl}, @code{rint},
@code{roundf}, @code{roundl}, @code{round}, @code{scalblnf},
@code{scalblnl}, @code{scalbln}, @code{scalbnf}, @code{scalbnl},
@code{scalbn}, @code{snprintf}, @code{tgammaf}, @code{tgammal},
@code{tgamma}, @code{truncf}, @code{truncl}, @code{trunc},
@code{vfscanf}, @code{vscanf}, @code{vsnprintf} and @code{vsscanf}
are handled as built-in functions
except in strict ISO C90 mode (@option{-ansi} or @option{-std=c89}).
@ -5148,16 +5164,19 @@ The ISO C90 functions
@code{abort}, @code{abs}, @code{acos}, @code{asin}, @code{atan2},
@code{atan}, @code{calloc}, @code{ceil}, @code{cosh}, @code{cos},
@code{exit}, @code{exp}, @code{fabs}, @code{floor}, @code{fmod},
@code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf}, @code{labs},
@code{ldexp}, @code{log10}, @code{log}, @code{malloc}, @code{memcmp},
@code{memcpy}, @code{memset}, @code{modf}, @code{pow}, @code{printf},
@code{putchar}, @code{puts}, @code{scanf}, @code{sinh}, @code{sin},
@code{snprintf}, @code{sprintf}, @code{sqrt}, @code{sscanf},
@code{strcat}, @code{strchr}, @code{strcmp}, @code{strcpy},
@code{strcspn}, @code{strlen}, @code{strncat}, @code{strncmp},
@code{strncpy}, @code{strpbrk}, @code{strrchr}, @code{strspn},
@code{strstr}, @code{tanh}, @code{tan}, @code{vfprintf}, @code{vprintf}
and @code{vsprintf}
@code{fprintf}, @code{fputs}, @code{frexp}, @code{fscanf},
@code{isalnum}, @code{isalpha}, @code{iscntrl}, @code{isdigit},
@code{isgraph}, @code{islower}, @code{isprint}, @code{ispunct},
@code{isspace}, @code{isupper}, @code{isxdigit}, @code{tolower},
@code{toupper}, @code{labs}, @code{ldexp}, @code{log10}, @code{log},
@code{malloc}, @code{memcmp}, @code{memcpy}, @code{memset}, @code{modf},
@code{pow}, @code{printf}, @code{putchar}, @code{puts}, @code{scanf},
@code{sinh}, @code{sin}, @code{snprintf}, @code{sprintf}, @code{sqrt},
@code{sscanf}, @code{strcat}, @code{strchr}, @code{strcmp},
@code{strcpy}, @code{strcspn}, @code{strlen}, @code{strncat},
@code{strncmp}, @code{strncpy}, @code{strpbrk}, @code{strrchr},
@code{strspn}, @code{strstr}, @code{tanh}, @code{tan}, @code{vfprintf},
@code{vprintf} and @code{vsprintf}
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

View File

@ -1,3 +1,7 @@
2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-ctype-1.c: New test.
2004-03-25 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gcc.dg/torture/builtin-explog-1.c: Add new cases.

View File

@ -0,0 +1,44 @@
/* Copyright (C) 2004 Free Software Foundation.
Verify that built-in ctype function attributes are correctly set by
the compiler.
Written by Kaveh Ghazi, 2004-03-23. */
/* { dg-do link } */
void test(int i)
{
/* All of these ctype functions should be const/pure and thus
eliminated. */
#define TEST_CTYPE(FN) \
extern int FN(int); \
extern void link_failure_##FN(void); \
if (FN(i) != FN(i)) \
link_failure_##FN()
#ifdef __OPTIMIZE__
TEST_CTYPE(isalnum);
TEST_CTYPE(isalpha);
TEST_CTYPE(isascii);
TEST_CTYPE(isblank);
TEST_CTYPE(iscntrl);
TEST_CTYPE(isdigit);
TEST_CTYPE(isgraph);
TEST_CTYPE(islower);
TEST_CTYPE(isprint);
TEST_CTYPE(ispunct);
TEST_CTYPE(isspace);
TEST_CTYPE(isupper);
TEST_CTYPE(isxdigit);
TEST_CTYPE(toascii);
TEST_CTYPE(tolower);
TEST_CTYPE(toupper);
#endif /* __OPTIMIZE__ */
}
int main (void)
{
return 0;
}