Reverting merge from trunk
[official-gcc.git] / libgo / go / reflect / makefunc_amd64.S
blob9d12f193f01875f42223f7f61701991c48aadc6d
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 amd64 assembly code.
7 #include "config.h"
9         .global reflect.makeFuncStub
11 #ifdef __ELF__
12         .type   reflect.makeFuncStub,@function
13 #endif
15 reflect.makeFuncStub:
16 .LFB1:
18         # Store all the parameter registers in a struct that looks
19         # like:
20         # struct {
21         #   rax uint64          // 0x0
22         #   rdi uint64          // 0x8
23         #   rsi uint64          // 0x10
24         #   rdx uint64          // 0x18
25         #   rcx uint64          // 0x20
26         #   r8 uint64           // 0x28
27         #   r9 uint64           // 0x30
28         #   rsp uint64          // 0x38 Pointer to arguments on stack.
29         #   xmm0 [2]uint64      // 0x40
30         #   xmm1 [2]uint64      // 0x50
31         #   xmm2 [2]uint64      // 0x60
32         #   xmm3 [2]uint64      // 0x70
33         #   xmm4 [2]uint64      // 0x80
34         #   xmm5 [2]uint64      // 0x90
35         #   xmm6 [2]uint64      // 0xa0
36         #   xmm7 [2]uint64      // 0xb0
37         # };
39         pushq   %rbp
40 .LCFI0:
41         movq    %rsp, %rbp
42 .LCFI1:
44         subq    $0xc0, %rsp             # Space for struct on stack.
46         movq    %rax, 0x0(%rsp)
47         movq    %rdi, 0x8(%rsp)
48         movq    %rsi, 0x10(%rsp)
49         movq    %rdx, 0x18(%rsp)
50         movq    %rcx, 0x20(%rsp)
51         movq    %r8, 0x28(%rsp)
52         movq    %r9, 0x30(%rsp)
53         leaq    16(%rbp), %rax
54         movq    %rax, 0x38(%rsp)
55         movdqa  %xmm0, 0x40(%rsp)
56         movdqa  %xmm1, 0x50(%rsp)
57         movdqa  %xmm2, 0x60(%rsp)
58         movdqa  %xmm3, 0x70(%rsp)
59         movdqa  %xmm4, 0x80(%rsp)
60         movdqa  %xmm5, 0x90(%rsp)
61         movdqa  %xmm6, 0xa0(%rsp)
62         movdqa  %xmm7, 0xb0(%rsp)
64         # Get function type.
65 #ifdef __PIC__
66         call    __go_get_closure@PLT
67 #else
68         call    __go_get_closure
69 #endif
70         movq    %rax, %rsi
72         movq    %rsp, %rdi
74 #ifdef __PIC__
75         call    reflect.MakeFuncStubGo@PLT
76 #else
77         call    reflect.MakeFuncStubGo
78 #endif
80         # The structure will be updated with any return values.  Load
81         # all possible return registers before returning to the caller.
83         movq    0x0(%rsp), %rax
84         movq    0x18(%rsp), %rdx
85         movq    0x8(%rsp), %rdi
86         movq    0x10(%rsp), %rsi
87         movdqa  0x40(%rsp), %xmm0
88         movdqa  0x50(%rsp), %xmm1
90         # long double values are returned on the floating point stack,
91         # but we don't worry about that since Go doesn't have a long
92         # double type.
94         leave
95 .LCFI2:
97         ret
98 .LFE1:
100 #ifdef __ELF__
101         .size   reflect.makeFuncStub, . - reflect.makeFuncStub
102 #endif
104 #ifdef __ELF__
105 #ifdef HAVE_AS_X86_64_UNWIND_SECTION_TYPE
106         .section        .eh_frame,"a",@unwind
107 #else
108         .section        .eh_frame,"a",@progbits
109 #endif
110 .Lframe1:
111         .long   .LECIE1-.LSCIE1 /* Length of Common Information Entry */
112 .LSCIE1:
113         .long   0x0             /* CIE Identifier Tag */
114         .byte   0x1             /* CIE Version */
115         .ascii "zR\0"           /* CIE Augmentation */
116         .uleb128 1              /* CIE Code Alignment Factor */
117         .sleb128 -8             /* CIE Data Alignment Factor */
118         .byte   0x10            /* CIE RA Column */
119         .uleb128 1              /* Augmentation size */
120         .byte   0x1b            /* FDE Encoding (pcrel sdata4) */
121         .byte   0xc             /* DW_CFA_def_cfa, %rsp offset 8 */
122         .uleb128 7
123         .uleb128 8
124         .byte   0x80+16         /* DW_CFA_offset, %rip offset 1*-8 */
125         .uleb128 1
126         .align 8
127 .LECIE1:
128 .LSFDE1:
129         .long   .LEFDE1-.LASFDE1        /* FDE Length */
130 .LASFDE1:
131         .long   .LASFDE1-.Lframe1       /* FDE CIE offset */
132 #if HAVE_AS_X86_PCREL
133         .long   .LFB1-.                 /* FDE initial location */
134 #else
135         .long   .LFB1@rel
136 #endif
137         .long   .LFE1-.LFB1             /* FDE address range */
138         .uleb128 0x0                    /* Augmentation size */
139         .byte   0x4                     /* DW_CFA_advance_loc4 */
140         .long   .LCFI0-.LFB1
141         .byte   0xe                     /* DW_CFA_def_cfa_offset */
142         .uleb128 16
143         .byte   0x86                    /* DW_CFA_offset, column 0x6 */
144         .uleb128 2
145         .byte   0x4                     /* DW_CFA_advance_loc4 */
146         .long   .LCFI1-.LCFI0
147         .byte   0xd                     /* DW_CFA_def_cfa_register */
148         .uleb128 6
149         .byte   0x2                     /* DW_CFA_advance_loc1 */
150         .byte   .LCFI2-.LCFI1
151         .byte   0xc                     /* DW_CFA_def_cfa */
152         .uleb128 7
153         .uleb128 8
154         .align 8
155 .LEFDE1:
156 #endif /* __ELF__ */
158 #if defined(__ELF__) && defined(__linux__)
159         .section        .note.GNU-stack,"",@progbits
160         .section        .note.GNU-split-stack,"",@progbits
161         .section        .note.GNU-no-split-stack,"",@progbits
162 #endif