diff options
Diffstat (limited to 'newlib')
-rw-r--r-- | newlib/libc/machine/riscv/rv_string.h (renamed from newlib/libc/machine/riscv/sys/string.h) | 8 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/stpcpy.c | 2 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/strcmp.S | 9 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/strcpy.c | 2 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/strlen.c | 2 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/sys/asm.h | 4 | ||||
-rw-r--r-- | newlib/libc/machine/riscv/xlenint.h | 14 | ||||
-rw-r--r-- | newlib/libm/machine/amdgcn/amdgcn_veclib.h | 17 |
8 files changed, 44 insertions, 14 deletions
diff --git a/newlib/libc/machine/riscv/sys/string.h b/newlib/libc/machine/riscv/rv_string.h index b65635c..362f66a 100644 --- a/newlib/libc/machine/riscv/sys/string.h +++ b/newlib/libc/machine/riscv/rv_string.h @@ -9,11 +9,11 @@ http://www.opensource.org/licenses. */ -#ifndef _SYS_STRING_H -#define _SYS_STRING_H +#ifndef _RV_STRING_H +#define _RV_STRING_H #include <stdbool.h> -#include "asm.h" +#include "xlenint.h" #if __riscv_zbb #include <riscv_bitmanip.h> @@ -121,4 +121,4 @@ static __inline char *__libc_strcpy(char *dst, const char *src, bool ret_start) } -#endif +#endif /* _RV_STRING_H */ diff --git a/newlib/libc/machine/riscv/stpcpy.c b/newlib/libc/machine/riscv/stpcpy.c index 9243457..14c3222 100644 --- a/newlib/libc/machine/riscv/stpcpy.c +++ b/newlib/libc/machine/riscv/stpcpy.c @@ -1,5 +1,5 @@ -#include <string.h> #include <stdbool.h> +#include "rv_string.h" char *stpcpy(char *dst, const char *src) { diff --git a/newlib/libc/machine/riscv/strcmp.S b/newlib/libc/machine/riscv/strcmp.S index 12c39db..cc29b7b 100644 --- a/newlib/libc/machine/riscv/strcmp.S +++ b/newlib/libc/machine/riscv/strcmp.S @@ -188,9 +188,16 @@ strcmp: foundnull 1 3 foundnull 2 3 #endif +#ifdef __riscv_cmodel_large + # Put the data within the funciton for large code model to prevent + # the data put too far. +.align 3 +mask: +.dword 0x7f7f7f7f7f7f7f7f +#endif .size strcmp, .-strcmp -#if SZREG == 8 +#if SZREG == 8 && !defined(__riscv_cmodel_large) .section .srodata.cst8,"aM",@progbits,8 .align 3 mask: diff --git a/newlib/libc/machine/riscv/strcpy.c b/newlib/libc/machine/riscv/strcpy.c index f770493..a05ec1c 100644 --- a/newlib/libc/machine/riscv/strcpy.c +++ b/newlib/libc/machine/riscv/strcpy.c @@ -9,8 +9,8 @@ http://www.opensource.org/licenses. */ -#include <string.h> #include <stdbool.h> +#include "rv_string.h" char *strcpy(char *dst, const char *src) { diff --git a/newlib/libc/machine/riscv/strlen.c b/newlib/libc/machine/riscv/strlen.c index 7e5d416..9bfd2a1 100644 --- a/newlib/libc/machine/riscv/strlen.c +++ b/newlib/libc/machine/riscv/strlen.c @@ -11,7 +11,7 @@ #include <string.h> #include <stdint.h> -#include "sys/asm.h" +#include "rv_string.h" size_t strlen(const char *str) { diff --git a/newlib/libc/machine/riscv/sys/asm.h b/newlib/libc/machine/riscv/sys/asm.h index 0a354b2..8c8aeb3 100644 --- a/newlib/libc/machine/riscv/sys/asm.h +++ b/newlib/libc/machine/riscv/sys/asm.h @@ -12,8 +12,6 @@ #ifndef _SYS_ASM_H #define _SYS_ASM_H -#include <stdint.h> - /* * Macros to handle different pointer/register sizes for 32/64-bit code */ @@ -22,13 +20,11 @@ # define SZREG 8 # define REG_S sd # define REG_L ld -typedef uint64_t uintxlen_t; #elif __riscv_xlen == 32 # define PTRLOG 2 # define SZREG 4 # define REG_S sw # define REG_L lw -typedef uint32_t uintxlen_t; #else # error __riscv_xlen must equal 32 or 64 #endif diff --git a/newlib/libc/machine/riscv/xlenint.h b/newlib/libc/machine/riscv/xlenint.h new file mode 100644 index 0000000..86363a8 --- /dev/null +++ b/newlib/libc/machine/riscv/xlenint.h @@ -0,0 +1,14 @@ +#ifndef _XLENINT_H +#define _XLENINT_H + +#include <stdint.h> + +#if __riscv_xlen == 64 +typedef uint64_t uintxlen_t; +#elif __riscv_xlen == 32 +typedef uint32_t uintxlen_t; +#else +# error __riscv_xlen must equal 32 or 64 +#endif + +#endif /* _XLENINT_H */ diff --git a/newlib/libm/machine/amdgcn/amdgcn_veclib.h b/newlib/libm/machine/amdgcn/amdgcn_veclib.h index bd67740..9e9d3eb 100644 --- a/newlib/libm/machine/amdgcn/amdgcn_veclib.h +++ b/newlib/libm/machine/amdgcn/amdgcn_veclib.h @@ -85,8 +85,21 @@ typedef union { #define RESIZE_VECTOR(to_t, from) \ ({ \ - __auto_type __from = (from); \ - *((to_t *) &__from); \ + to_t __to; \ + if (VECTOR_WIDTH (to_t) < VECTOR_WIDTH (__typeof (from))) \ + asm ("; no-op cast %0" : "=v"(__to) : "0"(from)); \ + else \ + { \ + unsigned long __mask = -1L; \ + int lanes = VECTOR_WIDTH (__typeof (from)); \ + __mask <<= lanes; \ + __builtin_choose_expr ( \ + V_SF_SI_P (to_t), \ + ({asm ("v_mov_b32 %0, 0" : "=v"(__to) : "0"(from), "e"(__mask));}), \ + ({asm ("v_mov_b32 %H0, 0\n\t" \ + "v_mov_b32 %L0, 0" : "=v"(__to) : "0"(from), "e"(__mask));})); \ + } \ + __to; \ }) /* Bit-wise cast vector FROM to type TO_T. */ |