summaryrefslogtreecommitdiff
path: root/gcc/config/avr/stdfix.h
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/config/avr/stdfix.h')
-rw-r--r--gcc/config/avr/stdfix.h477
1 files changed, 137 insertions, 340 deletions
diff --git a/gcc/config/avr/stdfix.h b/gcc/config/avr/stdfix.h
index b86195a3f16..afcacdfb079 100644
--- a/gcc/config/avr/stdfix.h
+++ b/gcc/config/avr/stdfix.h
@@ -35,10 +35,6 @@
#include <stdfix-gcc.h>
-#define _GCC_TYPEPUN(A, B) \
- __builtin_memcpy (&A, &B, sizeof (A))
-
-/* 7.18a.6 The fixed-point intrinsic functions. */
#if __SIZEOF_INT__ == 2
@@ -66,8 +62,7 @@ typedef long long unsigned int uint_ulk_t;
typedef long long int int_llk_t;
typedef long long unsigned int uint_ullk_t;
-#else /* __SIZEOF_INT__ = 1 (for -mint8) */
-
+#elif __SIZEOF_INT__ == 1 /* -mint8 */
typedef signed char int_hr_t;
typedef unsigned char uint_uhr_t;
@@ -84,356 +79,158 @@ typedef long long unsigned int uint_ulr_t;
typedef long long int int_k_t;
typedef long long unsigned int uint_uk_t;
-#endif /* __SIZEOF_INT__ == 2 */
+#endif /* __SIZEOF_INT__ == 1, 2 */
+
+
+/* 7.18a.6 The fixed-point intrinsic functions. */
-/* 7.18a.6.2 The fixed-point absolute value functions. */
+/* 7.18a.6.2 The fixed-point absolute value functions. */
+
+#define abshr __builtin_avr_abshr
+#define absr __builtin_avr_absr
+#define abslr __builtin_avr_abslr
+
+#define abshk __builtin_avr_abshk
+#define absk __builtin_avr_absk
+
+#if __SIZEOF_INT__ == 2
+
+#define abslk __builtin_avr_abslk
+#define absllr __builtin_avr_absllr /* GCC Extension */
+#define absllk __builtin_avr_absllk /* GCC Extension */
-/* short fract (hr): abshr */
+#endif /* sizeof (int) == 2 */
-static __inline__ __attribute__((__always_inline__))
-short fract abshr (const short fract __q)
-{
- return __builtin_avr_abshr (__q);
-}
-/* fract (r): absr */
+/* 7.18a.6.3 The fixed-point round functions. */
-static __inline__ __attribute__((__always_inline__))
-fract absr (const fract __q)
-{
- return __builtin_avr_absr (__q);
-}
+/* The Embedded-C paper specifies results only for rounding points
-/* long fract (lr): abslr */
+ 0 < RP < FBIT
+
+ As an extension, the following functions work as expected
+ with rounding points
-static __inline__ __attribute__((__always_inline__))
-long fract abslr (const long fract __q)
-{
- return __builtin_avr_abslr (__q);
-}
+ -IBIT < RP < FBIT
+
+ For example, rounding an accum with a rounding point of -1 will
+ result in an even integer value. */
-/* short accum (hk): abshk */
+#define roundhr __builtin_avr_roundhr
+#define roundr __builtin_avr_roundr
+#define roundlr __builtin_avr_roundlr
-static __inline__ __attribute__((__always_inline__))
-short accum abshk (const short accum __q)
-{
- return __builtin_avr_abshk (__q);
-}
+#define rounduhr __builtin_avr_rounduhr
+#define roundur __builtin_avr_roundur
+#define roundulr __builtin_avr_roundulr
-/* accum (k): absk */
+#define roundhk __builtin_avr_roundhk
+#define roundk __builtin_avr_roundk
-static __inline__ __attribute__((__always_inline__))
-accum absk (const accum __q)
-{
- return __builtin_avr_absk (__q);
-}
+#define rounduhk __builtin_avr_rounduhk
+#define rounduk __builtin_avr_rounduk
#if __SIZEOF_INT__ == 2
-/* long long fract (llr): absllr */
-
-static __inline__ __attribute__((__always_inline__))
-long long fract absllr (const long long fract __q) /* GCC extension */
-{
- return __builtin_avr_absllr (__q);
-}
-
-/* long accum (lk): abslk */
-
-static __inline__ __attribute__((__always_inline__))
-long accum abslk (const long accum __q)
-{
- return __builtin_avr_abslk (__q);
-}
-
-/* long long accum (llk): absllk */
-
-static __inline__ __attribute__((__always_inline__))
-long long accum absllk (const long long accum __q) /* GCC extension */
-{
- return __builtin_avr_absllk (__q);
-}
-
-#endif /* __SIZEOF_INT__ == 2 */
-
-
-/* 7.18a.6.5 The bitwise fixed-point to integer conversion functions. */
-/* 7.18a.6.6 The bitwise integer to fixed-point conversion functions. */
-
-/* short fract (hr): bitshr, bitsuhr, hrbits, uhrbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_hr_t bitshr (const short fract __q)
-{
- int_hr_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_uhr_t bitsuhr (const unsigned short fract __q)
-{
- uint_uhr_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-short fract hrbits (const int_hr_t __i)
-{
- short fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned short fract uhrbits (const uint_uhr_t __i)
-{
- unsigned short fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-/* fract (r): bitsr, bitsur, rbits, urbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_r_t bitsr (const fract __q)
-{
- int_r_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_ur_t bitsur (const unsigned fract __q)
-{
- uint_ur_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-fract rbits (const int_r_t __i)
-{
- fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned fract urbits (const uint_ur_t __i)
-{
- unsigned fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-/* long fract (lr): bitslr, bitsulr, lrbits, ulrbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_lr_t bitslr (const long fract __q)
-{
- int_lr_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_ulr_t bitsulr (const unsigned long fract __q)
-{
- uint_ulr_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-long fract lrbits (const int_lr_t __i)
-{
- long fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned long fract ulrbits (const uint_ulr_t __i)
-{
- unsigned long fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-/* short accum (hk): bitshk, bitsuhk, hkbits, uhkbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_hk_t bitshk (const short accum __q)
-{
- int_hk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_uhk_t bitsuhk (const unsigned short accum __q)
-{
- uint_uhk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-short accum hkbits (const int_hk_t __i)
-{
- short accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned short accum uhkbits (const uint_uhk_t __i)
-{
- unsigned short accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-/* accum (k): bitsk, bitsuk, kbits, ukbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_k_t bitsk (const accum __q)
-{
- int_k_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_uk_t bitsuk (const unsigned accum __q)
-{
- uint_uk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-accum kbits (const int_k_t __i)
-{
- accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned accum ukbits (const uint_uk_t __i)
-{
- unsigned accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
+#define roundlk __builtin_avr_roundlk
+#define roundulk __builtin_avr_roundulk
+#define roundllr __builtin_avr_roundllr /* GCC Extension */
+#define roundullr __builtin_avr_roundullr /* GCC Extension */
+#define roundllk __builtin_avr_roundllk /* GCC Extension */
+#define roundullk __builtin_avr_roundullk /* GCC Extension */
+
+#endif /* sizeof (int) == 2 */
+
+
+/* 7.18a.6.4 The fixed-point bit countls functions. */
+
+#define countlshr __builtin_avr_countlshr
+#define countlsr __builtin_avr_countlsr
+#define countlslr __builtin_avr_countlslr
+
+#define countlsuhr __builtin_avr_countlsuhr
+#define countlsur __builtin_avr_countlsur
+#define countlsulr __builtin_avr_countlsulr
+
+#define countlshk __builtin_avr_countlshk
+#define countlsk __builtin_avr_countlsk
+
+#define countlsuhk __builtin_avr_countlsuhk
+#define countlsuk __builtin_avr_countlsuk
#if __SIZEOF_INT__ == 2
-/* long long fract (llr): bitsllr, bitsullr, llrbits, ullrbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_llr_t bitsllr (const long long fract __q)
-{
- int_llr_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_ullr_t bitsullr (const unsigned long long fract __q)
-{
- uint_ullr_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-long long fract llrbits (const int_llr_t __i)
-{
- long long fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned long long fract ullrbits (const uint_ullr_t __i)
-{
- unsigned long long fract __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-/* long accum (lk): bitslk, bitsulk, lkbits, ulkbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_lk_t bitslk (const long accum __q)
-{
- int_lk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_ulk_t bitsulk (const unsigned long accum __q)
-{
- uint_ulk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-long accum lkbits (const int_lk_t __i)
-{
- long accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned long accum ulkbits (const uint_ulk_t __i)
-{
- unsigned long accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-/* long long accum (llk): bitsllk, bitsullk, llkbits, ullkbits */
-
-static __inline__ __attribute__((__always_inline__))
-int_llk_t bitsllk (const long long accum __q)
-{
- int_llk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-uint_ullk_t bitsullk (const unsigned long long accum __q)
-{
- uint_ullk_t __result;
- _GCC_TYPEPUN (__result, __q);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-long long accum llkbits (const int_llk_t __i)
-{
- long long accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-static __inline__ __attribute__((__always_inline__))
-unsigned long long accum ullkbits (const uint_ullk_t __i)
-{
- unsigned long long accum __result;
- _GCC_TYPEPUN (__result, __i);
- return __result;
-}
-
-#endif /* __SIZEOF_INT__ == 2 */
+#define countlslk __builtin_avr_countlslk
+#define countlsulk __builtin_avr_countlsulk
+#define countlsllr __builtin_avr_countlsllr /* GCC Extension */
+#define countlsullr __builtin_avr_countlsullr /* GCC Extension */
+#define countlsllk __builtin_avr_countlsllk /* GCC Extension */
+#define countlsullk __builtin_avr_countlsullk /* GCC Extension */
+
+#endif /* sizeof (int) == 2 */
+
+
+/* 7.18a.6.5 The bitwise fixed-point to integer conversion functions. */
+
+#define bitshr __builtin_avr_bitshr
+#define bitsr __builtin_avr_bitsr
+#define bitslr __builtin_avr_bitslr
+
+#define bitsuhr __builtin_avr_bitsuhr
+#define bitsur __builtin_avr_bitsur
+#define bitsulr __builtin_avr_bitsulr
+
+#define bitshk __builtin_avr_bitshk
+#define bitsk __builtin_avr_bitsk
+
+#define bitsuhk __builtin_avr_bitsuhk
+#define bitsuk __builtin_avr_bitsuk
+
+#if __SIZEOF_INT__ == 2
+
+#define bitslk __builtin_avr_bitslk
+#define bitsulk __builtin_avr_bitsulk
+#define bitsllr __builtin_avr_bitsllr /* GCC Extension */
+#define bitsullr __builtin_avr_bitsullr /* GCC Extension */
+#define bitsllk __builtin_avr_bitsllk /* GCC Extension */
+#define bitsullk __builtin_avr_bitsullk /* GCC Extension */
+
+#endif /* sizeof (int) == 2 */
+
+
+/* 7.18a.6.6 The bitwise integer to fixed-point conversion functions. */
+
+#define hrbits __builtin_avr_hrbits
+#define rbits __builtin_avr_rbits
+#define lrbits __builtin_avr_lrbits
+
+#define uhrbits __builtin_avr_uhrbits
+#define urbits __builtin_avr_urbits
+#define ulrbits __builtin_avr_ulrbits
+
+#define hkbits __builtin_avr_hkbits
+#define kbits __builtin_avr_kbits
+
+#define uhkbits __builtin_avr_uhkbits
+#define ukbits __builtin_avr_ukbits
+
+#if __SIZEOF_INT__ == 2
+
+#define lkbits __builtin_avr_lkbits
+#define ulkbits __builtin_avr_ulkbits
+#define llrbits __builtin_avr_llrbits /* GCC Extension */
+#define ullrbits __builtin_avr_ullrbits /* GCC Extension */
+#define llkbits __builtin_avr_llkbits /* GCC Extension */
+#define ullkbits __builtin_avr_ullkbits /* GCC Extension */
+
+#endif /* sizeof (int) == 2 */
+
+
+/* 7.18a.6.7 Type-generic fixed-point functions. */
+
+#define absfx __builtin_avr_absfx
+#define roundfx __builtin_avr_roundfx
+#define countlsfx __builtin_avr_countlsfx
+
#endif /* _AVRGCC_STDFIX_H */