]> git.sesse.net Git - x264/blob - common/aarch64/asm.S
aarch64: pixel metrics NEON asm
[x264] / common / aarch64 / asm.S
1 /*****************************************************************************
2  * asm.S: AArch64 utility macros
3  *****************************************************************************
4  * Copyright (C) 2008-2014 x264 project
5  *
6  * Authors: Mans Rullgard <mans@mansr.com>
7  *          David Conrad <lessen42@gmail.com>
8  *          Janne Grunau <janne-x264@jannau.net>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111, USA.
23  *
24  * This program is also available under a commercial proprietary license.
25  * For more information, contact us at licensing@x264.com.
26  *****************************************************************************/
27
28 #include "config.h"
29
30 #ifdef PREFIX
31 #   define EXTERN_ASM _
32 #else
33 #   define EXTERN_ASM
34 #endif
35
36 #ifdef __ELF__
37 #   define ELF
38 #else
39 #   define ELF  #
40 #endif
41
42 #ifdef __MACH__
43 #   define MACH
44 #else
45 #   define MACH #
46 #endif
47
48 #if HAVE_AS_FUNC
49 #   define FUNC
50 #else
51 #   define FUNC #
52 #endif
53
54 .macro  function name, export=0, align=2
55     .macro endfunc
56 ELF     .size   \name, . - \name
57 FUNC    .endfunc
58         .purgem endfunc
59     .endm
60         .text
61         .align          \align
62     .if \export
63         .global EXTERN_ASM\name
64 ELF     .type   EXTERN_ASM\name, %function
65 FUNC    .func   EXTERN_ASM\name
66 EXTERN_ASM\name:
67     .else
68 ELF     .type   \name, %function
69 FUNC    .func   \name
70 \name:
71     .endif
72 .endm
73
74 .macro  const   name, align=2
75     .macro endconst
76 ELF     .size   \name, . - \name
77         .purgem endconst
78     .endm
79 ELF     .section        .rodata
80 MACH    .const_data
81         .align          \align
82 \name:
83 .endm
84
85 .macro  movrel rd, val
86 #if defined(PIC) && defined(__APPLE__)
87         adrp            \rd, \val@PAGE
88         add             \rd, \rd, \val@PAGEOFF
89 #elif defined(PIC)
90         adrp            \rd, \val
91         add             \rd, \rd, :lo12:\val
92 #else
93         ldr             \rd, =\val
94 #endif
95 .endm
96
97 #define GLUE(a, b) a ## b
98 #define JOIN(a, b) GLUE(a, b)
99 #define X(s) JOIN(EXTERN_ASM, s)
100
101 #define FDEC_STRIDE 32
102 #define FENC_STRIDE 16
103
104
105 .macro SUMSUB_AB   sum, sub, a, b
106     add        \sum,  \a,  \b
107     sub        \sub,  \a,  \b
108 .endm
109
110 .macro transpose t1, t2, s1, s2
111     trn1        \t1,  \s1,  \s2
112     trn2        \t2,  \s1,  \s2
113 .endm