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>
This commit is contained in:
parent
21501ec751
commit
6f83861cc1
3 changed files with 25 additions and 5 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue