Imported Debian version 2.4.3~trusty1
[deb_ffmpeg.git] / ffmpeg / libavcodec / ppc / asm.S
CommitLineData
2ba45a60
DM
1/*
2 * Copyright (c) 2009 Loren Merritt
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "config.h"
22
23#define GLUE(a, b) a ## b
24#define JOIN(a, b) GLUE(a, b)
25#define X(s) JOIN(EXTERN_ASM, s)
26
27#if ARCH_PPC64
28
29#define PTR .quad
30#define lp ld
31#define lpx ldx
32#define stp std
33#define stpu stdu
34#define PS 8
35#define L(s) JOIN(., s)
36
37.macro extfunc name
38 .global X(\name)
39#if _CALL_ELF == 2
40 .text
41X(\name):
42 addis %r2, %r12, .TOC.-X(\name)@ha
43 addi %r2, %r2, .TOC.-X(\name)@l
44 .localentry X(\name), .-X(\name)
45#else
46 .section .opd, "aw"
47X(\name):
48 .quad L(\name), .TOC.@tocbase, 0
49 .previous
50 .type X(\name), STT_FUNC
51L(\name):
52#endif
53.endm
54
55.macro movrel rd, sym, gp
56 ld \rd, \sym@got(r2)
57.endm
58
59.macro get_got rd
60.endm
61
62#else /* ARCH_PPC64 */
63
64#define PTR .int
65#define lp lwz
66#define lpx lwzx
67#define stp stw
68#define stpu stwu
69#define PS 4
70#define L(s) s
71
72.macro extfunc name
73 .global X(\name)
74 .type X(\name), STT_FUNC
75X(\name):
76\name:
77.endm
78
79.macro movrel rd, sym, gp
80#if CONFIG_PIC
81 lwz \rd, \sym@got(\gp)
82#else
83 lis \rd, \sym@ha
84 la \rd, \sym@l(\rd)
85#endif
86.endm
87
88.macro get_got rd
89#if CONFIG_PIC
90 bcl 20, 31, .Lgot\@
91.Lgot\@:
92 mflr \rd
93 addis \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@ha
94 addi \rd, \rd, _GLOBAL_OFFSET_TABLE_ - .Lgot\@@l
95#endif
96.endm
97
98#endif /* ARCH_PPC64 */
99
100#if HAVE_IBM_ASM
101
102.macro DEFINE_REG n
103 .equiv r\n, \n
104 .equiv f\n, \n
105 .equiv v\n, \n
106.endm
107
108DEFINE_REG 0
109DEFINE_REG 1
110DEFINE_REG 2
111DEFINE_REG 3
112DEFINE_REG 4
113DEFINE_REG 5
114DEFINE_REG 6
115DEFINE_REG 7
116DEFINE_REG 8
117DEFINE_REG 9
118DEFINE_REG 10
119DEFINE_REG 11
120DEFINE_REG 12
121DEFINE_REG 13
122DEFINE_REG 14
123DEFINE_REG 15
124DEFINE_REG 16
125DEFINE_REG 17
126DEFINE_REG 18
127DEFINE_REG 19
128DEFINE_REG 20
129DEFINE_REG 21
130DEFINE_REG 22
131DEFINE_REG 23
132DEFINE_REG 24
133DEFINE_REG 25
134DEFINE_REG 26
135DEFINE_REG 27
136DEFINE_REG 28
137DEFINE_REG 29
138DEFINE_REG 30
139DEFINE_REG 31
140
141#endif /* HAVE_IBM_ASM */