comparison gcc/config/i386/cygwin.asm @ 67:f6334be47118

update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
author nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
date Tue, 22 Mar 2011 17:18:12 +0900
parents a06113de4d67
children
comparison
equal deleted inserted replaced
65:65488c3d617d 67:f6334be47118
1 /* stuff needed for libgcc on win32. 1 /* stuff needed for libgcc on win32.
2 * 2 *
3 * Copyright (C) 1996, 1998, 2001, 2003, 2008, 2009 Free Software Foundation, Inc. 3 * Copyright (C) 1996, 1998, 2001, 2003, 2008, 2009, 2010
4 * Free Software Foundation, Inc.
4 * Written By Steve Chamberlain 5 * Written By Steve Chamberlain
5 * 6 *
6 * This file is free software; you can redistribute it and/or modify it 7 * This file is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the 8 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 3, or (at your option) any 9 * Free Software Foundation; either version 3, or (at your option) any
21 * a copy of the GCC Runtime Library Exception along with this program; 22 * a copy of the GCC Runtime Library Exception along with this program;
22 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see 23 * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
23 * <http://www.gnu.org/licenses/>. 24 * <http://www.gnu.org/licenses/>.
24 */ 25 */
25 26
27 #include "auto-host.h"
28
29 #ifdef HAVE_GAS_CFI_SECTIONS_DIRECTIVE
30 .cfi_sections .debug_frame
31 # define cfi_startproc() .cfi_startproc
32 # define cfi_endproc() .cfi_endproc
33 # define cfi_adjust_cfa_offset(X) .cfi_adjust_cfa_offset X
34 # define cfi_def_cfa_register(X) .cfi_def_cfa_register X
35 # define cfi_register(D,S) .cfi_register D, S
36 # ifdef _WIN64
37 # define cfi_push(X) .cfi_adjust_cfa_offset 8; .cfi_rel_offset X, 0
38 # define cfi_pop(X) .cfi_adjust_cfa_offset -8; .cfi_restore X
39 # else
40 # define cfi_push(X) .cfi_adjust_cfa_offset 4; .cfi_rel_offset X, 0
41 # define cfi_pop(X) .cfi_adjust_cfa_offset -4; .cfi_restore X
42 # endif
43 #else
44 # define cfi_startproc()
45 # define cfi_endproc()
46 # define cfi_adjust_cfa_offset(X)
47 # define cfi_def_cfa_register(X)
48 # define cfi_register(D,S)
49 # define cfi_push(X)
50 # define cfi_pop(X)
51 #endif /* HAVE_GAS_CFI_SECTIONS_DIRECTIVE */
52
26 #ifdef L_chkstk 53 #ifdef L_chkstk
27 54 /* Function prologue calls __chkstk to probe the stack when allocating more
28 /* Function prologue calls _alloca to probe the stack when allocating more
29 than CHECK_STACK_LIMIT bytes in one go. Touching the stack at 4K 55 than CHECK_STACK_LIMIT bytes in one go. Touching the stack at 4K
30 increments is necessary to ensure that the guard pages used 56 increments is necessary to ensure that the guard pages used
31 by the OS virtual memory manger are allocated in correct sequence. */ 57 by the OS virtual memory manger are allocated in correct sequence. */
32 58
33 .global ___chkstk 59 .global ___chkstk
34 .global __alloca 60 .global __alloca
35 #ifndef _WIN64 61 #ifdef _WIN64
36 ___chkstk: 62 /* __alloca is a normal function call, which uses %rcx as the argument. */
63 cfi_startproc()
37 __alloca: 64 __alloca:
38 pushl %ecx /* save temp */ 65 movq %rcx, %rax
39 leal 8(%esp), %ecx /* point past return addr */ 66 /* FALLTHRU */
40 cmpl $0x1000, %eax /* > 4k ?*/
41 jb Ldone
42
43 Lprobe:
44 subl $0x1000, %ecx /* yes, move pointer down 4k*/
45 orl $0x0, (%ecx) /* probe there */
46 subl $0x1000, %eax /* decrement count */
47 cmpl $0x1000, %eax
48 ja Lprobe /* and do it again */
49
50 Ldone:
51 subl %eax, %ecx
52 orl $0x0, (%ecx) /* less than 4k, just peek here */
53
54 movl %esp, %eax /* save old stack pointer */
55 movl %ecx, %esp /* decrement stack */
56 movl (%eax), %ecx /* recover saved temp */
57 movl 4(%eax), %eax /* recover return address */
58
59 /* Push the return value back. Doing this instead of just
60 jumping to %eax preserves the cached call-return stack
61 used by most modern processors. */
62 pushl %eax
63 ret
64 #else
65 /* __alloca is a normal function call, which uses %rcx as the argument. And stack space
66 for the argument is saved. */
67 __alloca:
68 movq %rcx, %rax
69 addq $0x7, %rax
70 andq $0xfffffffffffffff8, %rax
71 popq %rcx /* pop return address */
72 popq %r10 /* Pop the reserved stack space. */
73 movq %rsp, %r10 /* get sp */
74 cmpq $0x1000, %rax /* > 4k ?*/
75 jb Ldone_alloca
76
77 Lprobe_alloca:
78 subq $0x1000, %r10 /* yes, move pointer down 4k*/
79 orq $0x0, (%r10) /* probe there */
80 subq $0x1000, %rax /* decrement count */
81 cmpq $0x1000, %rax
82 ja Lprobe_alloca /* and do it again */
83
84 Ldone_alloca:
85 subq %rax, %r10
86 orq $0x0, (%r10) /* less than 4k, just peek here */
87 movq %r10, %rax
88 subq $0x8, %r10 /* Reserve argument stack space. */
89 movq %r10, %rsp /* decrement stack */
90
91 /* Push the return value back. Doing this instead of just
92 jumping to %rcx preserves the cached call-return stack
93 used by most modern processors. */
94 pushq %rcx
95 ret
96 67
97 /* ___chkstk is a *special* function call, which uses %rax as the argument. 68 /* ___chkstk is a *special* function call, which uses %rax as the argument.
98 We avoid clobbering the 4 integer argument registers, %rcx, %rdx, 69 We avoid clobbering the 4 integer argument registers, %rcx, %rdx,
99 %r8 and %r9, which leaves us with %rax, %r10, and %r11 to use. */ 70 %r8 and %r9, which leaves us with %rax, %r10, and %r11 to use. */
71 .align 4
100 ___chkstk: 72 ___chkstk:
101 addq $0x7, %rax /* Make sure stack is on alignment of 8. */ 73 popq %r11 /* pop return address */
102 andq $0xfffffffffffffff8, %rax 74 cfi_adjust_cfa_offset(-8) /* indicate return address in r11 */
103 popq %r11 /* pop return address */ 75 cfi_register(%rip, %r11)
104 movq %rsp, %r10 /* get sp */ 76 movq %rsp, %r10
105 cmpq $0x1000, %rax /* > 4k ?*/ 77 cmpq $0x1000, %rax /* > 4k ?*/
106 jb Ldone 78 jb 2f
107 79
108 Lprobe: 80 1: subq $0x1000, %r10 /* yes, move pointer down 4k*/
109 subq $0x1000, %r10 /* yes, move pointer down 4k*/
110 orl $0x0, (%r10) /* probe there */ 81 orl $0x0, (%r10) /* probe there */
111 subq $0x1000, %rax /* decrement count */ 82 subq $0x1000, %rax /* decrement count */
112 cmpq $0x1000, %rax 83 cmpq $0x1000, %rax
113 ja Lprobe /* and do it again */ 84 ja 1b /* and do it again */
114 85
115 Ldone: 86 2: subq %rax, %r10
116 subq %rax, %r10 87 movq %rsp, %rax /* hold CFA until return */
117 orl $0x0, (%r10) /* less than 4k, just peek here */ 88 cfi_def_cfa_register(%rax)
118 movq %r10, %rsp /* decrement stack */ 89 orl $0x0, (%r10) /* less than 4k, just peek here */
90 movq %r10, %rsp /* decrement stack */
119 91
120 /* Push the return value back. Doing this instead of just 92 /* Push the return value back. Doing this instead of just
121 jumping to %r11 preserves the cached call-return stack 93 jumping to %r11 preserves the cached call-return stack
122 used by most modern processors. */ 94 used by most modern processors. */
123 pushq %r11 95 pushq %r11
124 ret 96 ret
125 #endif 97 cfi_endproc()
126 #endif 98 #else
99 cfi_startproc()
100 ___chkstk:
101 __alloca:
102 pushl %ecx /* save temp */
103 cfi_push(%eax)
104 leal 8(%esp), %ecx /* point past return addr */
105 cmpl $0x1000, %eax /* > 4k ?*/
106 jb 2f
107
108 1: subl $0x1000, %ecx /* yes, move pointer down 4k*/
109 orl $0x0, (%ecx) /* probe there */
110 subl $0x1000, %eax /* decrement count */
111 cmpl $0x1000, %eax
112 ja 1b /* and do it again */
113
114 2: subl %eax, %ecx
115 orl $0x0, (%ecx) /* less than 4k, just peek here */
116 movl %esp, %eax /* save current stack pointer */
117 cfi_def_cfa_register(%eax)
118 movl %ecx, %esp /* decrement stack */
119 movl (%eax), %ecx /* recover saved temp */
120
121 /* Copy the return register. Doing this instead of just jumping to
122 the address preserves the cached call-return stack used by most
123 modern processors. */
124 pushl 4(%eax)
125 ret
126 cfi_endproc()
127 #endif /* _WIN64 */
128 #endif /* L_chkstk */
129
130 #ifdef L_chkstk_ms
131 /* ___chkstk_ms is a *special* function call, which uses %rax as the argument.
132 We avoid clobbering any registers. Unlike ___chkstk, it just probes the
133 stack and does no stack allocation. */
134 .global ___chkstk_ms
135 #ifdef _WIN64
136 cfi_startproc()
137 ___chkstk_ms:
138 pushq %rcx /* save temps */
139 cfi_push(%rcx)
140 pushq %rax
141 cfi_push(%rax)
142 cmpq $0x1000, %rax /* > 4k ?*/
143 leaq 24(%rsp), %rcx /* point past return addr */
144 jb 2f
145
146 1: subq $0x1000, %rcx /* yes, move pointer down 4k */
147 orq $0x0, (%rcx) /* probe there */
148 subq $0x1000, %rax /* decrement count */
149 cmpq $0x1000, %rax
150 ja 1b /* and do it again */
151
152 2: subq %rax, %rcx
153 orq $0x0, (%rcx) /* less than 4k, just peek here */
154
155 popq %rax
156 cfi_pop(%rax)
157 popq %rcx
158 cfi_pop(%rcx)
159 ret
160 cfi_endproc()
161 #else
162 cfi_startproc()
163 ___chkstk_ms:
164 pushl %ecx /* save temp */
165 cfi_push(%ecx)
166 pushl %eax
167 cfi_push(%eax)
168 cmpl $0x1000, %eax /* > 4k ?*/
169 leal 12(%esp), %ecx /* point past return addr */
170 jb 2f
171
172 1: subl $0x1000, %ecx /* yes, move pointer down 4k*/
173 orl $0x0, (%ecx) /* probe there */
174 subl $0x1000, %eax /* decrement count */
175 cmpl $0x1000, %eax
176 ja 1b /* and do it again */
177
178 2: subl %eax, %ecx
179 orl $0x0, (%ecx) /* less than 4k, just peek here */
180
181 popl %eax
182 cfi_pop(%eax)
183 popl %ecx
184 cfi_pop(%ecx)
185 ret
186 cfi_endproc()
187 #endif /* _WIN64 */
188 #endif /* L_chkstk_ms */