From: geoffk Date: Wed, 1 Nov 2006 05:14:40 +0000 (+0000) Subject: 2006-09-07 Eric Christopher X-Git-Tag: upstream/4.9.2~52259 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=427911176defd91fb2ac55f17bde1da551c2c02b;p=platform%2Fupstream%2Flinaro-gcc.git 2006-09-07 Eric Christopher Falk Hueffner * doc/extend.texi (__builtin_bswap32): Document. (__builtin_bswap64): Ditto. * doc/libgcc.texi (bswapsi2): Document. (bswapdi2): Ditto. * doc/rtl.texi (bswap): Document. * optabs.c (expand_unop): Don't widen a bswap. (init_optabs): Init bswap. Set libfuncs explicitly for bswapsi2 and bswapdi2. * optabs.h (OTI_bswap): New. (bswap_optab): Ditto. * genopinit.c (optabs): Handle bswap_optab. * tree.h (tree_index): Add TI_UINT32_TYPE and TI_UINT64_TYPE. (uint32_type_node): New. (uint64_type_node): Ditto. * tree.c (build_common_tree_nodes_2): Initialize uint32_type_node and uint64_type_node. * builtins.c (expand_builtin_bswap): New. (expand_builtin): Call. (fold_builtin_bswap): New. (fold_builtin_1): Call. * fold-const.c (tree_expr_nonnegative_p): Return true for bswap. * builtin-types.def (BT_UINT32): New. (BT_UINT64): Ditto. (BT_FN_UINT32_UINT32): Ditto. (BT_FN_UINT64_UINT64): Ditto. * builtins.def (BUILT_IN_BSWAP32): New. (BUILT_IN_BSWAP64): Ditto. * rtl.def (BSWAP): New. * genattrtab.c (check_attr_value): New. * libgcc2.c (__bswapSI2): New. (__bswapDI2): Ditto. * libgcc2.h (__bswapSI2): Declare. (__bswapDI2): Ditto. * mklibgcc.in (lib2funcs): Add _bswapsi2 and _bswapdi2. * simplify-rtx.c (simplify_const_unary_operation): Return 0 for BSWAP. * libgcc-std.ver (__bwapsi2): Add. (__bswapdi2): Ditto. * reload1.c (eliminate_regs_1): Add bswap. (elimination_effects): Ditto. * config/i386/i386.h (x86_bswap): New. (TARGET_BSWAP): Use. * config/i386/i386.c (x86_bswap): Set. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@118361 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c5cf3b5..e60fc54 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,52 @@ +2006-09-07 Eric Christopher + Falk Hueffner + + * doc/extend.texi (__builtin_bswap32): Document. + (__builtin_bswap64): Ditto. + * doc/libgcc.texi (bswapsi2): Document. + (bswapdi2): Ditto. + * doc/rtl.texi (bswap): Document. + * optabs.c (expand_unop): Don't widen a bswap. + (init_optabs): Init bswap. Set libfuncs explicitly + for bswapsi2 and bswapdi2. + * optabs.h (OTI_bswap): New. + (bswap_optab): Ditto. + * genopinit.c (optabs): Handle bswap_optab. + * tree.h (tree_index): Add TI_UINT32_TYPE and + TI_UINT64_TYPE. + (uint32_type_node): New. + (uint64_type_node): Ditto. + * tree.c (build_common_tree_nodes_2): Initialize + uint32_type_node and uint64_type_node. + * builtins.c (expand_builtin_bswap): New. + (expand_builtin): Call. + (fold_builtin_bswap): New. + (fold_builtin_1): Call. + * fold-const.c (tree_expr_nonnegative_p): Return true + for bswap. + * builtin-types.def (BT_UINT32): New. + (BT_UINT64): Ditto. + (BT_FN_UINT32_UINT32): Ditto. + (BT_FN_UINT64_UINT64): Ditto. + * builtins.def (BUILT_IN_BSWAP32): New. + (BUILT_IN_BSWAP64): Ditto. + * rtl.def (BSWAP): New. + * genattrtab.c (check_attr_value): New. + * libgcc2.c (__bswapSI2): New. + (__bswapDI2): Ditto. + * libgcc2.h (__bswapSI2): Declare. + (__bswapDI2): Ditto. + * mklibgcc.in (lib2funcs): Add _bswapsi2 and _bswapdi2. + * simplify-rtx.c (simplify_const_unary_operation): Return + 0 for BSWAP. + * libgcc-std.ver (__bwapsi2): Add. + (__bswapdi2): Ditto. + * reload1.c (eliminate_regs_1): Add bswap. + (elimination_effects): Ditto. + * config/i386/i386.h (x86_bswap): New. + (TARGET_BSWAP): Use. + * config/i386/i386.c (x86_bswap): Set. + 2006-10-31 Geoffrey Keating * coverage.c (coverage_checksum_string): Update comment. diff --git a/gcc/builtin-types.def b/gcc/builtin-types.def index d6330b1..5d42b2e 100644 --- a/gcc/builtin-types.def +++ b/gcc/builtin-types.def @@ -75,6 +75,8 @@ DEF_PRIMITIVE_TYPE (BT_LONGLONG, long_long_integer_type_node) DEF_PRIMITIVE_TYPE (BT_ULONGLONG, long_long_unsigned_type_node) DEF_PRIMITIVE_TYPE (BT_INTMAX, intmax_type_node) DEF_PRIMITIVE_TYPE (BT_UINTMAX, uintmax_type_node) +DEF_PRIMITIVE_TYPE (BT_UINT32, uint32_type_node) +DEF_PRIMITIVE_TYPE (BT_UINT64, uint64_type_node) DEF_PRIMITIVE_TYPE (BT_WORD, (*lang_hooks.types.type_for_mode) (word_mode, 0)) DEF_PRIMITIVE_TYPE (BT_FLOAT, float_type_node) DEF_PRIMITIVE_TYPE (BT_DOUBLE, double_type_node) @@ -204,6 +206,10 @@ DEF_FUNCTION_TYPE_1 (BT_FN_DFLOAT128_DFLOAT128, BT_DFLOAT128, BT_DFLOAT128) DEF_FUNCTION_TYPE_1 (BT_FN_VOID_VPTR, BT_VOID, BT_VOLATILE_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_VOID_PTRPTR, BT_VOID, BT_PTR_PTR) DEF_FUNCTION_TYPE_1 (BT_FN_UINT_UINT, BT_UINT, BT_UINT) +DEF_FUNCTION_TYPE_1 (BT_FN_ULONG_ULONG, BT_ULONG, BT_ULONG) +DEF_FUNCTION_TYPE_1 (BT_FN_ULONGLONG_ULONGLONG, BT_ULONGLONG, BT_ULONGLONG) +DEF_FUNCTION_TYPE_1 (BT_FN_UINT32_UINT32, BT_UINT32, BT_UINT32) +DEF_FUNCTION_TYPE_1 (BT_FN_UINT64_UINT64, BT_UINT64, BT_UINT64) DEF_POINTER_TYPE (BT_PTR_FN_VOID_PTR, BT_FN_VOID_PTR) @@ -435,4 +441,3 @@ DEF_FUNCTION_TYPE_VAR_5 (BT_FN_INT_STRING_SIZE_INT_SIZE_CONST_STRING_VAR, DEF_POINTER_TYPE (BT_PTR_FN_VOID_VAR, BT_FN_VOID_VAR) DEF_FUNCTION_TYPE_3 (BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, BT_PTR, BT_PTR_FN_VOID_VAR, BT_PTR, BT_SIZE) - diff --git a/gcc/builtins.c b/gcc/builtins.c index 2184c71..7bbd632 100644 --- a/gcc/builtins.c +++ b/gcc/builtins.c @@ -4625,6 +4625,30 @@ expand_builtin_alloca (tree arglist, rtx target) return result; } +/* Expand a call to a bswap builtin. The arguments are in ARGLIST. MODE + is the mode to expand with. */ + +static rtx +expand_builtin_bswap (tree arglist, rtx target, rtx subtarget) +{ + enum machine_mode mode; + tree arg; + rtx op0; + + if (!validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE)) + return 0; + + arg = TREE_VALUE (arglist); + mode = TYPE_MODE (TREE_TYPE (arg)); + op0 = expand_expr (arg, subtarget, VOIDmode, 0); + + target = expand_unop (mode, bswap_optab, op0, target, 1); + + gcc_assert (target); + + return convert_to_mode (mode, target, 0); +} + /* 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. @@ -5903,6 +5927,14 @@ expand_builtin (tree exp, rtx target, rtx subtarget, enum machine_mode mode, expand_stack_restore (TREE_VALUE (arglist)); return const0_rtx; + case BUILT_IN_BSWAP32: + case BUILT_IN_BSWAP64: + target = expand_builtin_bswap (arglist, target, subtarget); + + if (target) + return target; + break; + CASE_INT_FN (BUILT_IN_FFS): case BUILT_IN_FFSIMAX: target = expand_builtin_unop (target_mode, arglist, target, @@ -7543,6 +7575,67 @@ fold_builtin_bitop (tree fndecl, tree arglist) return NULL_TREE; } +/* Fold function call to builtin_bswap and the long and long long + variants. Return NULL_TREE if no simplification can be made. */ +static tree +fold_builtin_bswap (tree fndecl, tree arglist) +{ + tree arg; + + if (! validate_arglist (arglist, INTEGER_TYPE, VOID_TYPE)) + return 0; + + /* Optimize constant value. */ + arg = TREE_VALUE (arglist); + if (TREE_CODE (arg) == INTEGER_CST && ! TREE_CONSTANT_OVERFLOW (arg)) + { + HOST_WIDE_INT hi, width, r_hi = 0; + unsigned HOST_WIDE_INT lo, r_lo = 0; + tree type; + + type = TREE_TYPE (arg); + width = TYPE_PRECISION (type); + lo = TREE_INT_CST_LOW (arg); + hi = TREE_INT_CST_HIGH (arg); + + switch (DECL_FUNCTION_CODE (fndecl)) + { + case BUILT_IN_BSWAP32: + case BUILT_IN_BSWAP64: + { + int s; + + for (s = 0; s < width; s += 8) + { + int d = width - s - 8; + unsigned HOST_WIDE_INT byte; + + if (s < HOST_BITS_PER_WIDE_INT) + byte = (lo >> s) & 0xff; + else + byte = (hi >> (s - HOST_BITS_PER_WIDE_INT)) & 0xff; + + if (d < HOST_BITS_PER_WIDE_INT) + r_lo |= byte << d; + else + r_hi |= byte << (d - HOST_BITS_PER_WIDE_INT); + } + } + + break; + + default: + gcc_unreachable (); + } + + if (width < HOST_BITS_PER_WIDE_INT) + return build_int_cst (TREE_TYPE (TREE_TYPE (fndecl)), r_lo); + else + return build_int_cst_wide (TREE_TYPE (TREE_TYPE (fndecl)), r_lo, r_hi); + } + + return NULL_TREE; +} /* Return true if EXPR is the real constant contained in VALUE. */ static bool @@ -9220,6 +9313,10 @@ fold_builtin_1 (tree fndecl, tree arglist, bool ignore) CASE_FLT_FN (BUILT_IN_LLRINT): return fold_fixed_mathfn (fndecl, arglist); + case BUILT_IN_BSWAP32: + case BUILT_IN_BSWAP64: + return fold_builtin_bswap (fndecl, arglist); + CASE_INT_FN (BUILT_IN_FFS): CASE_INT_FN (BUILT_IN_CLZ): CASE_INT_FN (BUILT_IN_CTZ): diff --git a/gcc/builtins.def b/gcc/builtins.def index 0e73cf4..d565f8c 100644 --- a/gcc/builtins.def +++ b/gcc/builtins.def @@ -594,6 +594,8 @@ DEF_EXT_LIB_BUILTIN (BUILT_IN_ALLOCA, "alloca", BT_FN_PTR_SIZE, ATTR_MALLOC_N DEF_GCC_BUILTIN (BUILT_IN_APPLY, "apply", BT_FN_PTR_PTR_FN_VOID_VAR_PTR_SIZE, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_APPLY_ARGS, "apply_args", BT_FN_PTR_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_ARGS_INFO, "args_info", BT_FN_INT_INT, ATTR_NULL) +DEF_GCC_BUILTIN (BUILT_IN_BSWAP32, "bswap32", BT_FN_UINT32_UINT32, ATTR_CONST_NOTHROW_LIST) +DEF_GCC_BUILTIN (BUILT_IN_BSWAP64, "bswap64", BT_FN_UINT64_UINT64, ATTR_CONST_NOTHROW_LIST) DEF_LIB_BUILTIN (BUILT_IN_CALLOC, "calloc", BT_FN_PTR_SIZE_SIZE, ATTR_MALLOC_NOTHROW_LIST) DEF_GCC_BUILTIN (BUILT_IN_CLASSIFY_TYPE, "classify_type", BT_FN_INT_VAR, ATTR_NULL) DEF_GCC_BUILTIN (BUILT_IN_CLZ, "clz", BT_FN_INT_UINT, ATTR_CONST_NOTHROW_LIST) diff --git a/gcc/config/i386/i386.c b/gcc/config/i386/i386.c index 074ce92..a7919dc 100644 --- a/gcc/config/i386/i386.c +++ b/gcc/config/i386/i386.c @@ -885,6 +885,8 @@ const int x86_cmpxchg8b = ~(m_386 | m_486); const int x86_cmpxchg16b = m_NOCONA; /* Exchange and add was added for 80486. */ const int x86_xadd = ~m_386; +/* Byteswap was added for 80486. */ +const int x86_bswap = ~m_386; const int x86_pad_returns = m_ATHLON_K8 | m_GENERIC; /* In case the average insn count for single function invocation is diff --git a/gcc/config/i386/i386.h b/gcc/config/i386/i386.h index 9fc5450..b40088a 100644 --- a/gcc/config/i386/i386.h +++ b/gcc/config/i386/i386.h @@ -165,6 +165,7 @@ extern const int x86_use_bt; extern const int x86_cmpxchg, x86_cmpxchg8b, x86_cmpxchg16b, x86_xadd; extern const int x86_use_incdec; extern const int x86_pad_returns; +extern const int x86_bswap; extern const int x86_partial_flag_reg_stall; extern int x86_prefetch_sse; @@ -238,6 +239,7 @@ extern int x86_prefetch_sse; #define TARGET_CMPXCHG8B (x86_cmpxchg8b & (1 << ix86_arch)) #define TARGET_CMPXCHG16B (x86_cmpxchg16b & (1 << ix86_arch)) #define TARGET_XADD (x86_xadd & (1 << ix86_arch)) +#define TARGET_BSWAP (x86_bswap & (1 << ix86_arch)) #ifndef TARGET_64BIT_DEFAULT #define TARGET_64BIT_DEFAULT 0 diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi index 422c422..9ec4460 100644 --- a/gcc/doc/extend.texi +++ b/gcc/doc/extend.texi @@ -6116,6 +6116,16 @@ Similar to @code{__builtin_powi}, except the argument and return types are @code{long double}. @end deftypefn +@deftypefn {Built-in Function} int32_t __builtin_bswap32 (int32_t x) +Returns @var{x} with the order of the bytes reversed; for example, +@code{0xaabbccdd} becomes @code{0xddccbbaa}. Byte here always means +exactly 8 bits. +@end deftypefn + +@deftypefn {Built-in Function} int64_t __builtin_bswap64 (int64_t x) +Similar to @code{__builtin_bswap32}, except the argument and return types +are 64-bit. +@end deftypefn @node Target Builtins @section Built-in Functions Specific to Particular Target Machines diff --git a/gcc/doc/libgcc.texi b/gcc/doc/libgcc.texi index f67b117..fcc55d7 100644 --- a/gcc/doc/libgcc.texi +++ b/gcc/doc/libgcc.texi @@ -212,6 +212,11 @@ These functions return the value zero if the number of bits set in These functions return the number of bits set in @var{a}. @end deftypefn +@deftypefn {Runtime Function} int32_t __bswapsi2 (int32_t @var{a}) +@deftypefnx {Runtime Function} int64_t __bswapdi2 (int64_t @var{a}) +These functions return the @var{a} byteswapped. +@end deftypefn + @node Soft float library routines @section Routines for floating point emulation @cindex soft float library @@ -728,4 +733,3 @@ document me! @deftypefn {Runtime Function} void __clear_cache (char *@var{beg}, char *@var{end}) This function clears the instruction cache between @var{beg} and @var{end}. @end deftypefn - diff --git a/gcc/doc/rtl.texi b/gcc/doc/rtl.texi index 76e8f16..d97b2b3 100644 --- a/gcc/doc/rtl.texi +++ b/gcc/doc/rtl.texi @@ -2084,6 +2084,11 @@ mode @var{m}. The mode of @var{x} will usually be an integer mode. Represents the number of 1-bits modulo 2 in @var{x}, represented as an integer of mode @var{m}. The mode of @var{x} will usually be an integer mode. + +@findex bswap +@item (bswap:@var{m} @var{x}) +Represents the value @var{x} with the order of bytes reversed, carried out +in mode @var{m}, which must be a fixed-point machine mode. @end table @node Comparisons diff --git a/gcc/fold-const.c b/gcc/fold-const.c index a718f14..0ac3c86 100644 --- a/gcc/fold-const.c +++ b/gcc/fold-const.c @@ -12302,6 +12302,8 @@ tree_expr_nonnegative_p (tree t) CASE_INT_FN (BUILT_IN_FFS): CASE_INT_FN (BUILT_IN_PARITY): CASE_INT_FN (BUILT_IN_POPCOUNT): + case BUILT_IN_BSWAP32: + case BUILT_IN_BSWAP64: /* Always true. */ return true; @@ -13241,4 +13243,3 @@ fold_strip_sign_ops (tree exp) } return NULL_TREE; } - diff --git a/gcc/genattrtab.c b/gcc/genattrtab.c index f11532f..3e0fd9e 100644 --- a/gcc/genattrtab.c +++ b/gcc/genattrtab.c @@ -959,6 +959,7 @@ check_attr_value (rtx exp, struct attr_desc *attr) case CTZ: case POPCOUNT: case PARITY: + case BSWAP: XEXP (exp, 0) = check_attr_value (XEXP (exp, 0), attr); break; diff --git a/gcc/libgcc-std.ver b/gcc/libgcc-std.ver index f8e9e52..2d0a43d 100644 --- a/gcc/libgcc-std.ver +++ b/gcc/libgcc-std.ver @@ -274,3 +274,10 @@ GCC_4.2.0 { __floatuntitf _Unwind_GetIPInfo } + +%inherit GCC_4.3 GCC_4.2.0 +GCC_4.3.0 { + # byte swapping routines + __bswapsi2 + __bswapdi2 +} diff --git a/gcc/libgcc2.c b/gcc/libgcc2.c index d093616..f3a0a24 100644 --- a/gcc/libgcc2.c +++ b/gcc/libgcc2.c @@ -492,6 +492,30 @@ __ashrdi3 (DWtype u, word_type b) } #endif +#ifdef L_bswapsi2 +UWtype +__bswapSI2 (UWtype u) +{ + return ((((u) & 0xff000000) >> 24) + | (((u) & 0x00ff0000) >> 8) + | (((u) & 0x0000ff00) << 8) + | (((u) & 0x000000ff) << 24)); +} +#endif +#ifdef L_bswapdi2 +UDWtype +__bswapDI2 (UDWtype u) +{ + return ((((u) & 0xff00000000000000ull) >> 56) + | (((u) & 0x00ff000000000000ull) >> 40) + | (((u) & 0x0000ff0000000000ull) >> 24) + | (((u) & 0x000000ff00000000ull) >> 8) + | (((u) & 0x00000000ff000000ull) << 8) + | (((u) & 0x0000000000ff0000ull) << 24) + | (((u) & 0x000000000000ff00ull) << 40) + | (((u) & 0x00000000000000ffull) << 56)); +} +#endif #ifdef L_ffssi2 #undef int int diff --git a/gcc/libgcc2.h b/gcc/libgcc2.h index c13f0c7..1182ba3 100644 --- a/gcc/libgcc2.h +++ b/gcc/libgcc2.h @@ -304,11 +304,13 @@ typedef int word_type __attribute__ ((mode (__word__))); #define __ctzSI2 __NW(ctz,2) #define __popcountSI2 __NW(popcount,2) #define __paritySI2 __NW(parity,2) +#define __bswapSI2 __NW(bswap,2) #define __ffsDI2 __NDW(ffs,2) #define __clzDI2 __NDW(clz,2) #define __ctzDI2 __NDW(ctz,2) #define __popcountDI2 __NDW(popcount,2) #define __parityDI2 __NDW(parity,2) +#define __bswapDI2 __NDW(bswap,2) extern DWtype __muldi3 (DWtype, DWtype); extern DWtype __divdi3 (DWtype, DWtype); @@ -345,11 +347,13 @@ extern Wtype __addvSI3 (Wtype, Wtype); extern Wtype __subvSI3 (Wtype, Wtype); extern Wtype __mulvSI3 (Wtype, Wtype); extern Wtype __negvSI2 (Wtype); +extern UWtype __bswapSI2 (UWtype); extern DWtype __absvDI2 (DWtype); extern DWtype __addvDI3 (DWtype, DWtype); extern DWtype __subvDI3 (DWtype, DWtype); extern DWtype __mulvDI3 (DWtype, DWtype); extern DWtype __negvDI2 (DWtype); +extern UDWtype __bswapDI2 (UDWtype); #ifdef COMPAT_SIMODE_TRAPPING_ARITHMETIC extern SItype __absvsi2 (SItype); diff --git a/gcc/mklibgcc.in b/gcc/mklibgcc.in index b4a31a6..60e3905 100644 --- a/gcc/mklibgcc.in +++ b/gcc/mklibgcc.in @@ -91,7 +91,7 @@ lib2funcs='_muldi3 _negdi2 _lshrdi3 _ashldi3 _ashrdi3 _ffssi2 _ffsdi2 _clz _clzsi2 _clzdi2 _ctzsi2 _ctzdi2 _popcount_tab _popcountsi2 _popcountdi2 _paritysi2 _paritydi2 _powisf2 _powidf2 _powixf2 _powitf2 _mulsc3 _muldc3 _mulxc3 _multc3 _divsc3 _divdc3 - _divxc3 _divtc3' + _divxc3 _divtc3 _bswapsi2 _bswapdi2' if [ "$LIB2_SIDITI_CONV_FUNCS" ]; then for func in $swfloatfuncs; do diff --git a/gcc/optabs.c b/gcc/optabs.c index 4f9374a..92887ab 100644 --- a/gcc/optabs.c +++ b/gcc/optabs.c @@ -2590,6 +2590,10 @@ expand_unop (enum machine_mode mode, optab unoptab, rtx op0, rtx target, goto try_libcall; } + /* We can't widen a bswap. */ + if (unoptab == bswap_optab) + goto try_libcall; + if (CLASS_HAS_WIDER_MODES_P (class)) for (wider_mode = GET_MODE_WIDER_MODE (mode); wider_mode != VOIDmode; @@ -5292,6 +5296,7 @@ init_optabs (void) absv_optab = init_optabv (ABS); addcc_optab = init_optab (UNKNOWN); one_cmpl_optab = init_optab (NOT); + bswap_optab = init_optab (BSWAP); ffs_optab = init_optab (FFS); clz_optab = init_optab (CLZ); ctz_optab = init_optab (CTZ); @@ -5504,6 +5509,11 @@ init_optabs (void) init_interclass_conv_libfuncs (trunc_optab, "trunc", MODE_FLOAT, MODE_DECIMAL_FLOAT); init_interclass_conv_libfuncs (trunc_optab, "trunc", MODE_DECIMAL_FLOAT, MODE_FLOAT); + /* Explicitly initialize the bswap libfuncs since we need them to be + valid for things other than word_mode. */ + set_optab_libfunc (bswap_optab, SImode, "__bswapsi2"); + set_optab_libfunc (bswap_optab, DImode, "__bswapdi2"); + /* Use cabs for double complex abs, since systems generally have cabs. Don't define any libcall for float complex, so that cabs will be used. */ if (complex_double_type_node) diff --git a/gcc/optabs.h b/gcc/optabs.h index 0f84c98..b47e762 100644 --- a/gcc/optabs.h +++ b/gcc/optabs.h @@ -146,6 +146,8 @@ enum optab_index /* Abs value */ OTI_abs, OTI_absv, + /* Byteswap */ + OTI_bswap, /* Bitwise not */ OTI_one_cmpl, /* Bit scanning and counting */ @@ -312,6 +314,7 @@ extern GTY(()) optab optab_table[OTI_MAX]; #define abs_optab (optab_table[OTI_abs]) #define absv_optab (optab_table[OTI_absv]) #define one_cmpl_optab (optab_table[OTI_one_cmpl]) +#define bswap_optab (optab_table[OTI_bswap]) #define ffs_optab (optab_table[OTI_ffs]) #define clz_optab (optab_table[OTI_clz]) #define ctz_optab (optab_table[OTI_ctz]) diff --git a/gcc/reload1.c b/gcc/reload1.c index 353eeec..e644322 100644 --- a/gcc/reload1.c +++ b/gcc/reload1.c @@ -2555,6 +2555,7 @@ eliminate_regs_1 (rtx x, enum machine_mode mem_mode, rtx insn, case CTZ: case POPCOUNT: case PARITY: + case BSWAP: new = eliminate_regs_1 (XEXP (x, 0), mem_mode, insn, false); if (new != XEXP (x, 0)) return gen_rtx_fmt_e (code, GET_MODE (x), new); @@ -2775,6 +2776,7 @@ elimination_effects (rtx x, enum machine_mode mem_mode) case CTZ: case POPCOUNT: case PARITY: + case BSWAP: elimination_effects (XEXP (x, 0), mem_mode); return; diff --git a/gcc/rtl.def b/gcc/rtl.def index 847b51c..cb37f1a 100644 --- a/gcc/rtl.def +++ b/gcc/rtl.def @@ -567,6 +567,9 @@ DEF_RTL_EXPR(ABS, "abs", "e", RTX_UNARY) /* Square root */ DEF_RTL_EXPR(SQRT, "sqrt", "e", RTX_UNARY) +/* Swap bytes. */ +DEF_RTL_EXPR(BSWAP, "bswap", "e", RTX_UNARY) + /* Find first bit that is set. Value is 1 + number of trailing zeros in the arg., or 0 if arg is 0. */ diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index fee07f9..fe5463a 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -1042,6 +1042,9 @@ simplify_const_unary_operation (enum rtx_code code, enum machine_mode mode, val &= 1; break; + case BSWAP: + return 0; + case TRUNCATE: val = arg0; break; @@ -4867,4 +4870,3 @@ simplify_rtx (rtx x) } return NULL; } - diff --git a/gcc/tree.c b/gcc/tree.c index d5e3f3f..5886e18 100644 --- a/gcc/tree.c +++ b/gcc/tree.c @@ -6576,6 +6576,10 @@ build_common_tree_nodes_2 (int short_double) long_double_ptr_type_node = build_pointer_type (long_double_type_node); integer_ptr_type_node = build_pointer_type (integer_type_node); + /* Fixed size integer types. */ + uint32_type_node = build_nonstandard_integer_type (32, true); + uint64_type_node = build_nonstandard_integer_type (64, true); + /* Decimal float types. */ dfloat32_type_node = make_node (REAL_TYPE); TYPE_PRECISION (dfloat32_type_node) = DECIMAL32_TYPE_SIZE; diff --git a/gcc/tree.h b/gcc/tree.h index 013232b..52a04c4 100644 --- a/gcc/tree.h +++ b/gcc/tree.h @@ -3217,6 +3217,9 @@ enum tree_index TI_UINTDI_TYPE, TI_UINTTI_TYPE, + TI_UINT32_TYPE, + TI_UINT64_TYPE, + TI_INTEGER_ZERO, TI_INTEGER_ONE, TI_INTEGER_MINUS_ONE, @@ -3292,6 +3295,9 @@ extern GTY(()) tree global_trees[TI_MAX]; #define unsigned_intDI_type_node global_trees[TI_UINTDI_TYPE] #define unsigned_intTI_type_node global_trees[TI_UINTTI_TYPE] +#define uint32_type_node global_trees[TI_UINT32_TYPE] +#define uint64_type_node global_trees[TI_UINT64_TYPE] + #define integer_zero_node global_trees[TI_INTEGER_ZERO] #define integer_one_node global_trees[TI_INTEGER_ONE] #define integer_minus_one_node global_trees[TI_INTEGER_MINUS_ONE]