2008-10-27 00:25:06 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2008 Mans Rullgard <mans@mansr.com>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2008-12-30 03:13:52 +00:00
|
|
|
#include "config.h"
|
|
|
|
|
2009-07-27 12:53:44 +00:00
|
|
|
#ifdef __ELF__
|
2009-07-27 22:55:55 +00:00
|
|
|
# define ELF
|
|
|
|
#else
|
|
|
|
# define ELF @
|
2011-06-14 10:29:48 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if CONFIG_THUMB
|
|
|
|
# define A @
|
|
|
|
# define T
|
|
|
|
#else
|
|
|
|
# define A
|
|
|
|
# define T @
|
2009-07-27 12:53:44 +00:00
|
|
|
#endif
|
2009-07-27 22:55:55 +00:00
|
|
|
|
2014-05-30 07:58:43 +00:00
|
|
|
#if HAVE_AS_FUNC
|
|
|
|
# define FUNC
|
|
|
|
#else
|
|
|
|
# define FUNC @
|
|
|
|
#endif
|
|
|
|
|
2016-07-18 20:23:50 +00:00
|
|
|
#if HAVE_AS_FPU_DIRECTIVE
|
|
|
|
# define FPU
|
|
|
|
#else
|
|
|
|
# define FPU @
|
|
|
|
#endif
|
|
|
|
|
2018-10-12 10:29:51 +00:00
|
|
|
#if CONFIG_THUMB && defined(__APPLE__)
|
|
|
|
# define TFUNC
|
|
|
|
#else
|
|
|
|
# define TFUNC @
|
|
|
|
#endif
|
|
|
|
|
2017-05-03 08:18:51 +00:00
|
|
|
#if HAVE_AS_ARCH_DIRECTIVE
|
2011-11-15 01:15:52 +00:00
|
|
|
#if HAVE_NEON
|
|
|
|
.arch armv7-a
|
|
|
|
#elif HAVE_ARMV6T2
|
|
|
|
.arch armv6t2
|
|
|
|
#elif HAVE_ARMV6
|
|
|
|
.arch armv6
|
|
|
|
#elif HAVE_ARMV5TE
|
|
|
|
.arch armv5te
|
|
|
|
#endif
|
2017-05-03 08:18:51 +00:00
|
|
|
#endif
|
2015-02-17 22:40:06 +00:00
|
|
|
#if HAVE_AS_OBJECT_ARCH
|
|
|
|
ELF .object_arch armv4
|
|
|
|
#endif
|
2011-11-15 01:15:52 +00:00
|
|
|
|
|
|
|
#if HAVE_NEON
|
2016-07-18 20:23:50 +00:00
|
|
|
FPU .fpu neon
|
2015-02-17 22:40:06 +00:00
|
|
|
ELF .eabi_attribute 10, 0 @ suppress Tag_FP_arch
|
|
|
|
ELF .eabi_attribute 12, 0 @ suppress Tag_Advanced_SIMD_arch
|
2012-12-04 23:29:34 +00:00
|
|
|
#elif HAVE_VFP
|
2016-07-18 20:23:50 +00:00
|
|
|
FPU .fpu vfp
|
2015-02-17 22:40:06 +00:00
|
|
|
ELF .eabi_attribute 10, 0 @ suppress Tag_FP_arch
|
2011-11-15 01:15:52 +00:00
|
|
|
#endif
|
|
|
|
|
2011-05-29 13:22:52 +00:00
|
|
|
.syntax unified
|
2011-06-14 10:29:48 +00:00
|
|
|
T .thumb
|
2012-10-02 23:42:57 +00:00
|
|
|
ELF .eabi_attribute 25, 1 @ Tag_ABI_align_preserved
|
2014-02-07 14:22:54 +00:00
|
|
|
ELF .section .note.GNU-stack,"",%progbits @ Mark stack as non-executable
|
2008-10-27 00:25:06 +00:00
|
|
|
|
2014-01-07 10:13:11 +00:00
|
|
|
.macro function name, export=0, align=2
|
2012-06-29 12:35:08 +00:00
|
|
|
.set .Lpic_idx, 0
|
|
|
|
.set .Lpic_gp, 0
|
2010-06-29 14:48:41 +00:00
|
|
|
.macro endfunc
|
2012-06-29 12:35:08 +00:00
|
|
|
.if .Lpic_idx
|
2012-09-20 21:53:41 +00:00
|
|
|
.align 2
|
2012-06-29 12:35:08 +00:00
|
|
|
.altmacro
|
|
|
|
put_pic %(.Lpic_idx - 1)
|
|
|
|
.noaltmacro
|
|
|
|
.endif
|
2016-11-14 10:32:20 +00:00
|
|
|
.if .Lpic_gp
|
|
|
|
.unreq gp
|
|
|
|
.endif
|
2010-03-10 21:39:58 +00:00
|
|
|
ELF .size \name, . - \name
|
2014-05-30 07:58:43 +00:00
|
|
|
FUNC .endfunc
|
2010-03-09 16:17:56 +00:00
|
|
|
.purgem endfunc
|
2010-06-29 14:48:41 +00:00
|
|
|
.endm
|
2010-07-07 20:09:41 +00:00
|
|
|
.text
|
2014-01-07 10:13:11 +00:00
|
|
|
.align \align
|
2010-06-29 14:48:41 +00:00
|
|
|
.if \export
|
2009-10-02 08:42:00 +00:00
|
|
|
.global EXTERN_ASM\name
|
2014-02-04 14:28:24 +00:00
|
|
|
ELF .type EXTERN_ASM\name, %function
|
2014-05-30 07:58:43 +00:00
|
|
|
FUNC .func EXTERN_ASM\name
|
2018-10-12 10:29:51 +00:00
|
|
|
TFUNC .thumb_func EXTERN_ASM\name
|
2009-10-02 08:42:00 +00:00
|
|
|
EXTERN_ASM\name:
|
2014-02-04 14:28:24 +00:00
|
|
|
.else
|
2009-07-27 22:55:55 +00:00
|
|
|
ELF .type \name, %function
|
2014-05-30 07:58:43 +00:00
|
|
|
FUNC .func \name
|
2018-10-12 10:29:51 +00:00
|
|
|
TFUNC .thumb_func \name
|
2008-10-27 00:25:06 +00:00
|
|
|
\name:
|
2014-02-04 14:28:24 +00:00
|
|
|
.endif
|
2010-06-29 14:48:41 +00:00
|
|
|
.endm
|
2008-12-30 03:13:52 +00:00
|
|
|
|
2014-11-16 10:51:54 +00:00
|
|
|
.macro const name, align=2, relocate=0
|
2011-01-26 22:26:51 +00:00
|
|
|
.macro endconst
|
|
|
|
ELF .size \name, . - \name
|
|
|
|
.purgem endconst
|
|
|
|
.endm
|
2018-03-30 09:33:46 +00:00
|
|
|
#if HAVE_SECTION_DATA_REL_RO
|
|
|
|
.if \relocate
|
2014-11-16 10:51:54 +00:00
|
|
|
.section .data.rel.ro
|
|
|
|
.else
|
2011-01-26 22:26:51 +00:00
|
|
|
.section .rodata
|
2014-11-16 10:51:54 +00:00
|
|
|
.endif
|
2019-01-11 13:23:16 +00:00
|
|
|
#elif defined(_WIN32)
|
|
|
|
.section .rdata
|
2018-03-30 09:33:46 +00:00
|
|
|
#elif !defined(__MACH__)
|
|
|
|
.section .rodata
|
|
|
|
#else
|
|
|
|
.const_data
|
|
|
|
#endif
|
2011-01-26 22:26:51 +00:00
|
|
|
.align \align
|
|
|
|
\name:
|
|
|
|
.endm
|
|
|
|
|
2012-12-01 16:41:39 +00:00
|
|
|
#if !HAVE_ARMV6T2_EXTERNAL
|
2012-03-20 17:04:54 +00:00
|
|
|
.macro movw rd, val
|
|
|
|
mov \rd, \val & 255
|
|
|
|
orr \rd, \val & ~255
|
|
|
|
.endm
|
|
|
|
#endif
|
|
|
|
|
2010-06-29 14:48:45 +00:00
|
|
|
.macro mov32 rd, val
|
2012-12-01 16:41:39 +00:00
|
|
|
#if HAVE_ARMV6T2_EXTERNAL
|
2010-06-29 14:48:45 +00:00
|
|
|
movw \rd, #(\val) & 0xffff
|
|
|
|
.if (\val) >> 16
|
|
|
|
movt \rd, #(\val) >> 16
|
|
|
|
.endif
|
|
|
|
#else
|
|
|
|
ldr \rd, =\val
|
|
|
|
#endif
|
|
|
|
.endm
|
|
|
|
|
2012-06-29 12:35:08 +00:00
|
|
|
.macro put_pic num
|
|
|
|
put_pic_\num
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro do_def_pic num, val, label
|
|
|
|
.macro put_pic_\num
|
|
|
|
.if \num
|
|
|
|
.altmacro
|
|
|
|
put_pic %(\num - 1)
|
|
|
|
.noaltmacro
|
|
|
|
.endif
|
|
|
|
\label: .word \val
|
|
|
|
.purgem put_pic_\num
|
|
|
|
.endm
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro def_pic val, label
|
|
|
|
.altmacro
|
|
|
|
do_def_pic %.Lpic_idx, \val, \label
|
|
|
|
.noaltmacro
|
|
|
|
.set .Lpic_idx, .Lpic_idx + 1
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro ldpic rd, val, indir=0
|
|
|
|
ldr \rd, .Lpicoff\@
|
|
|
|
.Lpic\@:
|
|
|
|
.if \indir
|
2012-10-01 23:32:24 +00:00
|
|
|
A ldr \rd, [pc, \rd]
|
|
|
|
T add \rd, pc
|
|
|
|
T ldr \rd, [\rd]
|
2012-06-29 12:35:08 +00:00
|
|
|
.else
|
2012-09-20 21:55:11 +00:00
|
|
|
add \rd, pc
|
2012-06-29 12:35:08 +00:00
|
|
|
.endif
|
|
|
|
def_pic \val - (.Lpic\@ + (8 >> CONFIG_THUMB)), .Lpicoff\@
|
|
|
|
.endm
|
|
|
|
|
2010-06-29 14:48:41 +00:00
|
|
|
.macro movrel rd, val
|
2012-06-29 12:35:08 +00:00
|
|
|
#if CONFIG_PIC
|
|
|
|
ldpic \rd, \val
|
2012-12-01 16:41:39 +00:00
|
|
|
#elif HAVE_ARMV6T2_EXTERNAL && !defined(__APPLE__)
|
2008-12-30 03:13:52 +00:00
|
|
|
movw \rd, #:lower16:\val
|
|
|
|
movt \rd, #:upper16:\val
|
|
|
|
#else
|
|
|
|
ldr \rd, =\val
|
|
|
|
#endif
|
2010-06-29 14:48:41 +00:00
|
|
|
.endm
|
2009-07-20 22:30:24 +00:00
|
|
|
|
2012-06-29 12:35:08 +00:00
|
|
|
.macro movrelx rd, val, gp
|
2016-11-18 20:06:40 +00:00
|
|
|
.ifc \rd,\gp
|
|
|
|
.error "movrelx needs two distinct registers"
|
|
|
|
.endif
|
|
|
|
.ifc \rd\()_\gp,r12_
|
|
|
|
.warning "movrelx rd=\rd without explicit set gp"
|
|
|
|
.endif
|
|
|
|
.ifc \rd\()_\gp,ip_
|
|
|
|
.warning "movrelx rd=\rd without explicit set gp"
|
|
|
|
.endif
|
2012-06-29 12:35:08 +00:00
|
|
|
#if CONFIG_PIC && defined(__ELF__)
|
|
|
|
.ifnb \gp
|
|
|
|
.if .Lpic_gp
|
|
|
|
.unreq gp
|
|
|
|
.endif
|
|
|
|
gp .req \gp
|
|
|
|
ldpic gp, _GLOBAL_OFFSET_TABLE_
|
|
|
|
.elseif !.Lpic_gp
|
|
|
|
gp .req r12
|
|
|
|
ldpic gp, _GLOBAL_OFFSET_TABLE_
|
|
|
|
.endif
|
|
|
|
.set .Lpic_gp, 1
|
|
|
|
ldr \rd, .Lpicoff\@
|
|
|
|
ldr \rd, [gp, \rd]
|
|
|
|
def_pic \val(GOT), .Lpicoff\@
|
|
|
|
#elif CONFIG_PIC && defined(__APPLE__)
|
|
|
|
ldpic \rd, .Lpic\@, indir=1
|
|
|
|
.non_lazy_symbol_pointer
|
|
|
|
.Lpic\@:
|
|
|
|
.indirect_symbol \val
|
|
|
|
.word 0
|
|
|
|
.text
|
|
|
|
#else
|
|
|
|
movrel \rd, \val
|
|
|
|
#endif
|
|
|
|
.endm
|
|
|
|
|
2012-07-05 21:47:41 +00:00
|
|
|
.macro add_sh rd, rn, rm, sh:vararg
|
|
|
|
A add \rd, \rn, \rm, \sh
|
|
|
|
T mov \rm, \rm, \sh
|
|
|
|
T add \rd, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
2011-06-14 10:29:48 +00:00
|
|
|
.macro ldr_pre rt, rn, rm:vararg
|
|
|
|
A ldr \rt, [\rn, \rm]!
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
T ldr \rt, [\rn]
|
|
|
|
.endm
|
|
|
|
|
2011-12-08 04:26:12 +00:00
|
|
|
.macro ldr_dpre rt, rn, rm:vararg
|
|
|
|
A ldr \rt, [\rn, -\rm]!
|
|
|
|
T sub \rn, \rn, \rm
|
|
|
|
T ldr \rt, [\rn]
|
2011-08-24 20:58:37 +00:00
|
|
|
.endm
|
|
|
|
|
2012-03-20 17:04:54 +00:00
|
|
|
.macro ldr_nreg rt, rn, rm:vararg
|
2011-12-15 16:24:43 +00:00
|
|
|
A ldr \rt, [\rn, -\rm]
|
|
|
|
T sub \rt, \rn, \rm
|
|
|
|
T ldr \rt, [\rt]
|
|
|
|
.endm
|
|
|
|
|
2011-06-14 10:29:48 +00:00
|
|
|
.macro ldr_post rt, rn, rm:vararg
|
|
|
|
A ldr \rt, [\rn], \rm
|
|
|
|
T ldr \rt, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
2014-03-05 11:44:57 +00:00
|
|
|
.macro ldrc_pre cc, rt, rn, rm:vararg
|
|
|
|
A ldr\cc \rt, [\rn, \rm]!
|
|
|
|
T itt \cc
|
|
|
|
T add\cc \rn, \rn, \rm
|
|
|
|
T ldr\cc \rt, [\rn]
|
|
|
|
.endm
|
|
|
|
|
2011-06-14 10:29:48 +00:00
|
|
|
.macro ldrd_reg rt, rt2, rn, rm
|
|
|
|
A ldrd \rt, \rt2, [\rn, \rm]
|
|
|
|
T add \rt, \rn, \rm
|
|
|
|
T ldrd \rt, \rt2, [\rt]
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro ldrd_post rt, rt2, rn, rm
|
|
|
|
A ldrd \rt, \rt2, [\rn], \rm
|
|
|
|
T ldrd \rt, \rt2, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro ldrh_pre rt, rn, rm
|
|
|
|
A ldrh \rt, [\rn, \rm]!
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
T ldrh \rt, [\rn]
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro ldrh_dpre rt, rn, rm
|
|
|
|
A ldrh \rt, [\rn, -\rm]!
|
|
|
|
T sub \rn, \rn, \rm
|
|
|
|
T ldrh \rt, [\rn]
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro ldrh_post rt, rn, rm
|
|
|
|
A ldrh \rt, [\rn], \rm
|
|
|
|
T ldrh \rt, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
2011-08-24 20:58:37 +00:00
|
|
|
.macro ldrb_post rt, rn, rm
|
|
|
|
A ldrb \rt, [\rn], \rm
|
|
|
|
T ldrb \rt, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
2011-06-14 10:29:48 +00:00
|
|
|
.macro str_post rt, rn, rm:vararg
|
|
|
|
A str \rt, [\rn], \rm
|
|
|
|
T str \rt, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro strb_post rt, rn, rm:vararg
|
|
|
|
A strb \rt, [\rn], \rm
|
|
|
|
T strb \rt, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro strd_post rt, rt2, rn, rm
|
|
|
|
A strd \rt, \rt2, [\rn], \rm
|
|
|
|
T strd \rt, \rt2, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro strh_pre rt, rn, rm
|
|
|
|
A strh \rt, [\rn, \rm]!
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
T strh \rt, [\rn]
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro strh_dpre rt, rn, rm
|
|
|
|
A strh \rt, [\rn, -\rm]!
|
|
|
|
T sub \rn, \rn, \rm
|
|
|
|
T strh \rt, [\rn]
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro strh_post rt, rn, rm
|
|
|
|
A strh \rt, [\rn], \rm
|
|
|
|
T strh \rt, [\rn]
|
|
|
|
T add \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
|
|
|
.macro strh_dpost rt, rn, rm
|
|
|
|
A strh \rt, [\rn], -\rm
|
|
|
|
T strh \rt, [\rn]
|
|
|
|
T sub \rn, \rn, \rm
|
|
|
|
.endm
|
|
|
|
|
2009-07-20 22:30:24 +00:00
|
|
|
#if HAVE_VFP_ARGS
|
2013-05-26 09:47:33 +00:00
|
|
|
ELF .eabi_attribute 28, 1
|
2009-07-20 22:30:24 +00:00
|
|
|
# define VFP
|
|
|
|
# define NOVFP @
|
|
|
|
#else
|
|
|
|
# define VFP @
|
|
|
|
# define NOVFP
|
|
|
|
#endif
|
2009-10-02 08:42:00 +00:00
|
|
|
|
|
|
|
#define GLUE(a, b) a ## b
|
|
|
|
#define JOIN(a, b) GLUE(a, b)
|
|
|
|
#define X(s) JOIN(EXTERN_ASM, s)
|