1 ;*****************************************************************************
2 ;* amd64inc.asm: h264 encoder library
3 ;*****************************************************************************
4 ;* Copyright (C) 2005 x264 project
6 ;* Authors: Andrew Dunstan
8 ;* This program is free software; you can redistribute it and/or modify
9 ;* it under the terms of the GNU General Public License as published by
10 ;* the Free Software Foundation; either version 2 of the License, or
11 ;* (at your option) any later version.
13 ;* This program is distributed in the hope that it will be useful,
14 ;* but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;* GNU General Public License for more details.
18 ;* You should have received a copy of the GNU General Public License
19 ;* along with this program; if not, write to the Free Software
20 ;* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
21 ;*****************************************************************************
25 ; FIXME: All of the 64bit asm functions that take a stride as an argument
26 ; via register, assume that the high dword of that register is filled with 0.
27 ; This is true in practice (since we never do any 64bit arithmetic on strides),
28 ; but is not guaranteed by the ABI.
68 %define parm5q [rsp+40]
69 %define parm6q [rsp+48]
70 %define parm7q [rsp+56]
71 %define parm8q [rsp+64]
76 %define parm5d dword parm5q
77 %define parm6d dword parm6q
78 %define parm7d dword parm7q
79 %define parm8d dword parm8q
86 %define unwindcode(count, code) .unwind %+ count EQU code
100 %define regcoder12 12
101 %define regcoder13 13
102 %define regcoder14 14
103 %define regcoder15 15
104 %define regcodexmm0 0
105 %define regcodexmm1 1
106 %define regcodexmm2 2
107 %define regcodexmm3 3
108 %define regcodexmm4 4
109 %define regcodexmm5 5
110 %define regcodexmm6 6
111 %define regcodexmm7 7
112 %define regcodexmm8 8
113 %define regcodexmm9 9
114 %define regcodexmm10 10
115 %define regcodexmm11 11
116 %define regcodexmm12 12
117 %define regcodexmm13 13
118 %define regcodexmm14 14
119 %define regcodexmm15 15
123 %error Stack Allocation must be at least 8 bytes.
125 %assign unwindcount unwindcount+1
126 unwindcode(unwindcount, $-.startfunc + 0x200 + (((%1-8)/8)<<12))
128 %assign unwindcount unwindcount+1
129 unwindcode(unwindcount, %1/8)
130 %assign unwindcount unwindcount+1
131 unwindcode(unwindcount, $-.startfunc + 0x100)
133 %assign unwindcount unwindcount+1
134 unwindcode(unwindcount, %1>>16)
135 %assign unwindcount unwindcount+1
136 unwindcode(unwindcount, %1 & 0x0000FFFF)
137 %assign unwindcount unwindcount+1
138 unwindcode(unwindcount, $-.startfunc + 0x1100)
143 %assign unwindcount unwindcount+1
144 unwindcode(unwindcount, $-.startfunc + 0 + (regcode%1 << 12))
148 %if ((%2 % 16) | (%2 > 240) | (%2 < 0))
149 %error Frame offset must be a multiple of 16 between 0 and 240.
151 %assign unwindcount unwindcount+1
152 unwindcode(unwindcount, $-.startfunc + (3 << 8 )+ (regcode%1 << 12))
153 %assign framereg regcode%1 + %2
157 %if ((%2 % 8) | (%2 < 0))
158 %error Offset must be a positive multiple of 8.
161 %assign unwindcount unwindcount+1
162 unwindcode(unwindcount, %2/8)
163 %assign unwindcount unwindcount +1
164 unwindcode(unwindcount, $-.startfunc + (4 << 8) + (regcode%1 << 12))
166 %assign unwindcount unwindcount+1
167 unwindcode(unwindcount, %2 >> 16)
168 %assign unwindcount unwindcount+1
169 unwindcode(unwindcount, %2 & 0x0000FFFF)
170 %assign unwindcount unwindcount+1
171 unwindcode(unwindcount, $-.startfunc + (5 << 8) + (regcode%1 << 12))
176 %if ((%2 % 16) | (%2 < 0))
177 %error Offset must be a positive multiple of 16.
180 %assign unwindcount unwindcount+1
181 unwindcode(unwindcount, %2/16)
182 %assign unwindcount unwindcount +1
183 unwindcode(unwindcount, $-.startfunc + (8 << 8) + (regcode%1 << 12))
185 %assign unwindcount unwindcount+1
186 unwindcode(unwindcount, %2 >> 16)
187 %assign unwindcount unwindcount+1
188 unwindcode(unwindcount, %2 & 0x0000FFFF)
189 %assign unwindcount unwindcount+1
190 unwindcode(unwindcount, $-.startfunc + (9 << 8) + (regcode%1 << 12))
199 db .endprolog-.startfunc
203 dw .unwind %+ unwindcount
204 %assign unwindcount unwindcount-1
226 %define parm7q [rsp+8]
227 %define parm8q [rsp+16]
234 %define parm7d dword parm7q
235 %define parm8d dword parm8q
261 ; PIC support macros. On x86_64 we just use RIP-relative addressing, which is
262 ; much simpler than the GOT handling we need to perform on x86.
264 ; - GLOBAL should be used as a suffix for global addressing, eg.
265 ; mov eax, [foo GLOBAL]
270 %define GLOBAL wrt rip
275 %assign FENC_STRIDE 16
276 %assign FDEC_STRIDE 32
278 ; This is needed for ELF, otherwise the GNU linker assumes the stack is
279 ; executable by default.
280 %ifidn __YASM_OBJFMT__,elf
281 section ".note.GNU-stack" noalloc noexec nowrite progbits