typo in the gcc handmade regalloc trigger
[libav.git] / libavcodec / ppc / gcc_fixes.h
CommitLineData
a9a07762
MN
1/*
2 * gcc fixes for altivec.
115329f1 3 * Used to workaround broken gcc (FSF gcc-3 pre gcc-3.3)
a9a07762
MN
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
aab34ca0
MN
15# ifndef __MWERKS__
16# define AVV(x...) (x)
17# else
18# define AVV
19# endif
a01e08ee 20#define REG_v(a) asm ( #a )
a9a07762 21#else
a01e08ee 22
a9a07762 23#define AVV(x...) {x}
a01e08ee
LB
24
25#if (__GNUC__ < 4)
a01e08ee 26# define REG_v(a)
fd925db3
LB
27#else
28# define REG_v(a) asm ( #a )
a01e08ee
LB
29#endif
30
115329f1 31#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303)
a9a07762
MN
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
782b80d9 41static inline vector signed char ff_vmrglb (vector signed char const A,
bb270c08 42 vector signed char const B)
a9a07762
MN
43{
44 static const vector unsigned char lowbyte = {
bb270c08
DB
45 0x08, 0x18, 0x09, 0x19, 0x0a, 0x1a, 0x0b, 0x1b,
46 0x0c, 0x1c, 0x0d, 0x1d, 0x0e, 0x1e, 0x0f, 0x1f
a9a07762
MN
47 };
48 return vec_perm (A, B, lowbyte);
49}
50
782b80d9 51static inline vector signed short ff_vmrglh (vector signed short const A,
bb270c08 52 vector signed short const B)
a9a07762
MN
53{
54 static const vector unsigned char lowhalf = {
bb270c08
DB
55 0x08, 0x09, 0x18, 0x19, 0x0a, 0x0b, 0x1a, 0x1b,
56 0x0c, 0x0d, 0x1c, 0x1d, 0x0e, 0x0f, 0x1e, 0x1f
a9a07762
MN
57 };
58 return vec_perm (A, B, lowhalf);
59}
60
782b80d9 61static inline vector signed int ff_vmrglw (vector signed int const A,
bb270c08 62 vector signed int const B)
a9a07762
MN
63{
64 static const vector unsigned char lowword = {
bb270c08
DB
65 0x08, 0x09, 0x0a, 0x0b, 0x18, 0x19, 0x1a, 0x1b,
66 0x0c, 0x0d, 0x0e, 0x0f, 0x1c, 0x1d, 0x1e, 0x1f
a9a07762
MN
67 };
68 return vec_perm (A, B, lowword);
69}
115329f1
DB
70/*#define ff_vmrglb ff_vmrglb
71#define ff_vmrglh ff_vmrglh
72#define ff_vmrglw ff_vmrglw
a9a07762
MN
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)), \
782b80d9 78 ((vector signed char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
a9a07762 79__ch (__bin_args_eq (vector unsigned char, (a1), vector unsigned char, (a2)), \
782b80d9 80 ((vector unsigned char) ff_vmrglb ((vector signed char) (a1), (vector signed char) (a2))), \
a9a07762 81__ch (__bin_args_eq (vector signed short, (a1), vector signed short, (a2)), \
782b80d9 82 ((vector signed short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
a9a07762 83__ch (__bin_args_eq (vector unsigned short, (a1), vector unsigned short, (a2)), \
782b80d9 84 ((vector unsigned short) ff_vmrglh ((vector signed short) (a1), (vector signed short) (a2))), \
a9a07762 85__ch (__bin_args_eq (vector float, (a1), vector float, (a2)), \
782b80d9 86 ((vector float) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
a9a07762 87__ch (__bin_args_eq (vector signed int, (a1), vector signed int, (a2)), \
782b80d9 88 ((vector signed int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
a9a07762 89__ch (__bin_args_eq (vector unsigned int, (a1), vector unsigned int, (a2)), \
782b80d9 90 ((vector unsigned int) ff_vmrglw ((vector signed int) (a1), (vector signed int) (a2))), \
a9a07762
MN
91 __altivec_link_error_invalid_argument ())))))))
92
93#endif
94
95#endif /* CONFIG_DARWIN */
96
aab34ca0
MN
97#ifndef __MWERKS__
98#define const_vector const vector
99#else
100#define const_vector vector
101#endif
102
a9a07762 103#endif /* _GCC_FIXES_ */