2 ; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
4 ; Use of this source code is governed by a BSD-style license
5 ; that can be found in the LICENSE file in the root of the source
6 ; tree. An additional intellectual property rights grant can be found
7 ; in the file PATENTS. All contributing project authors may
8 ; be found in the AUTHORS file in the root of the source tree.
12 %include "vpx_config.asm"
14 ; 32/64 bit compatibility macros
16 ; In general, we make the source use 64 bit syntax, then twiddle with it using
17 ; the preprocessor to get the 32 bit syntax on 32 bit platforms.
19 %ifidn __OUTPUT_FORMAT__
,elf32
20 %define ABI_IS_32BIT
1
21 %elifidn __OUTPUT_FORMAT__
,macho32
22 %define ABI_IS_32BIT
1
23 %elifidn __OUTPUT_FORMAT__
,win32
24 %define ABI_IS_32BIT
1
25 %elifidn __OUTPUT_FORMAT__
,aout
26 %define ABI_IS_32BIT
1
28 %define ABI_IS_32BIT
0
82 ; Set LIBVPX_YASM_WIN64 if output is Windows 64bit so the code will work if x64
83 ; or win64 is defined on the Yasm command line.
84 %ifidn __OUTPUT_FORMAT__
,win64
85 %define LIBVPX_YASM_WIN64
1
86 %elifidn __OUTPUT_FORMAT__
,x64
87 %define LIBVPX_YASM_WIN64
1
89 %define LIBVPX_YASM_WIN64
0
93 ; Return the proper symbol name for the target ABI.
95 ; Certain ABIs, notably MS COFF and Darwin MACH-O, require that symbols
96 ; with C linkage be prefixed with an underscore.
98 %ifidn __OUTPUT_FORMAT__
,elf32
100 %elifidn __OUTPUT_FORMAT__
,elf64
102 %elifidn __OUTPUT_FORMAT__
,elfx32
104 %elif LIBVPX_YASM_WIN64
107 %define sym
(x
) _
%+ x
111 ; Macro for the attribute to hide a global symbol for the target ABI.
112 ; This is only active if CHROMIUM is defined.
114 ; Chromium doesn't like exported global symbols due to symbol clashing with
115 ; plugins among other things.
117 ; Requires Chromium's patched copy of yasm:
118 ; http://src.chromium.org/viewvc/chrome?view=rev&revision=73761
119 ; http://www.tortall.net/projects/yasm/ticket/236
122 %ifidn __OUTPUT_FORMAT__
,elf32
123 %define PRIVATE
:hidden
124 %elifidn __OUTPUT_FORMAT__
,elf64
125 %define PRIVATE
:hidden
126 %elifidn __OUTPUT_FORMAT__
,elfx32
127 %define PRIVATE
:hidden
128 %elif LIBVPX_YASM_WIN64
131 %define PRIVATE
:private_extern
138 ; Return the address specification of the given argument
141 %define arg
(x
) [ebp+8+4*x
]
143 ; 64 bit ABI passes arguments in registers. This is a workaround to get up
144 ; and running quickly. Relies on SHADOW_ARGS_TO_STACK
145 %if LIBVPX_YASM_WIN64
146 %define arg
(x
) [rbp
+16+8*x
]
148 %define arg
(x
) [rbp
-8-8*x
]
152 ; REG_SZ_BYTES, REG_SZ_BITS
155 %define REG_SZ_BYTES
4
156 %define REG_SZ_BITS
32
158 %define REG_SZ_BYTES
8
159 %define REG_SZ_BITS
64
163 ; ALIGN_STACK <alignment> <register>
164 ; This macro aligns the stack to the given alignment (in bytes). The stack
165 ; is left such that the previous value of the stack pointer is the first
166 ; argument on the stack (ie, the inverse of this macro is 'pop rsp.')
167 ; This macro uses one temporary register, which is not preserved, and thus
168 ; must be specified as an argument.
172 lea rsp
, [rsp
- (%1 - REG_SZ_BYTES
)]
178 ; The Microsoft assembler tries to impose a certain amount of type safety in
179 ; its register usage. YASM doesn't recognize these directives, so we just
180 ; %define them away to maintain as much compatibility as possible with the
181 ; original inline assembler we're porting from.
191 %ifidn __OUTPUT_FORMAT__
,elf32
192 %define WRT_PLT wrt ..plt
194 extern _GLOBAL_OFFSET_TABLE_
201 add %1, _GLOBAL_OFFSET_TABLE_
+ $$
- %%sub_offset wrt ..gotpc
205 %define
GLOBAL(x
) x
+ %1 wrt ..gotoff
207 %define RESTORE_GOT
pop %1
209 %elifidn __OUTPUT_FORMAT__
,macho32
216 %define
GLOBAL(x
) x
+ %1 - %%get_got
218 %define RESTORE_GOT
pop %1
224 %ifidn __OUTPUT_FORMAT__
,macho32
225 %define HIDDEN_DATA
(x
) x:private_extern
227 %define HIDDEN_DATA
(x
) x
230 %define HIDDEN_DATA
(x
) x
235 %define
GLOBAL(x
) rel x
236 %ifidn __OUTPUT_FORMAT__
,elf64
237 %define WRT_PLT wrt ..plt
238 %define HIDDEN_DATA
(x
) x:data hidden
239 %elifidn __OUTPUT_FORMAT__
,elfx32
240 %define WRT_PLT wrt ..plt
241 %define HIDDEN_DATA
(x
) x:data hidden
242 %elifidn __OUTPUT_FORMAT__
,macho64
244 %define HIDDEN_DATA
(x
) x:private_extern
246 %define HIDDEN_DATA
(x
) x
249 %define HIDDEN_DATA
(x
) x
265 %macro SHADOW_ARGS_TO_STACK
1
267 %define UNSHADOW_ARGS
269 %if LIBVPX_YASM_WIN64
270 %macro SHADOW_ARGS_TO_STACK
1 ; argc
285 %macro SHADOW_ARGS_TO_STACK
1 ; argc
315 %define UNSHADOW_ARGS
mov rsp
, rbp
318 ; Win64 ABI requires that XMM6:XMM15 are callee saved
320 ; store registers 6-n on the stack
321 ; if u is specified, use unaligned movs.
322 ; Win64 ABI requires 16 byte stack alignment, but then pushes an 8 byte return
323 ; value. Typically we follow this up with 'push rbp' - re-aligning the stack -
324 ; but in some cases this is not done and unaligned movs must be used.
325 %if LIBVPX_YASM_WIN64
326 %macro SAVE_XMM
1-2 a
328 %error Only xmm registers
6-15 must be preserved
331 %define movxmm movdq
%+ %2
332 %assign xmm_stack_space
((last_xmm
- 5) * 16)
333 sub rsp
, xmm_stack_space
336 movxmm
[rsp
+ ((i
- 6) * 16)], xmm
%+ i
343 %error RESTORE_XMM must be paired with SAVE_XMM n
347 movxmm xmm
%+ i
, [rsp
+((i
- 6) * 16)]
350 add rsp
, xmm_stack_space
351 ; there are a couple functions which return from multiple places.
352 ; otherwise, we could uncomment these:
354 ; %undef xmm_stack_space
365 ; Name of the rodata section
367 ; .rodata seems to be an elf-ism, as it doesn't work on OSX.
369 %ifidn __OUTPUT_FORMAT__
,macho64
370 %define SECTION_RODATA
section .text
371 %elifidn __OUTPUT_FORMAT__
,macho32
372 %macro SECTION_RODATA
0
375 %elifidn __OUTPUT_FORMAT__
,aout
376 %define SECTION_RODATA
section .data
378 %define SECTION_RODATA
section .rodata
382 ; Tell GNU ld that we don't require an executable stack.
383 %ifidn __OUTPUT_FORMAT__
,elf32
384 section .note.GNU
-stack noalloc noexec nowrite progbits
386 %elifidn __OUTPUT_FORMAT__
,elf64
387 section .note.GNU
-stack noalloc noexec nowrite progbits
389 %elifidn __OUTPUT_FORMAT__
,elfx32
390 section .note.GNU
-stack noalloc noexec nowrite progbits
394 ; On Android platforms use lrand48 when building postproc routines. Prior to L
395 ; rand() was not available.
396 %if CONFIG_POSTPROC
=1 || CONFIG_VP9_POSTPROC
=1
399 %define LIBVPX_RAND lrand48
402 %define LIBVPX_RAND rand
404 %endif
; CONFIG_POSTPROC || CONFIG_VP9_POSTPROC