10l (vdpart fix)
[libav.git] / libavcodec / ppc / gcc_fixes.h
CommitLineData
a9a07762
MN
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
7#ifndef _GCC_FIXES_
8#define _GCC_FIXES_
9
10#ifdef HAVE_ALTIVEC_H
11#include <altivec.h>
12#endif
13
14#ifdef CONFIG_DARWIN
15#define AVV(x...) (x)
16#else
17#define AVV(x...) {x}
a9a07762
MN
18#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
19
20/* This code was provided to me by Bartosch Pixa
21 * as a separate header file (broken_mergel.h).
22 * thanks to lu_zero for the workaround.
23 *
24 * See this mail for more information:
25 * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
26 */
27
782b80d9 28static inline vector signed char ff_vmrglb (vector signed char const A,
a9a07762
MN
29 vector signed char const B)
30{
31 static const vector unsigned char lowbyte = {
32 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
33 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
34 };
35 return vec_perm (A, B, lowbyte);
36}
37
782b80d9 38static inline vector signed short ff_vmrglh (vector signed short const A,
a9a07762
MN
39 vector signed short const B)
40{
41 static const vector unsigned char lowhalf = {
42 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
43 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
44 };
45 return vec_perm (A, B, lowhalf);
46}
47
782b80d9 48static inline vector signed int ff_vmrglw (vector signed int const A,
a9a07762
MN
49 vector signed int const B)
50{
51 static const vector unsigned char lowword = {
52 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
53 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
54 };
55 return vec_perm (A, B, lowword);
56}
782b80d9
MN
57/*#define ff_vmrglb ff_vmrglb
58#define ff_vmrglh ff_vmrglh
59#define ff_vmrglw ff_vmrglw
a9a07762
MN
60*/
61#undef vec_mergel
62
63#define vec_mergel(a1, a2) \
64__ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
782b80d9 65 ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
a9a07762 66__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
782b80d9 67 ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
a9a07762 68__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
782b80d9 69 ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
a9a07762 70__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
782b80d9 71 ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
a9a07762 72__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
782b80d9 73 ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
a9a07762 74__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
782b80d9 75 ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
a9a07762 76__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
782b80d9 77 ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
a9a07762
MN
78 __altivec_link_error_invalid_argument ())))))))
79
80#endif
81
82#endif /* CONFIG_DARWIN */
83
84#endif /* _GCC_FIXES_ */