public inbox for gcc-cvs@sourceware.org help / color / mirror / Atom feed
From: Tobias Burnus <burnus@gcc.gnu.org> To: gcc-cvs@gcc.gnu.org Subject: [gcc/devel/omp/gcc-12] gcn: Add __builtin_gcn_kernarg_ptr Date: Fri, 18 Nov 2022 09:48:16 +0000 (GMT) [thread overview] Message-ID: <20221118094816.2BA54384F4A5@sourceware.org> (raw) https://gcc.gnu.org/g:43884163928197159acdff4735574a4366d4e245 commit 43884163928197159acdff4735574a4366d4e245 Author: Tobias Burnus <tobias@codesourcery.com> Date: Fri Nov 18 10:46:48 2022 +0100 gcn: Add __builtin_gcn_kernarg_ptr Add __builtin_gcn_kernarg_ptr to avoid using hard-coded register values and permit future ABI changes while keeping the API. gcc/ChangeLog: * config/gcn/gcn-builtins.def (KERNARG_PTR): Add. * config/gcn/gcn.cc (gcn_init_builtin_types): Change siptr_type_node, sfptr_type_node and voidptr_type_node from FLAT to ADDR_SPACE_DEFAULT. (gcn_expand_builtin_1): Handle GCN_BUILTIN_KERNARG_PTR. (gcn_oacc_dim_size): Return in ADDR_SPACE_FLAT. libgomp/ChangeLog: * config/gcn/team.c (gomp_gcn_enter_kernel): Use __builtin_gcn_kernarg_ptr instead of asm ("s8"). Co-Authored-By: Andrew Stubbs <ams@codesourcery.com> (cherry picked from commit 6f83861cc1c4d09425aa6539877bfa50ef90f183) Diff: --- gcc/ChangeLog.omp | 12 ++++++++++++ gcc/config/gcn/gcn-builtins.def | 4 ++++ gcc/config/gcn/gcn.cc | 24 ++++++++++++++++++++---- libgomp/ChangeLog.omp | 9 +++++++++ libgomp/config/gcn/team.c | 2 +- 5 files changed, 46 insertions(+), 5 deletions(-) diff --git a/gcc/ChangeLog.omp b/gcc/ChangeLog.omp index 61651fbfe37..fd420ef3431 100644 --- a/gcc/ChangeLog.omp +++ b/gcc/ChangeLog.omp @@ -1,3 +1,15 @@ +2022-11-18 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 2022-11-16 Tobias Burnus <tobias@codesourcery.com> + Andrew Stubbs <ams@codesourcery.com> + + * config/gcn/gcn-builtins.def (KERNARG_PTR): Add. + * config/gcn/gcn.cc (gcn_init_builtin_types): Change siptr_type_node, + sfptr_type_node and voidptr_type_node from FLAT to ADDR_SPACE_DEFAULT. + (gcn_expand_builtin_1): Handle GCN_BUILTIN_KERNARG_PTR. + (gcn_oacc_dim_size): Return in ADDR_SPACE_FLAT. + 2022-11-16 Tobias Burnus <tobias@codesourcery.com> Backported from master: diff --git a/gcc/config/gcn/gcn-builtins.def b/gcc/config/gcn/gcn-builtins.def index c50777bd3b0..eeeaebf9013 100644 --- a/gcc/config/gcn/gcn-builtins.def +++ b/gcc/config/gcn/gcn-builtins.def @@ -158,6 +158,10 @@ DEF_BUILTIN (ACC_SINGLE_COPY_END, -1, "single_copy_end", B_INSN, DEF_BUILTIN (ACC_BARRIER, -1, "acc_barrier", B_INSN, _A1 (GCN_BTI_VOID), gcn_expand_builtin_1) +/* Kernel inputs. */ + +DEF_BUILTIN (KERNARG_PTR, -1, "kernarg_ptr", B_INSN, _A1 (GCN_BTI_VOIDPTR), + gcn_expand_builtin_1) #undef _A1 #undef _A2 diff --git a/gcc/config/gcn/gcn.cc b/gcc/config/gcn/gcn.cc index 884703249ae..0d076aaa1a5 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -4091,15 +4091,15 @@ gcn_init_builtin_types (void) (integer_type_node) */ , 64); tree tmp = build_distinct_type_copy (intSI_type_node); - TYPE_ADDR_SPACE (tmp) = ADDR_SPACE_FLAT; + TYPE_ADDR_SPACE (tmp) = ADDR_SPACE_DEFAULT; siptr_type_node = build_pointer_type (tmp); tmp = build_distinct_type_copy (float_type_node); - TYPE_ADDR_SPACE (tmp) = ADDR_SPACE_FLAT; + TYPE_ADDR_SPACE (tmp) = ADDR_SPACE_DEFAULT; sfptr_type_node = build_pointer_type (tmp); tmp = build_distinct_type_copy (void_type_node); - TYPE_ADDR_SPACE (tmp) = ADDR_SPACE_FLAT; + TYPE_ADDR_SPACE (tmp) = ADDR_SPACE_DEFAULT; voidptr_type_node = build_pointer_type (tmp); tmp = build_distinct_type_copy (void_type_node); @@ -4526,6 +4526,20 @@ gcn_expand_builtin_1 (tree exp, rtx target, rtx /*subtarget */ , emit_insn (gen_gcn_wavefront_barrier ()); return target; + case GCN_BUILTIN_KERNARG_PTR: + { + rtx ptr; + if (cfun->machine->args.reg[KERNARG_SEGMENT_PTR_ARG] >= 0) + ptr = gen_rtx_REG (DImode, + cfun->machine->args.reg[KERNARG_SEGMENT_PTR_ARG]); + else + { + ptr = gen_reg_rtx (DImode); + emit_move_insn (ptr, const0_rtx); + } + return ptr; + } + default: gcc_unreachable (); } @@ -5840,7 +5854,9 @@ gcn_oacc_dim_size (int dim) cfun->machine->args. reg[DISPATCH_PTR_ARG]), GEN_INT (offset[dim])); - return gen_rtx_MEM (SImode, addr); + rtx mem = gen_rtx_MEM (SImode, addr); + set_mem_addr_space (mem, ADDR_SPACE_SCALAR_FLAT); + return mem; } /* Helper function for oacc_dim_pos instruction. diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp index 7e117fd5010..136b6f0d7f1 100644 --- a/libgomp/ChangeLog.omp +++ b/libgomp/ChangeLog.omp @@ -1,3 +1,12 @@ +2022-11-18 Tobias Burnus <tobias@codesourcery.com> + + Backported from master: + 2022-11-16 Tobias Burnus <tobias@codesourcery.com> + Andrew Stubbs <ams@codesourcery.com> + + * config/gcn/team.c (gomp_gcn_enter_kernel): Use + __builtin_gcn_kernarg_ptr instead of asm ("s8"). + 2022-11-14 Tobias Burnus <tobias@codesourcery.com> Backport from mainline: diff --git a/libgomp/config/gcn/team.c b/libgomp/config/gcn/team.c index 70fbf6f4822..7cf4c0be3cc 100644 --- a/libgomp/config/gcn/team.c +++ b/libgomp/config/gcn/team.c @@ -60,7 +60,7 @@ gomp_gcn_enter_kernel (void) /* Initialize the team arena for optimized memory allocation. The arena has been allocated on the host side, and the address passed in via the kernargs. Each team takes a small slice of it. */ - register void **kernargs asm("s8"); + void **kernargs = (void**) __builtin_gcn_kernarg_ptr (); void *team_arena = (kernargs[4] + TEAM_ARENA_SIZE*teamid); void * __lds *arena_start = (void * __lds *)TEAM_ARENA_START; void * __lds *arena_free = (void * __lds *)TEAM_ARENA_FREE;
reply other threads:[~2022-11-18 9:48 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20221118094816.2BA54384F4A5@sourceware.org \ --to=burnus@gcc.gnu.org \ --cc=gcc-cvs@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).