nvptx: support bar.red instruction
authorChung-Lin Tang <cltang@codesourcery.com>
Wed, 21 Dec 2022 13:26:06 +0000 (05:26 -0800)
committerChung-Lin Tang <cltang@codesourcery.com>
Wed, 21 Dec 2022 13:58:49 +0000 (05:58 -0800)
commit623daaf8a229fcb58f84448d954f8c71191ca486
tree58228ef7d6f61905df9b1bf868b76929163dd566
parentf661b3d11e57853864b5bd04490115dd79869533
nvptx: support bar.red instruction

This patch adds support for the PTX 'bar.red' (i.e. "barrier reduction")
instruction, in the form of nvptx-specific __builtin_nvptx_bar_red_[and/or/popc]
built-in functions.

gcc/ChangeLog:

* config/nvptx/nvptx.cc (nvptx_print_operand): Add 'p' case, adjust
comments.
(enum nvptx_builtins): Add NVPTX_BUILTIN_BAR_RED_AND,
NVPTX_BUILTIN_BAR_RED_OR, and NVPTX_BUILTIN_BAR_RED_POPC.
(nvptx_expand_bar_red): New function.
(nvptx_init_builtins):
Add DEFs of __builtin_nvptx_bar_red_[and/or/popc].
(nvptx_expand_builtin): Use nvptx_expand_bar_red to expand
NVPTX_BUILTIN_BAR_RED_[AND/OR/POPC] cases.

* config/nvptx/nvptx.md (define_c_enum "unspecv"): Add
UNSPECV_BARRED_AND, UNSPECV_BARRED_OR, and UNSPECV_BARRED_POPC.
(BARRED): New int iterator.
(barred_op,barred_mode,barred_ptxtype): New int attrs.
(nvptx_barred_<barred_op>): New define_insn.
gcc/config/nvptx/nvptx.cc
gcc/config/nvptx/nvptx.md