Optimize 32bit memset/memcpy with SSE2/SSSE3.
[glibc.git] / sysdeps / i386 / sysdep.h
blobefdc82dde7442df84cad25e511c6833aae18ec6f
1 /* Assembler macros for i386.
2 Copyright (C) 1991-93,95,96,98,2002,2003,2005,2006
3 Free Software Foundation, Inc.
4 This file is part of the GNU C Library.
6 The GNU C Library 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 The GNU C Library 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 the GNU C Library; if not, write to the Free
18 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
19 02111-1307 USA. */
21 #include <sysdeps/generic/sysdep.h>
23 #ifdef __ASSEMBLER__
25 /* Syntactic details of assembler. */
27 #ifdef HAVE_ELF
29 /* ELF uses byte-counts for .align, most others use log2 of count of bytes. */
30 #define ALIGNARG(log2) 1<<log2
31 /* For ELF we need the `.type' directive to make shared libs work right. */
32 #define ASM_TYPE_DIRECTIVE(name,typearg) .type name,typearg;
33 #define ASM_SIZE_DIRECTIVE(name) .size name,.-name;
35 /* In ELF C symbols are asm symbols. */
36 #undef NO_UNDERSCORES
37 #define NO_UNDERSCORES
39 #else
41 #define ALIGNARG(log2) log2
42 #define ASM_TYPE_DIRECTIVE(name,type) /* Nothing is specified. */
43 #define ASM_SIZE_DIRECTIVE(name) /* Nothing is specified. */
45 #endif
48 /* Define an entry point visible from C.
50 There is currently a bug in gdb which prevents us from specifying
51 incomplete stabs information. Fake some entries here which specify
52 the current source file. */
53 #define ENTRY(name) \
54 STABS_CURRENT_FILE1("") \
55 STABS_CURRENT_FILE(name) \
56 ASM_GLOBAL_DIRECTIVE C_SYMBOL_NAME(name); \
57 ASM_TYPE_DIRECTIVE (C_SYMBOL_NAME(name),@function) \
58 .align ALIGNARG(4); \
59 STABS_FUN(name) \
60 C_LABEL(name) \
61 cfi_startproc; \
62 CALL_MCOUNT
64 #undef END
65 #define END(name) \
66 cfi_endproc; \
67 ASM_SIZE_DIRECTIVE(name) \
68 STABS_FUN_END(name)
70 #define ENTRY_CHK(name) ENTRY (name)
71 #define END_CHK(name) END (name)
73 #ifdef HAVE_CPP_ASM_DEBUGINFO
74 /* Disable that goop, because we just pass -g through to the assembler
75 and it generates proper line number information directly. */
76 # define STABS_CURRENT_FILE1(name)
77 # define STABS_CURRENT_FILE(name)
78 # define STABS_FUN(name)
79 # define STABS_FUN_END(name)
80 #else
81 /* Remove the following two lines once the gdb bug is fixed. */
82 #define STABS_CURRENT_FILE(name) \
83 STABS_CURRENT_FILE1 (#name)
84 #define STABS_CURRENT_FILE1(name) \
85 1: .stabs name,100,0,0,1b;
86 /* Emit stabs definition lines. We use F(0,1) and define t(0,1) as `int',
87 the same way gcc does it. */
88 #define STABS_FUN(name) STABS_FUN2(name, name##:F(0,1))
89 #define STABS_FUN2(name, namestr) \
90 .stabs "int:t(0,1)=r(0,1);-2147483648;2147483647;",128,0,0,0; \
91 .stabs #namestr,36,0,0,name;
92 #define STABS_FUN_END(name) \
93 1: .stabs "",36,0,0,1b-name;
94 #endif
96 /* If compiled for profiling, call `mcount' at the start of each function. */
97 #ifdef PROF
98 /* The mcount code relies on a normal frame pointer being on the stack
99 to locate our caller, so push one just for its benefit. */
100 #define CALL_MCOUNT \
101 pushl %ebp; cfi_adjust_cfa_offset (4); movl %esp, %ebp; \
102 cfi_def_cfa_register (ebp); call JUMPTARGET(mcount); \
103 popl %ebp; cfi_def_cfa (esp, 4);
104 #else
105 #define CALL_MCOUNT /* Do nothing. */
106 #endif
108 #ifdef NO_UNDERSCORES
109 /* Since C identifiers are not normally prefixed with an underscore
110 on this system, the asm identifier `syscall_error' intrudes on the
111 C name space. Make sure we use an innocuous name. */
112 #define syscall_error __syscall_error
113 #define mcount _mcount
114 #endif
116 #define PSEUDO(name, syscall_name, args) \
117 .globl syscall_error; \
118 lose: SYSCALL_PIC_SETUP \
119 jmp JUMPTARGET(syscall_error); \
120 ENTRY (name) \
121 DO_CALL (syscall_name, args); \
122 jb lose
124 #undef PSEUDO_END
125 #define PSEUDO_END(name) \
126 END (name)
128 #undef JUMPTARGET
129 #ifdef PIC
130 #define JUMPTARGET(name) name##@PLT
131 #define SYSCALL_PIC_SETUP \
132 pushl %ebx; \
133 cfi_adjust_cfa_offset (4); \
134 call 0f; \
135 0: popl %ebx; \
136 cfi_adjust_cfa_offset (-4); \
137 addl $_GLOBAL_OFFSET_TABLE+[.-0b], %ebx;
139 # define SETUP_PIC_REG(reg) \
140 .ifndef __i686.get_pc_thunk.reg; \
141 .section .gnu.linkonce.t.__i686.get_pc_thunk.reg,"ax",@progbits; \
142 .globl __i686.get_pc_thunk.reg; \
143 .hidden __i686.get_pc_thunk.reg; \
144 .type __i686.get_pc_thunk.reg,@function; \
145 __i686.get_pc_thunk.reg: \
146 movl (%esp), %e##reg; \
147 ret; \
148 .size __i686.get_pc_thunk.reg, . - __i686.get_pc_thunk.reg; \
149 .previous; \
150 .endif; \
151 call __i686.get_pc_thunk.reg
153 # define LOAD_PIC_REG(reg) \
154 SETUP_PIC_REG(reg); addl $_GLOBAL_OFFSET_TABLE_, %e##reg
156 #else
157 #define JUMPTARGET(name) name
158 #define SYSCALL_PIC_SETUP /* Nothing. */
159 #endif
161 /* Local label name for asm code. */
162 #ifndef L
163 #ifdef HAVE_ELF
164 #define L(name) .L##name
165 #else
166 #define L(name) name
167 #endif
168 #endif
170 #endif /* __ASSEMBLER__ */