annotate i386/x86inc.asm @ 8241:585572f14e2c libavcodec

Remove unused RV40 spatial intra prediction function
author kostya
date Tue, 02 Dec 2008 17:34:26 +0000
parents 570c0c027998
children 4877d4c6d8ae
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
7541
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
1 ;*****************************************************************************
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
2 ;* x86inc.asm
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
3 ;*****************************************************************************
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
4 ;* Copyright (C) 2005-2008 Loren Merritt <lorenm@u.washington.edu>
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
5 ;*
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
6 ;* This file is part of FFmpeg.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
7 ;*
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
8 ;* FFmpeg is free software; you can redistribute it and/or
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
9 ;* modify it under the terms of the GNU Lesser General Public
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
10 ;* License as published by the Free Software Foundation; either
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
11 ;* version 2.1 of the License, or (at your option) any later version.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
12 ;*
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
13 ;* FFmpeg is distributed in the hope that it will be useful,
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
14 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
15 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
16 ;* Lesser General Public License for more details.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
17 ;*
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
18 ;* You should have received a copy of the GNU Lesser General Public
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
19 ;* License along with FFmpeg; if not, write to the Free Software
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
20 ;* 51, Inc., Foundation Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
21 ;*****************************************************************************
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
22
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
23 ; FIXME: All of the 64bit asm functions that take a stride as an argument
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
24 ; via register, assume that the high dword of that register is filled with 0.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
25 ; This is true in practice (since we never do any 64bit arithmetic on strides,
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
26 ; and x264's strides are all positive), but is not guaranteed by the ABI.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
27
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
28 ; Name of the .rodata section.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
29 ; Kludge: Something on OS X fails to align .rodata even given an align attribute,
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
30 ; so use a different read-only section.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
31 %macro SECTION_RODATA 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
32 %ifidn __OUTPUT_FORMAT__,macho64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
33 SECTION .text align=16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
34 %elifidn __OUTPUT_FORMAT__,macho
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
35 SECTION .text align=16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
36 fakegot:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
37 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
38 SECTION .rodata align=16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
39 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
40 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
41
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
42 ; PIC support macros. All these macros are totally harmless when PIC is
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
43 ; not defined but can ruin everything if misused in PIC mode. On x86_32, shared
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
44 ; objects cannot directly access global variables by address, they need to
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
45 ; go through the GOT (global offset table). Most OSes do not care about it
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
46 ; and let you load non-shared .so objects (Linux, Win32...). However, OS X
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
47 ; requires PIC code in its .dylib objects.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
48 ;
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
49 ; - GLOBAL should be used as a suffix for global addressing, eg.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
50 ; picgetgot ebx
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
51 ; mov eax, [foo GLOBAL]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
52 ; instead of
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
53 ; mov eax, [foo]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
54 ;
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
55 ; - picgetgot computes the GOT address into the given register in PIC
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
56 ; mode, otherwise does nothing. You need to do this before using GLOBAL.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
57 ; Before in both execution order and compiled code order (so GLOBAL knows
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
58 ; which register the GOT is in).
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
59
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
60 %ifndef PIC
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
61 %define GLOBAL
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
62 %macro picgetgot 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
63 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
64 %elifdef ARCH_X86_64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
65 %define PIC64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
66 %define GLOBAL wrt rip
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
67 %macro picgetgot 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
68 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
69 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
70 %define PIC32
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
71 %ifidn __OUTPUT_FORMAT__,macho
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
72 ; There is no real global offset table on OS X, but we still
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
73 ; need to reference our variables by offset.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
74 %macro picgetgot 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
75 call %%getgot
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
76 %%getgot:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
77 pop %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
78 add %1, $$ - %%getgot
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
79 %undef GLOBAL
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
80 %define GLOBAL + %1 - fakegot
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
81 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
82 %else ; elf
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
83 extern _GLOBAL_OFFSET_TABLE_
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
84 %macro picgetgot 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
85 call %%getgot
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
86 %%getgot:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
87 pop %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
88 add %1, _GLOBAL_OFFSET_TABLE_ + $$ - %%getgot wrt ..gotpc
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
89 %undef GLOBAL
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
90 %define GLOBAL + %1 wrt ..gotoff
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
91 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
92 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
93 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
94
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
95 ; Macros to eliminate most code duplication between x86_32 and x86_64:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
96 ; Currently this works only for leaf functions which load all their arguments
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
97 ; into registers at the start, and make no other use of the stack. Luckily that
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
98 ; covers most of x264's asm.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
99
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
100 ; PROLOGUE:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
101 ; %1 = number of arguments. loads them from stack if needed.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
102 ; %2 = number of registers used, not including PIC. pushes callee-saved regs if needed.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
103 ; %3 = whether global constants are used in this function. inits x86_32 PIC if needed.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
104 ; %4 = list of names to define to registers
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
105 ; PROLOGUE can also be invoked by adding the same options to cglobal
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
106
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
107 ; e.g.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
108 ; cglobal foo, 2,3,0, dst, src, tmp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
109 ; declares a function (foo), taking two args (dst and src), one local variable (tmp), and not using globals
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
110
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
111 ; TODO Some functions can use some args directly from the stack. If they're the
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
112 ; last args then you can just not declare them, but if they're in the middle
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
113 ; we need more flexible macro.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
114
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
115 ; RET:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
116 ; Pops anything that was pushed by PROLOGUE
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
117
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
118 ; REP_RET:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
119 ; Same, but if it doesn't pop anything it becomes a 2-byte ret, for athlons
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
120 ; which are slow when a normal ret follows a branch.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
121
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
122 %macro DECLARE_REG 6
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
123 %define r%1q %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
124 %define r%1d %3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
125 %define r%1w %4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
126 %define r%1b %5
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
127 %define r%1m %6
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
128 %define r%1 %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
129 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
130
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
131 %macro DECLARE_REG_SIZE 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
132 %define r%1q r%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
133 %define e%1q r%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
134 %define r%1d e%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
135 %define e%1d e%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
136 %define r%1w %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
137 %define e%1w %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
138 %define r%1b %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
139 %define e%1b %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
140 %ifndef ARCH_X86_64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
141 %define r%1 e%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
142 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
143 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
144
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
145 DECLARE_REG_SIZE ax, al
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
146 DECLARE_REG_SIZE bx, bl
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
147 DECLARE_REG_SIZE cx, cl
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
148 DECLARE_REG_SIZE dx, dl
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
149 DECLARE_REG_SIZE si, sil
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
150 DECLARE_REG_SIZE di, dil
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
151 DECLARE_REG_SIZE bp, bpl
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
152
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
153 %ifdef ARCH_X86_64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
154 %define gprsize 8
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
155 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
156 %define gprsize 4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
157 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
158
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
159 %macro PUSH 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
160 push %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
161 %assign stack_offset stack_offset+gprsize
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
162 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
163
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
164 %macro POP 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
165 pop %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
166 %assign stack_offset stack_offset-gprsize
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
167 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
168
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
169 %macro SUB 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
170 sub %1, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
171 %ifidn %1, rsp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
172 %assign stack_offset stack_offset+(%2)
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
173 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
174 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
175
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
176 %macro ADD 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
177 add %1, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
178 %ifidn %1, rsp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
179 %assign stack_offset stack_offset-(%2)
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
180 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
181 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
182
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
183 %macro movifnidn 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
184 %ifnidn %1, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
185 mov %1, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
186 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
187 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
188
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
189 %macro movsxdifnidn 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
190 %ifnidn %1, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
191 movsxd %1, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
192 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
193 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
194
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
195 %macro ASSERT 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
196 %if (%1) == 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
197 %error assert failed
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
198 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
199 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
200
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
201 %macro DEFINE_ARGS 0-*
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
202 %ifdef n_arg_names
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
203 %assign %%i 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
204 %rep n_arg_names
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
205 CAT_UNDEF arg_name %+ %%i, q
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
206 CAT_UNDEF arg_name %+ %%i, d
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
207 CAT_UNDEF arg_name %+ %%i, w
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
208 CAT_UNDEF arg_name %+ %%i, b
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
209 CAT_UNDEF arg_name, %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
210 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
211 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
212 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
213
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
214 %assign %%i 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
215 %rep %0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
216 %xdefine %1q r %+ %%i %+ q
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
217 %xdefine %1d r %+ %%i %+ d
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
218 %xdefine %1w r %+ %%i %+ w
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
219 %xdefine %1b r %+ %%i %+ b
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
220 CAT_XDEFINE arg_name, %%i, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
221 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
222 %rotate 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
223 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
224 %assign n_arg_names %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
225 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
226
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
227 %ifdef ARCH_X86_64 ;==========================================================
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
228 %ifidn __OUTPUT_FORMAT__,win32
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
229
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
230 DECLARE_REG 0, rcx, ecx, cx, cl, ecx
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
231 DECLARE_REG 1, rdx, edx, dx, dl, edx
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
232 DECLARE_REG 2, r8, r8d, r8w, r8b, r8d
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
233 DECLARE_REG 3, r9, r9d, r9w, r9b, r9d
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
234 DECLARE_REG 4, rdi, edi, di, dil, [rsp + stack_offset + 40]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
235 DECLARE_REG 5, rsi, esi, si, sil, [rsp + stack_offset + 48]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
236 DECLARE_REG 6, rax, eax, ax, al, [rsp + stack_offset + 56]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
237 %define r7m [rsp + stack_offset + 64]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
238 %define r8m [rsp + stack_offset + 72]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
239
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
240 %macro LOAD_IF_USED 2 ; reg_id, number_of_args
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
241 %if %1 < %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
242 mov r%1, [rsp + 8 + %1*8]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
243 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
244 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
245
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
246 %else ;=======================================================================
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
247
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
248 DECLARE_REG 0, rdi, edi, di, dil, edi
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
249 DECLARE_REG 1, rsi, esi, si, sil, esi
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
250 DECLARE_REG 2, rdx, edx, dx, dl, edx
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
251 DECLARE_REG 3, rcx, ecx, cx, cl, ecx
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
252 DECLARE_REG 4, r8, r8d, r8w, r8b, r8d
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
253 DECLARE_REG 5, r9, r9d, r9w, r9b, r9d
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
254 DECLARE_REG 6, rax, eax, ax, al, [rsp + stack_offset + 8]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
255 %define r7m [rsp + stack_offset + 16]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
256 %define r8m [rsp + stack_offset + 24]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
257
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
258 %macro LOAD_IF_USED 2 ; reg_id, number_of_args
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
259 %if %1 < %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
260 mov r%1, [rsp - 40 + %1*8]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
261 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
262 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
263
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
264 %endif ; !WIN64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
265
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
266 %macro PROLOGUE 2-4+ 0 ; #args, #regs, pic, arg_names...
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
267 ASSERT %2 >= %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
268 ASSERT %2 <= 7
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
269 %assign stack_offset 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
270 %ifidn __OUTPUT_FORMAT__,win32
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
271 LOAD_IF_USED 4, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
272 LOAD_IF_USED 5, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
273 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
274 LOAD_IF_USED 6, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
275 DEFINE_ARGS %4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
276 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
277
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
278 %macro RET 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
279 ret
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
280 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
281
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
282 %macro REP_RET 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
283 rep ret
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
284 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
285
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
286 %else ; X86_32 ;==============================================================
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
287
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
288 DECLARE_REG 0, eax, eax, ax, al, [esp + stack_offset + 4]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
289 DECLARE_REG 1, ecx, ecx, cx, cl, [esp + stack_offset + 8]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
290 DECLARE_REG 2, edx, edx, dx, dl, [esp + stack_offset + 12]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
291 DECLARE_REG 3, ebx, ebx, bx, bl, [esp + stack_offset + 16]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
292 DECLARE_REG 4, esi, esi, si, null, [esp + stack_offset + 20]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
293 DECLARE_REG 5, edi, edi, di, null, [esp + stack_offset + 24]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
294 DECLARE_REG 6, ebp, ebp, bp, null, [esp + stack_offset + 28]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
295 %define r7m [esp + stack_offset + 32]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
296 %define r8m [esp + stack_offset + 36]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
297 %define rsp esp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
298
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
299 %macro PUSH_IF_USED 1 ; reg_id
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
300 %if %1 < regs_used
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
301 push r%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
302 %assign stack_offset stack_offset+4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
303 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
304 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
305
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
306 %macro POP_IF_USED 1 ; reg_id
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
307 %if %1 < regs_used
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
308 pop r%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
309 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
310 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
311
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
312 %macro LOAD_IF_USED 2 ; reg_id, number_of_args
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
313 %if %1 < %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
314 mov r%1, [esp + stack_offset + 4 + %1*4]
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
315 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
316 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
317
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
318 %macro PROLOGUE 2-4+ 0 ; #args, #regs, pic, arg_names...
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
319 ASSERT %2 >= %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
320 %assign stack_offset 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
321 %assign regs_used %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
322 %ifdef PIC
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
323 %if %3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
324 %assign regs_used regs_used+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
325 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
326 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
327 ASSERT regs_used <= 7
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
328 PUSH_IF_USED 3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
329 PUSH_IF_USED 4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
330 PUSH_IF_USED 5
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
331 PUSH_IF_USED 6
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
332 LOAD_IF_USED 0, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
333 LOAD_IF_USED 1, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
334 LOAD_IF_USED 2, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
335 LOAD_IF_USED 3, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
336 LOAD_IF_USED 4, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
337 LOAD_IF_USED 5, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
338 LOAD_IF_USED 6, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
339 %if %3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
340 picgetgot r%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
341 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
342 DEFINE_ARGS %4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
343 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
344
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
345 %macro RET 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
346 POP_IF_USED 6
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
347 POP_IF_USED 5
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
348 POP_IF_USED 4
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
349 POP_IF_USED 3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
350 ret
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
351 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
352
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
353 %macro REP_RET 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
354 %if regs_used > 3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
355 RET
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
356 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
357 rep ret
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
358 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
359 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
360
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
361 %endif ;======================================================================
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
362
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
363
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
364
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
365 ;=============================================================================
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
366 ; arch-independent part
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
367 ;=============================================================================
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
368
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
369 %assign function_align 16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
370
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
371 ; Symbol prefix for C linkage
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
372 %macro cglobal 1-2+
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
373 %ifidn __OUTPUT_FORMAT__,elf
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
374 %ifdef PREFIX
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
375 global _%1:function hidden
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
376 %define %1 _%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
377 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
378 global %1:function hidden
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
379 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
380 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
381 %ifdef PREFIX
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
382 global _%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
383 %define %1 _%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
384 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
385 global %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
386 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
387 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
388 align function_align
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
389 %1:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
390 RESET_MM_PERMUTATION ; not really needed, but makes disassembly somewhat nicer
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
391 %if %0 > 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
392 PROLOGUE %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
393 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
394 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
395
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
396 %macro cextern 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
397 %ifdef PREFIX
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
398 extern _%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
399 %define %1 _%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
400 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
401 extern %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
402 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
403 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
404
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
405 ; This is needed for ELF, otherwise the GNU linker assumes the stack is
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
406 ; executable by default.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
407 %ifidn __OUTPUT_FORMAT__,elf
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
408 SECTION .note.GNU-stack noalloc noexec nowrite progbits
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
409 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
410
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
411 %assign FENC_STRIDE 16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
412 %assign FDEC_STRIDE 32
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
413
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
414 ; merge mmx and sse*
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
415
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
416 %macro CAT_XDEFINE 3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
417 %xdefine %1%2 %3
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
418 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
419
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
420 %macro CAT_UNDEF 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
421 %undef %1%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
422 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
423
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
424 %macro INIT_MMX 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
425 %define RESET_MM_PERMUTATION INIT_MMX
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
426 %define mmsize 8
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
427 %define num_mmregs 8
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
428 %define mova movq
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
429 %define movu movq
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
430 %define movh movd
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
431 %define movnt movntq
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
432 %assign %%i 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
433 %rep 8
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
434 CAT_XDEFINE m, %%i, mm %+ %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
435 CAT_XDEFINE nmm, %%i, %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
436 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
437 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
438 %rep 8
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
439 CAT_UNDEF m, %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
440 CAT_UNDEF nmm, %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
441 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
442 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
443 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
444
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
445 %macro INIT_XMM 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
446 %define RESET_MM_PERMUTATION INIT_XMM
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
447 %define mmsize 16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
448 %define num_mmregs 8
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
449 %ifdef ARCH_X86_64
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
450 %define num_mmregs 16
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
451 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
452 %define mova movdqa
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
453 %define movu movdqu
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
454 %define movh movq
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
455 %define movnt movntdq
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
456 %assign %%i 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
457 %rep num_mmregs
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
458 CAT_XDEFINE m, %%i, xmm %+ %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
459 CAT_XDEFINE nxmm, %%i, %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
460 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
461 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
462 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
463
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
464 INIT_MMX
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
465
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
466 ; I often want to use macros that permute their arguments. e.g. there's no
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
467 ; efficient way to implement butterfly or transpose or dct without swapping some
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
468 ; arguments.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
469 ;
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
470 ; I would like to not have to manually keep track of the permutations:
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
471 ; If I insert a permutation in the middle of a function, it should automatically
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
472 ; change everything that follows. For more complex macros I may also have multiple
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
473 ; implementations, e.g. the SSE2 and SSSE3 versions may have different permutations.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
474 ;
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
475 ; Hence these macros. Insert a PERMUTE or some SWAPs at the end of a macro that
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
476 ; permutes its arguments. It's equivalent to exchanging the contents of the
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
477 ; registers, except that this way you exchange the register names instead, so it
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
478 ; doesn't cost any cycles.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
479
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
480 %macro PERMUTE 2-* ; takes a list of pairs to swap
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
481 %rep %0/2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
482 %xdefine tmp%2 m%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
483 %xdefine ntmp%2 nm%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
484 %rotate 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
485 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
486 %rep %0/2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
487 %xdefine m%1 tmp%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
488 %xdefine nm%1 ntmp%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
489 %undef tmp%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
490 %undef ntmp%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
491 %rotate 2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
492 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
493 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
494
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
495 %macro SWAP 2-* ; swaps a single chain (sometimes more concise than pairs)
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
496 %rep %0-1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
497 %ifdef m%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
498 %xdefine tmp m%1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
499 %xdefine m%1 m%2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
500 %xdefine m%2 tmp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
501 CAT_XDEFINE n, m%1, %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
502 CAT_XDEFINE n, m%2, %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
503 %else
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
504 ; If we were called as "SWAP m0,m1" rather than "SWAP 0,1" infer the original numbers here.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
505 ; Be careful using this mode in nested macros though, as in some cases there may be
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
506 ; other copies of m# that have already been dereferenced and don't get updated correctly.
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
507 %xdefine %%n1 n %+ %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
508 %xdefine %%n2 n %+ %2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
509 %xdefine tmp m %+ %%n1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
510 CAT_XDEFINE m, %%n1, m %+ %%n2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
511 CAT_XDEFINE m, %%n2, tmp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
512 CAT_XDEFINE n, m %+ %%n1, %%n1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
513 CAT_XDEFINE n, m %+ %%n2, %%n2
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
514 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
515 %undef tmp
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
516 %rotate 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
517 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
518 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
519
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
520 %macro SAVE_MM_PERMUTATION 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
521 %assign %%i 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
522 %rep num_mmregs
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
523 CAT_XDEFINE %1_m, %%i, m %+ %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
524 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
525 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
526 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
527
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
528 %macro LOAD_MM_PERMUTATION 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
529 %assign %%i 0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
530 %rep num_mmregs
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
531 CAT_XDEFINE m, %%i, %1_m %+ %%i
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
532 %assign %%i %%i+1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
533 %endrep
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
534 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
535
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
536 %macro call 1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
537 call %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
538 %ifdef %1_m0
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
539 LOAD_MM_PERMUTATION %1
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
540 %endif
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
541 %endmacro
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
542
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
543 ; substitutions which are functionally identical but reduce code size
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
544 %define movdqa movaps
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
545 %define movdqu movups
570c0c027998 import yasm macros from x264
lorenm
parents:
diff changeset
546