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 | # ifndef __MWERKS__
|
---|
16 | # define AVV(x...) (x)
|
---|
17 | # else
|
---|
18 | # define AVV
|
---|
19 | # endif
|
---|
20 | #define REG_v(a) asm ( #a )
|
---|
21 | #else
|
---|
22 |
|
---|
23 | #define AVV(x...) {x}
|
---|
24 |
|
---|
25 | #if (__GNUC__ < 4)
|
---|
26 | # define REG_v(a)
|
---|
27 | #else
|
---|
28 | # define REG_v(a) asm ( #a )
|
---|
29 | #endif
|
---|
30 |
|
---|
31 | #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
|
---|
32 |
|
---|
33 | /* This code was provided to me by Bartosch Pixa
|
---|
34 | * as a separate header file (broken_mergel.h).
|
---|
35 | * thanks to lu_zero for the workaround.
|
---|
36 | *
|
---|
37 | * See this mail for more information:
|
---|
38 | * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
|
---|
39 | */
|
---|
40 |
|
---|
41 | static inline vector signed char ff_vmrglb (vector signed char const A,
|
---|
42 | vector signed char const B)
|
---|
43 | {
|
---|
44 | static const vector unsigned char lowbyte = {
|
---|
45 | 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
|
---|
46 | 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
|
---|
47 | };
|
---|
48 | return vec_perm (A, B, lowbyte);
|
---|
49 | }
|
---|
50 |
|
---|
51 | static inline vector signed short ff_vmrglh (vector signed short const A,
|
---|
52 | vector signed short const B)
|
---|
53 | {
|
---|
54 | static const vector unsigned char lowhalf = {
|
---|
55 | 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
|
---|
56 | 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
|
---|
57 | };
|
---|
58 | return vec_perm (A, B, lowhalf);
|
---|
59 | }
|
---|
60 |
|
---|
61 | static inline vector signed int ff_vmrglw (vector signed int const A,
|
---|
62 | vector signed int const B)
|
---|
63 | {
|
---|
64 | static const vector unsigned char lowword = {
|
---|
65 | 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
|
---|
66 | 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
|
---|
67 | };
|
---|
68 | return vec_perm (A, B, lowword);
|
---|
69 | }
|
---|
70 | /*#define ff_vmrglb ff_vmrglb
|
---|
71 | #define ff_vmrglh ff_vmrglh
|
---|
72 | #define ff_vmrglw ff_vmrglw
|
---|
73 | */
|
---|
74 | #undef vec_mergel
|
---|
75 |
|
---|
76 | #define vec_mergel(a1, a2) \
|
---|
77 | __ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
|
---|
78 | ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
|
---|
79 | __ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
|
---|
80 | ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
|
---|
81 | __ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
|
---|
82 | ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
|
---|
83 | __ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
|
---|
84 | ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
|
---|
85 | __ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
|
---|
86 | ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
|
---|
87 | __ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
|
---|
88 | ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
|
---|
89 | __ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
|
---|
90 | ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
|
---|
91 | __altivec_link_error_invalid_argument ())))))))
|
---|
92 |
|
---|
93 | #endif
|
---|
94 |
|
---|
95 | #endif /* CONFIG_DARWIN */
|
---|
96 |
|
---|
97 | #ifndef __MWERKS__
|
---|
98 | #define const_vector const vector
|
---|
99 | #else
|
---|
100 | #define const_vector vector
|
---|
101 | #endif
|
---|
102 |
|
---|
103 | #endif /* _GCC_FIXES_ */
|
---|