OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [newlib-1.18.0/] [newlib-1.18.0-or32-1.0rc1/] [newlib/] [libc/] [machine/] [xscale/] [strchr.c] - Diff between revs 207 and 345

Only display areas with differences | Details | Blame | View Log

Rev 207 Rev 345
#if defined __thumb__
#if defined __thumb__
 
 
#include "../../string/strchr.c"
#include "../../string/strchr.c"
 
 
#else
#else
 
 
#include <string.h>
#include <string.h>
#include "xscale.h"
#include "xscale.h"
 
 
char *
char *
strchr (const char *s, int c)
strchr (const char *s, int c)
{
{
  unsigned int c2;
  unsigned int c2;
  asm (PRELOADSTR ("%0") : : "r" (s));
  asm (PRELOADSTR ("%0") : : "r" (s));
 
 
  c &= 0xff;
  c &= 0xff;
 
 
#ifndef __OPTIMIZE_SIZE__
#ifndef __OPTIMIZE_SIZE__
  /* Skip unaligned part.  */
  /* Skip unaligned part.  */
  if ((long)s & 3)
  if ((long)s & 3)
    {
    {
      s--;
      s--;
      do
      do
        {
        {
          int c2 = *++s;
          int c2 = *++s;
          if (c2 == c)
          if (c2 == c)
            return (char *)s;
            return (char *)s;
          if (c2 == '\0')
          if (c2 == '\0')
            return 0;
            return 0;
        }
        }
      while (((long)s & 3) != 0);
      while (((long)s & 3) != 0);
    }
    }
 
 
  c2 = c + (c << 8);
  c2 = c + (c << 8);
  c2 += c2 << 16;
  c2 += c2 << 16;
 
 
  /* Load two constants:
  /* Load two constants:
     R6 = 0xfefefeff [ == ~(0x80808080 << 1) ]
     R6 = 0xfefefeff [ == ~(0x80808080 << 1) ]
     R5 = 0x80808080  */
     R5 = 0x80808080  */
 
 
  asm (PRELOADSTR ("%0") "\n\
  asm (PRELOADSTR ("%0") "\n\
        mov     r5, #0x80\n\
        mov     r5, #0x80\n\
        add     r5, r5, #0x8000\n\
        add     r5, r5, #0x8000\n\
        add     r5, r5, r5, lsl #16\n\
        add     r5, r5, r5, lsl #16\n\
        mvn     r6, r5, lsl #1\n\
        mvn     r6, r5, lsl #1\n\
\n\
\n\
        sub     %0, %0, #4\n\
        sub     %0, %0, #4\n\
0:\n\
0:\n\
        ldr     r1, [%0, #4]!\n\
        ldr     r1, [%0, #4]!\n\
"       PRELOADSTR ("%0") "\n\
"       PRELOADSTR ("%0") "\n\
        add     r3, r1, r6\n\
        add     r3, r1, r6\n\
        bic     r3, r3, r1\n\
        bic     r3, r3, r1\n\
        ands    r2, r3, r5\n\
        ands    r2, r3, r5\n\
        bne     1f\n\
        bne     1f\n\
        eor     r2, r1, %1\n\
        eor     r2, r1, %1\n\
        add     r3, r2, r6\n\
        add     r3, r2, r6\n\
        bic     r3, r3, r2\n\
        bic     r3, r3, r2\n\
        ands    r1, r3, r5\n\
        ands    r1, r3, r5\n\
        beq     0b\n\
        beq     0b\n\
1:"
1:"
       : "=&r" (s)
       : "=&r" (s)
       : "r" (c2), "0" (s)
       : "r" (c2), "0" (s)
       : "r1", "r2", "r3", "r5", "r6", "cc");
       : "r1", "r2", "r3", "r5", "r6", "cc");
#endif
#endif
 
 
  while (*s && *s != c)
  while (*s && *s != c)
    s++;
    s++;
  if (*s == c)
  if (*s == c)
    return (char *)s;
    return (char *)s;
  return NULL;
  return NULL;
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.