2 * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
4 * This file is part of Libav.
6 * Libav is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * Libav is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with Libav; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 #ifndef AVUTIL_X86_ASM_H
22 #define AVUTIL_X86_ASM_H
27 typedef struct xmm_reg { uint64_t a, b; } xmm_reg;
28 typedef struct ymm_reg { uint64_t a, b, c, d; } ymm_reg;
31 # define FF_OPSIZE "q"
32 # define FF_REG_a "rax"
33 # define FF_REG_b "rbx"
34 # define FF_REG_c "rcx"
35 # define FF_REG_d "rdx"
36 # define FF_REG_D "rdi"
37 # define FF_REG_S "rsi"
38 # define FF_PTR_SIZE "8"
39 typedef int64_t x86_reg;
41 # define FF_REG_SP "rsp"
42 # define FF_REG_BP "rbp"
52 # define FF_OPSIZE "l"
53 # define FF_REG_a "eax"
54 # define FF_REG_b "ebx"
55 # define FF_REG_c "ecx"
56 # define FF_REG_d "edx"
57 # define FF_REG_D "edi"
58 # define FF_REG_S "esi"
59 # define FF_PTR_SIZE "4"
60 typedef int32_t x86_reg;
62 # define FF_REG_SP "esp"
63 # define FF_REG_BP "ebp"
74 #define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
75 #define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
77 #if ARCH_X86_64 && defined(PIC)
78 # define BROKEN_RELOCATIONS 1
82 * If gcc is not set to support sse (-msse) it will not accept xmm registers
83 * in the clobber list for inline asm. XMM_CLOBBERS takes a list of xmm
84 * registers to be marked as clobbered and evaluates to nothing if they are
85 * not supported, or to the list itself if they are supported. Since a clobber
86 * list may not be empty, XMM_CLOBBERS_ONLY should be used if the xmm
87 * registers are the only in the clobber list.
88 * For example a list with "eax" and "xmm0" as clobbers should become:
89 * : XMM_CLOBBERS("xmm0",) "eax"
90 * and a list with only "xmm0" should become:
91 * XMM_CLOBBERS_ONLY("xmm0")
94 # define XMM_CLOBBERS(...) __VA_ARGS__
95 # define XMM_CLOBBERS_ONLY(...) : __VA_ARGS__
97 # define XMM_CLOBBERS(...)
98 # define XMM_CLOBBERS_ONLY(...)
101 /* Use to export labels from asm. */
102 #define LABEL_MANGLE(a) EXTERN_PREFIX #a
104 // Use rip-relative addressing if compiling PIC code on x86-64.
105 #if ARCH_X86_64 && defined(PIC)
106 # define LOCAL_MANGLE(a) #a "(%%rip)"
108 # define LOCAL_MANGLE(a) #a
111 #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
113 #endif /* AVUTIL_X86_ASM_H */