2 ; Copyright (c) 2010 The VP8 project authors. All Rights Reserved.
4 ; Use of this source code is governed by a BSD-style license and patent
5 ; grant that can be found in the LICENSE file in the root of the source
6 ; tree. All contributing project authors may be found in the AUTHORS
7 ; file in the root of the source tree.
11 %include "vpx_config.asm"
13 ; 32/64 bit compatibility macros
15 ; In general, we make the source use 64 bit syntax, then twiddle with it using
16 ; the preprocessor to get the 32 bit syntax on 32 bit platforms.
18 %ifidn __OUTPUT_FORMAT__,elf32
19 %define ABI_IS_32BIT 1
20 %elifidn __OUTPUT_FORMAT__,macho32
21 %define ABI_IS_32BIT 1
22 %elifidn __OUTPUT_FORMAT__,win32
23 %define ABI_IS_32BIT 1
25 %define ABI_IS_32BIT 0
42 ; Return the proper symbol name for the target ABI.
44 ; Certain ABIs, notably MS COFF and Darwin MACH-O, require that symbols
45 ; with C linkage be prefixed with an underscore.
47 %ifidn __OUTPUT_FORMAT__,elf32
49 %elifidn __OUTPUT_FORMAT__,elf64
51 %elifidn __OUTPUT_FORMAT__,x64
58 ; Return the address specification of the given argument
61 %define arg(x) [ebp+8+4*x]
63 ; 64 bit ABI passes arguments in registers. This is a workaround to get up
64 ; and running quickly. Relies on SHADOW_ARGS_TO_STACK
65 %ifidn __OUTPUT_FORMAT__,x64
66 %define arg(x) [rbp+16+8*x]
68 %define arg(x) [rbp-8-8*x]
72 ; REG_SZ_BYTES, REG_SZ_BITS
75 %define REG_SZ_BYTES 4
76 %define REG_SZ_BITS 32
78 %define REG_SZ_BYTES 8
79 %define REG_SZ_BITS 64
83 ; ALIGN_STACK <alignment> <register>
84 ; This macro aligns the stack to the given alignment (in bytes). The stack
85 ; is left such that the previous value of the stack pointer is the first
86 ; argument on the stack (ie, the inverse of this macro is 'pop rsp.')
87 ; This macro uses one temporary register, which is not preserved, and thus
88 ; must be specified as an argument.
92 sub rsp, %1 - REG_SZ_BYTES
98 ; The Microsoft assembler tries to impose a certain amount of type safety in
99 ; its register usage. YASM doesn't recognize these directives, so we just
100 ; %define them away to maintain as much compatibility as possible with the
101 ; original inline assembler we're porting from.
112 %ifidn __OUTPUT_FORMAT__,elf32
113 %define WRT_PLT wrt ..plt
115 extern _GLOBAL_OFFSET_TABLE_
120 add %1, _GLOBAL_OFFSET_TABLE_ + $$ - %%get_got wrt ..gotpc
122 %define GLOBAL + %1 wrt ..gotoff
124 %define RESTORE_GOT pop %1
126 %elifidn __OUTPUT_FORMAT__,macho32
132 add %1, fake_got - %%get_got
134 %define GLOBAL + %1 - fake_got
136 %define RESTORE_GOT pop %1
143 %define GLOBAL wrt rip
144 %ifidn __OUTPUT_FORMAT__,elf64
145 %define WRT_PLT wrt ..plt
161 %macro SHADOW_ARGS_TO_STACK 1
163 %define UNSHADOW_ARGS
165 %ifidn __OUTPUT_FORMAT__,x64
166 %macro SHADOW_ARGS_TO_STACK 1 ; argc
181 %macro SHADOW_ARGS_TO_STACK 1 ; argc
214 %define UNSHADOW_ARGS mov rsp, rbp
218 ; Name of the rodata section
220 ; .rodata seems to be an elf-ism, as it doesn't work on OSX.
222 %ifidn __OUTPUT_FORMAT__,macho64
223 %define SECTION_RODATA section .text
224 %elifidn __OUTPUT_FORMAT__,macho32
225 %macro SECTION_RODATA 0
230 %define SECTION_RODATA section .rodata