2 ; Copyright (c) 2010 The VP8 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
26 %define ABI_IS_32BIT 0
43 ; Return the proper symbol name for the target ABI.
45 ; Certain ABIs, notably MS COFF and Darwin MACH-O, require that symbols
46 ; with C linkage be prefixed with an underscore.
48 %ifidn __OUTPUT_FORMAT__,elf32
50 %elifidn __OUTPUT_FORMAT__,elf64
52 %elifidn __OUTPUT_FORMAT__,x64
59 ; Return the address specification of the given argument
62 %define arg(x) [ebp+8+4*x]
64 ; 64 bit ABI passes arguments in registers. This is a workaround to get up
65 ; and running quickly. Relies on SHADOW_ARGS_TO_STACK
66 %ifidn __OUTPUT_FORMAT__,x64
67 %define arg(x) [rbp+16+8*x]
69 %define arg(x) [rbp-8-8*x]
73 ; REG_SZ_BYTES, REG_SZ_BITS
76 %define REG_SZ_BYTES 4
77 %define REG_SZ_BITS 32
79 %define REG_SZ_BYTES 8
80 %define REG_SZ_BITS 64
84 ; ALIGN_STACK <alignment> <register>
85 ; This macro aligns the stack to the given alignment (in bytes). The stack
86 ; is left such that the previous value of the stack pointer is the first
87 ; argument on the stack (ie, the inverse of this macro is 'pop rsp.')
88 ; This macro uses one temporary register, which is not preserved, and thus
89 ; must be specified as an argument.
93 sub rsp, %1 - REG_SZ_BYTES
99 ; The Microsoft assembler tries to impose a certain amount of type safety in
100 ; its register usage. YASM doesn't recognize these directives, so we just
101 ; %define them away to maintain as much compatibility as possible with the
102 ; original inline assembler we're porting from.
113 %ifidn __OUTPUT_FORMAT__,elf32
114 %define WRT_PLT wrt ..plt
116 extern _GLOBAL_OFFSET_TABLE_
121 add %1, _GLOBAL_OFFSET_TABLE_ + $$ - %%get_got wrt ..gotpc
123 %define GLOBAL + %1 wrt ..gotoff
125 %define RESTORE_GOT pop %1
127 %elifidn __OUTPUT_FORMAT__,macho32
133 add %1, fake_got - %%get_got
135 %define GLOBAL + %1 - fake_got
137 %define RESTORE_GOT pop %1
144 %define GLOBAL wrt rip
145 %ifidn __OUTPUT_FORMAT__,elf64
146 %define WRT_PLT wrt ..plt
162 %macro SHADOW_ARGS_TO_STACK 1
164 %define UNSHADOW_ARGS
166 %ifidn __OUTPUT_FORMAT__,x64
167 %macro SHADOW_ARGS_TO_STACK 1 ; argc
182 %macro SHADOW_ARGS_TO_STACK 1 ; argc
212 %define UNSHADOW_ARGS mov rsp, rbp
215 ; must keep XMM6:XMM15 (libvpx uses XMM6 and XMM7) on Win64 ABI
216 ; rsp register has to be aligned
217 %ifidn __OUTPUT_FORMAT__,x64
220 movdqa XMMWORD PTR [rsp], xmm6
221 movdqa XMMWORD PTR [rsp+16], xmm7
224 movdqa xmm6, XMMWORD PTR [rsp]
225 movdqa xmm7, XMMWORD PTR [rsp+16]
235 ; Name of the rodata section
237 ; .rodata seems to be an elf-ism, as it doesn't work on OSX.
239 %ifidn __OUTPUT_FORMAT__,macho64
240 %define SECTION_RODATA section .text
241 %elifidn __OUTPUT_FORMAT__,macho32
242 %macro SECTION_RODATA 0
247 %define SECTION_RODATA section .rodata
251 ; Tell GNU ld that we don't require an executable stack.
252 %ifidn __OUTPUT_FORMAT__,elf32
253 section .note.GNU-stack noalloc noexec nowrite progbits
255 %elifidn __OUTPUT_FORMAT__,elf64
256 section .note.GNU-stack noalloc noexec nowrite progbits