* [3.4-BIB] Add trunc/round/floor/ceil/rint builtins @ 2002-11-06 2:27 Jan Hubicka 2002-11-06 6:03 ` Joseph S. Myers 2002-11-06 10:29 ` Richard Henderson 0 siblings, 2 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 2:27 UTC (permalink / raw) To: gcc-patches, rth Hi, this if the first change that adds the new builtins. Later I would like to add lrint and frinds too together with code simplifying rint to lrint and so on. I've found several occurences of these in mesa, crystal space and other 3d internal loops. Just first step :) Honza Tue Nov 5 19:12:19 PST 2002 Jan Hubicka <jh@suse.cz> * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/rint (expand_builtin): Likewise. * builtins.def: Add __builtin_floor, __builtin_floorf, __builtin_floorl __builtin_ceil, __builtin_ceilf, __builtin_ceill __builtin_round, __builtin_roundf, __builtin_roundl __builtin_trunc, __builtin_truncf, __builtin_truncl __builtin_rint, __builtin_rintf, __builtin_rintl. * genopinit.c (optabs): Initialize the new optabs. * optab.c (init_optabs): Likewise. * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, OTI_round, OTI_rint. (floor_optab, ceil_optab, trunc_optab, round_optab, rint_optab): New. * md.texi: Document new named patterns. Index: builtins.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.c,v retrieving revision 1.159.2.1 diff -c -3 -p -r1.159.2.1 builtins.c *** builtins.c 16 Oct 2002 16:07:05 -0000 1.159.2.1 --- builtins.c 6 Nov 2002 10:12:28 -0000 *************** expand_builtin_mathfn (exp, target, subt *** 1483,1488 **** --- 1483,1489 ---- tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree arglist = TREE_OPERAND (exp, 1); enum machine_mode argmode; + bool errno_set = true; if (!validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) return 0; *************** expand_builtin_mathfn (exp, target, subt *** 1533,1538 **** --- 1534,1559 ---- case BUILT_IN_LOGF: case BUILT_IN_LOGL: builtin_optab = log_optab; break; + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + errno_set = false ; builtin_optab = floor_optab; break; + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + errno_set = false ; builtin_optab = ceil_optab; break; + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + errno_set = false ; builtin_optab = trunc_optab; break; + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + errno_set = false ; builtin_optab = round_optab; break; + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: + errno_set = false ; builtin_optab = rint_optab; break; default: abort (); } *************** expand_builtin_mathfn (exp, target, subt *** 1553,1559 **** /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && HONOR_NANS (argmode)) { rtx lab1; --- 1574,1580 ---- /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && errno_set && HONOR_NANS (argmode)) { rtx lab1; *************** expand_builtin (exp, target, subtarget, *** 3743,3748 **** --- 3764,3784 ---- case BUILT_IN_FPUTC_UNLOCKED: case BUILT_IN_FPUTS_UNLOCKED: case BUILT_IN_FWRITE_UNLOCKED: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: return expand_call (exp, target, ignore); default: *************** expand_builtin (exp, target, subtarget, *** 3793,3798 **** --- 3829,3849 ---- case BUILT_IN_SQRT: case BUILT_IN_SQRTF: case BUILT_IN_SQRTL: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: target = expand_builtin_mathfn (exp, target, subtarget); if (target) return target; Index: builtins.def =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.def,v retrieving revision 1.34.2.1 diff -c -3 -p -r1.34.2.1 builtins.def *** builtins.def 16 Oct 2002 16:07:06 -0000 1.34.2.1 --- builtins.def 6 Nov 2002 10:12:28 -0000 *************** DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSL, *** 169,174 **** --- 169,224 ---- "__builtin_fabsl", BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOOR, + "__builtin_floor", + BT_FN_DOUBLE_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOORF, + "__builtin_floorf", + BT_FN_FLOAT_FLOAT) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOORL, + "__builtin_floorl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_CEIL, + "__builtin_ceil", + BT_FN_DOUBLE_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_CEILF, + "__builtin_ceilf", + BT_FN_FLOAT_FLOAT) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_CEILL, + "__builtin_ceill", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_ROUND, + "__builtin_round", + BT_FN_DOUBLE_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_ROUNDF, + "__builtin_roundf", + BT_FN_FLOAT_FLOAT) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_ROUNDL, + "__builtin_roundl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_TRUNC, + "__builtin_trunc", + BT_FN_DOUBLE_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_TRUNCF, + "__builtin_truncf", + BT_FN_FLOAT_FLOAT) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_TRUNCL, + "__builtin_truncl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_RINT, + "__builtin_rint", + BT_FN_DOUBLE_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_RINTF, + "__builtin_rintf", + BT_FN_FLOAT_FLOAT) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_RINTL, + "__builtin_rintl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_LLABS, "__builtin_llabs", BT_FN_LONGLONG_LONGLONG) Index: genopinit.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/genopinit.c,v retrieving revision 1.53 diff -c -3 -p -r1.53 genopinit.c *** genopinit.c 3 Aug 2002 23:21:30 -0000 1.53 --- genopinit.c 6 Nov 2002 10:12:34 -0000 *************** static const char * const optabs[] = *** 112,117 **** --- 112,122 ---- abs_optab->handlers[(int) $A].insn_code = CODE_FOR_$(abs$F$a2$)", "absv_optab->handlers[(int) $A].insn_code = CODE_FOR_$(absv$I$a2$)", "sqrt_optab->handlers[$A].insn_code = CODE_FOR_$(sqrt$a2$)", + "floor_optab->handlers[$A].insn_code = CODE_FOR_$(floor$a2$)", + "ceil_optab->handlers[$A].insn_code = CODE_FOR_$(ceil$a2$)", + "round_optab->handlers[$A].insn_code = CODE_FOR_$(round$a2$)", + "trunc_optab->handlers[$A].insn_code = CODE_FOR_$(trunc$a2$)", + "rint_optab->handlers[$A].insn_code = CODE_FOR_$(rint$a2$)", "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)", "cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$a2$)", "exp_optab->handlers[$A].insn_code = CODE_FOR_$(exp$a2$)", Index: optabs.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.c,v retrieving revision 1.143.2.2 diff -c -3 -p -r1.143.2.2 optabs.c *** optabs.c 30 Oct 2002 22:08:18 -0000 1.143.2.2 --- optabs.c 6 Nov 2002 10:12:35 -0000 *************** init_optabs () *** 5173,5178 **** --- 5173,5183 ---- one_cmpl_optab = init_optab (NOT); ffs_optab = init_optab (FFS); sqrt_optab = init_optab (SQRT); + floor_optab = init_optab (UNKNOWN); + ceil_optab = init_optab (UNKNOWN); + round_optab = init_optab (UNKNOWN); + trunc_optab = init_optab (UNKNOWN); + rint_optab = init_optab (UNKNOWN); sin_optab = init_optab (UNKNOWN); cos_optab = init_optab (UNKNOWN); exp_optab = init_optab (UNKNOWN); Index: optabs.h =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.h,v retrieving revision 1.7 diff -c -3 -p -r1.7 optabs.h *** optabs.h 3 Aug 2002 23:21:30 -0000 1.7 --- optabs.h 6 Nov 2002 10:12:35 -0000 *************** enum optab_index *** 135,140 **** --- 135,146 ---- OTI_exp, /* Natural Logarithm */ OTI_log, + /* Rounding functions */ + OTI_floor, + OTI_ceil, + OTI_trunc, + OTI_round, + OTI_rint, /* Compare insn; two operands. */ OTI_cmp, *************** extern GTY(()) optab optab_table[OTI_MAX *** 204,209 **** --- 210,220 ---- #define cos_optab (optab_table[OTI_cos]) #define exp_optab (optab_table[OTI_exp]) #define log_optab (optab_table[OTI_log]) + #define floor_optab (optab_table[OTI_floor]) + #define ceil_optab (optab_table[OTI_ceil]) + #define trunc_optab (optab_table[OTI_trunc]) + #define round_optab (optab_table[OTI_round]) + #define rint_optab (optab_table[OTI_rint]) #define cmp_optab (optab_table[OTI_cmp]) #define ucmp_optab (optab_table[OTI_ucmp]) Index: doc/md.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/md.texi,v retrieving revision 1.46.2.1 diff -c -3 -p -r1.46.2.1 md.texi *** doc/md.texi 16 Oct 2002 16:08:36 -0000 1.46.2.1 --- doc/md.texi 6 Nov 2002 10:12:45 -0000 *************** corresponds to the C data type @code{dou *** 2563,2568 **** --- 2563,2613 ---- built-in function uses the mode which corresponds to the C data type @code{float}. + @cindex @code{floor@var{m}2} instruction pattern + @item @samp{floor@var{m}2} + Store the largest integral value not greater than argument. + + The @code{floor} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{floorf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{trunc@var{m}2} instruction pattern + @item @samp{trunc@var{m}2} + Store the argument rounded to integer towards zero. + + The @code{trunc} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{truncf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{round@var{m}2} instruction pattern + @item @samp{round@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{round} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{roundf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{ceil@var{m}2} instruction pattern + @item @samp{ceil@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{ceil} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{ceilf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{rint@var{m}2} instruction pattern + @item @samp{rint@var{m}2} + Store the argument rounded to nearest integer. + + The @code{rint} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{rintf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + @cindex @code{ffs@var{m}2} instruction pattern @item @samp{ffs@var{m}2} Store into operandUILT_IN_SINL, BUILT_IN_NORMAL, "sinl", NULL_TREE); ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 2:27 [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Jan Hubicka @ 2002-11-06 6:03 ` Joseph S. Myers 2002-11-06 6:11 ` Jan Hubicka 2002-11-06 10:29 ` Richard Henderson 1 sibling, 1 reply; 36+ messages in thread From: Joseph S. Myers @ 2002-11-06 6:03 UTC (permalink / raw) To: Jan Hubicka; +Cc: gcc-patches, rth On Wed, 6 Nov 2002, Jan Hubicka wrote: > * builtins.def: Add > __builtin_floor, __builtin_floorf, __builtin_floorl > __builtin_ceil, __builtin_ceilf, __builtin_ceill > __builtin_round, __builtin_roundf, __builtin_roundl > __builtin_trunc, __builtin_truncf, __builtin_truncl > __builtin_rint, __builtin_rintf, __builtin_rintl. Built-in functions must be documented in extend.texi. -- Joseph S. Myers jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 6:03 ` Joseph S. Myers @ 2002-11-06 6:11 ` Jan Hubicka 2002-11-06 11:14 ` Joseph S. Myers 0 siblings, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 6:11 UTC (permalink / raw) To: Joseph S. Myers; +Cc: Jan Hubicka, gcc-patches, rth > On Wed, 6 Nov 2002, Jan Hubicka wrote: > > > * builtins.def: Add > > __builtin_floor, __builtin_floorf, __builtin_floorl > > __builtin_ceil, __builtin_ceilf, __builtin_ceill > > __builtin_round, __builtin_roundf, __builtin_roundl > > __builtin_trunc, __builtin_truncf, __builtin_truncl > > __builtin_rint, __builtin_rintf, __builtin_rintl. > > Built-in functions must be documented in extend.texi. Sorry, somehow I've forgot about that hunk of patch. Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> * extend.texi (builtin functions) Document floor, floorf, floorl, ceil, ceilf, ceill, round, roundf, roundl, trunc, truncf, truncl, rint, rintf, rintl. Index: extend.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/extend.texi,v retrieving revision 1.107 diff -c -3 -p -r1.107 extend.texi *** extend.texi 16 Oct 2002 13:14:21 -0000 1.107 --- extend.texi 6 Nov 2002 14:09:05 -0000 *************** v4si f (v4si a, v4si b, v4si c) *** 4568,4573 **** --- 4568,4588 ---- @findex strrchr @findex strspn @findex strstr + @findex floor + @findex floorf + @findex floorl + @findex ceil + @findex ceilf + @findex ceill + @findex round + @findex roundf + @findex roundl + @findex trunc + @findex truncf + @findex truncl + @findex rint + @findex rintf + @findex rintl GCC provides a large number of built-in functions other than the ones mentioned above. Some of these are for internal use in the processing *************** The ISO C99 functions @code{conj}, @code *** 4609,4621 **** 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}, 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{cos}, @code{exp}, @code{fabs}, @code{fprintf}, @code{fputs}, @code{labs}, @code{log}, @code{memcmp}, @code{memcpy}, @code{memset}, @code{printf}, @code{sin}, @code{sqrt}, @code{strcat}, @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn}, --- 4624,4639 ---- 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{floorf}, @code{ceilf}, @code{roundf}, @code{trainf}, @code{rintf}, ! @code{floorl}, @code{ceill}, @code{roundl}, @code{trainl} and @code{rintl} ! 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{round}, @code{train}, @code{rint}, @code{memcmp}, @code{memcpy}, @code{memset}, @code{printf}, @code{sin}, @code{sqrt}, @code{strcat}, @code{strchr}, @code{strcmp}, @code{strcpy}, @code{strcspn}, ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 6:11 ` Jan Hubicka @ 2002-11-06 11:14 ` Joseph S. Myers 2002-11-06 11:29 ` Dale Johannesen 2002-11-06 13:12 ` Jan Hubicka 0 siblings, 2 replies; 36+ messages in thread From: Joseph S. Myers @ 2002-11-06 11:14 UTC (permalink / raw) To: Jan Hubicka; +Cc: gcc-patches, rth On Wed, 6 Nov 2002, Jan Hubicka wrote: > Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> > * extend.texi (builtin functions) Document > floor, floorf, floorl, ceil, ceilf, > ceill, round, roundf, roundl, trunc, > truncf, truncl, rint, rintf, rintl. Some of these are C99-only (the round, trunc, rint functions I think; my copy of C90 isn't to hand right now). Note from comp.std.c and the WG14 reflector that C90 is available for sale again from BSI, I recommend buying it. The C99-only nature of those built-in functions needs to be reflected in both the code and the docs. > 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{floorf}, @code{ceilf}, @code{roundf}, @code{trainf}, @code{rintf}, > ! @code{floorl}, @code{ceill}, @code{roundl}, @code{trainl} and @code{rintl} > ! that are recognized in any mode since ISO C90 reserves "train" appears to be a typo here and below. -- Joseph S. Myers jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 11:14 ` Joseph S. Myers @ 2002-11-06 11:29 ` Dale Johannesen 2002-11-06 13:12 ` Jan Hubicka 1 sibling, 0 replies; 36+ messages in thread From: Dale Johannesen @ 2002-11-06 11:29 UTC (permalink / raw) To: Joseph S. Myers; +Cc: Dale Johannesen, Jan Hubicka, gcc-patches, rth On Wednesday, November 6, 2002, at 11:14 AM, Joseph S. Myers wrote: > On Wed, 6 Nov 2002, Jan Hubicka wrote: > >> Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> >> * extend.texi (builtin functions) Document >> floor, floorf, floorl, ceil, ceilf, >> ceill, round, roundf, roundl, trunc, >> truncf, truncl, rint, rintf, rintl. > > Some of these are C99-only (the round, trunc, rint functions I think; This is correct. Also, the -f and -l variants do not have defined behavior in C90, but the names are reserved. ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 11:14 ` Joseph S. Myers 2002-11-06 11:29 ` Dale Johannesen @ 2002-11-06 13:12 ` Jan Hubicka 2002-11-06 13:18 ` Gabriel Dos Reis 2002-11-06 14:04 ` Dale Johannesen 1 sibling, 2 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 13:12 UTC (permalink / raw) To: Joseph S. Myers; +Cc: Jan Hubicka, gcc-patches, rth > On Wed, 6 Nov 2002, Jan Hubicka wrote: > > > Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> > > * extend.texi (builtin functions) Document > > floor, floorf, floorl, ceil, ceilf, > > ceill, round, roundf, roundl, trunc, > > truncf, truncl, rint, rintf, rintl. > > Some of these are C99-only (the round, trunc, rint functions I think; my > copy of C90 isn't to hand right now). Note from comp.std.c and the WG14 > reflector that C90 is available for sale again from BSI, I recommend > buying it. The C99-only nature of those built-in functions needs to be > reflected in both the code and the docs. I see. Man page claims: CONFORMING TO The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO 9899. The other functions are from C99. So I will disable the builtins for non c++ except for floor, right? > > > 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{floorf}, @code{ceilf}, @code{roundf}, @code{trainf}, @code{rintf}, > > ! @code{floorl}, @code{ceill}, @code{roundl}, @code{trainl} and @code{rintl} > > ! that are recognized in any mode since ISO C90 reserves > > "train" appears to be a typo here and below. Thanks. Honza > > -- > Joseph S. Myers > jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 13:12 ` Jan Hubicka @ 2002-11-06 13:18 ` Gabriel Dos Reis 2002-11-06 13:20 ` Jan Hubicka 2002-11-06 14:04 ` Dale Johannesen 1 sibling, 1 reply; 36+ messages in thread From: Gabriel Dos Reis @ 2002-11-06 13:18 UTC (permalink / raw) To: Jan Hubicka; +Cc: Joseph S. Myers, gcc-patches, rth Jan Hubicka <jh@suse.cz> writes: | > On Wed, 6 Nov 2002, Jan Hubicka wrote: | > | > > Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> | > > * extend.texi (builtin functions) Document | > > floor, floorf, floorl, ceil, ceilf, | > > ceill, round, roundf, roundl, trunc, | > > truncf, truncl, rint, rintf, rintl. | > | > Some of these are C99-only (the round, trunc, rint functions I think; my | > copy of C90 isn't to hand right now). Note from comp.std.c and the WG14 | > reflector that C90 is available for sale again from BSI, I recommend | > buying it. The C99-only nature of those built-in functions needs to be | > reflected in both the code and the docs. | | I see. Man page claims: | CONFORMING TO | The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO | 9899. The other functions are from C99. | | So I will disable the builtins for non c++ except for floor, right? If they are seen as __builtin_xxx() in source code then I don't think there is any need to disable them for C++. -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 13:18 ` Gabriel Dos Reis @ 2002-11-06 13:20 ` Jan Hubicka 2002-11-06 13:31 ` Gabriel Dos Reis 0 siblings, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 13:20 UTC (permalink / raw) To: Gabriel Dos Reis; +Cc: Jan Hubicka, Joseph S. Myers, gcc-patches, rth > Jan Hubicka <jh@suse.cz> writes: > > | > On Wed, 6 Nov 2002, Jan Hubicka wrote: > | > > | > > Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> > | > > * extend.texi (builtin functions) Document > | > > floor, floorf, floorl, ceil, ceilf, > | > > ceill, round, roundf, roundl, trunc, > | > > truncf, truncl, rint, rintf, rintl. > | > > | > Some of these are C99-only (the round, trunc, rint functions I think; my > | > copy of C90 isn't to hand right now). Note from comp.std.c and the WG14 > | > reflector that C90 is available for sale again from BSI, I recommend > | > buying it. The C99-only nature of those built-in functions needs to be > | > reflected in both the code and the docs. > | > | I see. Man page claims: > | CONFORMING TO > | The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO > | 9899. The other functions are from C99. > | > | So I will disable the builtins for non c++ except for floor, right? > > If they are seen as __builtin_xxx() in source code then I don't think > there is any need to disable them for C++. I meant c99. I believe the behaviour is that they will be __bulitin_xxx but not xxx. Honza > > -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 13:20 ` Jan Hubicka @ 2002-11-06 13:31 ` Gabriel Dos Reis 2002-11-06 13:35 ` Jan Hubicka 0 siblings, 1 reply; 36+ messages in thread From: Gabriel Dos Reis @ 2002-11-06 13:31 UTC (permalink / raw) To: Jan Hubicka; +Cc: Joseph S. Myers, gcc-patches, rth Jan Hubicka <jh@suse.cz> writes: [...] | > | I see. Man page claims: | > | CONFORMING TO | > | The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO | > | 9899. The other functions are from C99. | > | | > | So I will disable the builtins for non c++ except for floor, right? | > | > If they are seen as __builtin_xxx() in source code then I don't think | > there is any need to disable them for C++. | I meant c99. OK. But then, I don't understand why you would want to disable it for C89 (the same reason(s) should apply to C++ equally). | I believe the behaviour is that they will be __bulitin_xxx but not xxx. then, I have no problem with it. -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 13:31 ` Gabriel Dos Reis @ 2002-11-06 13:35 ` Jan Hubicka 2002-11-06 13:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Jan Hubicka 2002-11-06 14:04 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Gabriel Dos Reis 0 siblings, 2 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 13:35 UTC (permalink / raw) To: Gabriel Dos Reis; +Cc: Jan Hubicka, Joseph S. Myers, gcc-patches, rth > Jan Hubicka <jh@suse.cz> writes: > > [...] > > | > | I see. Man page claims: > | > | CONFORMING TO > | > | The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO > | > | 9899. The other functions are from C99. > | > | > | > | So I will disable the builtins for non c++ except for floor, right? > | > > | > If they are seen as __builtin_xxx() in source code then I don't think > | > there is any need to disable them for C++. > | I meant c99. > > OK. But then, I don't understand why you would want to disable it for > C89 (the same reason(s) should apply to C++ equally). In case rint is defined only by C99 and C89 don't even reserve it, I have to. In case it is reserved, my previous patch was correct modulo the documentation bit. I don't have standard here, can you check? Honza > > | I believe the behaviour is that they will be __bulitin_xxx but not xxx. > > then, I have no problem with it. > > -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 13:35 ` Jan Hubicka @ 2002-11-06 13:54 ` Jan Hubicka 2002-11-06 14:29 ` Richard Henderson 2002-11-06 14:04 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Gabriel Dos Reis 1 sibling, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 13:54 UTC (permalink / raw) To: Jan Hubicka; +Cc: Gabriel Dos Reis, Joseph S. Myers, gcc-patches, rth Hi, here is patch with updates for the C99 standard. OK now? Tue Nov 5 19:12:19 PST 2002 Jan Hubicka <jh@suse.cz> * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/rint (expand_builtin): Likewise. * builtins.def: Add __builtin_floor, __builtin_floorf, __builtin_floorl __builtin_ceil, __builtin_ceilf, __builtin_ceill __builtin_round, __builtin_roundf, __builtin_roundl __builtin_trunc, __builtin_truncf, __builtin_truncl __builtin_rint, __builtin_rintf, __builtin_rintl. * genopinit.c (optabs): Initialize the new optabs. * optab.c (init_optabs): Likewise. * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, OTI_round, OTI_rint. (floor_optab, ceil_optab, trunc_optab, round_optab, rint_optab): New. * doc/md.texi: Document new named patterns. * doc/extend.texi (builtin functions) Document floor, floorf, floorl, ceil, ceilf, ceill, round, roundf, roundl, trunc, truncf, truncl, rint, rintf, rintl. Index: builtins.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.c,v retrieving revision 1.159.2.1 diff -c -3 -p -r1.159.2.1 builtins.c *** builtins.c 16 Oct 2002 16:07:05 -0000 1.159.2.1 --- builtins.c 6 Nov 2002 21:49:02 -0000 *************** expand_builtin_mathfn (exp, target, subt *** 1483,1488 **** --- 1483,1489 ---- tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree arglist = TREE_OPERAND (exp, 1); enum machine_mode argmode; + bool errno_set = true; if (!validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) return 0; *************** expand_builtin_mathfn (exp, target, subt *** 1533,1538 **** --- 1534,1559 ---- case BUILT_IN_LOGF: case BUILT_IN_LOGL: builtin_optab = log_optab; break; + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + errno_set = false ; builtin_optab = floor_optab; break; + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + errno_set = false ; builtin_optab = ceil_optab; break; + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + errno_set = false ; builtin_optab = trunc_optab; break; + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + errno_set = false ; builtin_optab = round_optab; break; + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: + errno_set = false ; builtin_optab = rint_optab; break; default: abort (); } *************** expand_builtin_mathfn (exp, target, subt *** 1553,1559 **** /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && HONOR_NANS (argmode)) { rtx lab1; --- 1574,1580 ---- /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && errno_set && HONOR_NANS (argmode)) { rtx lab1; *************** expand_builtin (exp, target, subtarget, *** 3743,3748 **** --- 3764,3784 ---- case BUILT_IN_FPUTC_UNLOCKED: case BUILT_IN_FPUTS_UNLOCKED: case BUILT_IN_FWRITE_UNLOCKED: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: return expand_call (exp, target, ignore); default: *************** expand_builtin (exp, target, subtarget, *** 3793,3798 **** --- 3829,3849 ---- case BUILT_IN_SQRT: case BUILT_IN_SQRTF: case BUILT_IN_SQRTL: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: target = expand_builtin_mathfn (exp, target, subtarget); if (target) return target; Index: builtins.def =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.def,v retrieving revision 1.34.2.1 diff -c -3 -p -r1.34.2.1 builtins.def *** builtins.def 16 Oct 2002 16:07:06 -0000 1.34.2.1 --- builtins.def 6 Nov 2002 21:49:02 -0000 *************** DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSL, *** 169,174 **** --- 169,224 ---- "__builtin_fabsl", BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOOR, + "__builtin_floor", + BT_FN_DOUBLE_DOUBLE) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOORF, + "__builtin_floorf", + BT_FN_FLOAT_FLOAT) + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOORL, + "__builtin_floorl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_C99_BUILTIN(BUILT_IN_CEIL, + "__builtin_ceil", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_CEILF, + "__builtin_ceilf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_CEILL, + "__builtin_ceill", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_C99_BUILTIN(BUILT_IN_ROUND, + "__builtin_round", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_ROUNDF, + "__builtin_roundf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_ROUNDL, + "__builtin_roundl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_C99_BUILTIN(BUILT_IN_TRUNC, + "__builtin_trunc", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_TRUNCF, + "__builtin_truncf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_TRUNCL, + "__builtin_truncl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_C99_BUILTIN(BUILT_IN_RINT, + "__builtin_rint", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_RINTF, + "__builtin_rintf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_RINTL, + "__builtin_rintl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_LLABS, "__builtin_llabs", BT_FN_LONGLONG_LONGLONG) Index: genopinit.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/genopinit.c,v retrieving revision 1.53 diff -c -3 -p -r1.53 genopinit.c *** genopinit.c 3 Aug 2002 23:21:30 -0000 1.53 --- genopinit.c 6 Nov 2002 21:49:10 -0000 *************** static const char * const optabs[] = *** 112,117 **** --- 112,122 ---- abs_optab->handlers[(int) $A].insn_code = CODE_FOR_$(abs$F$a2$)", "absv_optab->handlers[(int) $A].insn_code = CODE_FOR_$(absv$I$a2$)", "sqrt_optab->handlers[$A].insn_code = CODE_FOR_$(sqrt$a2$)", + "floor_optab->handlers[$A].insn_code = CODE_FOR_$(floor$a2$)", + "ceil_optab->handlers[$A].insn_code = CODE_FOR_$(ceil$a2$)", + "round_optab->handlers[$A].insn_code = CODE_FOR_$(round$a2$)", + "trunc_optab->handlers[$A].insn_code = CODE_FOR_$(trunc$a2$)", + "rint_optab->handlers[$A].insn_code = CODE_FOR_$(rint$a2$)", "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)", "cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$a2$)", "exp_optab->handlers[$A].insn_code = CODE_FOR_$(exp$a2$)", Index: optabs.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.c,v retrieving revision 1.143.2.2 diff -c -3 -p -r1.143.2.2 optabs.c *** optabs.c 30 Oct 2002 22:08:18 -0000 1.143.2.2 --- optabs.c 6 Nov 2002 21:49:11 -0000 *************** init_optabs () *** 5173,5178 **** --- 5173,5183 ---- one_cmpl_optab = init_optab (NOT); ffs_optab = init_optab (FFS); sqrt_optab = init_optab (SQRT); + floor_optab = init_optab (UNKNOWN); + ceil_optab = init_optab (UNKNOWN); + round_optab = init_optab (UNKNOWN); + trunc_optab = init_optab (UNKNOWN); + rint_optab = init_optab (UNKNOWN); sin_optab = init_optab (UNKNOWN); cos_optab = init_optab (UNKNOWN); exp_optab = init_optab (UNKNOWN); Index: optabs.h =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.h,v retrieving revision 1.7 diff -c -3 -p -r1.7 optabs.h *** optabs.h 3 Aug 2002 23:21:30 -0000 1.7 --- optabs.h 6 Nov 2002 21:49:11 -0000 *************** enum optab_index *** 135,140 **** --- 135,146 ---- OTI_exp, /* Natural Logarithm */ OTI_log, + /* Rounding functions */ + OTI_floor, + OTI_ceil, + OTI_trunc, + OTI_round, + OTI_rint, /* Compare insn; two operands. */ OTI_cmp, *************** extern GTY(()) optab optab_table[OTI_MAX *** 204,209 **** --- 210,220 ---- #define cos_optab (optab_table[OTI_cos]) #define exp_optab (optab_table[OTI_exp]) #define log_optab (optab_table[OTI_log]) + #define floor_optab (optab_table[OTI_floor]) + #define ceil_optab (optab_table[OTI_ceil]) + #define trunc_optab (optab_table[OTI_trunc]) + #define round_optab (optab_table[OTI_round]) + #define rint_optab (optab_table[OTI_rint]) #define cmp_optab (optab_table[OTI_cmp]) #define ucmp_optab (optab_table[OTI_ucmp]) Index: doc/extend.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/extend.texi,v retrieving revision 1.95.2.2 diff -c -3 -p -r1.95.2.2 extend.texi *** doc/extend.texi 23 Oct 2002 15:48:54 -0000 1.95.2.2 --- doc/extend.texi 6 Nov 2002 21:49:23 -0000 *************** v4si f (v4si a, v4si b, v4si c) *** 4568,4573 **** --- 4568,4588 ---- @findex strrchr @findex strspn @findex strstr + @findex floor + @findex floorf + @findex floorl + @findex ceil + @findex ceilf + @findex ceill + @findex round + @findex roundf + @findex roundl + @findex trunc + @findex truncf + @findex truncl + @findex rint + @findex rintf + @findex rintl GCC provides a large number of built-in functions other than the ones mentioned above. Some of these are for internal use in the processing *************** built-in functions. All these functions *** 4603,4630 **** 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}, @code{llabs} and @code{imaxabs} 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}, 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{cos}, @code{exp}, @code{fabs}, ! @code{fprintf}, @code{fputs}, @code{labs}, @code{log}, ! @code{memcmp}, @code{memcpy}, ! @code{memset}, @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 corresponding ! versions prefixed with @code{__builtin_}. GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have --- 4618,4646 ---- 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}, ! @code{llabs}, @code{imaxabs}, @code{ceil}, @code{round}, @code{train}, ! @code{rint}, @code{ceilf}, @code{roundf}, @code{rintf}, @code{ceill}, ! @code{roundl}, @code{truncl} and @code{rintl} 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{floorl}, @code{floorf} and @code{floor} 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{memcmp}, @code{memcpy}, @code{memset}, @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 corresponding versions prefixed with ! @code{__builtin_}. GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have Index: doc/md.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/md.texi,v retrieving revision 1.46.2.1 diff -c -3 -p -r1.46.2.1 md.texi *** doc/md.texi 16 Oct 2002 16:08:36 -0000 1.46.2.1 --- doc/md.texi 6 Nov 2002 21:49:24 -0000 *************** corresponds to the C data type @code{dou *** 2563,2568 **** --- 2563,2613 ---- built-in function uses the mode which corresponds to the C data type @code{float}. + @cindex @code{floor@var{m}2} instruction pattern + @item @samp{floor@var{m}2} + Store the largest integral value not greater than argument. + + The @code{floor} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{floorf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{trunc@var{m}2} instruction pattern + @item @samp{trunc@var{m}2} + Store the argument rounded to integer towards zero. + + The @code{trunc} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{truncf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{round@var{m}2} instruction pattern + @item @samp{round@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{round} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{roundf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{ceil@var{m}2} instruction pattern + @item @samp{ceil@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{ceil} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{ceilf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{rint@var{m}2} instruction pattern + @item @samp{rint@var{m}2} + Store the argument rounded to nearest integer. + + The @code{rint} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{rintf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + @cindex @code{ffs@var{m}2} instruction pattern @item @samp{ffs@var{m}2} Store into operand 0 one plus the index of the least significant 1-bit ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 13:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Jan Hubicka @ 2002-11-06 14:29 ` Richard Henderson 2002-11-06 14:41 ` Jan Hubicka 2002-11-06 14:52 ` Jan Hubicka 0 siblings, 2 replies; 36+ messages in thread From: Richard Henderson @ 2002-11-06 14:29 UTC (permalink / raw) To: Jan Hubicka; +Cc: Gabriel Dos Reis, Joseph S. Myers, gcc-patches On Wed, Nov 06, 2002 at 10:54:05PM +0100, Jan Hubicka wrote: > + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOOR, > + "__builtin_floor", > + BT_FN_DOUBLE_DOUBLE) Surely this should be DEF_LIB_BUILTIN, since floor is in C90. > + DEF_C99_BUILTIN(BUILT_IN_CEIL, > + "__builtin_ceil", > + BT_FN_DOUBLE_DOUBLE) I would be shocked if this didn't exist on a platform that did have floor, and thus I would think that we should be able to fall back on the libm version if the target doesn't support it. Do these show up as "foo" when !flag_iso? r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 14:29 ` Richard Henderson @ 2002-11-06 14:41 ` Jan Hubicka 2002-11-06 14:52 ` Jan Hubicka 1 sibling, 0 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 14:41 UTC (permalink / raw) To: Richard Henderson, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches > On Wed, Nov 06, 2002 at 10:54:05PM +0100, Jan Hubicka wrote: > > + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOOR, > > + "__builtin_floor", > > + BT_FN_DOUBLE_DOUBLE) > > Surely this should be DEF_LIB_BUILTIN, since floor is in C90. OK, I see now. Should it use ATTR_CONST_NOTHROW_LIST? > > > + DEF_C99_BUILTIN(BUILT_IN_CEIL, > > + "__builtin_ceil", > > + BT_FN_DOUBLE_DOUBLE) > > I would be shocked if this didn't exist on a platform that did > have floor, and thus I would think that we should be able to > fall back on the libm version if the target doesn't support it. I was wrong here. ceil is standard. > > Do these show up as "foo" when !flag_iso? Hmm, it seems to require flag_isoc99. I will update the patch fith time :) Honza ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 14:29 ` Richard Henderson 2002-11-06 14:41 ` Jan Hubicka @ 2002-11-06 14:52 ` Jan Hubicka 2002-11-06 15:06 ` Richard Henderson ` (2 more replies) 1 sibling, 3 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 14:52 UTC (permalink / raw) To: Richard Henderson, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches > On Wed, Nov 06, 2002 at 10:54:05PM +0100, Jan Hubicka wrote: > > + DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FLOOR, > > + "__builtin_floor", > > + BT_FN_DOUBLE_DOUBLE) > > Surely this should be DEF_LIB_BUILTIN, since floor is in C90. > > > + DEF_C99_BUILTIN(BUILT_IN_CEIL, > > + "__builtin_ceil", > > + BT_FN_DOUBLE_DOUBLE) > > I would be shocked if this didn't exist on a platform that did > have floor, and thus I would think that we should be able to > fall back on the libm version if the target doesn't support it. > > Do these show up as "foo" when !flag_iso? OK, here is fifth update. Does it look ok now? Hope so... Perhaps I will need to add FLAG_PURE_LIST but I am not quite sure why, as none of these can trap, so I am not quite sure why sqrt is doing that at first time. Honza Wed Nov 6 23:23:27 CET 2002 Jan Hubicka <jh@suse.cz> * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/rint (expand_builtin): Likewise. * builtins.def: Add __builtin_floor, __builtin_floorf, __builtin_floorl __builtin_ceil, __builtin_ceilf, __builtin_ceill __builtin_round, __builtin_roundf, __builtin_roundl __builtin_trunc, __builtin_truncf, __builtin_truncl __builtin_rint, __builtin_rintf, __builtin_rintl. * genopinit.c (optabs): Initialize the new optabs. * optab.c (init_optabs): Likewise. * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, OTI_round, OTI_rint. (floor_optab, ceil_optab, trunc_optab, round_optab, rint_optab): New. * doc/md.texi: Document new named patterns. * doc/extend.texi (builtin functions) Document floor, floorf, floorl, ceil, ceilf, ceill, round, roundf, roundl, trunc, truncf, truncl, rint, rintf, rintl. Index: builtins.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.c,v retrieving revision 1.159.4.4 diff -c -3 -p -r1.159.4.4 builtins.c *** builtins.c 4 Nov 2002 00:04:22 -0000 1.159.4.4 --- builtins.c 6 Nov 2002 22:46:15 -0000 *************** expand_builtin_mathfn (exp, target, subt *** 1483,1488 **** --- 1483,1489 ---- tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree arglist = TREE_OPERAND (exp, 1); enum machine_mode argmode; + bool errno_set = true; if (!validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) return 0; *************** expand_builtin_mathfn (exp, target, subt *** 1533,1538 **** --- 1534,1559 ---- case BUILT_IN_LOGF: case BUILT_IN_LOGL: builtin_optab = log_optab; break; + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + errno_set = false ; builtin_optab = floor_optab; break; + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + errno_set = false ; builtin_optab = ceil_optab; break; + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + errno_set = false ; builtin_optab = trunc_optab; break; + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + errno_set = false ; builtin_optab = round_optab; break; + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: + errno_set = false ; builtin_optab = rint_optab; break; default: abort (); } *************** expand_builtin_mathfn (exp, target, subt *** 1553,1559 **** /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && HONOR_NANS (argmode)) { rtx lab1; --- 1574,1580 ---- /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && errno_set && HONOR_NANS (argmode)) { rtx lab1; *************** expand_builtin (exp, target, subtarget, *** 3743,3748 **** --- 3764,3784 ---- case BUILT_IN_FPUTC_UNLOCKED: case BUILT_IN_FPUTS_UNLOCKED: case BUILT_IN_FWRITE_UNLOCKED: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: return expand_call (exp, target, ignore); default: *************** expand_builtin (exp, target, subtarget, *** 3793,3798 **** --- 3829,3849 ---- case BUILT_IN_SQRT: case BUILT_IN_SQRTF: case BUILT_IN_SQRTL: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_RINT: + case BUILT_IN_RINTF: + case BUILT_IN_RINTL: target = expand_builtin_mathfn (exp, target, subtarget); if (target) return target; Index: builtins.def =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.def,v retrieving revision 1.34.4.3 diff -c -3 -p -r1.34.4.3 builtins.def *** builtins.def 1 Oct 2002 17:31:36 -0000 1.34.4.3 --- builtins.def 6 Nov 2002 22:46:15 -0000 *************** DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSL, *** 169,174 **** --- 169,230 ---- "__builtin_fabsl", BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_LIB_BUILTIN(BUILT_IN_FLOOR, + "__builtin_floor", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_FLOORF, + "__builtin_floorf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_FLOORL, + "__builtin_floorl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + + DEF_LIB_BUILTIN(BUILT_IN_CEIL, + "__builtin_ceil", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_CEILF, + "__builtin_ceilf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_CEILL, + "__builtin_ceill", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + + DEF_C99_BUILTIN(BUILT_IN_ROUND, + "__builtin_round", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_ROUNDF, + "__builtin_roundf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_ROUNDL, + "__builtin_roundl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_C99_BUILTIN(BUILT_IN_TRUNC, + "__builtin_trunc", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_TRUNCF, + "__builtin_truncf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_TRUNCL, + "__builtin_truncl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + + DEF_C99_BUILTIN(BUILT_IN_RINT, + "__builtin_rint", + BT_FN_DOUBLE_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_RINTF, + "__builtin_rintf", + BT_FN_FLOAT_FLOAT) + DEF_C99_BUILTIN(BUILT_IN_RINTL, + "__builtin_rintl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_C99_BUILTIN(BUILT_IN_LLABS, "__builtin_llabs", BT_FN_LONGLONG_LONGLONG) Index: genopinit.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/genopinit.c,v retrieving revision 1.53 diff -c -3 -p -r1.53 genopinit.c *** genopinit.c 3 Aug 2002 23:21:30 -0000 1.53 --- genopinit.c 6 Nov 2002 22:46:15 -0000 *************** static const char * const optabs[] = *** 112,117 **** --- 112,122 ---- abs_optab->handlers[(int) $A].insn_code = CODE_FOR_$(abs$F$a2$)", "absv_optab->handlers[(int) $A].insn_code = CODE_FOR_$(absv$I$a2$)", "sqrt_optab->handlers[$A].insn_code = CODE_FOR_$(sqrt$a2$)", + "floor_optab->handlers[$A].insn_code = CODE_FOR_$(floor$a2$)", + "ceil_optab->handlers[$A].insn_code = CODE_FOR_$(ceil$a2$)", + "round_optab->handlers[$A].insn_code = CODE_FOR_$(round$a2$)", + "trunc_optab->handlers[$A].insn_code = CODE_FOR_$(trunc$a2$)", + "rint_optab->handlers[$A].insn_code = CODE_FOR_$(rint$a2$)", "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)", "cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$a2$)", "exp_optab->handlers[$A].insn_code = CODE_FOR_$(exp$a2$)", Index: optabs.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.c,v retrieving revision 1.143.4.5 diff -c -3 -p -r1.143.4.5 optabs.c *** optabs.c 28 Oct 2002 19:47:07 -0000 1.143.4.5 --- optabs.c 6 Nov 2002 22:46:17 -0000 *************** init_optabs () *** 5173,5178 **** --- 5173,5183 ---- one_cmpl_optab = init_optab (NOT); ffs_optab = init_optab (FFS); sqrt_optab = init_optab (SQRT); + floor_optab = init_optab (UNKNOWN); + ceil_optab = init_optab (UNKNOWN); + round_optab = init_optab (UNKNOWN); + trunc_optab = init_optab (UNKNOWN); + rint_optab = init_optab (UNKNOWN); sin_optab = init_optab (UNKNOWN); cos_optab = init_optab (UNKNOWN); exp_optab = init_optab (UNKNOWN); Index: optabs.h =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.h,v retrieving revision 1.7 diff -c -3 -p -r1.7 optabs.h *** optabs.h 3 Aug 2002 23:21:30 -0000 1.7 --- optabs.h 6 Nov 2002 22:46:17 -0000 *************** enum optab_index *** 135,140 **** --- 135,146 ---- OTI_exp, /* Natural Logarithm */ OTI_log, + /* Rounding functions */ + OTI_floor, + OTI_ceil, + OTI_trunc, + OTI_round, + OTI_rint, /* Compare insn; two operands. */ OTI_cmp, *************** extern GTY(()) optab optab_table[OTI_MAX *** 204,209 **** --- 210,220 ---- #define cos_optab (optab_table[OTI_cos]) #define exp_optab (optab_table[OTI_exp]) #define log_optab (optab_table[OTI_log]) + #define floor_optab (optab_table[OTI_floor]) + #define ceil_optab (optab_table[OTI_ceil]) + #define trunc_optab (optab_table[OTI_trunc]) + #define round_optab (optab_table[OTI_round]) + #define rint_optab (optab_table[OTI_rint]) #define cmp_optab (optab_table[OTI_cmp]) #define ucmp_optab (optab_table[OTI_ucmp]) Index: doc/extend.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/extend.texi,v retrieving revision 1.95.4.5 diff -c -3 -p -r1.95.4.5 extend.texi *** doc/extend.texi 21 Oct 2002 17:52:59 -0000 1.95.4.5 --- doc/extend.texi 6 Nov 2002 22:46:21 -0000 *************** v4si f (v4si a, v4si b, v4si c) *** 4568,4573 **** --- 4568,4588 ---- @findex strrchr @findex strspn @findex strstr + @findex floor + @findex floorf + @findex floorl + @findex ceil + @findex ceilf + @findex ceill + @findex round + @findex roundf + @findex roundl + @findex trunc + @findex truncf + @findex truncl + @findex rint + @findex rintf + @findex rintl GCC provides a large number of built-in functions other than the ones mentioned above. Some of these are for internal use in the processing *************** built-in functions. All these functions *** 4603,4630 **** 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}, @code{llabs} and @code{imaxabs} 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}, 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{cos}, @code{exp}, @code{fabs}, ! @code{fprintf}, @code{fputs}, @code{labs}, @code{log}, ! @code{memcmp}, @code{memcpy}, ! @code{memset}, @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 corresponding ! versions prefixed with @code{__builtin_}. GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have --- 4618,4646 ---- 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}, ! @code{llabs}, @code{imaxabs}, @code{round}, @code{trunc}, @code{rint}, ! @code{roundf}, @code{truncf}, @code{rintf}, @code{roundl}, @code{truncl} and ! @code{rintl} 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{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 ! corresponding versions prefixed with @code{__builtin_}. GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have Index: doc/md.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/md.texi,v retrieving revision 1.47.2.3 diff -c -3 -p -r1.47.2.3 md.texi *** doc/md.texi 5 Nov 2002 19:12:27 -0000 1.47.2.3 --- doc/md.texi 6 Nov 2002 22:46:25 -0000 *************** corresponds to the C data type @code{dou *** 2569,2574 **** --- 2569,2619 ---- built-in function uses the mode which corresponds to the C data type @code{float}. + @cindex @code{floor@var{m}2} instruction pattern + @item @samp{floor@var{m}2} + Store the largest integral value not greater than argument. + + The @code{floor} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{floorf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{trunc@var{m}2} instruction pattern + @item @samp{trunc@var{m}2} + Store the argument rounded to integer towards zero. + + The @code{trunc} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{truncf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{round@var{m}2} instruction pattern + @item @samp{round@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{round} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{roundf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{ceil@var{m}2} instruction pattern + @item @samp{ceil@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{ceil} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{ceilf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{rint@var{m}2} instruction pattern + @item @samp{rint@var{m}2} + Store the argument rounded to nearest integer. + + The @code{rint} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{rintf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + @cindex @code{ffs@var{m}2} instruction pattern @item @samp{ffs@var{m}2} Store into operand 0 one plus the index of the least significant 1-bit ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 14:52 ` Jan Hubicka @ 2002-11-06 15:06 ` Richard Henderson 2002-11-06 15:32 ` Dale Johannesen 2002-11-07 1:08 ` Jan Hubicka 2002-11-06 16:05 ` Joseph S. Myers 2002-11-07 4:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Hans-Peter Nilsson 2 siblings, 2 replies; 36+ messages in thread From: Richard Henderson @ 2002-11-06 15:06 UTC (permalink / raw) To: Jan Hubicka; +Cc: Gabriel Dos Reis, Joseph S. Myers, gcc-patches On Wed, Nov 06, 2002 at 11:52:33PM +0100, Jan Hubicka wrote: > + DEF_LIB_BUILTIN(BUILT_IN_FLOOR, > + "__builtin_floor", > + BT_FN_DOUBLE_DOUBLE, > + ATTR_CONST_NOTHROW_LIST) > + DEF_LIB_BUILTIN(BUILT_IN_FLOORF, > + "__builtin_floorf", > + BT_FN_FLOAT_FLOAT, > + ATTR_CONST_NOTHROW_LIST) Well, see, C90 does have floor, but not floorf, IIRC. Unfortunately I seem to have misplaced my C90 book, so I can't check at the moment. :-( So the -f and -l forms need to be DEF_C99_BUILTIN as well. Also, it would be a Good Thing if DEF_C99_BUILTIN took an ATTRS parameter as well, since ATTR_CONST_NOTHROW_LIST is correct for all of these. r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:06 ` Richard Henderson @ 2002-11-06 15:32 ` Dale Johannesen 2002-11-06 15:48 ` Richard Henderson 2002-11-07 1:08 ` Jan Hubicka 1 sibling, 1 reply; 36+ messages in thread From: Dale Johannesen @ 2002-11-06 15:32 UTC (permalink / raw) To: Richard Henderson Cc: Dale Johannesen, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches On Wednesday, November 6, 2002, at 03:06 PM, Richard Henderson wrote: > On Wed, Nov 06, 2002 at 11:52:33PM +0100, Jan Hubicka wrote: >> + DEF_LIB_BUILTIN(BUILT_IN_FLOOR, >> + "__builtin_floor", >> + BT_FN_DOUBLE_DOUBLE, >> + ATTR_CONST_NOTHROW_LIST) >> + DEF_LIB_BUILTIN(BUILT_IN_FLOORF, >> + "__builtin_floorf", >> + BT_FN_FLOAT_FLOAT, >> + ATTR_CONST_NOTHROW_LIST) > > Well, see, C90 does have floor, but not floorf, IIRC. > Unfortunately I seem to have misplaced my C90 book, > so I can't check at the moment. :-( > > So the -f and -l forms need to be DEF_C99_BUILTIN as well. Hmm, I addressed this once, but I see it was accidentally private e-mail. This is what C90 says: floor[lf] ceil[lf] are reserved: "The names of [floor and ceil], suffixed with f or l, are reserved respectively for corresponding functions with float and long double arguments and return values." But implementing such functions is not required. I'd read this to say you can implement them if you want to. ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:32 ` Dale Johannesen @ 2002-11-06 15:48 ` Richard Henderson 2002-11-06 15:57 ` Dale Johannesen ` (2 more replies) 0 siblings, 3 replies; 36+ messages in thread From: Richard Henderson @ 2002-11-06 15:48 UTC (permalink / raw) To: Dale Johannesen Cc: Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches On Wed, Nov 06, 2002 at 03:31:48PM -0800, Dale Johannesen wrote: > This is what C90 says: > > floor[lf] ceil[lf] are reserved: > > "The names of [floor and ceil], suffixed with f or l, are reserved > respectively for corresponding functions with float and long double > arguments and return values." > > But implementing such functions is not required. I'd read this to > say you can implement them if you want to. What it means is that we can't make __builtin_floorf call floorf if the backend doesn't implement the pattern though. I think. r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:48 ` Richard Henderson @ 2002-11-06 15:57 ` Dale Johannesen 2002-11-07 0:48 ` Neil Booth 2002-11-06 16:01 ` Joseph S. Myers 2002-11-07 1:08 ` Jan Hubicka 2 siblings, 1 reply; 36+ messages in thread From: Dale Johannesen @ 2002-11-06 15:57 UTC (permalink / raw) To: Richard Henderson Cc: Dale Johannesen, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches On Wednesday, November 6, 2002, at 03:47 PM, Richard Henderson wrote: > On Wed, Nov 06, 2002 at 03:31:48PM -0800, Dale Johannesen wrote: >> This is what C90 says: >> >> floor[lf] ceil[lf] are reserved: >> >> "The names of [floor and ceil], suffixed with f or l, are reserved >> respectively for corresponding functions with float and long double >> arguments and return values." >> >> But implementing such functions is not required. I'd read this to >> say you can implement them if you want to. > > What it means is that we can't make __builtin_floorf call > floorf if the backend doesn't implement the pattern though. Right, the compiler can't assume a library function named floorf exists (in C90 mode). Generating code for it inline is OK though, I think. Now if the compiler were to acquire ownership of the library... ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:57 ` Dale Johannesen @ 2002-11-07 0:48 ` Neil Booth 0 siblings, 0 replies; 36+ messages in thread From: Neil Booth @ 2002-11-07 0:48 UTC (permalink / raw) To: Dale Johannesen Cc: Richard Henderson, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches Dale Johannesen wrote:- > Now if the compiler were to acquire ownership of the library... Hey, we can add email too if you like 8-) Neil. ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:48 ` Richard Henderson 2002-11-06 15:57 ` Dale Johannesen @ 2002-11-06 16:01 ` Joseph S. Myers 2002-11-06 16:04 ` Richard Henderson 2002-11-07 1:08 ` Jan Hubicka 2 siblings, 1 reply; 36+ messages in thread From: Joseph S. Myers @ 2002-11-06 16:01 UTC (permalink / raw) To: Richard Henderson Cc: Dale Johannesen, Jan Hubicka, Gabriel Dos Reis, gcc-patches On Wed, 6 Nov 2002, Richard Henderson wrote: > What it means is that we can't make __builtin_floorf call > floorf if the backend doesn't implement the pattern though. > > I think. It's normal for __builtin_foo to require the library to have the function foo. Problems are only if it converts to a call to a different function (e.g., float f; __builtin_floor(f); mustn't get converted to a call to floorf). -- Joseph S. Myers jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 16:01 ` Joseph S. Myers @ 2002-11-06 16:04 ` Richard Henderson 2002-11-07 1:10 ` Jan Hubicka 0 siblings, 1 reply; 36+ messages in thread From: Richard Henderson @ 2002-11-06 16:04 UTC (permalink / raw) To: Joseph S. Myers Cc: Dale Johannesen, Jan Hubicka, Gabriel Dos Reis, gcc-patches On Thu, Nov 07, 2002 at 12:01:13AM +0000, Joseph S. Myers wrote: > It's normal for __builtin_foo to require the library to have the function > foo. Problems are only if it converts to a call to a different function > (e.g., float f; __builtin_floor(f); mustn't get converted to a call to > floorf). Much better. I guess we'll need tests for all of this... r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 16:04 ` Richard Henderson @ 2002-11-07 1:10 ` Jan Hubicka 0 siblings, 0 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-07 1:10 UTC (permalink / raw) To: Richard Henderson, Joseph S. Myers, Dale Johannesen, Jan Hubicka, Gabriel Dos Reis, gcc-patches > On Thu, Nov 07, 2002 at 12:01:13AM +0000, Joseph S. Myers wrote: > > It's normal for __builtin_foo to require the library to have the function > > foo. Problems are only if it converts to a call to a different function > > (e.g., float f; __builtin_floor(f); mustn't get converted to a call to > > floorf). > > Much better. This does not happen at the moment. Of course I plan this to do as next step. What interface would you like for that? Perhaps I can just test for flag_isoc99 when producing floorf? Honza > > I guess we'll need tests for all of this... > > > r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:48 ` Richard Henderson 2002-11-06 15:57 ` Dale Johannesen 2002-11-06 16:01 ` Joseph S. Myers @ 2002-11-07 1:08 ` Jan Hubicka 2 siblings, 0 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-07 1:08 UTC (permalink / raw) To: Richard Henderson, Dale Johannesen, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches > On Wed, Nov 06, 2002 at 03:31:48PM -0800, Dale Johannesen wrote: > > This is what C90 says: > > > > floor[lf] ceil[lf] are reserved: > > > > "The names of [floor and ceil], suffixed with f or l, are reserved > > respectively for corresponding functions with float and long double > > arguments and return values." > > > > But implementing such functions is not required. I'd read this to > > say you can implement them if you want to. > > What it means is that we can't make __builtin_floorf call > floorf if the backend doesn't implement the pattern though. > > I think. We can, when __builtin_floorf has undefined behaviour, we can do anything we like to. Honza > > > r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 15:06 ` Richard Henderson 2002-11-06 15:32 ` Dale Johannesen @ 2002-11-07 1:08 ` Jan Hubicka 1 sibling, 0 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-07 1:08 UTC (permalink / raw) To: Richard Henderson, Jan Hubicka, Gabriel Dos Reis, Joseph S. Myers, gcc-patches > On Wed, Nov 06, 2002 at 11:52:33PM +0100, Jan Hubicka wrote: > > + DEF_LIB_BUILTIN(BUILT_IN_FLOOR, > > + "__builtin_floor", > > + BT_FN_DOUBLE_DOUBLE, > > + ATTR_CONST_NOTHROW_LIST) > > + DEF_LIB_BUILTIN(BUILT_IN_FLOORF, > > + "__builtin_floorf", > > + BT_FN_FLOAT_FLOAT, > > + ATTR_CONST_NOTHROW_LIST) > > Well, see, C90 does have floor, but not floorf, IIRC. > Unfortunately I seem to have misplaced my C90 book, > so I can't check at the moment. :-( They are same category as fabsl - not defined behaviour in C90 but reserved names, so we can safely define these in C99 way. > > So the -f and -l forms need to be DEF_C99_BUILTIN as well. > > Also, it would be a Good Thing if DEF_C99_BUILTIN took an > ATTRS parameter as well, since ATTR_CONST_NOTHROW_LIST is > correct for all of these. I can add this in next patch. Or should I include that? Honza > > > r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 14:52 ` Jan Hubicka 2002-11-06 15:06 ` Richard Henderson @ 2002-11-06 16:05 ` Joseph S. Myers 2002-11-07 1:10 ` Jan Hubicka 2002-11-07 4:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Hans-Peter Nilsson 2 siblings, 1 reply; 36+ messages in thread From: Joseph S. Myers @ 2002-11-06 16:05 UTC (permalink / raw) To: Jan Hubicka; +Cc: Richard Henderson, Gabriel Dos Reis, gcc-patches On Wed, 6 Nov 2002, Jan Hubicka wrote: > OK, here is fifth update. > Does it look ok now? Hope so... There should be testcases. Except for rint*, these functions ought to be optimized for constant arguments unconditionally. (Even without optimizations for constant arguments, you can still do execution tests for the sanity of the built-ins.) -- Joseph S. Myers jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 16:05 ` Joseph S. Myers @ 2002-11-07 1:10 ` Jan Hubicka 2002-11-07 1:18 ` Jan Hubicka 0 siblings, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-07 1:10 UTC (permalink / raw) To: Joseph S. Myers Cc: Jan Hubicka, Richard Henderson, Gabriel Dos Reis, gcc-patches > On Wed, 6 Nov 2002, Jan Hubicka wrote: > > > OK, here is fifth update. > > Does it look ok now? Hope so... > > There should be testcases. Except for rint*, these functions ought to be > optimized for constant arguments unconditionally. (Even without > optimizations for constant arguments, you can still do execution tests for > the sanity of the built-ins.) I would like to do optimizations next. THe patch is already problematic enought. Honza > > -- > Joseph S. Myers > jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-07 1:10 ` Jan Hubicka @ 2002-11-07 1:18 ` Jan Hubicka 2002-11-07 3:05 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins III Jan Hubicka 0 siblings, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-07 1:18 UTC (permalink / raw) To: Jan Hubicka Cc: Joseph S. Myers, Richard Henderson, Gabriel Dos Reis, gcc-patches > > On Wed, 6 Nov 2002, Jan Hubicka wrote: > > > > > OK, here is fifth update. > > > Does it look ok now? Hope so... > > > > There should be testcases. Except for rint*, these functions ought to be > > optimized for constant arguments unconditionally. (Even without > > optimizations for constant arguments, you can still do execution tests for > > the sanity of the built-ins.) > > I would like to do optimizations next. THe patch is already problematic > enought. But if you have idea for testcases just for the fact that the builtins are recognized, I will add these. Otherwise I will add testcases for the optimizations that will trigger link errors when these does not happen. Richard, any hints on how to fold-const these using the emulator? Honza > > Honza > > > > -- > > Joseph S. Myers > > jsm28@cam.ac.uk ^ permalink raw reply [flat|nested] 36+ messages in thread
* [3.4-BIB] Add trunc/round/floor/ceil/rint builtins III 2002-11-07 1:18 ` Jan Hubicka @ 2002-11-07 3:05 ` Jan Hubicka 2002-11-07 16:56 ` Richard Henderson 0 siblings, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-07 3:05 UTC (permalink / raw) To: Jan Hubicka Cc: Joseph S. Myers, Richard Henderson, Gabriel Dos Reis, gcc-patches Hi, this patch combines all the problems we found so far: 1) I've changed rint builtin to nearbyint. None of the other builtins do exception, so nearbyint completes the familly, not rint. In next turn we can add rint one that will exapnd into nearbyint when inlining and rint call when not when the hypotesis about not trapping is correct or do that for fast-math when not. 2) I've added attrs to C99 builtins per Richard's request 3) I kept floorl/floorf/ceill/ceilf as LIB_BUILTINS, so in C90 mode we recognize floorl and expand it into floorl call by default. This is consistent as C90 reserve the name. To be C90 library compliant, we probably want prevent the implicit construction of these, but this can be done by separate patch as we produce none (but we produce similar cases in the other patch) We can still produce floorf style functions and expand these into (float)floor((double)x) when in-line expansion fails, but this is complicated, so I would like to handle this incrementaly. Honza Wed Nov 6 23:23:27 CET 2002 Jan Hubicka <jh@suse.cz> * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/nearbyint (expand_builtin): Likewise. * builtins.def: Add __builtin_floor, __builtin_floorf, __builtin_floorl __builtin_ceil, __builtin_ceilf, __builtin_ceill __builtin_round, __builtin_roundf, __builtin_roundl __builtin_trunc, __builtin_truncf, __builtin_truncl __builtin_nearbyint, __builtin_nearbyintf, __builtin_nearbyintl. * genopinit.c (optabs): Initialize the new optabs. * optab.c (init_optabs): Likewise. * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, OTI_round, OTI_nearbyint. (floor_optab, ceil_optab, trunc_optab, round_optab, nearbyint_optab): New. * doc/md.texi: Document new named patterns. * doc/extend.texi (builtin functions) Document floor, floorf, floorl, ceil, ceilf, ceill, round, roundf, roundl, trunc, truncf, truncl, nearbyint, nearbyintf, nearbyintl. Index: builtins.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.c,v retrieving revision 1.159.4.4 diff -c -3 -p -r1.159.4.4 builtins.c *** builtins.c 4 Nov 2002 00:04:22 -0000 1.159.4.4 --- builtins.c 7 Nov 2002 10:45:54 -0000 *************** expand_builtin_mathfn (exp, target, subt *** 1483,1488 **** --- 1483,1489 ---- tree fndecl = TREE_OPERAND (TREE_OPERAND (exp, 0), 0); tree arglist = TREE_OPERAND (exp, 1); enum machine_mode argmode; + bool errno_set = true; if (!validate_arglist (arglist, REAL_TYPE, VOID_TYPE)) return 0; *************** expand_builtin_mathfn (exp, target, subt *** 1533,1538 **** --- 1534,1559 ---- case BUILT_IN_LOGF: case BUILT_IN_LOGL: builtin_optab = log_optab; break; + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + errno_set = false ; builtin_optab = floor_optab; break; + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + errno_set = false ; builtin_optab = ceil_optab; break; + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + errno_set = false ; builtin_optab = trunc_optab; break; + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + errno_set = false ; builtin_optab = round_optab; break; + case BUILT_IN_NEARBYINT: + case BUILT_IN_NEARBYINTF: + case BUILT_IN_NEARBYINTL: + errno_set = false ; builtin_optab = nearbyint_optab; break; default: abort (); } *************** expand_builtin_mathfn (exp, target, subt *** 1553,1559 **** /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && HONOR_NANS (argmode)) { rtx lab1; --- 1574,1580 ---- /* If errno must be maintained, we must set it to EDOM for NaN results. */ ! if (flag_errno_math && errno_set && HONOR_NANS (argmode)) { rtx lab1; *************** expand_builtin (exp, target, subtarget, *** 3743,3748 **** --- 3764,3784 ---- case BUILT_IN_FPUTC_UNLOCKED: case BUILT_IN_FPUTS_UNLOCKED: case BUILT_IN_FWRITE_UNLOCKED: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_NEARBYINT: + case BUILT_IN_NEARBYINTF: + case BUILT_IN_NEARBYINTL: return expand_call (exp, target, ignore); default: *************** expand_builtin (exp, target, subtarget, *** 3793,3798 **** --- 3829,3849 ---- case BUILT_IN_SQRT: case BUILT_IN_SQRTF: case BUILT_IN_SQRTL: + case BUILT_IN_FLOOR: + case BUILT_IN_FLOORF: + case BUILT_IN_FLOORL: + case BUILT_IN_CEIL: + case BUILT_IN_CEILF: + case BUILT_IN_CEILL: + case BUILT_IN_TRUNC: + case BUILT_IN_TRUNCF: + case BUILT_IN_TRUNCL: + case BUILT_IN_ROUND: + case BUILT_IN_ROUNDF: + case BUILT_IN_ROUNDL: + case BUILT_IN_NEARBYINT: + case BUILT_IN_NEARBYINTF: + case BUILT_IN_NEARBYINTL: target = expand_builtin_mathfn (exp, target, subtarget); if (target) return target; Index: builtins.def =================================================================== RCS file: /cvs/gcc/egcs/gcc/builtins.def,v retrieving revision 1.34.4.3 diff -c -3 -p -r1.34.4.3 builtins.def *** builtins.def 1 Oct 2002 17:31:36 -0000 1.34.4.3 --- builtins.def 7 Nov 2002 10:45:54 -0000 *************** Software Foundation, 59 Temple Place - S *** 112,120 **** /* Like DEF_LIB_BUILTIN, except that the function is only a part of the standard in C99 or above. */ #undef DEF_C99_BUILTIN ! #define DEF_C99_BUILTIN(ENUM, NAME, TYPE) \ DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ ! true, !flag_isoc99, true, ATTR_NOTHROW_LIST) /* Like DEF_LIB_BUILTIN, except that the function is expanded in the front-end. */ --- 112,120 ---- /* Like DEF_LIB_BUILTIN, except that the function is only a part of the standard in C99 or above. */ #undef DEF_C99_BUILTIN ! #define DEF_C99_BUILTIN(ENUM, NAME, TYPE, ATTRS) \ DEF_BUILTIN (ENUM, NAME, BUILT_IN_NORMAL, TYPE, TYPE, \ ! true, !flag_isoc99, true, ATTRS) /* Like DEF_LIB_BUILTIN, except that the function is expanded in the front-end. */ *************** DEF_LIB_ALWAYS_BUILTIN(BUILT_IN_FABSL, *** 169,207 **** "__builtin_fabsl", BT_FN_LONG_DOUBLE_LONG_DOUBLE) DEF_C99_BUILTIN(BUILT_IN_LLABS, "__builtin_llabs", ! BT_FN_LONGLONG_LONGLONG) DEF_C99_BUILTIN(BUILT_IN_IMAXABS, "__builtin_imaxabs", ! BT_FN_INTMAX_INTMAX) DEF_C99_BUILTIN(BUILT_IN_CONJ, "__builtin_conj", ! BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE) DEF_C99_BUILTIN(BUILT_IN_CONJF, "__builtin_conjf", ! BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT) DEF_C99_BUILTIN(BUILT_IN_CONJL, "__builtin_conjl", ! BT_FN_COMPLEX_LONG_DOUBLE_COMPLEX_LONG_DOUBLE) DEF_C99_BUILTIN(BUILT_IN_CREAL, "__builtin_creal", ! BT_FN_DOUBLE_COMPLEX_DOUBLE) DEF_C99_BUILTIN(BUILT_IN_CREALF, "__builtin_crealf", ! BT_FN_FLOAT_COMPLEX_FLOAT) DEF_C99_BUILTIN(BUILT_IN_CREALL, "__builtin_creall", ! BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE) DEF_C99_BUILTIN(BUILT_IN_CIMAG, "__builtin_cimag", ! BT_FN_DOUBLE_COMPLEX_DOUBLE) DEF_C99_BUILTIN(BUILT_IN_CIMAGF, "__builtin_cimagf", ! BT_FN_FLOAT_COMPLEX_FLOAT) DEF_C99_BUILTIN(BUILT_IN_CIMAGL, "__builtin_cimagl", ! BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE) DEF_UNUSED_BUILTIN(BUILT_IN_DIV) DEF_UNUSED_BUILTIN(BUILT_IN_LDIV) --- 169,283 ---- "__builtin_fabsl", BT_FN_LONG_DOUBLE_LONG_DOUBLE) + DEF_LIB_BUILTIN(BUILT_IN_FLOOR, + "__builtin_floor", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_FLOORF, + "__builtin_floorf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_FLOORL, + "__builtin_floorl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + + DEF_LIB_BUILTIN(BUILT_IN_CEIL, + "__builtin_ceil", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_CEILF, + "__builtin_ceilf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_LIB_BUILTIN(BUILT_IN_CEILL, + "__builtin_ceill", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + + DEF_C99_BUILTIN(BUILT_IN_ROUND, + "__builtin_round", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_ROUNDF, + "__builtin_roundf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_ROUNDL, + "__builtin_roundl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + + DEF_C99_BUILTIN(BUILT_IN_TRUNC, + "__builtin_trunc", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_TRUNCF, + "__builtin_truncf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_TRUNCL, + "__builtin_truncl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + + DEF_C99_BUILTIN(BUILT_IN_NEARBYINT, + "__builtin_nearbyint", + BT_FN_DOUBLE_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_NEARBYINTF, + "__builtin_nearbyintf", + BT_FN_FLOAT_FLOAT, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_NEARBYINTL, + "__builtin_nearbyintl", + BT_FN_LONG_DOUBLE_LONG_DOUBLE, + ATTR_CONST_NOTHROW_LIST) + DEF_C99_BUILTIN(BUILT_IN_LLABS, "__builtin_llabs", ! BT_FN_LONGLONG_LONGLONG, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_IMAXABS, "__builtin_imaxabs", ! BT_FN_INTMAX_INTMAX, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CONJ, "__builtin_conj", ! BT_FN_COMPLEX_DOUBLE_COMPLEX_DOUBLE, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CONJF, "__builtin_conjf", ! BT_FN_COMPLEX_FLOAT_COMPLEX_FLOAT, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CONJL, "__builtin_conjl", ! BT_FN_COMPLEX_LONG_DOUBLE_COMPLEX_LONG_DOUBLE, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CREAL, "__builtin_creal", ! BT_FN_DOUBLE_COMPLEX_DOUBLE, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CREALF, "__builtin_crealf", ! BT_FN_FLOAT_COMPLEX_FLOAT, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CREALL, "__builtin_creall", ! BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CIMAG, "__builtin_cimag", ! BT_FN_DOUBLE_COMPLEX_DOUBLE, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CIMAGF, "__builtin_cimagf", ! BT_FN_FLOAT_COMPLEX_FLOAT, ! ATTR_CONST_NOTHROW_LIST) DEF_C99_BUILTIN(BUILT_IN_CIMAGL, "__builtin_cimagl", ! BT_FN_LONG_DOUBLE_COMPLEX_LONG_DOUBLE, ! ATTR_CONST_NOTHROW_LIST) DEF_UNUSED_BUILTIN(BUILT_IN_DIV) DEF_UNUSED_BUILTIN(BUILT_IN_LDIV) Index: genopinit.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/genopinit.c,v retrieving revision 1.53 diff -c -3 -p -r1.53 genopinit.c *** genopinit.c 3 Aug 2002 23:21:30 -0000 1.53 --- genopinit.c 7 Nov 2002 10:45:54 -0000 *************** static const char * const optabs[] = *** 112,117 **** --- 112,122 ---- abs_optab->handlers[(int) $A].insn_code = CODE_FOR_$(abs$F$a2$)", "absv_optab->handlers[(int) $A].insn_code = CODE_FOR_$(absv$I$a2$)", "sqrt_optab->handlers[$A].insn_code = CODE_FOR_$(sqrt$a2$)", + "floor_optab->handlers[$A].insn_code = CODE_FOR_$(floor$a2$)", + "ceil_optab->handlers[$A].insn_code = CODE_FOR_$(ceil$a2$)", + "round_optab->handlers[$A].insn_code = CODE_FOR_$(round$a2$)", + "trunc_optab->handlers[$A].insn_code = CODE_FOR_$(trunc$a2$)", + "nearbyint_optab->handlers[$A].insn_code = CODE_FOR_$(nearbyint$a2$)", "sin_optab->handlers[$A].insn_code = CODE_FOR_$(sin$a2$)", "cos_optab->handlers[$A].insn_code = CODE_FOR_$(cos$a2$)", "exp_optab->handlers[$A].insn_code = CODE_FOR_$(exp$a2$)", Index: optabs.c =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.c,v retrieving revision 1.143.4.5 diff -c -3 -p -r1.143.4.5 optabs.c *** optabs.c 28 Oct 2002 19:47:07 -0000 1.143.4.5 --- optabs.c 7 Nov 2002 10:45:55 -0000 *************** init_optabs () *** 5173,5178 **** --- 5173,5183 ---- one_cmpl_optab = init_optab (NOT); ffs_optab = init_optab (FFS); sqrt_optab = init_optab (SQRT); + floor_optab = init_optab (UNKNOWN); + ceil_optab = init_optab (UNKNOWN); + round_optab = init_optab (UNKNOWN); + trunc_optab = init_optab (UNKNOWN); + nearbyint_optab = init_optab (UNKNOWN); sin_optab = init_optab (UNKNOWN); cos_optab = init_optab (UNKNOWN); exp_optab = init_optab (UNKNOWN); Index: optabs.h =================================================================== RCS file: /cvs/gcc/egcs/gcc/optabs.h,v retrieving revision 1.7 diff -c -3 -p -r1.7 optabs.h *** optabs.h 3 Aug 2002 23:21:30 -0000 1.7 --- optabs.h 7 Nov 2002 10:45:56 -0000 *************** enum optab_index *** 135,140 **** --- 135,146 ---- OTI_exp, /* Natural Logarithm */ OTI_log, + /* Rounding functions */ + OTI_floor, + OTI_ceil, + OTI_trunc, + OTI_round, + OTI_nearbyint, /* Compare insn; two operands. */ OTI_cmp, *************** extern GTY(()) optab optab_table[OTI_MAX *** 204,209 **** --- 210,220 ---- #define cos_optab (optab_table[OTI_cos]) #define exp_optab (optab_table[OTI_exp]) #define log_optab (optab_table[OTI_log]) + #define floor_optab (optab_table[OTI_floor]) + #define ceil_optab (optab_table[OTI_ceil]) + #define trunc_optab (optab_table[OTI_trunc]) + #define round_optab (optab_table[OTI_round]) + #define nearbyint_optab (optab_table[OTI_nearbyint]) #define cmp_optab (optab_table[OTI_cmp]) #define ucmp_optab (optab_table[OTI_ucmp]) Index: doc/extend.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/extend.texi,v retrieving revision 1.95.4.5 diff -c -3 -p -r1.95.4.5 extend.texi *** doc/extend.texi 21 Oct 2002 17:52:59 -0000 1.95.4.5 --- doc/extend.texi 7 Nov 2002 10:46:01 -0000 *************** v4si f (v4si a, v4si b, v4si c) *** 4568,4573 **** --- 4568,4588 ---- @findex strrchr @findex strspn @findex strstr + @findex floor + @findex floorf + @findex floorl + @findex ceil + @findex ceilf + @findex ceill + @findex round + @findex roundf + @findex roundl + @findex trunc + @findex truncf + @findex truncl + @findex nearbyint + @findex nearbyintf + @findex nearbyintl GCC provides a large number of built-in functions other than the ones mentioned above. Some of these are for internal use in the processing *************** built-in functions. All these functions *** 4603,4630 **** 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}, @code{llabs} and @code{imaxabs} 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}, 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{cos}, @code{exp}, @code{fabs}, ! @code{fprintf}, @code{fputs}, @code{labs}, @code{log}, ! @code{memcmp}, @code{memcpy}, ! @code{memset}, @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 corresponding ! versions prefixed with @code{__builtin_}. GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have --- 4618,4646 ---- 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}, ! @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{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 ! corresponding versions prefixed with @code{__builtin_}. GCC provides built-in versions of the ISO C99 floating point comparison macros that avoid raising exceptions for unordered operands. They have Index: doc/md.texi =================================================================== RCS file: /cvs/gcc/egcs/gcc/doc/md.texi,v retrieving revision 1.47.2.3 diff -c -3 -p -r1.47.2.3 md.texi *** doc/md.texi 5 Nov 2002 19:12:27 -0000 1.47.2.3 --- doc/md.texi 7 Nov 2002 10:46:02 -0000 *************** corresponds to the C data type @code{dou *** 2569,2574 **** --- 2569,2619 ---- built-in function uses the mode which corresponds to the C data type @code{float}. + @cindex @code{floor@var{m}2} instruction pattern + @item @samp{floor@var{m}2} + Store the largest integral value not greater than argument. + + The @code{floor} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{floorf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{trunc@var{m}2} instruction pattern + @item @samp{trunc@var{m}2} + Store the argument rounded to integer towards zero. + + The @code{trunc} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{truncf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{round@var{m}2} instruction pattern + @item @samp{round@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{round} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{roundf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{ceil@var{m}2} instruction pattern + @item @samp{ceil@var{m}2} + Store the argument rounded to integer away from zero. + + The @code{ceil} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{ceilf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + + @cindex @code{nearbyint@var{m}2} instruction pattern + @item @samp{nearbyint@var{m}2} + Store the argument rounded according to the default rounding mode + + The @code{nearbyint} built-in function of C always uses the mode which + corresponds to the C data type @code{double} and the @code{nearbyintf} + built-in function uses the mode which corresponds to the C data + type @code{float}. + @cindex @code{ffs@var{m}2} instruction pattern @item @samp{ffs@var{m}2} Store into operand 0 one plus the index of the least significant 1-bit ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins III 2002-11-07 3:05 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins III Jan Hubicka @ 2002-11-07 16:56 ` Richard Henderson 0 siblings, 0 replies; 36+ messages in thread From: Richard Henderson @ 2002-11-07 16:56 UTC (permalink / raw) To: Jan Hubicka; +Cc: Joseph S. Myers, Gabriel Dos Reis, gcc-patches On Thu, Nov 07, 2002 at 12:04:11PM +0100, Jan Hubicka wrote: > * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/nearbyint > (expand_builtin): Likewise. > * builtins.def: Add > __builtin_floor, __builtin_floorf, __builtin_floorl > __builtin_ceil, __builtin_ceilf, __builtin_ceill > __builtin_round, __builtin_roundf, __builtin_roundl > __builtin_trunc, __builtin_truncf, __builtin_truncl > __builtin_nearbyint, __builtin_nearbyintf, __builtin_nearbyintl. > * genopinit.c (optabs): Initialize the new optabs. > * optab.c (init_optabs): Likewise. > * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, > OTI_round, OTI_nearbyint. > (floor_optab, ceil_optab, trunc_optab, round_optab, nearbyint_optab): New. > * doc/md.texi: Document new named patterns. > * doc/extend.texi (builtin functions) Document > floor, floorf, floorl, ceil, ceilf, > ceill, round, roundf, roundl, trunc, > truncf, truncl, nearbyint, nearbyintf, nearbyintl. Ok. r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II 2002-11-06 14:52 ` Jan Hubicka 2002-11-06 15:06 ` Richard Henderson 2002-11-06 16:05 ` Joseph S. Myers @ 2002-11-07 4:54 ` Hans-Peter Nilsson 2 siblings, 0 replies; 36+ messages in thread From: Hans-Peter Nilsson @ 2002-11-07 4:54 UTC (permalink / raw) To: Jan Hubicka; +Cc: gcc-patches On Wed, 6 Nov 2002, Jan Hubicka wrote: > Wed Nov 6 23:23:27 CET 2002 Jan Hubicka <jh@suse.cz> > * doc/md.texi: Document new named patterns. > Index: doc/md.texi > + @cindex @code{trunc@var{m}2} instruction pattern > + @item @samp{trunc@var{m}2} > + Store the argument rounded to integer towards zero. > + > + The @code{trunc} built-in function of C always uses the mode which > + corresponds to the C data type @code{double} and the @code{truncf} > + built-in function uses the mode which corresponds to the C data > + type @code{float}. There's overlap with trunc@var{mn}2 or at least confusion. (What's the difference?) Perhaps also for other of the new patterns. brgds, H-P ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 13:35 ` Jan Hubicka 2002-11-06 13:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Jan Hubicka @ 2002-11-06 14:04 ` Gabriel Dos Reis 2002-11-06 14:06 ` Jan Hubicka 1 sibling, 1 reply; 36+ messages in thread From: Gabriel Dos Reis @ 2002-11-06 14:04 UTC (permalink / raw) To: Jan Hubicka; +Cc: Joseph S. Myers, gcc-patches, rth Jan Hubicka <jh@suse.cz> writes: | > Jan Hubicka <jh@suse.cz> writes: | > | > [...] | > | > | > | I see. Man page claims: | > | > | CONFORMING TO | > | > | The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO | > | > | 9899. The other functions are from C99. | > | > | | > | > | So I will disable the builtins for non c++ except for floor, right? | > | > | > | > If they are seen as __builtin_xxx() in source code then I don't think | > | > there is any need to disable them for C++. | > | I meant c99. | > | > OK. But then, I don't understand why you would want to disable it for | > C89 (the same reason(s) should apply to C++ equally). | In case rint is defined only by C99 and C89 don't even reserve it, I | have to. I don't have a copy of C89 handy; but I don't think it says anything about rint. But I still don't understand why you ought to reverse that portion, if it is spelt __builtin_rint. Please, could you elaborate? -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 14:04 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Gabriel Dos Reis @ 2002-11-06 14:06 ` Jan Hubicka 2002-11-06 14:09 ` Gabriel Dos Reis 0 siblings, 1 reply; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 14:06 UTC (permalink / raw) To: Gabriel Dos Reis; +Cc: Jan Hubicka, Joseph S. Myers, gcc-patches, rth > Jan Hubicka <jh@suse.cz> writes: > > | > Jan Hubicka <jh@suse.cz> writes: > | > > | > [...] > | > > | > | > | I see. Man page claims: > | > | > | CONFORMING TO > | > | > | The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO > | > | > | 9899. The other functions are from C99. > | > | > | > | > | > | So I will disable the builtins for non c++ except for floor, right? > | > | > > | > | > If they are seen as __builtin_xxx() in source code then I don't think > | > | > there is any need to disable them for C++. > | > | I meant c99. > | > > | > OK. But then, I don't understand why you would want to disable it for > | > C89 (the same reason(s) should apply to C++ equally). > | In case rint is defined only by C99 and C89 don't even reserve it, I > | have to. > > I don't have a copy of C89 handy; but I don't think it says anything > about rint. But I still don't understand why you ought to reverse > that portion, if it is spelt __builtin_rint. Please, could you > elaborate? We always recognize __builtin_rint, but we also recognize rint when standard defines is that way. Question is when we should recognize what. Honza > > -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 14:06 ` Jan Hubicka @ 2002-11-06 14:09 ` Gabriel Dos Reis 0 siblings, 0 replies; 36+ messages in thread From: Gabriel Dos Reis @ 2002-11-06 14:09 UTC (permalink / raw) To: Jan Hubicka; +Cc: Joseph S. Myers, gcc-patches, rth Jan Hubicka <jh@suse.cz> writes: | We always recognize __builtin_rint, but we also recognize rint when | standard defines is that way. Question is when we should recognize | what. Ah, okay. Thanks! -- Gaby ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 13:12 ` Jan Hubicka 2002-11-06 13:18 ` Gabriel Dos Reis @ 2002-11-06 14:04 ` Dale Johannesen 1 sibling, 0 replies; 36+ messages in thread From: Dale Johannesen @ 2002-11-06 14:04 UTC (permalink / raw) To: Jan Hubicka; +Cc: Dale Johannesen, Joseph S. Myers, gcc-patches, rth On Wednesday, November 6, 2002, at 01:12 PM, Jan Hubicka wrote: >> On Wed, 6 Nov 2002, Jan Hubicka wrote: >> >>> Wed Nov 6 15:09:21 CET 2002 Jan Hubicka <jh@suse.cz> >>> * extend.texi (builtin functions) Document >>> floor, floorf, floorl, ceil, ceilf, >>> ceill, round, roundf, roundl, trunc, >>> truncf, truncl, rint, rintf, rintl. >> >> Some of these are C99-only (the round, trunc, rint functions I think; >> my >> copy of C90 isn't to hand right now). Note from comp.std.c and the >> WG14 >> reflector that C90 is available for sale again from BSI, I recommend >> buying it. The C99-only nature of those built-in functions needs to >> be >> reflected in both the code and the docs. > > I see. Man page claims: > CONFORMING TO > The floor() function conforms to SVID 3, POSIX, BSD 4.3, ISO > 9899. The other functions are from C99. > > So I will disable the builtins for non c++ except for floor, right? ceil is also in C90. ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 2:27 [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Jan Hubicka 2002-11-06 6:03 ` Joseph S. Myers @ 2002-11-06 10:29 ` Richard Henderson 2002-11-06 13:13 ` Jan Hubicka 1 sibling, 1 reply; 36+ messages in thread From: Richard Henderson @ 2002-11-06 10:29 UTC (permalink / raw) To: Jan Hubicka; +Cc: gcc-patches On Wed, Nov 06, 2002 at 11:27:49AM +0100, Jan Hubicka wrote: > * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/rint > (expand_builtin): Likewise. > * builtins.def: Add > __builtin_floor, __builtin_floorf, __builtin_floorl > __builtin_ceil, __builtin_ceilf, __builtin_ceill > __builtin_round, __builtin_roundf, __builtin_roundl > __builtin_trunc, __builtin_truncf, __builtin_truncl > __builtin_rint, __builtin_rintf, __builtin_rintl. > * genopinit.c (optabs): Initialize the new optabs. > * optab.c (init_optabs): Likewise. > * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, > OTI_round, OTI_rint. > (floor_optab, ceil_optab, trunc_optab, round_optab, rint_optab): New. > * md.texi: Document new named patterns. Ok, with the extend.texi hunk posted later. r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
* Re: [3.4-BIB] Add trunc/round/floor/ceil/rint builtins 2002-11-06 10:29 ` Richard Henderson @ 2002-11-06 13:13 ` Jan Hubicka 0 siblings, 0 replies; 36+ messages in thread From: Jan Hubicka @ 2002-11-06 13:13 UTC (permalink / raw) To: Richard Henderson, Jan Hubicka, gcc-patches > On Wed, Nov 06, 2002 at 11:27:49AM +0100, Jan Hubicka wrote: > > * builtins.c (expand_builtin_mathfn): Handle floor/ceil/trunc/round/rint > > (expand_builtin): Likewise. > > * builtins.def: Add > > __builtin_floor, __builtin_floorf, __builtin_floorl > > __builtin_ceil, __builtin_ceilf, __builtin_ceill > > __builtin_round, __builtin_roundf, __builtin_roundl > > __builtin_trunc, __builtin_truncf, __builtin_truncl > > __builtin_rint, __builtin_rintf, __builtin_rintl. > > * genopinit.c (optabs): Initialize the new optabs. > > * optab.c (init_optabs): Likewise. > > * optabs.h (optab_index): Add OTI_floor, OTI_ceil, OTI_trunc, > > OTI_round, OTI_rint. > > (floor_optab, ceil_optab, trunc_optab, round_optab, rint_optab): New. > > * md.texi: Document new named patterns. > > Ok, with the extend.texi hunk posted later. I will add the c99 changes requested and send the patch shortly. Thanks! Honza > > > r~ ^ permalink raw reply [flat|nested] 36+ messages in thread
end of thread, other threads:[~2002-11-08 0:56 UTC | newest] Thread overview: 36+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-11-06 2:27 [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Jan Hubicka 2002-11-06 6:03 ` Joseph S. Myers 2002-11-06 6:11 ` Jan Hubicka 2002-11-06 11:14 ` Joseph S. Myers 2002-11-06 11:29 ` Dale Johannesen 2002-11-06 13:12 ` Jan Hubicka 2002-11-06 13:18 ` Gabriel Dos Reis 2002-11-06 13:20 ` Jan Hubicka 2002-11-06 13:31 ` Gabriel Dos Reis 2002-11-06 13:35 ` Jan Hubicka 2002-11-06 13:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Jan Hubicka 2002-11-06 14:29 ` Richard Henderson 2002-11-06 14:41 ` Jan Hubicka 2002-11-06 14:52 ` Jan Hubicka 2002-11-06 15:06 ` Richard Henderson 2002-11-06 15:32 ` Dale Johannesen 2002-11-06 15:48 ` Richard Henderson 2002-11-06 15:57 ` Dale Johannesen 2002-11-07 0:48 ` Neil Booth 2002-11-06 16:01 ` Joseph S. Myers 2002-11-06 16:04 ` Richard Henderson 2002-11-07 1:10 ` Jan Hubicka 2002-11-07 1:08 ` Jan Hubicka 2002-11-07 1:08 ` Jan Hubicka 2002-11-06 16:05 ` Joseph S. Myers 2002-11-07 1:10 ` Jan Hubicka 2002-11-07 1:18 ` Jan Hubicka 2002-11-07 3:05 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins III Jan Hubicka 2002-11-07 16:56 ` Richard Henderson 2002-11-07 4:54 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins II Hans-Peter Nilsson 2002-11-06 14:04 ` [3.4-BIB] Add trunc/round/floor/ceil/rint builtins Gabriel Dos Reis 2002-11-06 14:06 ` Jan Hubicka 2002-11-06 14:09 ` Gabriel Dos Reis 2002-11-06 14:04 ` Dale Johannesen 2002-11-06 10:29 ` Richard Henderson 2002-11-06 13:13 ` Jan Hubicka
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).