This is the mail archive of the newlib@sources.redhat.com mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

h8sx support added to h8300 port


This patch adds support for H8SX to the h8300 port, matching the
just-contributed changes to GCC.  Ok to install?

Index: newlib/ChangeLog
from  Alexandre Oliva  <aoliva@redhat.com>

	2003-07-02  Richard Sandiford  <rsandifo@redhat.com>
	* libc/machine/h8300/Makefile.am (lib_a_SOURCES): Add h8sx_strcpy.S.
	* libc/machine/h8300/defines.h (LEN): New macro.
	* libc/machine/h8300/memcpy.S: Add h8sx version.
	* libc/machine/h8300/memset.S: Likewise.
	* libc/machine/h8300/strcmp.S: Likewise.
	* libc/machine/h8300/setjmp.S: Use h8sx move instructions.
	* libc/machine/h8300/h8sx_strcpy.S: New file.
	2003-06-30  Richard Sandiford  <rsandifo@redhat.com>
	* libc/include/machine/ieeefp.h: Extend __H8300S__ handling to
	__H8300SX__.
	* libc/include/machine/setjmp.h: Likewise.
	* libc/include/sys/config.h: Likewise.
	* libc/machine/h8300/defines.h: Likewise.
	* libc/machine/h8300/setjmp.S: Likewise.
	* libc/machine/h8300/strcmp.S: Likewise.
	* libc/sys/h8300hms/close.S: Likewise.
	* libc/sys/h8300hms/fstat.S: Likewise.
	* libc/sys/h8300hms/lseek.S: Likewise.
	* libc/sys/h8300hms/read.S: Likewise.
	* libc/sys/h8300hms/write.S: Likewise.
	* libc/sys/h8300hms/crt0.S: Likewise.
	* libc/machine/h8300/setarch.h: Use .h8300sx or .h8300sxn if
	__H8300SX__ is defined.
	* libc/sys/h8300hms/setarch.h: Likewise.

Index: newlib/libc/include/machine/ieeefp.h
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/include/machine/ieeefp.h,v
retrieving revision 1.21
diff -u -p -r1.21 ieeefp.h
--- newlib/libc/include/machine/ieeefp.h 5 Feb 2004 20:21:03 -0000 1.21
+++ newlib/libc/include/machine/ieeefp.h 21 Jun 2004 10:43:00 -0000
@@ -92,7 +92,7 @@
 #endif
 #endif
 
-#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__)
+#if defined (__H8300__) || defined (__H8300H__) || defined (__H8300S__) || defined (__H8500__) || defined (__H8300SX__)
 #define __IEEE_BIG_ENDIAN
 #define _FLOAT_ARG float
 #define _DOUBLE_IS_32BITS
Index: newlib/libc/include/machine/setjmp.h
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/include/machine/setjmp.h,v
retrieving revision 1.18
diff -u -p -r1.18 setjmp.h
--- newlib/libc/include/machine/setjmp.h 8 Apr 2004 18:42:46 -0000 1.18
+++ newlib/libc/include/machine/setjmp.h 21 Jun 2004 10:43:01 -0000
@@ -95,7 +95,7 @@ typedef int jmp_buf[_JBLEN];
 #define _JBTYPE long
 #endif
 
-#ifdef __H8300S__
+#if defined (__H8300S__) || defined (__H8300SX__)
 /* same as H8/300 but registers are twice as big */
 #define _JBLEN 5
 #define _JBTYPE long
Index: newlib/libc/include/sys/config.h
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/include/sys/config.h,v
retrieving revision 1.39
diff -u -p -r1.39 config.h
--- newlib/libc/include/sys/config.h 13 May 2003 09:46:48 -0000 1.39
+++ newlib/libc/include/sys/config.h 21 Jun 2004 10:43:01 -0000
@@ -20,7 +20,7 @@
 #define UINT_MAX 65535
 #endif
 
-#if defined (__H8300__) || defined (__H8300H__) || defined(__H8300S__)
+#if defined (__H8300__) || defined (__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
 #define __SMALL_BITFIELDS
 #define H8300 1
 #undef INT_MAX
Index: newlib/libc/machine/h8300/Makefile.am
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/Makefile.am,v
retrieving revision 1.2
diff -u -p -r1.2 Makefile.am
--- newlib/libc/machine/h8300/Makefile.am 31 Mar 2004 01:27:53 -0000 1.2
+++ newlib/libc/machine/h8300/Makefile.am 21 Jun 2004 10:43:01 -0000
@@ -7,7 +7,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
 noinst_LIBRARIES = lib.a
 
 lib_a_SOURCES = reg_memcpy.S reg_memset.S strcmp.S memcpy.S memset.S \
-	setjmp.S
+	setjmp.S h8sx_strcpy.S
 lib_a_LIBADD = 
 lib_a_DEPENDENCIES = 
 
Index: newlib/libc/machine/h8300/Makefile.in
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/Makefile.in,v
retrieving revision 1.7
diff -u -p -r1.7 Makefile.in
--- newlib/libc/machine/h8300/Makefile.in 31 Mar 2004 01:27:53 -0000 1.7
+++ newlib/libc/machine/h8300/Makefile.in 21 Jun 2004 10:43:01 -0000
@@ -89,7 +89,7 @@ INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
 
 noinst_LIBRARIES = lib.a
 
-lib_a_SOURCES = reg_memcpy.S reg_memset.S strcmp.S memcpy.S memset.S 	setjmp.S
+lib_a_SOURCES = reg_memcpy.S reg_memset.S strcmp.S memcpy.S memset.S 	setjmp.S h8sx_strcpy.S
 
 lib_a_LIBADD = 
 lib_a_DEPENDENCIES = 
@@ -106,7 +106,7 @@ DEFS = @DEFS@ -I. -I$(srcdir) 
 CPPFLAGS = @CPPFLAGS@
 LIBS = @LIBS@
 lib_a_OBJECTS =  reg_memcpy.o reg_memset.o strcmp.o memcpy.o memset.o \
-setjmp.o
+setjmp.o h8sx_strcpy.o
 CFLAGS = @CFLAGS@
 COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
 CCLD = $(CC)
Index: newlib/libc/machine/h8300/defines.h
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/defines.h,v
retrieving revision 1.2
diff -u -p -r1.2 defines.h
--- newlib/libc/machine/h8300/defines.h 20 Nov 2003 19:59:03 -0000 1.2
+++ newlib/libc/machine/h8300/defines.h 21 Jun 2004 10:43:01 -0000
@@ -88,7 +88,7 @@
 
 #endif /* __H8300H__ */
 
-#ifdef __H8300S__
+#if defined (__H8300S__) || defined (__H8300SX__)
 
 #ifdef __NORMAL_MODE__
 
@@ -129,4 +129,10 @@
 #define A2E	e2
 #define A3E	e3
 
+
+#ifdef __NORMAL_MODE__
+#define LEN(X) X
+#else
+#define LEN(X) e##X
+#endif
 #endif /* __H8300S__ */
Index: newlib/libc/machine/h8300/h8sx_strcpy.S
===================================================================
RCS file: newlib/libc/machine/h8300/h8sx_strcpy.S
diff -N newlib/libc/machine/h8300/h8sx_strcpy.S
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ newlib/libc/machine/h8300/h8sx_strcpy.S 21 Jun 2004 10:43:01 -0000
@@ -0,0 +1,14 @@
+; This file exists to provide a movsd implementation of strcpy().
+; Continue to use the generic version for targets other than h8sx.
+#ifdef __H8300SX__
+#include "setarch.h"
+
+	.global _strcpy
+_strcpy:
+	stm.l	er4-er6,@-er7
+	mov.l	er0,er6
+	mov.l	er1,er5
+1:	movsd	2f
+	bra	1b
+2:	rts/l	er4-er6
+#endif
Index: newlib/libc/machine/h8300/memcpy.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/memcpy.S,v
retrieving revision 1.4
diff -u -p -r1.4 memcpy.S
--- newlib/libc/machine/h8300/memcpy.S 20 Nov 2003 19:59:03 -0000 1.4
+++ newlib/libc/machine/h8300/memcpy.S 21 Jun 2004 10:43:01 -0000
@@ -2,6 +2,104 @@
 
 #include "defines.h"
 
+#ifdef __H8300SX__
+
+	.global _memcpy
+_memcpy:
+	stm.l	er4-er6,@-er7
+
+	; Set up source and destination pointers for movmd.
+	mov.l	er0,er6
+	mov.l	er1,er5
+
+	; See whether the copy is long enough to use the movmd.l code.
+	; Although the code can handle anything longer than 6 bytes,
+	; it can be more expensive than movmd.b for small moves.
+	; It's better to use a higher threshold to account for this.
+	;
+	; Note that the exact overhead of the movmd.l checks depends on
+	; the alignments of the length and pointers.  They are faster when
+	; er0 & 3 == er1 & 3 == er2 & 3, faster still when these values
+	; are 0.  This threshold is a compromise between the various cases.
+	cmp	#16,LEN(r2)
+	blo	simple
+
+	; movmd.l only works for even addresses.  If one of the addresses
+	; is odd and the other is not, fall back on a simple move.
+	bld	#0,r5l
+	bxor	#0,r6l
+	bcs	simple
+
+	; Make the addresses even.
+	bld	#0,r5l
+	bcc	word_aligned
+	mov.b	@er5+,@er6+
+	sub	#1,LEN(r2)
+
+word_aligned:
+	; See if copying one word would make the first operand longword
+	; aligned.  Although this is only really worthwhile if it aligns
+	; the second operand as well, it's no worse if doesn't, so it
+	; hardly seems worth the overhead of a "band" check.
+	bld	#1,r6l
+	bcc	fast_copy
+	mov.w	@er5+,@er6+
+	sub	#2,LEN(r2)
+
+fast_copy:
+	; Set (e)r4 to the number of longwords to copy.
+	mov	LEN(r2),LEN(r4)
+	shlr	#2,LEN(r4)
+
+#ifdef __NORMAL_MODE__
+	; 16-bit pointers and size_ts: one movmd.l is enough.  This code
+	; is never reached with r4 == 0.
+	movmd.l
+	and.w	#3,r2
+simple:
+	mov.w	r2,r4
+	beq	quit
+	movmd.b
+quit:
+	rts/l	er4-er6
+#else
+	; Skip the first iteration if the number of longwords is divisible
+	; by 0x10000.
+	mov.w	r4,r4
+	beq	fast_loop_next
+
+	; This loop copies r4 (!= 0) longwords the first time round and 65536
+	; longwords on each iteration after that.
+fast_loop:
+	movmd.l
+fast_loop_next:
+	sub.w	#1,e4
+	bhs	fast_loop
+
+	; Mop up any left-over bytes.  We could just fall through to the
+	; simple code after the "and" but the version below is quicker
+	; and only takes 10 more bytes.
+	and.w	#3,r2
+	beq	quit
+	mov.w	r2,r4
+	movmd.b
+quit:
+	rts/l	er4-er6
+
+simple:
+	; Simple bytewise copy.  We need to handle all lengths, including zero.
+	mov.w	r2,r4
+	beq	simple_loop_next
+simple_loop:
+	movmd.b
+simple_loop_next:
+	sub.w	#1,e2
+	bhs	simple_loop
+	rts/l	er4-er6
+#endif
+
+#else
+
 	.global _memcpy
 _memcpy:
 ;	MOVP	@(2/4,r7),A0P	; dst
@@ -48,3 +146,4 @@ byteloop:
 	; return with A0 pointing to dst
 quit:	rts
 
+#endif
Index: newlib/libc/machine/h8300/memset.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/memset.S,v
retrieving revision 1.3
diff -u -p -r1.3 memset.S
--- newlib/libc/machine/h8300/memset.S 24 Jun 2003 19:43:58 -0000 1.3
+++ newlib/libc/machine/h8300/memset.S 21 Jun 2004 10:43:01 -0000
@@ -2,6 +2,63 @@
 
 #include "defines.h"
 
+#if defined (__H8300SX__)
+
+	.global	_memset
+_memset:
+	; Use er3 is a temporary since er0 must remain unchanged on exit.
+	mov.l	er0,er3
+
+	; Fill er1 with the byte to copy.
+	mov.b	r1l,r1h
+	mov.w	r1,e1
+
+	; Account for any excess bytes and words that will be copied after
+	; the main loop.  r2 >= 0 if there is a longword to copy.
+	sub	#4,LEN(r2)
+	blo	longs_done
+
+	; Copy one byte if doing so will make er3 word-aligned.
+	; This isn't needed for correctness but it makes the main loop
+	; slightly faster.
+	bld	#0,r3l
+	bcc	word_aligned
+	mov.b	r1l,@er3+
+	sub	#1,LEN(r2)
+	blo	longs_done
+
+word_aligned:
+	; Likewise one word for longword alignment.
+	bld	#1,r3l
+	bcc	long_copy
+	mov.w	r1,@er3+
+	sub	#2,LEN(r2)
+	blo	longs_done
+
+long_copy:
+	; Copy longwords.
+	mov.l	er1,@er3+
+	sub	#4,LEN(r2)
+	bhs	long_copy
+
+longs_done:
+	; At this point, we need to copy r2 & 3 bytes.  Copy a word
+	; if necessary.
+	bld	#1,r2l
+	bcc	words_done
+	mov.w	r1,@er3+
+
+words_done:
+	; Copy a byte.
+	bld	#0,r2l
+	bcc	bytes_done
+	mov.b	r1l,@er3+
+
+bytes_done:
+	rts
+
+#else
+
 ; A0P pointer to cursor
 ; A1P thing to copy
 	.global	_memset
@@ -42,3 +99,4 @@ byteloop:
 	bne	byteloop
 	rts
 
+#endif
Index: newlib/libc/machine/h8300/setarch.h
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/setarch.h,v
retrieving revision 1.1
diff -u -p -r1.1 setarch.h
--- newlib/libc/machine/h8300/setarch.h 24 Jun 2003 19:43:58 -0000 1.1
+++ newlib/libc/machine/h8300/setarch.h 21 Jun 2004 10:43:01 -0000
@@ -12,3 +12,10 @@
 	.h8300s
 #endif
 #endif
+#ifdef __H8300SX__
+#ifdef __NORMAL_MODE__
+	.h8300sxn
+#else
+	.h8300sx
+#endif
+#endif
Index: newlib/libc/machine/h8300/setjmp.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/setjmp.S,v
retrieving revision 1.4
diff -u -p -r1.4 setjmp.S
--- newlib/libc/machine/h8300/setjmp.S 24 Jun 2003 19:43:58 -0000 1.4
+++ newlib/libc/machine/h8300/setjmp.S 21 Jun 2004 10:43:01 -0000
@@ -6,7 +6,14 @@
 	.align	2
 	.global	_setjmp
 _setjmp:
-#if defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300SX__)
+	mov.l	er7,@er0+
+	mov.l	er6,@er0+
+	mov.l	er5,@er0+
+	mov.l	er4,@er0+
+	mov.l	@sp,@er0
+	sub.l   er0,er0
+#elif defined(__H8300H__) || defined(__H8300S__)
 	mov.l	er7,@er0
 	mov.l	er6,@(4,er0)
 	mov.l	er5,@(8,er0)
@@ -27,13 +34,17 @@ _setjmp:
 
 	.global	_longjmp
 _longjmp:
-#if defined(__H8300H__) || defined (__H8300S__)
+#if defined(__H8300H__) || defined (__H8300S__) || defined (__H8300SX__)
 	mov.l	@er0+,er7
 	mov.l	@er0+,er6
 	mov.l	@er0+,er5
 	mov.l	@er0+,er4
+#if defined(__H8300SX__)
+	mov.l	@er0,@sp
+#else
 	mov.l	@er0,er2
 	mov.l	er2,@sp
+#endif
 #if (__INT_MAX__ <= 32767)
 	mov.w	r1,r0
 #else
Index: newlib/libc/machine/h8300/strcmp.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/machine/h8300/strcmp.S,v
retrieving revision 1.4
diff -u -p -r1.4 strcmp.S
--- newlib/libc/machine/h8300/strcmp.S 20 Nov 2003 19:59:03 -0000 1.4
+++ newlib/libc/machine/h8300/strcmp.S 21 Jun 2004 10:43:01 -0000
@@ -2,6 +2,22 @@
 
 #include "defines.h"
 
+#if defined (__H8300SX__)
+	.global _strcmp
+_strcmp:
+	mov.l	er0,er2
+loop:
+	mov.b	@er2+,r0l
+	beq	eos
+	sub.b	@er1+,r0l
+	beq	loop
+	exts.l	#2,er0
+	rts
+eos:
+	sub.b	@er1,r0l
+	exts.l	#2,er0
+	rts
+#else
 	.section .text
 	.align 2
 	.global _strcmp
@@ -41,3 +57,4 @@ _strcmp:
 #endif
 	rts
 	.end
+#endif
Index: newlib/libc/sys/h8300hms/close.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/close.S,v
retrieving revision 1.2
diff -u -p -r1.2 close.S
--- newlib/libc/sys/h8300hms/close.S 10 Jun 2003 07:44:30 -0000 1.2
+++ newlib/libc/sys/h8300hms/close.S 21 Jun 2004 10:43:03 -0000
@@ -7,7 +7,7 @@
 	.align 2
 	.global __close
 __close:
-#if defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
 #if __INT_MAX__ == 32767
 	extu.l er0
 #endif
Index: newlib/libc/sys/h8300hms/crt0.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/crt0.S,v
retrieving revision 1.9
diff -u -p -r1.9 crt0.S
--- newlib/libc/sys/h8300hms/crt0.S 24 Jun 2003 18:13:35 -0000 1.9
+++ newlib/libc/sys/h8300hms/crt0.S 21 Jun 2004 10:43:03 -0000
@@ -70,7 +70,7 @@ _stack:	.long 	1
 
 #endif
 
-#ifdef __H8300S__
+#if defined (__H8300S__) || defined (__H8300SX__)
 
 	.section .text
 	.global	_start
Index: newlib/libc/sys/h8300hms/fstat.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/fstat.S,v
retrieving revision 1.2
diff -u -p -r1.2 fstat.S
--- newlib/libc/sys/h8300hms/fstat.S 10 Jun 2003 07:44:30 -0000 1.2
+++ newlib/libc/sys/h8300hms/fstat.S 21 Jun 2004 10:43:03 -0000
@@ -7,7 +7,7 @@
 	.align 2
 	.global __fstat
 __fstat:
-#if defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
 #if __INT_MAX__ == 32767
 	extu.l	er0
 #endif
Index: newlib/libc/sys/h8300hms/lseek.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/lseek.S,v
retrieving revision 1.2
diff -u -p -r1.2 lseek.S
--- newlib/libc/sys/h8300hms/lseek.S 10 Jun 2003 07:44:30 -0000 1.2
+++ newlib/libc/sys/h8300hms/lseek.S 21 Jun 2004 10:43:03 -0000
@@ -7,7 +7,7 @@
 	.align 2
 	.global __lseek
 __lseek:
-#if defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
 #if __INT_MAX__ == 32767
 	extu.l er0
 	extu.l er2
Index: newlib/libc/sys/h8300hms/read.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/read.S,v
retrieving revision 1.2
diff -u -p -r1.2 read.S
--- newlib/libc/sys/h8300hms/read.S 10 Jun 2003 07:44:30 -0000 1.2
+++ newlib/libc/sys/h8300hms/read.S 21 Jun 2004 10:43:03 -0000
@@ -7,7 +7,7 @@
 	.align 2
 	.global __read
 __read:
-#if defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
 #if __INT_MAX__ == 32767
 	extu.l  er0
 #endif
Index: newlib/libc/sys/h8300hms/setarch.h
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/setarch.h,v
retrieving revision 1.1
diff -u -p -r1.1 setarch.h
--- newlib/libc/sys/h8300hms/setarch.h 10 Jun 2003 07:44:30 -0000 1.1
+++ newlib/libc/sys/h8300hms/setarch.h 21 Jun 2004 10:43:03 -0000
@@ -12,3 +12,10 @@
 	.h8300s
 #endif
 #endif
+#ifdef __H8300SX__
+#ifdef __NORMAL_MODE__
+	.h8300sxn
+#else
+	.h8300sx
+#endif
+#endif
Index: newlib/libc/sys/h8300hms/write.S
===================================================================
RCS file: /cvs/uberbaum/./newlib/libc/sys/h8300hms/write.S,v
retrieving revision 1.2
diff -u -p -r1.2 write.S
--- newlib/libc/sys/h8300hms/write.S 10 Jun 2003 07:44:30 -0000 1.2
+++ newlib/libc/sys/h8300hms/write.S 21 Jun 2004 10:43:03 -0000
@@ -7,7 +7,7 @@
 	.align 2
 	.global __write
 __write:
-#if defined(__H8300H__) || defined(__H8300S__)
+#if defined(__H8300H__) || defined(__H8300S__) || defined (__H8300SX__)
 #if __INT_MAX__ == 32767
 	extu.l	er0
 #endif

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]