diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2013-07-16 07:48:53 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2013-07-16 07:48:53 +0000 |
commit | 6041792ec6b89f5e9eae79d8addbb0f706f9addd (patch) | |
tree | 05a286d63fb8d9fddb81195e6ff80a2f6ad8b2be /newlib/libc | |
parent | f6ddaa2a292bc9e4d5190a413c0b4c1fa7c81374 (diff) | |
download | cygnal-6041792ec6b89f5e9eae79d8addbb0f706f9addd.tar.gz cygnal-6041792ec6b89f5e9eae79d8addbb0f706f9addd.tar.bz2 cygnal-6041792ec6b89f5e9eae79d8addbb0f706f9addd.zip |
* configure.host: Change to microblaze*.
* libc/include/machine/ieeefp.h: Add __MICROBLAZEEL__.
* libc/machine/microblaze/mb_endian.h: New file.
* newlib/libc/machine/microblaze/strcmp.c: Add little endian support.
* newlib/libc/machine/microblaze/strcpy.c: Likewise.
* newlib/libc/machine/microblaze/strlen.c: Likewise.
* configure.in: Change to microblaze*.
* configure: Regenerate.
* microblaze/xilinx.ld: Remove OUTPUT_FORMAT.
Diffstat (limited to 'newlib/libc')
-rw-r--r-- | newlib/libc/include/machine/ieeefp.h | 4 | ||||
-rw-r--r-- | newlib/libc/machine/microblaze/mb_endian.h | 15 | ||||
-rw-r--r-- | newlib/libc/machine/microblaze/strcmp.c | 11 | ||||
-rw-r--r-- | newlib/libc/machine/microblaze/strcpy.c | 16 | ||||
-rw-r--r-- | newlib/libc/machine/microblaze/strlen.c | 7 |
5 files changed, 41 insertions, 12 deletions
diff --git a/newlib/libc/include/machine/ieeefp.h b/newlib/libc/include/machine/ieeefp.h index 256a78171..042e7f409 100644 --- a/newlib/libc/include/machine/ieeefp.h +++ b/newlib/libc/include/machine/ieeefp.h @@ -364,7 +364,11 @@ #endif #ifdef __MICROBLAZE__ +#ifndef __MICROBLAZEEL__ #define __IEEE_BIG_ENDIAN +#else +#define __IEEE_LITTLE_ENDIAN +#endif #endif #ifdef __MSP430__ diff --git a/newlib/libc/machine/microblaze/mb_endian.h b/newlib/libc/machine/microblaze/mb_endian.h new file mode 100644 index 000000000..fb217ec85 --- /dev/null +++ b/newlib/libc/machine/microblaze/mb_endian.h @@ -0,0 +1,15 @@ +#ifndef _MB_ENDIAN_H +#define _MB_ENDIAN_H + +/* Convenience macros for loading and store 4 bytes in a byte invariant way with + * a singe instruction. Endianess affects this and we rely on MicroBlaze + * load/store reverse instructions to do the trick on little-endian systems. + */ +#ifdef __LITTLE_ENDIAN__ +#define LOAD4BYTES(rD,rA,rB) "\tlwr\t" rD ", " rA ", " rB "\n" +#define STORE4BYTES(rD,rA,rB) "\tswr\t" rD ", " rA ", " rB "\n" +#else +#define LOAD4BYTES(rD,rA,rB) "\tlw\t" rD ", " rA ", " rB "\n" +#define STORE4BYTES(rD,rA,rB) "\tsw\t" rD ", " rA ", " rB "\n" +#endif +#endif diff --git a/newlib/libc/machine/microblaze/strcmp.c b/newlib/libc/machine/microblaze/strcmp.c index dbac3878f..2f0337412 100644 --- a/newlib/libc/machine/microblaze/strcmp.c +++ b/newlib/libc/machine/microblaze/strcmp.c @@ -138,16 +138,19 @@ _DEFUN (strcmp, (s1, s2), #else +#include "mb_endian.h" + asm volatile (" \n\ - or r9, r0, r0 /* Index register */ \n\ + or r9, r0, r0 /* Index register */\n\ check_alignment: \n\ andi r3, r5, 3 \n\ andi r4, r6, 3 \n\ bnei r3, try_align_args \n\ bnei r4, regular_strcmp /* At this point we don't have a choice */ \n\ -cmp_loop: \n\ - lw r3, r5, r9 \n\ - lw r4, r6, r9 \n\ +cmp_loop: \n" + LOAD4BYTES("r3", "r5", "r9") + LOAD4BYTES("r4", "r6", "r9") +" \n\ pcmpbf r7, r3, r0 /* See if there is Null byte */ \n\ bnei r7, end_cmp_loop /* IF yes (r7 > 0) use byte compares in end_cmp_loop */ \n\ cmpu r7, r4, r3 /* ELSE compare whole word */ \n\ diff --git a/newlib/libc/machine/microblaze/strcpy.c b/newlib/libc/machine/microblaze/strcpy.c index 6f0ad05e7..d5430a305 100644 --- a/newlib/libc/machine/microblaze/strcpy.c +++ b/newlib/libc/machine/microblaze/strcpy.c @@ -131,18 +131,22 @@ _DEFUN (strcpy, (dst0, src0), #else - asm volatile (" \ - or r9, r0, r0 /* Index register */ \n\ +#include "mb_endian.h" + + asm volatile (" \n\ + or r9, r0, r0 /* Index register */ \n\ check_alignment: \n\ andi r3, r5, 3 \n\ andi r4, r6, 3 \n\ bnei r3, try_align_args \n\ bnei r4, regular_strcpy /* At this point we dont have a choice */ \n\ -cpy_loop: \n\ - lw r3, r6, r9 \n\ +cpy_loop: \n" + LOAD4BYTES("r3", "r6", "r9") +" \n\ pcmpbf r4, r0, r3 \n\ - bnei r4, cpy_bytes /* If r4 != 0, then null present within string */\n\ - sw r3, r5, r9 \n\ + bnei r4, cpy_bytes /* If r4 != 0, then null present within string */\n" + STORE4BYTES("r3", "r5", "r9") +" \n\ brid cpy_loop \n\ addik r9, r9, 4 \n\ cpy_bytes: \n\ diff --git a/newlib/libc/machine/microblaze/strlen.c b/newlib/libc/machine/microblaze/strlen.c index 82eede86e..51387cd9c 100644 --- a/newlib/libc/machine/microblaze/strlen.c +++ b/newlib/libc/machine/microblaze/strlen.c @@ -120,13 +120,16 @@ _DEFUN (strlen, (str), #else +#include "mb_endian.h" + asm volatile (" \n\ or r9, r0, r0 /* Index register */ \n\ check_alignment: \n\ andi r3, r5, 3 \n\ bnei r3, align_arg \n\ -len_loop: \n\ - lw r3, r5, r9 \n\ +len_loop: \n" + LOAD4BYTES("r3", "r5", "r9") +" \n\ pcmpbf r4, r3, r0 \n\ bnei r4, end_len \n\ brid len_loop \n\ |