Merge pull request #3976 from rliebscher/Use_Renesas_RX_intrinsics_with_CC-RX_compiler

Renesas RX: Use intrinsics for rot[rl], revl
This commit is contained in:
David Garske
2021-05-17 11:05:01 -07:00
committed by GitHub
2 changed files with 34 additions and 0 deletions

View File

@ -81,6 +81,30 @@ masking and clearing memory logic.
return y ? _lrotr(x, y) : x; return y ? _lrotr(x, y) : x;
} }
#elif defined(__CCRX__)
#include <builtin.h> /* get intrinsic definitions */
#if !defined(NO_INLINE)
#define rotlFixed(x, y) _builtin_rotl(x, y)
#define rotrFixed(x, y) _builtin_rotr(x, y)
#else /* create real function */
WC_STATIC WC_INLINE word32 rotlFixed(word32 x, word32 y)
{
return _builtin_rotl(x, y);
}
WC_STATIC WC_INLINE word32 rotrFixed(word32 x, word32 y)
{
return _builtin_rotr(x, y);
}
#endif
#else /* generic */ #else /* generic */
/* This routine performs a left circular arithmetic shift of <x> by <y> value. */ /* This routine performs a left circular arithmetic shift of <x> by <y> value. */
@ -115,6 +139,9 @@ WC_STATIC WC_INLINE word16 rotrFixed16(word16 x, word16 y)
#endif /* WC_RC2 */ #endif /* WC_RC2 */
/* This routine performs a byte swap of 32-bit word value. */ /* This routine performs a byte swap of 32-bit word value. */
#if defined(__CCRX__) && !defined(NO_INLINE) // shortest version for CC-RX
#define ByteReverseWord32(value) _builtin_revl(value)
#else
WC_STATIC WC_INLINE word32 ByteReverseWord32(word32 value) WC_STATIC WC_INLINE word32 ByteReverseWord32(word32 value)
{ {
#ifdef PPC_INTRINSICS #ifdef PPC_INTRINSICS
@ -124,6 +151,8 @@ WC_STATIC WC_INLINE word32 ByteReverseWord32(word32 value)
return (word32)__REV(value); return (word32)__REV(value);
#elif defined(KEIL_INTRINSICS) #elif defined(KEIL_INTRINSICS)
return (word32)__rev(value); return (word32)__rev(value);
#elif defined(__CCRX__)
return (word32)_builtin_revl(value);
#elif defined(WOLF_ALLOW_BUILTIN) && \ #elif defined(WOLF_ALLOW_BUILTIN) && \
defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3) defined(__GNUC_PREREQ) && __GNUC_PREREQ(4, 3)
return (word32)__builtin_bswap32(value); return (word32)__builtin_bswap32(value);
@ -153,6 +182,7 @@ WC_STATIC WC_INLINE word32 ByteReverseWord32(word32 value)
return rotlFixed(value, 16U); return rotlFixed(value, 16U);
#endif #endif
} }
#endif /* __CCRX__ */
/* This routine performs a byte swap of words array of a given count. */ /* This routine performs a byte swap of words array of a given count. */
WC_STATIC WC_INLINE void ByteReverseWords(word32* out, const word32* in, WC_STATIC WC_INLINE void ByteReverseWords(word32* out, const word32* in,
word32 byteCount) word32 byteCount)

View File

@ -221,6 +221,8 @@ decouple library dependencies with standard string, memory and so on.
#else #else
#define WC_INLINE inline #define WC_INLINE inline
#endif #endif
#elif defined(__CCRX__)
#define WC_INLINE inline
#else #else
#define WC_INLINE #define WC_INLINE
#endif #endif
@ -246,6 +248,8 @@ decouple library dependencies with standard string, memory and so on.
#elif defined(__MWERKS__) && TARGET_CPU_PPC #elif defined(__MWERKS__) && TARGET_CPU_PPC
#define PPC_INTRINSICS #define PPC_INTRINSICS
#define FAST_ROTATE #define FAST_ROTATE
#elif defined(__CCRX__)
#define FAST_ROTATE
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
/* GCC does peephole optimizations which should result in using rotate /* GCC does peephole optimizations which should result in using rotate
instructions */ instructions */