amdgcn: Replace asm("s8") by __builtin_gcn_kernarg_ptr if existing
Check whether __builtin_gcn_kernarg_ptr is available and, if it is, call it instead using the hard-coded 'asm("s8")' in: * newlib/libc/machine/amdgcn/exit-value.h (exit_with_int) * newlib/libc/machine/amdgcn/mlock.c (sbrk) * newlib/libc/sys/amdgcn/write.c (write) newlib/libc/machine/amdgcn/exit-value.h | 6 ++++++ newlib/libc/machine/amdgcn/mlock.c | 10 +++++++--- newlib/libc/sys/amdgcn/write.c | 4 ++++ 3 files changed, 17 insertions(+), 3 deletions(-)
This commit is contained in:
parent
32d6a6cb5f
commit
b9898fc993
|
@ -21,8 +21,14 @@ exit_with_int (int val)
|
||||||
{
|
{
|
||||||
/* Write the exit value to the conventional place. */
|
/* Write the exit value to the conventional place. */
|
||||||
int *return_value;
|
int *return_value;
|
||||||
|
#if defined(__has_builtin) && __has_builtin(__builtin_gcn_kernarg_ptr)
|
||||||
|
asm ("s_load_dwordx2 %0, %1, 16 glc\n\t"
|
||||||
|
"s_waitcnt 0"
|
||||||
|
: "=Sg"(return_value) : "r"(__builtin_gcn_kernarg_ptr()));
|
||||||
|
#else
|
||||||
asm ("s_load_dwordx2 %0, s[8:9], 16 glc\n\t"
|
asm ("s_load_dwordx2 %0, s[8:9], 16 glc\n\t"
|
||||||
"s_waitcnt 0" : "=Sg"(return_value));
|
"s_waitcnt 0" : "=Sg"(return_value));
|
||||||
|
#endif
|
||||||
*return_value = val;
|
*return_value = val;
|
||||||
|
|
||||||
/* Terminate the current kernel. */
|
/* Terminate the current kernel. */
|
||||||
|
|
|
@ -39,11 +39,15 @@ sbrk (ptrdiff_t nbytes)
|
||||||
{
|
{
|
||||||
if (__heap_ptr == (char *)-1)
|
if (__heap_ptr == (char *)-1)
|
||||||
{
|
{
|
||||||
/* Find the heap from kernargs.
|
/* Find the heap from kernargs. */
|
||||||
The kernargs pointer is in s[8:9].
|
|
||||||
This will break if the enable_sgpr_* flags are ever changed. */
|
|
||||||
char *kernargs;
|
char *kernargs;
|
||||||
|
#if defined(__has_builtin) && __has_builtin(__builtin_gcn_kernarg_ptr)
|
||||||
|
kernargs = __builtin_gcn_kernarg_ptr ();
|
||||||
|
#else
|
||||||
|
/* The kernargs pointer is in s[8:9].
|
||||||
|
This will break if the enable_sgpr_* flags are ever changed. */
|
||||||
asm ("s_mov_b64 %0, s[8:9]" : "=Sg"(kernargs));
|
asm ("s_mov_b64 %0, s[8:9]" : "=Sg"(kernargs));
|
||||||
|
#endif
|
||||||
|
|
||||||
/* The heap data is at kernargs[3]. */
|
/* The heap data is at kernargs[3]. */
|
||||||
struct heap *heap = *(struct heap **)(kernargs + 24);
|
struct heap *heap = *(struct heap **)(kernargs + 24);
|
||||||
|
|
|
@ -56,7 +56,11 @@ _READ_WRITE_RETURN_TYPE write (int fd, const void *buf, size_t count)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* The output data is at ((void*)kernargs)[2]. */
|
/* The output data is at ((void*)kernargs)[2]. */
|
||||||
|
#if defined(__has_builtin) && __has_builtin(__builtin_gcn_kernarg_ptr)
|
||||||
|
register void **kernargs = __builtin_gcn_kernarg_ptr ();
|
||||||
|
#else
|
||||||
register void **kernargs asm("s8");
|
register void **kernargs asm("s8");
|
||||||
|
#endif
|
||||||
struct output *data = (struct output *)kernargs[2];
|
struct output *data = (struct output *)kernargs[2];
|
||||||
|
|
||||||
/* Each output slot allows 256 bytes, so reserve as many as we need. */
|
/* Each output slot allows 256 bytes, so reserve as many as we need. */
|
||||||
|
|
Loading…
Reference in New Issue