diff options
author | Richard Henderson <rth@gcc.gnu.org> | 2003-02-01 11:00:02 -0800 |
---|---|---|
committer | Richard Henderson <rth@gcc.gnu.org> | 2003-02-01 11:00:02 -0800 |
commit | 2928cd7aace2187ca6d892872490e01f2a2bb17a (patch) | |
tree | df0468b560ad2e3e7a8fb8def8c31b83ba736922 /gcc/builtins.c | |
parent | 112f7223d17a7e98e996af22e1b474855e7cae48 (diff) | |
download | gcc-2928cd7aace2187ca6d892872490e01f2a2bb17a.zip gcc-2928cd7aace2187ca6d892872490e01f2a2bb17a.tar.gz gcc-2928cd7aace2187ca6d892872490e01f2a2bb17a.tar.bz2 |
[multiple changes]
2003-02-01 Richard Henderson <rth@redhat.com>
* optabs.c (expand_unop): Use word_mode for outmode of bit scaners.
* libgcc2.c (__ffsdi2, __clzsi2, __clzdi2, __ctzsi2, __ctzdi2,
__popcountsi2, __popcountdi2, __paritysi2 __paritydi2): Change
return type to Wtype.
* libgcc-std.ver (GCC_3.4): Fix inheritance.
* config/i386/i386.md (ffssi2): Use nonimmediate_operand for
expander input constraint.
2003-02-01 Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
* optabs.h (optab_index): Add OTI_clz, OTI_ctz, OTI_popcount and
OTI_parity.
(clz_optab, ctz_optab, popcount_optab, parity_optab): New.
* optabs.c (widen_clz, expand_parity): New.
(expand_unop): Handle clz and parity. Hardcode SImode as outmode
for libcalls to clz, ctz, popcount, and parity.
(init_optabs): Init clz_optab, ctz_optab, popcount_optab and
parity_optab, and set up libfunc handlers.
* libgcc2.c (__clzsi2, __clzdi2, __ctzsi2, __ctzdi2,
__popcountsi2, __popcountdi2, __paritysi2 __paritydi2,
__popcount_tab): New.
* libgcc2.h: Declare them.
* libgcc-std.ver (GCC_3.4): Add new functions from libgcc2.c.
* genopinit.c (optabs): Add clz_optab, ctz_optab, popcount_optab
and parity_optab.
* builtin-types.def (BT_FN_INT_LONG, BT_FN_INT_LONGLONG): New.
* builtins.def (BUILT_IN_CLZ, BUILT_IN_CTZ, BUILT_IN_POPCOUNT,
BUILT_IN_PARITY, BUILT_IN_FFSL, BUILT_IN_CLZL, BUILT_IN_CTZL,
BUILT_IN_POPCOUNTL, BUILT_IN_PARITYL, BUILT_IN_FFSLL,
BUILT_IN_CLZLL, BUILT_IN_CTZLL, BUILT_IN_POPCOUNTLL,
BUILT_IN_PARITYLL): New.
* builtins.c (expand_builtin_unop): Rename from expand_builtin_ffs
and add optab argument.
(expand_builtin): Expand BUILT_IN_{FFS,CLZ,POPCOUNT,PARITY}*.
* tree.def (CLZ_EXPR, CTZ_EXPR, POPCOUNT_EXPR, PARITY_EXPR): New.
* expr.c (expand_expr): Handle them.
* fold-const.c (tree_expr_nonnegative_p): Likewise.
* rtl.def (CLZ, CTZ, POPCOUNT, PARITY): New.
* reload1.c (eliminate_regs): Handle them.
(elimination_effects): Likewise.
* function.c (instantiate_virtual_regs_1): Likewise
* genattrtab.c (check_attr_value): Likewise.
* simplify-rtx.c (simplify_unary_operation): Likewise.
* c-common.c (c_common_truthvalue_conversion): Handle POPCOUNT_EXPR.
* combine.c (combine_simplify_rtx): Handle POPCOUNT and PARITY.
(nonzero_bits): Handle CLZ, CTZ, POPCOUNT and PARITY.
* config/alpha/alpha.md (clzdi2, ctzdi2, popcountdi2): New.
* config/arm/arm.c (arm_init_builtins): Rename __builtin_clz to
__builtin_arm_clz.
* Makefile.in (LIB2FUNCS_1, LIB2FUNCS_2): Move...
* mklibgcc.in (lib2funcs): ...here and merge. Add new members.
* doc/extend.texi (Other Builtins): Add new builtins.
* doc/md.texi (Standard Names): Add new patterns.
From-SVN: r62252
Diffstat (limited to 'gcc/builtins.c')
-rw-r--r-- | gcc/builtins.c | 48 |
1 files changed, 42 insertions, 6 deletions
diff --git a/gcc/builtins.c b/gcc/builtins.c index d7d8054..47d93e2 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -147,7 +147,7 @@ static rtx expand_builtin_strchr PARAMS ((tree, rtx, static rtx expand_builtin_strrchr PARAMS ((tree, rtx, enum machine_mode)); static rtx expand_builtin_alloca PARAMS ((tree, rtx)); -static rtx expand_builtin_ffs PARAMS ((tree, rtx, rtx)); +static rtx expand_builtin_unop PARAMS ((tree, rtx, rtx, optab)); static rtx expand_builtin_frame_address PARAMS ((tree)); static rtx expand_builtin_fputs PARAMS ((tree, int, int)); static tree stabilize_va_list PARAMS ((tree, int)); @@ -3581,15 +3581,16 @@ expand_builtin_alloca (arglist, target) return result; } -/* Expand a call to the ffs builtin. The arguments are in ARGLIST. +/* Expand a call to a unary builtin. The arguments are in ARGLIST. Return 0 if a normal call should be emitted rather than expanding the function in-line. If convenient, the result should be placed in TARGET. SUBTARGET may be used as the target for computing one of EXP's operands. */ static rtx -expand_builtin_ffs (arglist, target, subtarget) +expand_builtin_unop (arglist, target, subtarget, op_optab) tree arglist; rtx target, subtarget; + optab op_optab; { rtx op0; if (!validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE)) @@ -3597,10 +3598,10 @@ expand_builtin_ffs (arglist, target, subtarget) /* Compute the argument. */ op0 = expand_expr (TREE_VALUE (arglist), subtarget, VOIDmode, 0); - /* Compute ffs, into TARGET if possible. + /* Compute op, into TARGET if possible. Set TARGET to wherever the result comes back. */ target = expand_unop (TYPE_MODE (TREE_TYPE (TREE_VALUE (arglist))), - ffs_optab, op0, target, 1); + op_optab, op0, target, 1); if (target == 0) abort (); return target; @@ -4099,7 +4100,42 @@ expand_builtin (exp, target, subtarget, mode, ignore) break; case BUILT_IN_FFS: - target = expand_builtin_ffs (arglist, target, subtarget); + case BUILT_IN_FFSL: + case BUILT_IN_FFSLL: + target = expand_builtin_unop (arglist, target, subtarget, ffs_optab); + if (target) + return target; + break; + + case BUILT_IN_CLZ: + case BUILT_IN_CLZL: + case BUILT_IN_CLZLL: + target = expand_builtin_unop (arglist, target, subtarget, clz_optab); + if (target) + return target; + break; + + case BUILT_IN_CTZ: + case BUILT_IN_CTZL: + case BUILT_IN_CTZLL: + target = expand_builtin_unop (arglist, target, subtarget, ctz_optab); + if (target) + return target; + break; + + case BUILT_IN_POPCOUNT: + case BUILT_IN_POPCOUNTL: + case BUILT_IN_POPCOUNTLL: + target = expand_builtin_unop (arglist, target, subtarget, + popcount_optab); + if (target) + return target; + break; + + case BUILT_IN_PARITY: + case BUILT_IN_PARITYL: + case BUILT_IN_PARITYLL: + target = expand_builtin_unop (arglist, target, subtarget, parity_optab); if (target) return target; break; |