Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTobias Burnus <tobias@codesourcery.com>2022-11-18 11:50:20 +0300
committerCorinna Vinschen <corinna@vinschen.de>2022-11-21 15:10:29 +0300
commitb9898fc99379b35e41311012c4a3fe5b60305a3d (patch)
tree61c827b02f4768be5272c63846a7473db40b3a59 /newlib/libc/machine
parent32d6a6cb5f1e5a136ae86247e124edd68dc1800e (diff)
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(-)
Diffstat (limited to 'newlib/libc/machine')
-rw-r--r--newlib/libc/machine/amdgcn/exit-value.h6
-rw-r--r--newlib/libc/machine/amdgcn/mlock.c10
2 files changed, 13 insertions, 3 deletions
diff --git a/newlib/libc/machine/amdgcn/exit-value.h b/newlib/libc/machine/amdgcn/exit-value.h
index 6e88625b7..7aa2508bb 100644
--- a/newlib/libc/machine/amdgcn/exit-value.h
+++ b/newlib/libc/machine/amdgcn/exit-value.h
@@ -21,8 +21,14 @@ exit_with_int (int val)
{
/* Write the exit value to the conventional place. */
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"
"s_waitcnt 0" : "=Sg"(return_value));
+#endif
*return_value = val;
/* Terminate the current kernel. */
diff --git a/newlib/libc/machine/amdgcn/mlock.c b/newlib/libc/machine/amdgcn/mlock.c
index 4848c978c..fbc4944e6 100644
--- a/newlib/libc/machine/amdgcn/mlock.c
+++ b/newlib/libc/machine/amdgcn/mlock.c
@@ -39,11 +39,15 @@ sbrk (ptrdiff_t nbytes)
{
if (__heap_ptr == (char *)-1)
{
- /* Find the heap from kernargs.
- The kernargs pointer is in s[8:9].
- This will break if the enable_sgpr_* flags are ever changed. */
+ /* Find the heap from 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));
+#endif
/* The heap data is at kernargs[3]. */
struct heap *heap = *(struct heap **)(kernargs + 24);