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]

libc/machine/sh/strlen.S added


Tested for sh64-elf and sh-elf.
-- 
--------------------------
SuperH
2430 Aztec West / Almondsbury / BRISTOL / BS32 4AQ
T:+44 1454 462330
Mon Jun 24 21:17:02 2002  J"orn Rennecke <joern.rennecke@superh.com>

	* libc/machine/sh/strcpy.S: New file.
	* libc/machine/sh/Makefile.am (lib_a_SOURCES): Add rule for it.
	* libc/machine/sh/Makefile.am: Regenerate.

Index: libc/machine/sh/Makefile.am
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/sh/Makefile.am,v
retrieving revision 1.3
diff -p -r1.3 Makefile.am
*** libc/machine/sh/Makefile.am	6 Mar 2002 10:43:18 -0000	1.3
--- libc/machine/sh/Makefile.am	24 Jun 2002 20:15:15 -0000
*************** INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLA
*** 7,15 ****
  noinst_LIBRARIES = lib.a
  
  if SH64
! lib_a_SOURCES = memcpy.S memset.S setjmp.S strcpy.S
  else
! lib_a_SOURCES = memcpy.S memset.S setjmp.S strcpy.S strcmp.S
  endif
  
  memcpy.o: asm.h
--- 7,15 ----
  noinst_LIBRARIES = lib.a
  
  if SH64
! lib_a_SOURCES = memcpy.S memset.S setjmp.S strcpy.S strlen.S
  else
! lib_a_SOURCES = memcpy.S memset.S setjmp.S strcpy.S strlen.S strcmp.S
  endif
  
  memcpy.o: asm.h
Index: libc/machine/sh/Makefile.in
===================================================================
RCS file: /cvs/src/src/newlib/libc/machine/sh/Makefile.in,v
retrieving revision 1.7
diff -p -r1.7 Makefile.in
*** libc/machine/sh/Makefile.in	7 Jun 2002 21:59:42 -0000	1.7
--- libc/machine/sh/Makefile.in	24 Jun 2002 20:15:15 -0000
***************
*** 1,6 ****
! # Makefile.in generated automatically by automake 1.4 from Makefile.am
  
! # Copyright (C) 1994, 1995-8, 1999 Free Software Foundation, Inc.
  # This Makefile.in is free software; the Free Software Foundation
  # gives unlimited permission to copy and/or distribute it,
  # with or without modifications, as long as this notice is preserved.
--- 1,6 ----
! # Makefile.in generated automatically by automake 1.4-p5 from Makefile.am
  
! # Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
  # This Makefile.in is free software; the Free Software Foundation
  # gives unlimited permission to copy and/or distribute it,
  # with or without modifications, as long as this notice is preserved.
*************** AUTOMAKE_OPTIONS = cygnus
*** 88,95 ****
  INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
  
  noinst_LIBRARIES = lib.a
! @SH64_TRUE@lib_a_SOURCES = @SH64_TRUE@memcpy.S memset.S setjmp.S strcpy.S
! @SH64_FALSE@lib_a_SOURCES = @SH64_FALSE@memcpy.S memset.S setjmp.S strcpy.S strcmp.S
  
  ACLOCAL_AMFLAGS = -I ../../..
  CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
--- 88,95 ----
  INCLUDES = $(NEWLIB_CFLAGS) $(CROSS_CFLAGS) $(TARGET_CFLAGS)
  
  noinst_LIBRARIES = lib.a
! @SH64_TRUE@lib_a_SOURCES = @SH64_TRUE@memcpy.S memset.S setjmp.S strcpy.S strlen.S
! @SH64_FALSE@lib_a_SOURCES = @SH64_FALSE@memcpy.S memset.S setjmp.S strcpy.S strlen.S strcmp.S
  
  ACLOCAL_AMFLAGS = -I ../../..
  CONFIG_STATUS_DEPENDENCIES = $(newlib_basedir)/configure.host
*************** DEFS = @DEFS@ -I. -I$(srcdir) 
*** 103,111 ****
  CPPFLAGS = @CPPFLAGS@
  LIBS = @LIBS@
  lib_a_LIBADD = 
! @SH64_TRUE@lib_a_OBJECTS =  memcpy.o memset.o setjmp.o strcpy.o
  @SH64_FALSE@lib_a_OBJECTS =  memcpy.o memset.o setjmp.o strcpy.o \
! @SH64_FALSE@strcmp.o
  CFLAGS = @CFLAGS@
  COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  CCLD = $(CC)
--- 103,111 ----
  CPPFLAGS = @CPPFLAGS@
  LIBS = @LIBS@
  lib_a_LIBADD = 
! @SH64_TRUE@lib_a_OBJECTS =  memcpy.o memset.o setjmp.o strcpy.o strlen.o
  @SH64_FALSE@lib_a_OBJECTS =  memcpy.o memset.o setjmp.o strcpy.o \
! @SH64_FALSE@strlen.o strcmp.o
  CFLAGS = @CFLAGS@
  COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
  CCLD = $(CC)
*** /dev/null	Thu Aug 30 21:30:55 2001
--- libc/machine/sh/strlen.S	Mon Jun 24 11:42:52 2002
***************
*** 0 ****
--- 1,87 ----
+ ! Entry: arg0: string start address
+ ! Exit:  result: length
+ !
+ ! Copyright 2002 SuperH Ltd.
+ 
+ #include "asm.h"
+ 
+ ENTRY(strlen)
+ 
+ #if __SHMEDIA__
+ 
+ 	ldlo.q r2,0,r3
+ 	ptabs/l r18,tr0
+ 	pta/l loop,tr1
+ 	andi r2,-8,r0
+ 	shlli r2,3,r1
+ 	mcmpeq.b r3,r63,r3
+ 	SHHI r3,r1,r4
+ 	beqi/u r4,0,tr1 // loop
+ #ifdef __LITTLE_ENDIAN__
+ 	movi -1,r2
+ 	addi r3,-1,r4
+ 	msad.ubq r3,r4,r2
+ #else
+ 	shlri r3,1,r3
+ 	nsb r3,r3
+ 	shlri r3,3,r2
+ #endif
+ 	blink tr0,r63
+ 
+ loop:
+ 	ldlo.q r0,8,r3
+ 	addi r0,8,r0
+ 	ldlo.q r0,8,r63
+ 	mcmpeq.b r3,r63,r3
+ 	beqi/l r3,0,tr1 // loop
+ 	sub r0,r2,r2
+ #ifdef __LITTLE_ENDIAN__
+ 	addi r3,-1,r4
+ 	addi r2,-1,r2
+ 	msad.ubq r3,r4,r2
+ #else
+ 	shlri r3,1,r3
+ 	nsb r3,r3
+ 	shlri r3,3,r3
+ 	add r2,r3,r2
+ #endif
+ 	blink tr0,r63
+ 
+ #else /* ! __SHMEDIA__, i.e. SH 1..4 / SHcompact */
+ 
+ #ifdef __SH5__
+ #define STR_INIT r2
+ #define STR_ORIG r0
+ #define STR_COPY STR_ORIG
+ #define MASK r1
+ #define TMP r3
+ #define RESULT r2
+ !        r0,r1,r3: clobbered
+ #else
+ #define STR_INIT r4
+ #define STR_ORIG STR_INIT
+ #define STR_COPY STR
+ #define MASK r1
+ #define TMP r3
+ #define RESULT r0
+ !        r1,r3: clobbered
+ #endif
+ #define STR RESULT
+ 
+ 	mov #3,MASK
+ 	and STR_INIT,MASK
+ 	tst MASK,MASK
+ 	SL(bf, L_char_loop, mov STR_INIT, STR_COPY)
+ L_word_loop:
+ 	mov.l @STR+,TMP
+ 	cmp/str MASK,TMP
+ 	bf L_word_loop
+ 	add #-4,STR
+ L_char_loop:
+ 	mov.b @STR+,TMP
+ 	tst TMP,TMP
+ 	bf L_char_loop
+ 	add #-1,STR
+ 	rts
+ 	sub STR_ORIG,STR
+ #endif /* ! __SHMEDIA__ */

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