This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [patch] Add generic __builtin_bswap16 support


On Mon, Apr 9, 2012 at 11:43 PM, Eric Botcazou <ebotcazou@adacore.com> wrote:
> Hi,
>
> this adds generic support for __builtin_bswap16 (only PowerPC has it for now).
> It is mapped to the bswap optab in HImode, whose implementation is as follows:
> ?- if a bswaphi2 pattern is present (PowerPC), it is directly used; or else
> ?- if a rotlhi2/rotrhi2 pattern is present (x86), it is directly used, or else
> ?- if ashlxx2 & lshrxx2 are present (SPARC), they are used to open-code the
> operation, or else,
> ?- if a bswapsi2 pattern is present, it is used (with a final shift), otherwise
> ?- the bswapsi2 libcall is used (with a final shift).
>
> Since it is expected that most architectures will fall into one of the first 3
> cases, no __bswaphi2 symbol is added to libgcc. ?And pass_optimize_bswap isn't
> modified to recognize the builtin either, as this seems overkill to me.
>
> Tested on x86, x86-64 and PowerPC Linux, OK for the mainline?

Ok.

Thanks,
Richard.

>
> 2012-04-09 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> ? ? ? ?PR target/52624
> ? ? ? ?* doc/extend.texi (Other Builtins): Document __builtin_bswap16.
> ? ? ? ?(PowerPC AltiVec/VSX Built-in Functions): Remove it.
> ? ? ? ?* builtin-types.def (BT_UINT16): New primitive type.
> ? ? ? ?(BT_FN_UINT16_UINT16): New function type.
> ? ? ? ?* builtins.def (BUILT_IN_BSWAP16): New.
> ? ? ? ?* builtins.c (expand_builtin_bswap): Add TARGET_MODE argument.
> ? ? ? ?(expand_builtin) <BUILT_IN_BSWAP16>: New case. ?Pass TARGET_MODE to
> ? ? ? ?expand_builtin_bswap.
> ? ? ? ?* optabs.c (expand_unop): Deal with bswap in HImode specially. ?Add
> ? ? ? ?missing bits for bswap to libcall code.
> ? ? ? ?* tree.c (build_common_tree_nodes): Build uint16_type_node.
> ? ? ? ?* tree.h (enum tree_index): Add TI_UINT16_TYPE.
> ? ? ? ?(uint16_type_node): New define.
> ? ? ? ?* config/rs6000/rs6000-builtin.def (RS6000_BUILTIN_BSWAP_HI): Delete.
> ? ? ? ?* config/rs6000/rs6000.c (rs6000_expand_builtin): Remove handling of
> ? ? ? ?above builtin.
> ? ? ? ?(rs6000_init_builtins): Likewise.
> ? ? ? ?* config/rs6000/rs6000.md (bswaphi2): Add TARGET_POWERPC predicate.
>
>
> 2012-04-09 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> c-family/
> ? ? ? ?* c-common.h (uint16_type_node): Rename into...
> ? ? ? ?(c_uint16_type_node): ...this.
> ? ? ? ?* c-common.c (c_common_nodes_and_builtins): Adjust for above renaming.
> ? ? ? ?* c-cppbuiltin.c (builtin_define_stdint_macros): Likewise.
>
>
> 2012-04-09 ?Eric Botcazou ?<ebotcazou@adacore.com>
>
> testsuite/
> ? ? ? ?* gcc.dg/builtin-bswap-1.c: Test __builtin_bswap16 & __builtin_bswap64.
> ? ? ? ?* gcc.dg/builtin-bswap-4.c: Test __builtin_bswap16.
> ? ? ? ?* gcc.dg/builtin-bswap-5.c: Likewise.
> ? ? ? ?* gcc.target/i386/builtin-bswap-4.c: New test.
>
>
> --
> Eric Botcazou


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]