Commit | Line | Data |
---|---|---|
a9a07762 MN |
1 | /* |
2 | * gcc fixes for altivec. | |
115329f1 | 3 | * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3) |
a9a07762 | 4 | * and to stay somewhat compatible with Darwin. |
04d7f601 | 5 | * |
b78e7197 DB |
6 | * This file is part of FFmpeg. |
7 | * | |
8 | * FFmpeg is free software; you can redistribute it and/or | |
04d7f601 DB |
9 | * modify it under the terms of the GNU Lesser General Public |
10 | * License as published by the Free Software Foundation; either | |
b78e7197 | 11 | * version 2.1 of the License, or (at your option) any later version. |
04d7f601 | 12 | * |
b78e7197 | 13 | * FFmpeg is distributed in the hope that it will be useful, |
04d7f601 DB |
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
16 | * Lesser General Public License for more details. | |
17 | * | |
18 | * You should have received a copy of the GNU Lesser General Public | |
b78e7197 | 19 | * License along with FFmpeg; if not, write to the Free Software |
04d7f601 | 20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
a9a07762 MN |
21 | */ |
22 | ||
5b21bdab DB |
23 | #ifndef FFMPEG_GCC_FIXES_H |
24 | #define FFMPEG_GCC_FIXES_H | |
a9a07762 | 25 | |
35562dc9 DB |
26 | #include "config.h" |
27 | ||
a9a07762 MN |
28 | #ifdef HAVE_ALTIVEC_H |
29 | #include <altivec.h> | |
30 | #endif | |
31 | ||
a01e08ee | 32 | #if (__GNUC__ < 4) |
a01e08ee | 33 | # define REG_v(a) |
fd925db3 LB |
34 | #else |
35 | # define REG_v(a) asm ( #a ) | |
a01e08ee LB |
36 | #endif |
37 | ||
115329f1 | 38 | #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303) |
a9a07762 MN |
39 | |
40 | /* This code was provided to me by Bartosch Pixa | |
41 | * as a separate header file (broken_mergel.h). | |
42 | * thanks to lu_zero for the workaround. | |
43 | * | |
44 | * See this mail for more information: | |
45 | * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html | |
46 | */ | |
47 | ||
782b80d9 | 48 | static inline vector signed char ff_vmrglb (vector signed char const A, |
bb270c08 | 49 | vector signed char const B) |
a9a07762 MN |
50 | { |
51 | static const vector unsigned char lowbyte = { | |
bb270c08 DB |
52 | 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b, |
53 | 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f | |
a9a07762 MN |
54 | }; |
55 | return vec_perm (A, B, lowbyte); | |
56 | } | |
57 | ||
782b80d9 | 58 | static inline vector signed short ff_vmrglh (vector signed short const A, |
bb270c08 | 59 | vector signed short const B) |
a9a07762 MN |
60 | { |
61 | static const vector unsigned char lowhalf = { | |
bb270c08 DB |
62 | 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b, |
63 | 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f | |
a9a07762 MN |
64 | }; |
65 | return vec_perm (A, B, lowhalf); | |
66 | } | |
67 | ||
782b80d9 | 68 | static inline vector signed int ff_vmrglw (vector signed int const A, |
bb270c08 | 69 | vector signed int const B) |
a9a07762 MN |
70 | { |
71 | static const vector unsigned char lowword = { | |
bb270c08 DB |
72 | 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b, |
73 | 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f | |
a9a07762 MN |
74 | }; |
75 | return vec_perm (A, B, lowword); | |
76 | } | |
115329f1 DB |
77 | /*#define ff_vmrglb ff_vmrglb |
78 | #define ff_vmrglh ff_vmrglh | |
79 | #define ff_vmrglw ff_vmrglw | |
a9a07762 MN |
80 | */ |
81 | #undef vec_mergel | |
82 | ||
83 | #define vec_mergel(a1, a2) \ | |
84 | __ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \ | |
782b80d9 | 85 | ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \ |
a9a07762 | 86 | __ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \ |
782b80d9 | 87 | ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \ |
a9a07762 | 88 | __ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \ |
782b80d9 | 89 | ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \ |
a9a07762 | 90 | __ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \ |
782b80d9 | 91 | ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \ |
a9a07762 | 92 | __ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \ |
782b80d9 | 93 | ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \ |
a9a07762 | 94 | __ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \ |
782b80d9 | 95 | ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \ |
a9a07762 | 96 | __ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \ |
782b80d9 | 97 | ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \ |
a9a07762 MN |
98 | __altivec_link_error_invalid_argument ()))))))) |
99 | ||
100 | #endif | |
101 | ||
5b21bdab | 102 | #endif /* FFMPEG_GCC_FIXES_H */ |