Reverting merge from trunk
[official-gcc.git] / libgo / go / reflect / makefunc_386.S
blob5878bc44c56317f089f1d93243e40b5802836e61
1 /* Copyright 2013 The Go Authors. All rights reserved.
2    Use of this source code is governed by a BSD-style
3    license that can be found in the LICENSE file.
5    MakeFunc 386 assembly code.  */
7 #include "config.h"
9         .globl reflect.makeFuncStub
11 #ifdef __ELF__
12         .type reflect.makeFuncStub,@function
13 #endif
15 reflect.makeFuncStub:
16 .LFB1:
18         /* Go does not provide any equivalent to the regparm function
19            attribute, so on Go we do not need to worry about passing
20            parameters in registers.  We just pass a pointer to the
21            arguments on the stack.
22         
23            We do need to pick up the return values, though, so we pass
24            a pointer to a struct that looks like this.
25            struct {
26              esp uint32         // 0x0
27              eax uint32         // 0x4
28              st0 uint64         // 0x8
29            }
30         */
32         pushl   %ebp
33 .LCFI0:
34         movl    %esp, %ebp
35 .LCFI1:
36         pushl   %ebx            /* In case this is PIC.  */
37         subl    $36, %esp       /* Enough for args and to align stack.  */
38 .LCFI2:
40 #ifdef __PIC__
41         call    __x86.get_pc_thunk.bx
42         addl    $_GLOBAL_OFFSET_TABLE_, %ebx
43 #endif
45         leal    8(%ebp), %eax   /* Set esp field in struct.  */
46         movl    %eax, -24(%ebp)
48 #ifdef __PIC__
49         call    __go_get_closure@PLT
50 #else
51         call    __go_get_closure
52 #endif
54         movl    %eax, 4(%esp)
56         leal    -24(%ebp), %eax
57         movl    %eax, (%esp)
59 #ifdef __PIC__
60         call    reflect.MakeFuncStubGo@PLT
61 #else
62         call    reflect.MakeFuncStubGo
63 #endif
65         /* Set return registers.  */
67         movl    -20(%ebp), %eax
68         fldl    -16(%ebp)
70 #ifdef __SSE2__
71         /* In case we are compiling with -msseregparm.  This won't work
72            correctly if only SSE1 is supported, but that seems unlikely.  */
73         movsd   -16(%ebp), %xmm0
74 #endif
76         addl    $36, %esp
77         popl    %ebx
78 .LCFI3:
79         popl    %ebp
80 .LCFI4:
81         ret
82 .LFE1:
83 #ifdef __ELF__
84         .size   reflect.makeFuncStub, . - reflect.makeFuncStub
85 #endif
87 #ifdef __PIC__
88 #ifdef HAVE_AS_COMDAT_GAS
89         .section        .text.__x86.get_pc_thunk.bx,"axG",@progbits,__x86.get_pc_thunk.bx,comdat
90 #else
91         /* Sun as needs a different syntax.  */
92         .section        .text.__x86.get_pc_thunk.bx%__x86.get_pc_thunk.bx,"ax",@progbits
93         .group          __x86.get_pc_thunk.bx,.text.__x86.get_pc_thunk.bx%__x86.get_pc_thunk.bx,#comdat
94 #endif
95         .globl  __x86.get_pc_thunk.bx
96         .hidden __x86.get_pc_thunk.bx
97 #ifdef __ELF__
98         .type   __x86.get_pc_thunk.bx, @function
99 #endif
100 __x86.get_pc_thunk.bx:
101 .LFB2:
102         movl    (%esp), %ebx
103         ret
104 .LFE2:
105 #ifdef __ELF__
106         .size   __x86.get_pc_thunk.bx, . - __x86.get_pc_thunk.bx
107 #endif
108 #endif
110 #ifdef __ELF__
111 #if defined __PIC__
112 # if defined __sun__ && defined __svr4__
113 /* 32-bit Solaris 2/x86 uses datarel encoding for PIC.  GNU ld before 2.22
114    doesn't correctly sort .eh_frame_hdr with mixed encodings, so match this.  */
115 #  define FDE_ENCODING          0x30    /* datarel */
116 #  define FDE_ENCODE(X)         X@GOTOFF
117 # else
118 #  define FDE_ENCODING          0x1b    /* pcrel sdata4 */
119 #  if defined HAVE_AS_X86_PCREL
120 #   define FDE_ENCODE(X)        X-.
121 #  else
122 #   define FDE_ENCODE(X)        X@rel
123 #  endif
124 # endif
125 #else
126 # define FDE_ENCODING           0       /* absolute */
127 # define FDE_ENCODE(X)          X
128 #endif
130         .section        .eh_frame,EH_FRAME_FLAGS,@progbits
131 .Lframe1:
132         .long   .LECIE1-.LSCIE1 /* Length of Common Information Entry */
133 .LSCIE1:
134         .long   0x0     /* CIE Identifier Tag */
135         .byte   0x1     /* CIE Version */
136         .ascii "zR\0"   /* CIE Augmentation */
137         .byte   0x1     /* .uleb128 0x1; CIE Code Alignment Factor */
138         .byte   0x7c    /* .sleb128 -4; CIE Data Alignment Factor */
139         .byte   0x8     /* CIE RA Column */
140         .byte   0x1     /* .uleb128 0x1; Augmentation size */
141         .byte   FDE_ENCODING
142         .byte   0xc     /* DW_CFA_def_cfa */
143         .byte   0x4     /* .uleb128 0x4 */
144         .byte   0x4     /* .uleb128 0x4 */
145         .byte   0x88    /* DW_CFA_offset, column 0x8 */
146         .byte   0x1     /* .uleb128 0x1 */
147         .align 4
148 .LECIE1:
149 .LSFDE1:
150         .long   .LEFDE1-.LASFDE1        /* FDE Length */
151 .LASFDE1:
152         .long   .LASFDE1-.Lframe1       /* FDE CIE offset */
153         .long   FDE_ENCODE(.LFB1)       /* FDE initial location */
154         .long   .LFE1-.LFB1             /* FDE address range */
155         .byte   0x0     /* .uleb128 0x0; Augmentation size */
156         .byte   0x4     /* DW_CFA_advance_loc4 */
157         .long   .LCFI0-.LFB1
158         .byte   0xe     /* DW_CFA_def_cfa_offset */
159         .byte   0x8     /* .uleb128 0x8 */
160         .byte   0x85    /* DW_CFA_offset, column 0x5 */
161         .byte   0x2     /* .uleb128 0x2 */
162         .byte   0x4     /* DW_CFA_advance_loc4 */
163         .long   .LCFI1-.LCFI0
164         .byte   0xd     /* DW_CFA_def_cfa_register */
165         .byte   0x5     /* .uleb128 0x5 */
166         .byte   0x4     /* DW_CFA_advance_loc4 */
167         .long   .LCFI2-.LCFI1
168         .byte   0x83    /* .DW_CFA_offset, column 0x3 */
169         .byte   0x3     /* .uleb128 0x3 */
170         .byte   0x4     /* DW_CFA_advance_loc4 */
171         .long   .LCFI3-.LCFI2
172         .byte   0xc3    /* DW_CFA_restore, column 0x3 */
173         .byte   0x4     /* DW_CFA_advance_loc4 */
174         .long   .LCFI4-.LCFI3
175         .byte   0xc5    /* DW_CFA_restore, column 0x5 */
176         .byte   0xc     /* DW_CFA_def_cfa */
177         .byte   0x4     /* .uleb128 0x4 */
178         .byte   0x4     /* .uleb128 0x4 */
179         .align 4
180 .LEFDE1:
181 #ifdef __PIC__
182 .LSFDE2:
183         .long   .LEFDE2-.LASFDE2        /* FDE Length */
184 .LASFDE2:
185         .long   .LASFDE2-.Lframe1       /* FDE CIE offset */
186         .long   FDE_ENCODE(.LFB2)       /* FDE initial location */
187         .long   .LFE2-.LFB2             /* FDE address range */
188         .byte   0x0     /* .uleb128 0x0; Augmentation size */
189         .align 4
190 .LEFDE2:
191 #endif /* __PIC__ */
192 #endif /* __ELF__ */
194 #if defined(__ELF__) && defined(__linux__)
195         .section        .note.GNU-stack,"",@progbits
196         .section        .note.GNU-split-stack,"",@progbits
197         .section        .note.GNU-no-split-stack,"",@progbits
198 #endif