public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
* Minor improvement to H8 startup code
@ 2023-12-30  3:56 Jeff Law
  2023-12-30 21:46 ` Jeff Johnston
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Law @ 2023-12-30  3:56 UTC (permalink / raw)
  To: newlib

[-- Attachment #1: Type: text/plain, Size: 717 bytes --]

Basically the startup code needs to clear memory from _edata to _end. 
In the past it's been done with a fairly naive copy loop.  This changes 
the code to just call memset and let memset figure out a sensible way to 
handle the operation given the size and alignment requirements.

I don't have performance data on this.  I cobbled it together some time 
ago in response to seeing some of the GCC tests with larger .bss 
sections taking an insane amount of time to just get from _start to 
main.  With the fixes to the H8 decoder in the simulator it may not 
matter nearly as much anymore.

This has been in my tester for months.  Naturally it does not cause any 
regressions in the H8 port.

OK for the trunk?

Jeff

[-- Attachment #2: P --]
[-- Type: text/plain, Size: 1227 bytes --]

diff --git a/newlib/libc/sys/h8300hms/crt0.S b/newlib/libc/sys/h8300hms/crt0.S
index 6394f6841..05634113c 100644
--- a/newlib/libc/sys/h8300hms/crt0.S
+++ b/newlib/libc/sys/h8300hms/crt0.S
@@ -9,12 +9,10 @@
 _start:
 	mov.w	#_stack,sp
 	mov.w	#_edata,r0
-	mov.w	#_end,r1
-	sub.w   r2,r2
-.Loop:	mov.w	r2,@r0
-	adds	#2,r0
-	cmp	r1,r0
-	blo	.Loop
+	mov.w	#_end,r2
+	sub.w   r1,r1
+	sub.w	r0,r2
+	jsr	@_memset
 #ifdef __ELF__
 	mov.l   #__fini,r0
 	jsr     @_atexit
@@ -43,12 +41,10 @@ _stack:	.word 	1
 _start:
 	mov.l	#_stack,sp
 	mov.l	#_edata,er0
-	mov.l	#_end,er1
-	sub.w   r2,r2           ; not sure about alignment requirements
-.Loop:	mov.w	r2,@er0		; playing it safe for now
-	adds	#2,er0
-	cmp.l	er1,er0
-	blo	.Loop
+	mov.l	#_end,er2
+	sub.w   r1,r1
+	sub.l	er0,er2
+	jsr	@_memset
 #ifdef __ELF__
 	mov.l   #__fini,er0
 	jsr     @_atexit
@@ -77,12 +73,10 @@ _stack:	.long 	1
 _start:
 	mov.l	#_stack,sp
 	mov.l	#_edata,er0
-	mov.l	#_end,er1
-	sub.w   r2,r2           ; not sure about alignment requirements
-.Loop:	mov.w	r2,@er0		; playing it safe for now
-	adds	#2,er0
-	cmp.l	er1,er0
-	blo	.Loop
+	mov.l	#_end,er2
+	sub.w   r1,r1
+	sub.l	er0,er2
+	jsr	@_memset
 #ifdef __ELF__
 	mov.l   #__fini,er0
 	jsr     @_atexit

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Minor improvement to H8 startup code
  2023-12-30  3:56 Minor improvement to H8 startup code Jeff Law
@ 2023-12-30 21:46 ` Jeff Johnston
  2023-12-31 17:03   ` Jeff Law
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Johnston @ 2023-12-30 21:46 UTC (permalink / raw)
  To: Jeff Law; +Cc: newlib

[-- Attachment #1: Type: text/plain, Size: 951 bytes --]

Ok.  Can we call this one the last for snapshot?  I would like to do the
snapshot before Jan 1st.

-- Jeff J.

On Fri, Dec 29, 2023 at 10:57 PM Jeff Law <jeffreyalaw@gmail.com> wrote:

> Basically the startup code needs to clear memory from _edata to _end.
> In the past it's been done with a fairly naive copy loop.  This changes
> the code to just call memset and let memset figure out a sensible way to
> handle the operation given the size and alignment requirements.
>
> I don't have performance data on this.  I cobbled it together some time
> ago in response to seeing some of the GCC tests with larger .bss
> sections taking an insane amount of time to just get from _start to
> main.  With the fixes to the H8 decoder in the simulator it may not
> matter nearly as much anymore.
>
> This has been in my tester for months.  Naturally it does not cause any
> regressions in the H8 port.
>
> OK for the trunk?
>
> Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Minor improvement to H8 startup code
  2023-12-30 21:46 ` Jeff Johnston
@ 2023-12-31 17:03   ` Jeff Law
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Law @ 2023-12-31 17:03 UTC (permalink / raw)
  To: Jeff Johnston; +Cc: newlib



On 12/30/23 14:46, Jeff Johnston wrote:
> Ok.  Can we call this one the last for snapshot?  I would like to do the 
> snapshot before Jan 1st.
Sure.  I've only got one more target dependent change I'm carrying for 
libgloss c99/gcc-14.  There's still some generic newlib stuff for 
c99/gcc-14, but I think we can trickle those in after the snapshot. 
The fixes should only affect building with the unreleased gcc-14.

Jeff

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-12-31 17:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-30  3:56 Minor improvement to H8 startup code Jeff Law
2023-12-30 21:46 ` Jeff Johnston
2023-12-31 17:03   ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).