From e78a0f58f23347c822c182d1c01f6eb9b9866d60 Mon Sep 17 00:00:00 2001 From: Max Filippov Date: Wed, 16 Sep 2015 01:49:49 +0300 Subject: xtensa: support call0 ABI Most changes are mechanical replacement of 'retw' instruction with 'abi_ret' macro, defined to 'retw' or 'ret' according to ABI. Assembly code that makes calls is duplicated for call0 ABI with changed register numbers for parameters/return value and call instruction. 'entry' instructions are replaced with 'abi_entry' macro. More interesting changes: - non-leaf assembly functions (e.g. _dl_tlsdesc_dynamic, _dl_linux_resolve, SYSCALL_ERROR_HANDLER, PSEUDO) now need to preserve registers around intermediate calls they make, use temporary stack frame for that; - setjmp/longjmp only need to save and restore return address, stack pointer and callee-saved registers in the jmpbuf; - __clone and syscall functions had hardcoded offsets to parameter passed on stack, on call0 ABI they don't need stack frame, so the offset is different. Replace these offsets with FRAMESIZE macro. Signed-off-by: Max Filippov --- libc/string/xtensa/memcpy.S | 16 ++++++++-------- libc/string/xtensa/memset.S | 4 ++-- libc/string/xtensa/strcmp.S | 20 ++++++++++---------- libc/string/xtensa/strcpy.S | 12 ++++++------ libc/string/xtensa/strlen.S | 8 ++++---- libc/string/xtensa/strncpy.S | 6 +++--- 6 files changed, 33 insertions(+), 33 deletions(-) (limited to 'libc/string') diff --git a/libc/string/xtensa/memcpy.S b/libc/string/xtensa/memcpy.S index 2b23b4113..244205611 100644 --- a/libc/string/xtensa/memcpy.S +++ b/libc/string/xtensa/memcpy.S @@ -91,7 +91,7 @@ __memcpy_aux: #if !XCHAL_HAVE_LOOPS blt a3, a7, 1b #endif -2: retw +2: abi_ret /* Destination is unaligned. */ @@ -181,7 +181,7 @@ ENTRY (memcpy) 3: bbsi.l a4, 2, 4f bbsi.l a4, 1, 5f bbsi.l a4, 0, 6f - retw + abi_ret /* Copy 4 bytes. */ 4: l32i a6, a3, 0 @@ -190,7 +190,7 @@ ENTRY (memcpy) addi a5, a5, 4 bbsi.l a4, 1, 5f bbsi.l a4, 0, 6f - retw + abi_ret /* Copy 2 bytes. */ 5: l16ui a6, a3, 0 @@ -198,14 +198,14 @@ ENTRY (memcpy) s16i a6, a5, 0 addi a5, a5, 2 bbsi.l a4, 0, 6f - retw + abi_ret /* Copy 1 byte. */ 6: l8ui a6, a3, 0 s8i a6, a5, 0 .Ldone: - retw + abi_ret /* Destination is aligned; source is unaligned. */ @@ -276,7 +276,7 @@ ENTRY (memcpy) #endif bbsi.l a4, 1, 5f bbsi.l a4, 0, 6f - retw + abi_ret /* Copy 2 bytes. */ 5: l8ui a6, a3, 0 @@ -286,11 +286,11 @@ ENTRY (memcpy) s8i a7, a5, 1 addi a5, a5, 2 bbsi.l a4, 0, 6f - retw + abi_ret /* Copy 1 byte. */ 6: l8ui a6, a3, 0 s8i a6, a5, 0 - retw + abi_ret libc_hidden_def (memcpy) diff --git a/libc/string/xtensa/memset.S b/libc/string/xtensa/memset.S index 435d6dea0..20bf14c75 100644 --- a/libc/string/xtensa/memset.S +++ b/libc/string/xtensa/memset.S @@ -63,7 +63,7 @@ __memset_aux: #if !XCHAL_HAVE_LOOPS blt a5, a6, 1b #endif -2: retw +2: abi_ret /* Destination is unaligned. */ @@ -159,6 +159,6 @@ ENTRY (memset) /* Set 1 byte. */ s8i a3, a5, 0 -6: retw +6: abi_ret libc_hidden_def (memset) diff --git a/libc/string/xtensa/strcmp.S b/libc/string/xtensa/strcmp.S index 8ed1ed009..2dce590db 100644 --- a/libc/string/xtensa/strcmp.S +++ b/libc/string/xtensa/strcmp.S @@ -108,7 +108,7 @@ ENTRY (strcmp) #endif .Lretdiff: sub a2, a8, a9 - retw + abi_ret /* s1 is word-aligned; s2 is word-aligned. @@ -229,7 +229,7 @@ ENTRY (strcmp) /* Words are equal; some byte is zero. */ .Leq: movi a2, 0 /* return equal */ - retw + abi_ret .Lwne2: /* Words are not equal. On big-endian processors, if none of the bytes are zero, the return value can be determined by a simple @@ -239,10 +239,10 @@ ENTRY (strcmp) bnall a10, a7, .Lsomezero bgeu a8, a9, .Lposreturn movi a2, -1 - retw + abi_ret .Lposreturn: movi a2, 1 - retw + abi_ret .Lsomezero: /* There is probably some zero byte. */ #endif /* __XTENSA_EB__ */ .Lwne: /* Words are not equal. */ @@ -263,14 +263,14 @@ ENTRY (strcmp) byte. Just subtract words to get the return value. The high order equal bytes cancel, leaving room for the sign. */ sub a2, a8, a9 - retw + abi_ret .Ldiff0: /* Need to make room for the sign, so can't subtract whole words. */ extui a10, a8, 24, 8 extui a11, a9, 24, 8 sub a2, a10, a11 - retw + abi_ret #else /* !__XTENSA_EB__ */ /* Little-endian is a little more difficult because can't subtract @@ -281,28 +281,28 @@ ENTRY (strcmp) extui a10, a8, 24, 8 extui a11, a9, 24, 8 sub a2, a10, a11 - retw + abi_ret .Ldiff0: /* Byte 0 is different. */ extui a10, a8, 0, 8 extui a11, a9, 0, 8 sub a2, a10, a11 - retw + abi_ret .Ldiff1: /* Byte 0 is equal; byte 1 is different. */ extui a10, a8, 8, 8 extui a11, a9, 8, 8 sub a2, a10, a11 - retw + abi_ret .Ldiff2: /* Bytes 0-1 are equal; byte 2 is different. */ extui a10, a8, 16, 8 extui a11, a9, 16, 8 sub a2, a10, a11 - retw + abi_ret #endif /* !__XTENSA_EB */ diff --git a/libc/string/xtensa/strcpy.S b/libc/string/xtensa/strcpy.S index f9f586896..9f42b34e6 100644 --- a/libc/string/xtensa/strcpy.S +++ b/libc/string/xtensa/strcpy.S @@ -68,7 +68,7 @@ ENTRY (strcpy) s8i a8, a10, 1 /* store byte 0 */ addi a10, a10, 2 /* advance dst pointer */ bnez a8, .Lsrcaligned -1: retw +1: abi_ret /* dst is word-aligned; src is word-aligned. */ @@ -102,21 +102,21 @@ ENTRY (strcpy) #endif /* !XCHAL_HAVE_LOOPS */ .Lz3: /* Byte 3 is zero. */ - retw + abi_ret .Lz0: /* Byte 0 is zero. */ #ifdef __XTENSA_EB__ movi a8, 0 #endif s8i a8, a10, 0 - retw + abi_ret .Lz1: /* Byte 1 is zero. */ #ifdef __XTENSA_EB__ extui a8, a8, 16, 16 #endif s16i a8, a10, 0 - retw + abi_ret .Lz2: /* Byte 2 is zero. */ #ifdef __XTENSA_EB__ @@ -125,7 +125,7 @@ ENTRY (strcpy) s16i a8, a10, 0 movi a8, 0 s8i a8, a10, 2 - retw + abi_ret .align 4 /* (2 mod 4) alignment for loop instruction */ @@ -144,6 +144,6 @@ ENTRY (strcpy) #else bnez a8, 1b #endif -2: retw +2: abi_ret libc_hidden_def (strcpy) diff --git a/libc/string/xtensa/strlen.S b/libc/string/xtensa/strlen.S index 86fe11390..e1c98c8f0 100644 --- a/libc/string/xtensa/strlen.S +++ b/libc/string/xtensa/strlen.S @@ -59,7 +59,7 @@ ENTRY (strlen) /* Byte 3 is zero. */ addi a3, a3, 3 /* point to zero byte */ sub a2, a3, a2 /* subtract to get length */ - retw + abi_ret /* String is word-aligned. */ @@ -88,16 +88,16 @@ ENTRY (strlen) .Lz0: /* Byte 0 is zero. */ sub a2, a3, a2 /* subtract to get length */ - retw + abi_ret .Lz1: /* Byte 1 is zero. */ addi a3, a3, 1 /* point to zero byte */ sub a2, a3, a2 /* subtract to get length */ - retw + abi_ret .Lz2: /* Byte 2 is zero. */ addi a3, a3, 2 /* point to zero byte */ sub a2, a3, a2 /* subtract to get length */ - retw + abi_ret libc_hidden_def (strlen) diff --git a/libc/string/xtensa/strncpy.S b/libc/string/xtensa/strncpy.S index 115d44cf8..aa8db5da1 100644 --- a/libc/string/xtensa/strncpy.S +++ b/libc/string/xtensa/strncpy.S @@ -67,7 +67,7 @@ __strncpy_aux: j .Lfill .Lret: - retw + abi_ret ENTRY (strncpy) @@ -129,7 +129,7 @@ ENTRY (strncpy) addi a10, a10, 1 bnez a4, .Lfillcleanup -2: retw +2: abi_ret .Lfill1mod2: /* dst address is odd */ s8i a9, a10, 0 /* store byte 0 */ @@ -235,6 +235,6 @@ ENTRY (strncpy) #endif 2: j .Lfill -3: retw +3: abi_ret libc_hidden_def (strncpy) -- cgit v1.2.3