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/] [memset.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/memset.c"
#include "../../string/memset.c"
 
 
#else
#else
 
 
#include <string.h>
#include <string.h>
#include "xscale.h"
#include "xscale.h"
 
 
void *
void *
memset (void *dst, int c, size_t len)
memset (void *dst, int c, size_t len)
{
{
  int dummy;
  int dummy;
 
 
  asm volatile ("tst    %0, #0x3"
  asm volatile ("tst    %0, #0x3"
#ifndef __OPTIMIZE_SIZE__
#ifndef __OPTIMIZE_SIZE__
"\n\
"\n\
        beq     1f\n\
        beq     1f\n\
        b       2f\n\
        b       2f\n\
0:\n\
0:\n\
        strb    %1, [%0], #1\n\
        strb    %1, [%0], #1\n\
        tst     %0, #0x3\n\
        tst     %0, #0x3\n\
        beq     1f\n\
        beq     1f\n\
2:\n\
2:\n\
        movs    r3, %2\n\
        movs    r3, %2\n\
        sub     %2, %2, #1\n\
        sub     %2, %2, #1\n\
        bne     0b\n\
        bne     0b\n\
# At this point we know that %2 == len == -1 (since the SUB has already taken\n\
# At this point we know that %2 == len == -1 (since the SUB has already taken\n\
# place).  If we fall through to the 1: label (as the code used to do), the\n\
# place).  If we fall through to the 1: label (as the code used to do), the\n\
# CMP will detect this negative value and branch to the 2: label.  This will\n\
# CMP will detect this negative value and branch to the 2: label.  This will\n\
# test %2 again, but this time against 0.  The test will fail and the loop\n\
# test %2 again, but this time against 0.  The test will fail and the loop\n\
# at 2: will go on for (almost) ever.  Hence the explicit branch to the end\n\
# at 2: will go on for (almost) ever.  Hence the explicit branch to the end\n\
# of the hand written assembly code.\n\
# of the hand written assembly code.\n\
        b       4f\n\
        b       4f\n\
1:\n\
1:\n\
        cmp     %2, #0x3\n\
        cmp     %2, #0x3\n\
        bls     2f\n\
        bls     2f\n\
        and     %1, %1, #0xff\n\
        and     %1, %1, #0xff\n\
        orr     lr, %1, %1, asl #8\n\
        orr     lr, %1, %1, asl #8\n\
        cmp     %2, #0xf\n\
        cmp     %2, #0xf\n\
        orr     lr, lr, lr, asl #16\n\
        orr     lr, lr, lr, asl #16\n\
        bls     1f\n\
        bls     1f\n\
        mov     r3, lr\n\
        mov     r3, lr\n\
        mov     r4, lr\n\
        mov     r4, lr\n\
        mov     r5, lr\n\
        mov     r5, lr\n\
0:\n\
0:\n\
        sub     %2, %2, #16\n\
        sub     %2, %2, #16\n\
        stmia   %0!, { r3, r4, r5, lr }\n\
        stmia   %0!, { r3, r4, r5, lr }\n\
        cmp     %2, #0xf\n\
        cmp     %2, #0xf\n\
        bhi     0b\n\
        bhi     0b\n\
1:\n\
1:\n\
        cmp     %2, #0x7\n\
        cmp     %2, #0x7\n\
        bls     1f\n\
        bls     1f\n\
        mov     r3, lr\n\
        mov     r3, lr\n\
0:\n\
0:\n\
        sub     %2, %2, #8\n\
        sub     %2, %2, #8\n\
        stmia   %0!, { r3, lr }\n\
        stmia   %0!, { r3, lr }\n\
        cmp     %2, #0x7\n\
        cmp     %2, #0x7\n\
        bhi     0b\n\
        bhi     0b\n\
1:\n\
1:\n\
        cmp     %2, #0x3\n\
        cmp     %2, #0x3\n\
        bls     2f\n\
        bls     2f\n\
0:\n\
0:\n\
        sub     %2, %2, #4\n\
        sub     %2, %2, #4\n\
        str     lr, [%0], #4\n\
        str     lr, [%0], #4\n\
        cmp     %2, #0x3\n\
        cmp     %2, #0x3\n\
        bhi     0b\n\
        bhi     0b\n\
"
"
#endif /* !__OPTIMIZE_SIZE__ */
#endif /* !__OPTIMIZE_SIZE__ */
"\n\
"\n\
2:\n\
2:\n\
        movs    r3, %2\n\
        movs    r3, %2\n\
        sub     %2, %2, #1\n\
        sub     %2, %2, #1\n\
        beq     4f\n\
        beq     4f\n\
0:\n\
0:\n\
        movs    r3, %2\n\
        movs    r3, %2\n\
        sub     %2, %2, #1\n\
        sub     %2, %2, #1\n\
        strb    %1, [%0], #1\n\
        strb    %1, [%0], #1\n\
        bne     0b\n\
        bne     0b\n\
4:"
4:"
 
 
       : "=&r" (dummy), "=&r" (c), "=&r" (len)
       : "=&r" (dummy), "=&r" (c), "=&r" (len)
       : "0" (dst), "1" (c), "2" (len)
       : "0" (dst), "1" (c), "2" (len)
       : "memory", "r3", "r4", "r5", "lr");
       : "memory", "r3", "r4", "r5", "lr");
 
 
  return dst;
  return dst;
}
}
 
 
#endif
#endif
 
 

powered by: WebSVN 2.1.0

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