2015-02-26 Steve Ellcey <sellcey@imgtec.com>

* libc/machine/mips/memcpy.S: Fix macro indentation and typos in
	comments.
This commit is contained in:
Steve Ellcey 2015-02-26 23:36:56 +00:00
parent 0fb41ffa65
commit d2f9dbb3ee
2 changed files with 113 additions and 108 deletions

View File

@ -1,3 +1,8 @@
2015-02-26 Steve Ellcey <sellcey@imgtec.com>
* libc/machine/mips/memcpy.S: Fix macro indentation and typos in
comments.
2015-02-24 Jon TURNEY <jon.turney@dronecode.org.uk> 2015-02-24 Jon TURNEY <jon.turney@dronecode.org.uk>
* libc/include/sys/cdefs.h (_GNU_SOURCE): Move check so it has an * libc/include/sys/cdefs.h (_GNU_SOURCE): Move check so it has an

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2012 * Copyright (c) 2012-2015
* MIPS Technologies, Inc., California. * MIPS Technologies, Inc., California.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -28,25 +28,25 @@
*/ */
#ifdef ANDROID_CHANGES #ifdef ANDROID_CHANGES
#include "machine/asm.h" # include "machine/asm.h"
#include "machine/regdef.h" # include "machine/regdef.h"
#define USE_MEMMOVE_FOR_OVERLAP # define USE_MEMMOVE_FOR_OVERLAP
#define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED
#define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
#elif _LIBC #elif _LIBC
#include <sysdep.h> # include <sysdep.h>
#include <regdef.h> # include <regdef.h>
#include <sys/asm.h> # include <sys/asm.h>
#define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED
#define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
#elif _COMPILING_NEWLIB #elif _COMPILING_NEWLIB
#include "machine/asm.h" # include "machine/asm.h"
#include "machine/regdef.h" # include "machine/regdef.h"
#define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD_STREAMED
#define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE # define PREFETCH_STORE_HINT PREFETCH_HINT_PREPAREFORSTORE
#else #else
#include <regdef.h> # include <regdef.h>
#include <sys/asm.h> # include <sys/asm.h>
#endif #endif
/* Check to see if the MIPS architecture we are compiling for supports /* Check to see if the MIPS architecture we are compiling for supports
@ -54,44 +54,44 @@
*/ */
#if (__mips == 4) || (__mips == 5) || (__mips == 32) || (__mips == 64) #if (__mips == 4) || (__mips == 5) || (__mips == 32) || (__mips == 64)
#ifndef DISABLE_PREFETCH # ifndef DISABLE_PREFETCH
#define USE_PREFETCH # define USE_PREFETCH
#endif # endif
#endif #endif
#if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32)) #if defined(_MIPS_SIM) && ((_MIPS_SIM == _ABI64) || (_MIPS_SIM == _ABIN32))
#ifndef DISABLE_DOUBLE # ifndef DISABLE_DOUBLE
#define USE_DOUBLE # define USE_DOUBLE
#endif # endif
#endif #endif
/* Some asm.h files do not have the L macro definition. */ /* Some asm.h files do not have the L macro definition. */
#ifndef L #ifndef L
#if _MIPS_SIM == _ABIO32 # if _MIPS_SIM == _ABIO32
# define L(label) $L ## label # define L(label) $L ## label
#else # else
# define L(label) .L ## label # define L(label) .L ## label
#endif # endif
#endif #endif
/* Some asm.h files do not have the PTR_ADDIU macro definition. */ /* Some asm.h files do not have the PTR_ADDIU macro definition. */
#ifndef PTR_ADDIU #ifndef PTR_ADDIU
#ifdef USE_DOUBLE # ifdef USE_DOUBLE
#define PTR_ADDIU daddiu # define PTR_ADDIU daddiu
#else # else
#define PTR_ADDIU addiu # define PTR_ADDIU addiu
#endif # endif
#endif #endif
/* Some asm.h files do not have the PTR_SRA macro definition. */ /* Some asm.h files do not have the PTR_SRA macro definition. */
#ifndef PTR_SRA #ifndef PTR_SRA
#ifdef USE_DOUBLE # ifdef USE_DOUBLE
#define PTR_SRA dsra # define PTR_SRA dsra
#else # else
#define PTR_SRA sra # define PTR_SRA sra
#endif # endif
#endif #endif
@ -141,12 +141,12 @@
* If we have not picked out what hints to use at this point use the * If we have not picked out what hints to use at this point use the
* standard load and store prefetch hints. * standard load and store prefetch hints.
*/ */
#ifndef PREFETCH_STORE_HINT # ifndef PREFETCH_STORE_HINT
# define PREFETCH_STORE_HINT PREFETCH_HINT_STORE # define PREFETCH_STORE_HINT PREFETCH_HINT_STORE
#endif # endif
#ifndef PREFETCH_LOAD_HINT # ifndef PREFETCH_LOAD_HINT
# define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD # define PREFETCH_LOAD_HINT PREFETCH_HINT_LOAD
#endif # endif
/* /*
* We double everything when USE_DOUBLE is true so we do 2 prefetches to * We double everything when USE_DOUBLE is true so we do 2 prefetches to
@ -154,43 +154,43 @@
* prefetch brings in 32 bytes. * prefetch brings in 32 bytes.
*/ */
#ifdef USE_DOUBLE # ifdef USE_DOUBLE
# define PREFETCH_CHUNK 64 # define PREFETCH_CHUNK 64
# define PREFETCH_FOR_LOAD(chunk, reg) \ # define PREFETCH_FOR_LOAD(chunk, reg) \
pref PREFETCH_LOAD_HINT, (chunk)*64(reg); \ pref PREFETCH_LOAD_HINT, (chunk)*64(reg); \
pref PREFETCH_LOAD_HINT, ((chunk)*64)+32(reg) pref PREFETCH_LOAD_HINT, ((chunk)*64)+32(reg)
# define PREFETCH_FOR_STORE(chunk, reg) \ # define PREFETCH_FOR_STORE(chunk, reg) \
pref PREFETCH_STORE_HINT, (chunk)*64(reg); \ pref PREFETCH_STORE_HINT, (chunk)*64(reg); \
pref PREFETCH_STORE_HINT, ((chunk)*64)+32(reg) pref PREFETCH_STORE_HINT, ((chunk)*64)+32(reg)
#else # else
# define PREFETCH_CHUNK 32 # define PREFETCH_CHUNK 32
# define PREFETCH_FOR_LOAD(chunk, reg) \ # define PREFETCH_FOR_LOAD(chunk, reg) \
pref PREFETCH_LOAD_HINT, (chunk)*32(reg) pref PREFETCH_LOAD_HINT, (chunk)*32(reg)
# define PREFETCH_FOR_STORE(chunk, reg) \ # define PREFETCH_FOR_STORE(chunk, reg) \
pref PREFETCH_STORE_HINT, (chunk)*32(reg) pref PREFETCH_STORE_HINT, (chunk)*32(reg)
#endif # endif
/* MAX_PREFETCH_SIZE is the maximum size of a prefetch, it must not be less /* MAX_PREFETCH_SIZE is the maximum size of a prefetch, it must not be less
* then PREFETCH_CHUNK, the assumed size of each prefetch. If the real size * than PREFETCH_CHUNK, the assumed size of each prefetch. If the real size
* of a prefetch is greater then MAX_PREFETCH_SIZE and the PREPAREFORSTORE * of a prefetch is greater than MAX_PREFETCH_SIZE and the PREPAREFORSTORE
* hint is used, the code will not work corrrectly. If PREPAREFORSTORE is not * hint is used, the code will not work correctly. If PREPAREFORSTORE is not
* used then MAX_PREFETCH_SIZE does not matter. */ * used then MAX_PREFETCH_SIZE does not matter. */
#define MAX_PREFETCH_SIZE 128 # define MAX_PREFETCH_SIZE 128
/* PREFETCH_LIMIT is set based on the fact that we neve use an offset greater /* PREFETCH_LIMIT is set based on the fact that we never use an offset greater
* then 5 on a STORE prefetch and that a single prefetch can never be larger * than 5 on a STORE prefetch and that a single prefetch can never be larger
* then MAX_PREFETCH_SIZE. We add the extra 32 when USE_DOUBLE is set because * than MAX_PREFETCH_SIZE. We add the extra 32 when USE_DOUBLE is set because
* we actually do two prefetches in that case, one 32 bytes after the other. */ * we actually do two prefetches in that case, one 32 bytes after the other. */
#ifdef USE_DOUBLE # ifdef USE_DOUBLE
# define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + 32 + MAX_PREFETCH_SIZE # define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + 32 + MAX_PREFETCH_SIZE
#else # else
# define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + MAX_PREFETCH_SIZE # define PREFETCH_LIMIT (5 * PREFETCH_CHUNK) + MAX_PREFETCH_SIZE
#endif # endif
#if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) \ # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) \
&& ((PREFETCH_CHUNK * 4) < MAX_PREFETCH_SIZE) && ((PREFETCH_CHUNK * 4) < MAX_PREFETCH_SIZE)
/* We cannot handle this because the initial prefetches may fetch bytes that /* We cannot handle this because the initial prefetches may fetch bytes that
* are before the buffer being copied. We start copies with an offset * are before the buffer being copied. We start copies with an offset
* of 4 so avoid this situation when using PREPAREFORSTORE. */ * of 4 so avoid this situation when using PREPAREFORSTORE. */
#error "PREFETCH_CHUNK is too large and/or MAX_PREFETCH_SIZE is too small." #error "PREFETCH_CHUNK is too large and/or MAX_PREFETCH_SIZE is too small."
#endif # endif
#else /* USE_PREFETCH not defined */ #else /* USE_PREFETCH not defined */
# define PREFETCH_FOR_LOAD(offset, reg) # define PREFETCH_FOR_LOAD(offset, reg)
# define PREFETCH_FOR_STORE(offset, reg) # define PREFETCH_FOR_STORE(offset, reg)
@ -198,7 +198,7 @@
/* Allow the routine to be named something else if desired. */ /* Allow the routine to be named something else if desired. */
#ifndef MEMCPY_NAME #ifndef MEMCPY_NAME
#define MEMCPY_NAME memcpy # define MEMCPY_NAME memcpy
#endif #endif
/* We use these 32/64 bit registers as temporaries to do the copying. */ /* We use these 32/64 bit registers as temporaries to do the copying. */
@ -207,15 +207,15 @@
#define REG2 t2 #define REG2 t2
#define REG3 t3 #define REG3 t3
#if defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64) #if defined(_MIPS_SIM) && (_MIPS_SIM == _ABIO32 || _MIPS_SIM == _ABIO64)
# define REG4 t4 # define REG4 t4
# define REG5 t5 # define REG5 t5
# define REG6 t6 # define REG6 t6
# define REG7 t7 # define REG7 t7
#else #else
# define REG4 ta0 # define REG4 ta0
# define REG5 ta1 # define REG5 ta1
# define REG6 ta2 # define REG6 ta2
# define REG7 ta3 # define REG7 ta3
#endif #endif
/* We load/store 64 bits at a time when USE_DOUBLE is true. /* We load/store 64 bits at a time when USE_DOUBLE is true.
@ -223,44 +223,44 @@
* conflicts with system header files. */ * conflicts with system header files. */
#ifdef USE_DOUBLE #ifdef USE_DOUBLE
# define C_ST sd # define C_ST sd
# define C_LD ld # define C_LD ld
#if __MIPSEB # if __MIPSEB
# define C_LDHI ldl /* high part is left in big-endian */ # define C_LDHI ldl /* high part is left in big-endian */
# define C_STHI sdl /* high part is left in big-endian */ # define C_STHI sdl /* high part is left in big-endian */
# define C_LDLO ldr /* low part is right in big-endian */ # define C_LDLO ldr /* low part is right in big-endian */
# define C_STLO sdr /* low part is right in big-endian */ # define C_STLO sdr /* low part is right in big-endian */
#else # else
# define C_LDHI ldr /* high part is right in little-endian */ # define C_LDHI ldr /* high part is right in little-endian */
# define C_STHI sdr /* high part is right in little-endian */ # define C_STHI sdr /* high part is right in little-endian */
# define C_LDLO ldl /* low part is left in little-endian */ # define C_LDLO ldl /* low part is left in little-endian */
# define C_STLO sdl /* low part is left in little-endian */ # define C_STLO sdl /* low part is left in little-endian */
#endif # endif
#else #else
# define C_ST sw # define C_ST sw
# define C_LD lw # define C_LD lw
#if __MIPSEB # if __MIPSEB
# define C_LDHI lwl /* high part is left in big-endian */ # define C_LDHI lwl /* high part is left in big-endian */
# define C_STHI swl /* high part is left in big-endian */ # define C_STHI swl /* high part is left in big-endian */
# define C_LDLO lwr /* low part is right in big-endian */ # define C_LDLO lwr /* low part is right in big-endian */
# define C_STLO swr /* low part is right in big-endian */ # define C_STLO swr /* low part is right in big-endian */
#else # else
# define C_LDHI lwr /* high part is right in little-endian */ # define C_LDHI lwr /* high part is right in little-endian */
# define C_STHI swr /* high part is right in little-endian */ # define C_STHI swr /* high part is right in little-endian */
# define C_LDLO lwl /* low part is left in little-endian */ # define C_LDLO lwl /* low part is left in little-endian */
# define C_STLO swl /* low part is left in little-endian */ # define C_STLO swl /* low part is left in little-endian */
#endif # endif
#endif #endif
/* Bookkeeping values for 32 vs. 64 bit mode. */ /* Bookkeeping values for 32 vs. 64 bit mode. */
#ifdef USE_DOUBLE #ifdef USE_DOUBLE
# define NSIZE 8 # define NSIZE 8
# define NSIZEMASK 0x3f # define NSIZEMASK 0x3f
# define NSIZEDMASK 0x7f # define NSIZEDMASK 0x7f
#else #else
# define NSIZE 4 # define NSIZE 4
# define NSIZEMASK 0x1f # define NSIZEMASK 0x1f
# define NSIZEDMASK 0x3f # define NSIZEDMASK 0x3f
#endif #endif
#define UNIT(unit) ((unit)*NSIZE) #define UNIT(unit) ((unit)*NSIZE)
#define UNITM1(unit) (((unit)*NSIZE)-1) #define UNITM1(unit) (((unit)*NSIZE)-1)
@ -290,7 +290,7 @@ LEAF(MEMCPY_NAME)
L(memcpy): L(memcpy):
#endif #endif
/* /*
* If the size is less then 2*NSIZE (8 or 16), go to L(lastb). Regardless of * If the size is less than 2*NSIZE (8 or 16), go to L(lastb). Regardless of
* size, copy dst pointer to v0 for the return value. * size, copy dst pointer to v0 for the return value.
*/ */
slti t2,a2,(2 * NSIZE) slti t2,a2,(2 * NSIZE)
@ -354,22 +354,22 @@ L(aligned):
PREFETCH_FOR_STORE (3, a0) PREFETCH_FOR_STORE (3, a0)
#endif #endif
#if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH) #if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH)
#if PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE # if PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE
sltu v1,t9,a0 sltu v1,t9,a0
bgtz v1,L(skip_set) bgtz v1,L(skip_set)
nop nop
PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4)
L(skip_set): L(skip_set):
#else # else
PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1)
#endif # endif
#endif #endif
#if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH) \ #if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH) \
&& (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE) && (PREFETCH_STORE_HINT != PREFETCH_HINT_PREPAREFORSTORE)
PTR_ADDIU v0,a0,(PREFETCH_CHUNK*3) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*3)
#ifdef USE_DOUBLE # ifdef USE_DOUBLE
PTR_ADDIU v0,v0,32 PTR_ADDIU v0,v0,32
#endif # endif
#endif #endif
L(loop16w): L(loop16w):
C_LD t0,UNIT(0)(a1) C_LD t0,UNIT(0)(a1)
@ -382,9 +382,9 @@ L(loop16w):
PREFETCH_FOR_STORE (5, a0) PREFETCH_FOR_STORE (5, a0)
#if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH) #if defined(RETURN_LAST_PREFETCH) && defined(USE_PREFETCH)
PTR_ADDIU v0,a0,(PREFETCH_CHUNK*5) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*5)
#ifdef USE_DOUBLE # ifdef USE_DOUBLE
PTR_ADDIU v0,v0,32 PTR_ADDIU v0,v0,32
#endif # endif
#endif #endif
L(skip_pref): L(skip_pref):
C_LD REG2,UNIT(2)(a1) C_LD REG2,UNIT(2)(a1)
@ -458,7 +458,7 @@ L(chkw):
PTR_ADDIU a0,a0,UNIT(8) PTR_ADDIU a0,a0,UNIT(8)
/* /*
* Here we have less then 32(64) bytes to copy. Set up for a loop to * Here we have less than 32(64) bytes to copy. Set up for a loop to
* copy one word (or double word) at a time. Set a2 to count how many * copy one word (or double word) at a time. Set a2 to count how many
* bytes we have to copy after all the word (or double word) chunks are * bytes we have to copy after all the word (or double word) chunks are
* copied and a3 to the dst pointer after all the (d)word chunks have * copied and a3 to the dst pointer after all the (d)word chunks have
@ -538,15 +538,15 @@ L(ua_chk16w):
PREFETCH_FOR_STORE (3, a0) PREFETCH_FOR_STORE (3, a0)
#endif #endif
#if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH) #if defined(RETURN_FIRST_PREFETCH) && defined(USE_PREFETCH)
#if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE) # if (PREFETCH_STORE_HINT == PREFETCH_HINT_PREPAREFORSTORE)
sltu v1,t9,a0 sltu v1,t9,a0
bgtz v1,L(ua_skip_set) bgtz v1,L(ua_skip_set)
nop nop
PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*4)
L(ua_skip_set): L(ua_skip_set):
#else # else
PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1) PTR_ADDIU v0,a0,(PREFETCH_CHUNK*1)
#endif # endif
#endif #endif
L(ua_loop16w): L(ua_loop16w):
PREFETCH_FOR_LOAD (3, a1) PREFETCH_FOR_LOAD (3, a1)
@ -650,7 +650,7 @@ L(ua_chkw):
C_ST REG7,UNIT(7)(a0) C_ST REG7,UNIT(7)(a0)
PTR_ADDIU a0,a0,UNIT(8) PTR_ADDIU a0,a0,UNIT(8)
/* /*
* Here we have less then 32(64) bytes to copy. Set up for a loop to * Here we have less than 32(64) bytes to copy. Set up for a loop to
* copy one word (or double word) at a time. * copy one word (or double word) at a time.
*/ */
L(ua_chk1w): L(ua_chk1w):
@ -686,7 +686,7 @@ L(ua_smallCopy_loop):
.set reorder .set reorder
END(MEMCPY_NAME) END(MEMCPY_NAME)
#ifndef ANDROID_CHANGES #ifndef ANDROID_CHANGES
#ifdef _LIBC # ifdef _LIBC
libc_hidden_builtin_def (MEMCPY_NAME) libc_hidden_builtin_def (MEMCPY_NAME)
#endif # endif
#endif #endif