arm: Add EXTERN_ASM to the .func and .type declarations for exported symbols
[libav.git] / libavutil / arm / asm.S
CommitLineData
c72ab301
MR
1/*
2 * Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
3 *
2912e87a 4 * This file is part of Libav.
c72ab301 5 *
2912e87a 6 * Libav is free software; you can redistribute it and/or
c72ab301
MR
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 *
2912e87a 11 * Libav is distributed in the hope that it will be useful,
c72ab301
MR
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
2912e87a 17 * License along with Libav; if not, write to the Free Software
c72ab301
MR
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
172a39d1
MR
21#include "config.h"
22
e21a8921 23#ifdef __ELF__
341f394f
MR
24# define ELF
25#else
26# define ELF @
e21a8921 27#endif
341f394f 28
8986fddc
MR
29#if CONFIG_THUMB
30# define A @
31# define T
32#else
33# define A
34# define T @
35#endif
36
8ee2b467
MR
37#if HAVE_NEON
38 .arch armv7-a
39#elif HAVE_ARMV6T2
40 .arch armv6t2
41#elif HAVE_ARMV6
42 .arch armv6
43#elif HAVE_ARMV5TE
44 .arch armv5te
45#endif
46
47#if HAVE_NEON
48 .fpu neon
b3267559 49#elif HAVE_VFP
8ee2b467
MR
50 .fpu vfp
51#endif
52
371266da 53 .syntax unified
8986fddc 54T .thumb
51a15ed7 55ELF .eabi_attribute 25, 1 @ Tag_ABI_align_preserved
c72ab301 56
5dae4872 57.macro function name, export=0, align=2
62634158
MR
58 .set .Lpic_idx, 0
59 .set .Lpic_gp, 0
480cb7ed 60 .macro endfunc
62634158 61 .if .Lpic_idx
cdb7db5a 62 .align 2
62634158
MR
63 .altmacro
64 put_pic %(.Lpic_idx - 1)
65 .noaltmacro
66 .endif
18c31f6f 67ELF .size \name, . - \name
a7e7d40c
MR
68 .endfunc
69 .purgem endfunc
480cb7ed 70 .endm
278caa6a 71 .text
5dae4872 72 .align \align
480cb7ed 73 .if \export
e654b7c2 74 .global EXTERN_ASM\name
e3fec3f0
MS
75ELF .type EXTERN_ASM\name, %function
76 .func EXTERN_ASM\name
e654b7c2 77EXTERN_ASM\name:
e3fec3f0 78 .else
341f394f 79ELF .type \name, %function
c72ab301
MR
80 .func \name
81\name:
e3fec3f0 82 .endif
480cb7ed 83.endm
172a39d1 84
b9a639dd
MR
85.macro const name, align=2
86 .macro endconst
87ELF .size \name, . - \name
88 .purgem endconst
89 .endm
90 .section .rodata
91 .align \align
92\name:
93.endm
94
a7831d50 95#if !HAVE_ARMV6T2_EXTERNAL
dac78fd1
MR
96.macro movw rd, val
97 mov \rd, \val & 255
98 orr \rd, \val & ~255
99.endm
100#endif
101
a4edc5a9 102.macro mov32 rd, val
a7831d50 103#if HAVE_ARMV6T2_EXTERNAL
a4edc5a9
MR
104 movw \rd, #(\val) & 0xffff
105 .if (\val) >> 16
106 movt \rd, #(\val) >> 16
107 .endif
108#else
109 ldr \rd, =\val
110#endif
111.endm
112
62634158
MR
113.macro put_pic num
114 put_pic_\num
115.endm
116
117.macro do_def_pic num, val, label
118 .macro put_pic_\num
119 .if \num
120 .altmacro
121 put_pic %(\num - 1)
122 .noaltmacro
123 .endif
124\label: .word \val
125 .purgem put_pic_\num
126 .endm
127.endm
128
129.macro def_pic val, label
130 .altmacro
131 do_def_pic %.Lpic_idx, \val, \label
132 .noaltmacro
133 .set .Lpic_idx, .Lpic_idx + 1
134.endm
135
136.macro ldpic rd, val, indir=0
137 ldr \rd, .Lpicoff\@
138.Lpic\@:
139 .if \indir
7bda4ed7
MR
140A ldr \rd, [pc, \rd]
141T add \rd, pc
142T ldr \rd, [\rd]
62634158 143 .else
8995d349 144 add \rd, pc
62634158
MR
145 .endif
146 def_pic \val - (.Lpic\@ + (8 >> CONFIG_THUMB)), .Lpicoff\@
147.endm
148
480cb7ed 149.macro movrel rd, val
62634158
MR
150#if CONFIG_PIC
151 ldpic \rd, \val
a7831d50 152#elif HAVE_ARMV6T2_EXTERNAL && !defined(__APPLE__)
172a39d1
MR
153 movw \rd, #:lower16:\val
154 movt \rd, #:upper16:\val
155#else
156 ldr \rd, =\val
157#endif
480cb7ed 158.endm
ce742de2 159
62634158
MR
160.macro movrelx rd, val, gp
161#if CONFIG_PIC && defined(__ELF__)
162 .ifnb \gp
163 .if .Lpic_gp
164 .unreq gp
165 .endif
166 gp .req \gp
167 ldpic gp, _GLOBAL_OFFSET_TABLE_
168 .elseif !.Lpic_gp
169 gp .req r12
170 ldpic gp, _GLOBAL_OFFSET_TABLE_
171 .endif
172 .set .Lpic_gp, 1
173 ldr \rd, .Lpicoff\@
174 ldr \rd, [gp, \rd]
175 def_pic \val(GOT), .Lpicoff\@
176#elif CONFIG_PIC && defined(__APPLE__)
177 ldpic \rd, .Lpic\@, indir=1
178 .non_lazy_symbol_pointer
179.Lpic\@:
180 .indirect_symbol \val
181 .word 0
182 .text
183#else
184 movrel \rd, \val
185#endif
186.endm
187
7689eea4
MR
188.macro add_sh rd, rn, rm, sh:vararg
189A add \rd, \rn, \rm, \sh
190T mov \rm, \rm, \sh
191T add \rd, \rn, \rm
192.endm
193
8986fddc
MR
194.macro ldr_pre rt, rn, rm:vararg
195A ldr \rt, [\rn, \rm]!
196T add \rn, \rn, \rm
197T ldr \rt, [\rn]
198.endm
199
71ce7602
MR
200.macro ldr_dpre rt, rn, rm:vararg
201A ldr \rt, [\rn, -\rm]!
202T sub \rn, \rn, \rm
203T ldr \rt, [\rn]
204.endm
205
dac78fd1
MR
206.macro ldr_nreg rt, rn, rm:vararg
207A ldr \rt, [\rn, -\rm]
208T sub \rt, \rn, \rm
209T ldr \rt, [\rt]
210.endm
211
8986fddc
MR
212.macro ldr_post rt, rn, rm:vararg
213A ldr \rt, [\rn], \rm
214T ldr \rt, [\rn]
215T add \rn, \rn, \rm
216.endm
217
218.macro ldrd_reg rt, rt2, rn, rm
219A ldrd \rt, \rt2, [\rn, \rm]
220T add \rt, \rn, \rm
221T ldrd \rt, \rt2, [\rt]
222.endm
223
224.macro ldrd_post rt, rt2, rn, rm
225A ldrd \rt, \rt2, [\rn], \rm
226T ldrd \rt, \rt2, [\rn]
227T add \rn, \rn, \rm
228.endm
229
230.macro ldrh_pre rt, rn, rm
231A ldrh \rt, [\rn, \rm]!
232T add \rn, \rn, \rm
233T ldrh \rt, [\rn]
234.endm
235
236.macro ldrh_dpre rt, rn, rm
237A ldrh \rt, [\rn, -\rm]!
238T sub \rn, \rn, \rm
239T ldrh \rt, [\rn]
240.endm
241
242.macro ldrh_post rt, rn, rm
243A ldrh \rt, [\rn], \rm
244T ldrh \rt, [\rn]
245T add \rn, \rn, \rm
246.endm
247
dac78fd1
MR
248.macro ldrb_post rt, rn, rm
249A ldrb \rt, [\rn], \rm
250T ldrb \rt, [\rn]
251T add \rn, \rn, \rm
252.endm
253
8986fddc
MR
254.macro str_post rt, rn, rm:vararg
255A str \rt, [\rn], \rm
256T str \rt, [\rn]
257T add \rn, \rn, \rm
258.endm
259
260.macro strb_post rt, rn, rm:vararg
261A strb \rt, [\rn], \rm
262T strb \rt, [\rn]
263T add \rn, \rn, \rm
264.endm
265
266.macro strd_post rt, rt2, rn, rm
267A strd \rt, \rt2, [\rn], \rm
268T strd \rt, \rt2, [\rn]
269T add \rn, \rn, \rm
270.endm
271
272.macro strh_pre rt, rn, rm
273A strh \rt, [\rn, \rm]!
274T add \rn, \rn, \rm
275T strh \rt, [\rn]
276.endm
277
278.macro strh_dpre rt, rn, rm
279A strh \rt, [\rn, -\rm]!
280T sub \rn, \rn, \rm
281T strh \rt, [\rn]
282.endm
283
284.macro strh_post rt, rn, rm
285A strh \rt, [\rn], \rm
286T strh \rt, [\rn]
287T add \rn, \rn, \rm
288.endm
289
290.macro strh_dpost rt, rn, rm
291A strh \rt, [\rn], -\rm
292T strh \rt, [\rn]
293T sub \rn, \rn, \rm
294.endm
295
ce742de2 296#if HAVE_VFP_ARGS
be7952b5 297ELF .eabi_attribute 28, 1
ce742de2
MR
298# define VFP
299# define NOVFP @
300#else
301# define VFP @
302# define NOVFP
303#endif
e654b7c2
MR
304
305#define GLUE(a, b) a ## b
306#define JOIN(a, b) GLUE(a, b)
307#define X(s) JOIN(EXTERN_ASM, s)