Skip to contentSkip to conversation

arm: lib: add __gnu_thumb1_case_si

RFC PATCH In review Francis Laniel 4 participants 6 messages Apr 1, 2023 – Apr 8, 2023 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 arm: lib: add __gnu_thumb1_case_si

The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted as width suffix was removed for the add instruction [1].

[1] https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156

---
 arch/arm/lib/lib1funcs.S | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/lib/lib1funcs.S +17 -0
index 7ff4446dd6..79cedc0aad 100644
@@ -424,4 +424,21 @@ ENTRY(__gnu_thumb1_case_uhi)
 	ret	lr
 ENDPROC(__gnu_thumb1_case_uhi)
 .popsection
+
+/* Taken and adapted from: https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156 */
+.pushsection .text.__gnu_thumb1_case_si, "ax"
+ENTRY(__gnu_thumb1_case_si)
+	push	{r0, r1}
+	mov	r1, lr
+	adds	r1, r1, #2	/* Align to word.  */
+	lsrs	r1, r1, #2
+	lsls	r0, r0, #2
+	lsls	r1, r1, #2
+	ldr	r0, [r1, r0]
+	adds	r0, r0, r1
+	mov	lr, r0
+	pop	{r0, r1}
+	mov	pc, lr		/* We know we were called from thumb code.  */
+ENDPROC(__gnu_thumb1_case_si)
+.popsection
 #endif

--
2.34.1

#1 lore raw

Hi Francis,

Quoted 7 lines · Francis Laniel

The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted as width suffix was removed for the add instruction [1].

[1] https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156

Thanks for the patch! I've added Tom, Pali, and Stefan.

I think we need to do some more testing for other boards that have CONFIG_HAS_THUMB2 and CONFIG_SPL_SYS_THUMB_BUILD. My test target (Marvell Armada 385 SoC) is somewhat broken right now. So it will take some time for me to get that back running to run this test.

All the best,
Tony

Quoted 33 lines
---
 arch/arm/lib/lib1funcs.S | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/lib/lib1funcs.S +17 -1
index 7ff4446dd6..79cedc0aad 100644
@@ -424,4 +424,21 @@ ENTRY(__gnu_thumb1_case_uhi)
        ret     lr
 ENDPROC(__gnu_thumb1_case_uhi)
 .popsection
+
+/* Taken and adapted from: https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156 */
+.pushsection .text.__gnu_thumb1_case_si, "ax"
+ENTRY(__gnu_thumb1_case_si)
+       push    {r0, r1}
+       mov     r1, lr
+       adds    r1, r1, #2      /* Align to word.  */
+       lsrs    r1, r1, #2
+       lsls    r0, r0, #2
+       lsls    r1, r1, #2
+       ldr     r0, [r1, r0]
+       adds    r0, r0, r1
+       mov     lr, r0
+       pop     {r0, r1}
+       mov     pc, lr          /* We know we were called from thumb code.  */
+ENDPROC(__gnu_thumb1_case_si)
+.popsection
 #endif
--

2.34.1

Acked-by
#2 lore raw
Quoted 5 lines · On Saturday 01 April 2023 15:17:59 Tony Dinh wrote:

Hi Francis,

Quoted 1 line · Francis Laniel
Quoted 8 lines
Quoted 6 lines

The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted as width suffix was removed for the add instruction [1].

[1] https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156

Thanks for the patch! I've added Tom, Pali, and Stefan.

Looks good,

Quoted 41 lines

I think we need to do some more testing for other boards that have CONFIG_HAS_THUMB2 and CONFIG_SPL_SYS_THUMB_BUILD. My test target (Marvell Armada 385 SoC) is somewhat broken right now. So it will take some time for me to get that back running to run this test.

All the best,
Tony

Quoted 33 lines
---
 arch/arm/lib/lib1funcs.S | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/lib/lib1funcs.S +17 -1
index 7ff4446dd6..79cedc0aad 100644
@@ -424,4 +424,21 @@ ENTRY(__gnu_thumb1_case_uhi)
        ret     lr
 ENDPROC(__gnu_thumb1_case_uhi)
 .popsection
+
+/* Taken and adapted from: https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156 */
+.pushsection .text.__gnu_thumb1_case_si, "ax"
+ENTRY(__gnu_thumb1_case_si)
+       push    {r0, r1}
+       mov     r1, lr
+       adds    r1, r1, #2      /* Align to word.  */
+       lsrs    r1, r1, #2
+       lsls    r0, r0, #2
+       lsls    r1, r1, #2
+       ldr     r0, [r1, r0]
+       adds    r0, r0, r1
+       mov     lr, r0
+       pop     {r0, r1}
+       mov     pc, lr          /* We know we were called from thumb code.  */
+ENDPROC(__gnu_thumb1_case_si)
+.popsection
 #endif
--

2.34.1

Acked-by
#3 lore raw

Hi Francis,

Quoted 14 lines · Pali Rohár
Quoted 12 lines · On Saturday 01 April 2023 15:17:59 Tony Dinh wrote:

Hi Francis,

Quoted 7 lines · Francis Laniel

The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted as width suffix was removed for the add instruction [1].

[1] https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156

Quoted 10 lines
Quoted 1 line

Thanks for the patch! I've added Tom, Pali, and Stefan.

Looks good,

Quoted 4 lines

I think we need to do some more testing for other boards that have CONFIG_HAS_THUMB2 and CONFIG_SPL_SYS_THUMB_BUILD. My test target (Marvell Armada 385 SoC) is somewhat broken right now. So it will take some time for me to get that back running to run this test.

I've done some more testing with other boards. I'm seeing some problems with LTO in gcc-12, but it is not related to this patch.

Thanks,
Tony

Quoted 37 lines
Quoted 37 lines

All the best,
Tony

Quoted 33 lines
---
 arch/arm/lib/lib1funcs.S | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)
arch/arm/lib/lib1funcs.S +17 -1
index 7ff4446dd6..79cedc0aad 100644
@@ -424,4 +424,21 @@ ENTRY(__gnu_thumb1_case_uhi)
        ret     lr
 ENDPROC(__gnu_thumb1_case_uhi)
 .popsection
+
+/* Taken and adapted from: https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156 */
+.pushsection .text.__gnu_thumb1_case_si, "ax"
+ENTRY(__gnu_thumb1_case_si)
+       push    {r0, r1}
+       mov     r1, lr
+       adds    r1, r1, #2      /* Align to word.  */
+       lsrs    r1, r1, #2
+       lsls    r0, r0, #2
+       lsls    r1, r1, #2
+       ldr     r0, [r1, r0]
+       adds    r0, r0, r1
+       mov     lr, r0
+       pop     {r0, r1}
+       mov     pc, lr          /* We know we were called from thumb code.  */
+ENDPROC(__gnu_thumb1_case_si)
+.popsection
 #endif
--

2.34.1

#4 lore raw
In reply to Francis Laniel
Quoted 8 lines · Francis Laniel

The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted as width suffix was removed for the add instruction [1].

[1] https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be9018f1611/libgcc/config/arm/lib1funcs.S#L2156

Applied to u-boot/master, thanks!

Signature · 1 line
Tom
#5 lore raw
Quoted 12 lines · Le vendredi 7 avril 2023, 15:51:09 WEST Tom Rini a écrit :
Quoted 10 lines · Francis Laniel

The assembly for __gnu_thumb1_case_si was taken from upstream gcc and adapted as width suffix was removed for the add instruction [1].

https://github.com/gcc-mirror/gcc/blob/4f181f9c7ee3efc509d185fdfda33be901
8f1611/libgcc/config/arm/lib1funcs.S#L2156 Acked-by: Pali Rohár <[email protected]>

Quoted 1 line

Applied to u-boot/master, thanks!

Thank you for the merge!