libavutil/x86/asm.h
Go to the documentation of this file.
1 /*
2  * copyright (c) 2006 Michael Niedermayer <michaelni@gmx.at>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg 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.
10  *
11  * FFmpeg 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.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 #ifndef AVUTIL_X86_ASM_H
22 #define AVUTIL_X86_ASM_H
23 
24 #include <stdint.h>
25 #include "config.h"
26 
27 typedef struct xmm_reg { uint64_t a, b; } xmm_reg;
28 
29 #if ARCH_X86_64
30 # define OPSIZE "q"
31 # define REG_a "rax"
32 # define REG_b "rbx"
33 # define REG_c "rcx"
34 # define REG_d "rdx"
35 # define REG_D "rdi"
36 # define REG_S "rsi"
37 # define PTR_SIZE "8"
38 typedef int64_t x86_reg;
39 
40 # define REG_SP "rsp"
41 # define REG_BP "rbp"
42 # define REGBP rbp
43 # define REGa rax
44 # define REGb rbx
45 # define REGc rcx
46 # define REGd rdx
47 # define REGSP rsp
48 
49 #elif ARCH_X86_32
50 
51 # define OPSIZE "l"
52 # define REG_a "eax"
53 # define REG_b "ebx"
54 # define REG_c "ecx"
55 # define REG_d "edx"
56 # define REG_D "edi"
57 # define REG_S "esi"
58 # define PTR_SIZE "4"
59 typedef int32_t x86_reg;
60 
61 # define REG_SP "esp"
62 # define REG_BP "ebp"
63 # define REGBP ebp
64 # define REGa eax
65 # define REGb ebx
66 # define REGc ecx
67 # define REGd edx
68 # define REGSP esp
69 #else
70 typedef int x86_reg;
71 #endif
72 
73 #define HAVE_7REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE && HAVE_EBP_AVAILABLE))
74 #define HAVE_6REGS (ARCH_X86_64 || (HAVE_EBX_AVAILABLE || HAVE_EBP_AVAILABLE))
75 
76 #if ARCH_X86_64 && defined(PIC)
77 # define BROKEN_RELOCATIONS 1
78 #endif
79 
80 /*
81  * If gcc is not set to support sse (-msse) it will not accept xmm registers
82  * in the clobber list for inline asm. XMM_CLOBBERS takes a list of xmm
83  * registers to be marked as clobbered and evaluates to nothing if they are
84  * not supported, or to the list itself if they are supported. Since a clobber
85  * list may not be empty, XMM_CLOBBERS_ONLY should be used if the xmm
86  * registers are the only in the clobber list.
87  * For example a list with "eax" and "xmm0" as clobbers should become:
88  * : XMM_CLOBBERS("xmm0",) "eax"
89  * and a list with only "xmm0" should become:
90  * XMM_CLOBBERS_ONLY("xmm0")
91  */
92 #if HAVE_XMM_CLOBBERS
93 # define XMM_CLOBBERS(...) __VA_ARGS__
94 # define XMM_CLOBBERS_ONLY(...) : __VA_ARGS__
95 #else
96 # define XMM_CLOBBERS(...)
97 # define XMM_CLOBBERS_ONLY(...)
98 #endif
99 
100 /* Use to export labels from asm. */
101 #define LABEL_MANGLE(a) EXTERN_PREFIX #a
102 
103 // Use rip-relative addressing if compiling PIC code on x86-64.
104 #if ARCH_X86_64 && defined(PIC)
105 # define LOCAL_MANGLE(a) #a "(%%rip)"
106 #else
107 # define LOCAL_MANGLE(a) #a
108 #endif
109 
110 #define MANGLE(a) EXTERN_PREFIX LOCAL_MANGLE(a)
111 
112 #endif /* AVUTIL_X86_ASM_H */
uint64_t b
uint64_t a
int32_t
struct xmm_reg xmm_reg
int x86_reg