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.
6 * This file is part of FFmpeg.
8 * FFmpeg is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * FFmpeg is distributed in the hope that it will be useful,
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.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with FFmpeg; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #ifndef FFMPEG_GCC_FIXES_H
24 #define FFMPEG_GCC_FIXES_H
33 # define REG_v(a) asm ( #a )
36 #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
38 /* This code was provided to me by Bartosch Pixa
39 * as a separate header file (broken_mergel.h).
40 * thanks to lu_zero for the workaround.
42 * See this mail for more information:
43 * http://gcc.gnu.org/ml/gcc/2003-04/msg00967.html
46 static inline vector signed char ff_vmrglb (vector signed char const A,
47 vector signed char const B)
49 static const vector unsigned char lowbyte = {
50 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
51 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
53 return vec_perm (A, B, lowbyte);
56 static inline vector signed short ff_vmrglh (vector signed short const A,
57 vector signed short const B)
59 static const vector unsigned char lowhalf = {
60 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
61 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
63 return vec_perm (A, B, lowhalf);
66 static inline vector signed int ff_vmrglw (vector signed int const A,
67 vector signed int const B)
69 static const vector unsigned char lowword = {
70 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
71 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
73 return vec_perm (A, B, lowword);
75 /*#define ff_vmrglb ff_vmrglb
76 #define ff_vmrglh ff_vmrglh
77 #define ff_vmrglw ff_vmrglw
81 #define vec_mergel(a1, a2) \
82 __ch (__bin_args_eq (vector signed char, (a1), vector signed char, (a2)), \
83 ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
84 __ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
85 ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
86 __ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
87 ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
88 __ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
89 ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
90 __ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
91 ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
92 __ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
93 ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
94 __ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
95 ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
96 __altivec_link_error_invalid_argument ())))))))
100 #endif /* FFMPEG_GCC_FIXES_H */