diff options
author | Tobias Burnus <tobias@codesourcery.com> | 2022-11-16 14:24:01 +0100 |
---|---|---|
committer | Tobias Burnus <tobias@codesourcery.com> | 2022-11-16 14:25:28 +0100 |
commit | 6f83861cc1c4d09425aa6539877bfa50ef90f183 (patch) | |
tree | bc48fe578030835e3ccd38d6def7b421d4757fbb /gcc/config/gcn | |
parent | 21501ec751c102ce06ff3483375eb922c5c9cee3 (diff) | |
download | gcc-6f83861cc1c4d09425aa6539877bfa50ef90f183.zip gcc-6f83861cc1c4d09425aa6539877bfa50ef90f183.tar.gz gcc-6f83861cc1c4d09425aa6539877bfa50ef90f183.tar.bz2 |
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>
Diffstat (limited to 'gcc/config/gcn')
-rw-r--r-- | gcc/config/gcn/gcn-builtins.def | 4 | ||||
-rw-r--r-- | gcc/config/gcn/gcn.cc | 24 |
2 files changed, 24 insertions, 4 deletions
diff --git a/gcc/config/gcn/gcn-builtins.def b/gcc/config/gcn/gcn-builtins.def index c50777bd..eeeaebf 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 5e6f3b8..b3814c2 100644 --- a/gcc/config/gcn/gcn.cc +++ b/gcc/config/gcn/gcn.cc @@ -4058,15 +4058,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); @@ -4493,6 +4493,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 (); } @@ -5700,7 +5714,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. |