You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
2.9KB

  1. /*
  2. * gcc fixes for altivec.
  3. * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3)
  4. * and to stay somewhat compatible with Darwin.
  5. */
  6. #ifndef _GCC_FIXES_
  7. #define _GCC_FIXES_
  8. #ifdef HAVE_ALTIVEC_H
  9. #include <altivec.h>
  10. #endif
  11. #ifdef CONFIG_DARWIN
  12. #define AVV(x...) (x)
  13. #else
  14. #define AVV(x...) {x}
  15. #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
  16. /* This code was provided to me by Bartosch Pixa
  17. * as a separate header file (broken_mergel.h).
  18. * thanks to lu_zero for the workaround.
  19. *
  20. * See this mail for more information:
  21. * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
  22. */
  23. static inline vector signed char ff_vmrglb (vector signed char const A,
  24. vector signed char const B)
  25. {
  26. static const vector unsigned char lowbyte = {
  27. 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
  28. 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
  29. };
  30. return vec_perm (A, B, lowbyte);
  31. }
  32. static inline vector signed short ff_vmrglh (vector signed short const A,
  33. vector signed short const B)
  34. {
  35. static const vector unsigned char lowhalf = {
  36. 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
  37. 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
  38. };
  39. return vec_perm (A, B, lowhalf);
  40. }
  41. static inline vector signed int ff_vmrglw (vector signed int const A,
  42. vector signed int const B)
  43. {
  44. static const vector unsigned char lowword = {
  45. 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
  46. 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
  47. };
  48. return vec_perm (A, B, lowword);
  49. }
  50. /*#define ff_vmrglb ff_vmrglb
  51. #define ff_vmrglh ff_vmrglh
  52. #define ff_vmrglw ff_vmrglw
  53. */
  54. #undef vec_mergel
  55. #define vec_mergel(a1, a2) \
  56. __ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
  57. ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
  58. __ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
  59. ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
  60. __ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
  61. ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
  62. __ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
  63. ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
  64. __ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
  65. ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
  66. __ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
  67. ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
  68. __ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
  69. ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
  70. __altivec_link_error_invalid_argument ())))))))
  71. #endif
  72. #endif /* CONFIG_DARWIN */
  73. #endif /* _GCC_FIXES_ */