Use __inhibit_loop_to_libcall in all memset/memcpy implementations

This macro selects a compiler option that disables recognition of
common memset/memcpy patterns and converting those to direct
memset/memcpy calls.

Signed-off-by: Keith Packard <keithp@keithp.com>
This commit is contained in:
Keith Packard 2018-08-27 11:32:31 -07:00 committed by Corinna Vinschen
parent 088a45cdf6
commit 82dfae9ab0
10 changed files with 28 additions and 2 deletions

View File

@ -31,6 +31,7 @@
than what we describe. An assembly file should be used instead. */ than what we describe. An assembly file should be used instead. */
#include <stddef.h> #include <stddef.h>
#include "../../string/local.h"
/* Break even between movem and move16 is really at 38.7 * 2, but /* Break even between movem and move16 is really at 38.7 * 2, but
modulo 44, so up to the next multiple of 44, we use ordinary code. */ modulo 44, so up to the next multiple of 44, we use ordinary code. */
@ -40,6 +41,7 @@
__asm__ (".syntax no_register_prefix"); __asm__ (".syntax no_register_prefix");
void * void *
__inhibit_loop_to_libcall
memcpy(void *__restrict pdst, const void *__restrict psrc, size_t pn) memcpy(void *__restrict pdst, const void *__restrict psrc, size_t pn)
{ {
/* Now we want the parameters put in special registers. /* Now we want the parameters put in special registers.

View File

@ -11,10 +11,12 @@
#include <string.h> #include <string.h>
#include <stdint.h> #include <stdint.h>
#include "../../string/local.h"
#define unlikely(X) __builtin_expect (!!(X), 0) #define unlikely(X) __builtin_expect (!!(X), 0)
void * void *
__inhibit_loop_to_libcall
memcpy(void *__restrict aa, const void *__restrict bb, size_t n) memcpy(void *__restrict aa, const void *__restrict bb, size_t n)
{ {
#define BODY(a, b, t) { \ #define BODY(a, b, t) { \

View File

@ -33,6 +33,7 @@
#include <spu_intrinsics.h> #include <spu_intrinsics.h>
#include <stddef.h> #include <stddef.h>
#include <vec_literal.h> #include <vec_literal.h>
#include "../../string/local.h"
/* Copy n bytes from memory area src to memory area dest. /* Copy n bytes from memory area src to memory area dest.
* The memory areas may not overlap. The memcpy subroutine * The memory areas may not overlap. The memcpy subroutine
@ -42,7 +43,9 @@
* either with prior knowledge of the alignment or special * either with prior knowledge of the alignment or special
* casing specific optimal alignments. * casing specific optimal alignments.
*/ */
void * memcpy(void * __restrict__ dest, const void * __restrict__ src, size_t n) void *
__inhibit_loop_to_libcall
memcpy(void * __restrict__ dest, const void * __restrict__ src, size_t n)
{ {
int adjust, delta; int adjust, delta;
unsigned int soffset1, doffset1, doffset2; unsigned int soffset1, doffset1, doffset2;

View File

@ -34,10 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include "ea_internal.h" #include "ea_internal.h"
#include <ea.h> #include <ea.h>
#include <spu_cache.h> #include <spu_cache.h>
#include "../../string/local.h"
COMPAT_EA_ALIAS (memcpy_ea); COMPAT_EA_ALIAS (memcpy_ea);
__ea void * __ea void *
__inhibit_loop_to_libcall
memcpy_ea (__ea void *dest, __ea const void *src, size_ea_t n) memcpy_ea (__ea void *dest, __ea const void *src, size_ea_t n)
{ {
__ea void *curr_dest = dest; __ea void *curr_dest = dest;

View File

@ -34,10 +34,12 @@ POSSIBILITY OF SUCH DAMAGE.
#include <spu_cache.h> #include <spu_cache.h>
#include "ea_internal.h" #include "ea_internal.h"
#include <ea.h> #include <ea.h>
#include "../../string/local.h"
COMPAT_EA_ALIAS (memset_ea); COMPAT_EA_ALIAS (memset_ea);
__ea void * __ea void *
__inhibit_loop_to_libcall
memset_ea (__ea void *dest, int c, size_ea_t n) memset_ea (__ea void *dest, int c, size_ea_t n)
{ {
__ea void *curr_dest = dest; __ea void *curr_dest = dest;

View File

@ -31,6 +31,7 @@
#include <stddef.h> #include <stddef.h>
#include "memcpy.h" #include "memcpy.h"
#include "../../string/local.h"
#define INST_BARRIER __asm__ __volatile__ ("":::"memory"); #define INST_BARRIER __asm__ __volatile__ ("":::"memory");
@ -422,6 +423,7 @@ do { \
static inline void static inline void
__inhibit_loop_to_libcall
__int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n) __int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{ {
int value = n; int value = n;
@ -562,6 +564,7 @@ __int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
} }
static inline void static inline void
__inhibit_loop_to_libcall
__shrt_int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n) __shrt_int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{ {
int value = n; int value = n;
@ -703,6 +706,7 @@ __shrt_int_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
static inline void static inline void
__inhibit_loop_to_libcall
__byte_memcpy (void *__restrict s1, const void *__restrict s2, size_t n) __byte_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{ {
int value = n; int value = n;
@ -846,6 +850,7 @@ __byte_memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
/* Exposed interface. */ /* Exposed interface. */
void * void *
__inhibit_loop_to_libcall
memcpy (void *__restrict s1, const void *__restrict s2, size_t n) memcpy (void *__restrict s1, const void *__restrict s2, size_t n)
{ {
void *result = s1; void *result = s1;

View File

@ -31,6 +31,7 @@
#include <stddef.h> #include <stddef.h>
#include "memset.h" #include "memset.h"
#include "../../string/local.h"
#define SET_32_OBJECTS(out) \ #define SET_32_OBJECTS(out) \
do { \ do { \
@ -228,8 +229,8 @@ do { \
out += 1; \ out += 1; \
} while(0) } while(0)
static inline void static inline void
__inhibit_loop_to_libcall
__int_memset (void *__restrict s1, int val, size_t n) __int_memset (void *__restrict s1, int val, size_t n)
{ {
int value = n; int value = n;
@ -369,6 +370,7 @@ __int_memset (void *__restrict s1, int val, size_t n)
} }
static inline void static inline void
__inhibit_loop_to_libcall
__short_int_memset (void *__restrict s1, int val, size_t n) __short_int_memset (void *__restrict s1, int val, size_t n)
{ {
int value = n; int value = n;
@ -508,6 +510,7 @@ __short_int_memset (void *__restrict s1, int val, size_t n)
} }
static inline void static inline void
__inhibit_loop_to_libcall
__byte_memset (void *__restrict s1, int val, size_t n) __byte_memset (void *__restrict s1, int val, size_t n)
{ {
int value = n; int value = n;
@ -650,6 +653,7 @@ __byte_memset (void *__restrict s1, int val, size_t n)
/* Exposed interface. */ /* Exposed interface. */
void * void *
__inhibit_loop_to_libcall
memset (void *s, int c, size_t n) memset (void *s, int c, size_t n)
{ {
void *result = s; void *result = s;

View File

@ -6,8 +6,10 @@
#include <string.h> #include <string.h>
#include "xscale.h" #include "xscale.h"
#include "../../string/local.h"
void * void *
__inhibit_loop_to_libcall
memcpy (void *__restrict dst0, const void *__restrict src0, size_t len) memcpy (void *__restrict dst0, const void *__restrict src0, size_t len)
{ {
int dummy; int dummy;

View File

@ -6,8 +6,10 @@
#include <string.h> #include <string.h>
#include "xscale.h" #include "xscale.h"
#include "../../string/local.h"
void * void *
__inhibit_loop_to_libcall
memset (void *dst, int c, size_t len) memset (void *dst, int c, size_t len)
{ {
int dummy; int dummy;

View File

@ -29,6 +29,7 @@ QUICKREF
#include <_ansi.h> #include <_ansi.h>
#include <string.h> #include <string.h>
#include "local.h"
/* Nonzero if either X or Y is not aligned on a "long" boundary. */ /* Nonzero if either X or Y is not aligned on a "long" boundary. */
#define UNALIGNED(X, Y) \ #define UNALIGNED(X, Y) \
@ -44,6 +45,7 @@ QUICKREF
#define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE) #define TOO_SMALL(LEN) ((LEN) < BIGBLOCKSIZE)
void * void *
__inhibit_loop_to_libcall
memcpy (void *__restrict dst0, memcpy (void *__restrict dst0,
const void *__restrict src0, const void *__restrict src0,
size_t len0) size_t len0)