gas/
[external/binutils.git] / gas / testsuite / gas / cfi / cfi-x86_64.s
1         .text
2
3 #; func_locvars
4 #; - function with a space on the stack 
5 #;   allocated for local variables
6
7         .type   func_locvars,@function
8 func_locvars:
9         .cfi_startproc
10         
11         #; alocate space for local vars
12         sub     $0x1234,%rsp
13         .cfi_adjust_cfa_offset  0x1234
14         
15         #; dummy body
16         movl    $1,%eax
17         
18         #; release space of local vars and return
19         add     $0x1234,%rsp
20         .cfi_adjust_cfa_offset  -0x1234
21         ret
22         .cfi_endproc
23
24 #; func_prologue
25 #; - functions that begins with standard
26 #;   prologue: "pushq %rbp; movq %rsp,%rbp"
27
28         .type   func_prologue,@function
29 func_prologue:
30         .cfi_startproc
31         
32         #; prologue, CFI is valid after 
33         #; each instruction.
34         pushq   %rbp
35         .cfi_def_cfa_offset     16
36         .cfi_offset             %rbp, -16
37         movq    %rsp, %rbp
38         .cfi_def_cfa_register   %rbp
39
40         #; function body
41         call    func_locvars
42         addl    $3, %eax
43
44         #; epilogue with valid CFI
45         #; (we're better than gcc :-)
46         leaveq
47         .cfi_def_cfa            %rsp, 8
48         ret
49         .cfi_endproc
50
51 #; func_otherreg
52 #; - function that moves frame pointer to 
53 #;   another register (r12) and then allocates 
54 #;   a space for local variables
55
56         .type   func_otherreg,@function
57 func_otherreg:
58         .cfi_startproc
59
60         #; save frame pointer to r8
61         movq    %rsp,%r8
62         .cfi_def_cfa_register   r8
63
64         #; alocate space for local vars
65         #;  (no .cfi_{def,adjust}_cfa_offset here,
66         #;   because CFA is computed from r8!)
67         sub     $100,%rsp
68
69         #; function body
70         call    func_prologue
71         addl    $2, %eax
72         
73         #; restore frame pointer from r8
74         movq    %r8,%rsp
75         .cfi_def_cfa_register   rsp
76         ret
77         .cfi_endproc
78
79 #; main
80 #; - typical function
81         .type   main,@function
82 main:
83         .cfi_startproc
84         
85         #; only function body that doesn't
86         #; touch the stack at all.
87         call    func_otherreg
88         
89         #; return
90         ret
91         .cfi_endproc
92
93 #; _start
94 #; - standard entry point
95
96         .type   _start,@function
97         .globl  _start
98 _start:
99         .cfi_startproc
100         call    main
101         movq    %rax,%rdi
102         movq    $0x3c,%rax
103         syscall
104         hlt
105         .cfi_endproc
106
107 #; func_alldirectives
108 #; - test for all .cfi directives. 
109 #;   This function is never called and the CFI info doesn't make sense.
110
111         .type   func_alldirectives,@function
112 func_alldirectives:
113         .cfi_startproc simple
114         .cfi_def_cfa    rsp,8
115         nop
116         .cfi_def_cfa_offset     16
117         nop
118         .cfi_def_cfa_register   r8
119         nop
120         .cfi_adjust_cfa_offset  0x1234
121         nop
122         .cfi_offset     %rsi, 0x10
123         nop
124         .cfi_register   %r8, %r9
125         nop
126         .cfi_remember_state
127         nop
128         .cfi_restore %rbp
129         nop
130         .cfi_undefined %rip
131         nop
132         .cfi_same_value rbx
133         nop
134         .cfi_restore_state
135         ret
136         .cfi_endproc
137
138 #; func_all_registers
139 #; - test for all .cfi register numbers. 
140 #;   This function is never called and the CFI info doesn't make sense.
141
142         .type   func_all_registers,@function
143 func_all_registers:
144         .cfi_startproc simple
145
146         .cfi_undefined rip      ; nop
147         .cfi_undefined rax      ; nop
148         .cfi_undefined rcx      ; nop
149         .cfi_undefined rdx      ; nop
150         .cfi_undefined rbx      ; nop
151         .cfi_undefined rsp      ; nop
152         .cfi_undefined rbp      ; nop
153         .cfi_undefined rsi      ; nop
154         .cfi_undefined rdi      ; nop
155         .cfi_undefined r8       ; nop
156         .cfi_undefined r9       ; nop
157         .cfi_undefined r10      ; nop
158         .cfi_undefined r11      ; nop
159         .cfi_undefined r12      ; nop
160         .cfi_undefined r13      ; nop
161         .cfi_undefined r14      ; nop
162         .cfi_undefined r15      ; nop
163         .cfi_undefined rflags   ; nop
164
165         .cfi_undefined es       ; nop
166         .cfi_undefined cs       ; nop
167         .cfi_undefined ds       ; nop
168         .cfi_undefined ss       ; nop
169         .cfi_undefined fs       ; nop
170         .cfi_undefined gs       ; nop
171         .cfi_undefined tr       ; nop
172         .cfi_undefined ldtr     ; nop
173         .cfi_undefined fs.base  ; nop
174         .cfi_undefined gs.base  ; nop
175
176         .cfi_undefined mxcsr    ; nop
177         .cfi_undefined xmm0     ; nop
178         .cfi_undefined xmm1     ; nop
179         .cfi_undefined xmm2     ; nop
180         .cfi_undefined xmm3     ; nop
181         .cfi_undefined xmm4     ; nop
182         .cfi_undefined xmm5     ; nop
183         .cfi_undefined xmm6     ; nop
184         .cfi_undefined xmm7     ; nop
185         .cfi_undefined xmm8     ; nop
186         .cfi_undefined xmm9     ; nop
187         .cfi_undefined xmm10    ; nop
188         .cfi_undefined xmm11    ; nop
189         .cfi_undefined xmm12    ; nop
190         .cfi_undefined xmm13    ; nop
191         .cfi_undefined xmm14    ; nop
192         .cfi_undefined xmm15    ; nop
193
194         .cfi_undefined fcw      ; nop
195         .cfi_undefined fsw      ; nop
196         .cfi_undefined st       ; nop
197         .cfi_undefined st(1)    ; nop
198         .cfi_undefined st(2)    ; nop
199         .cfi_undefined st(3)    ; nop
200         .cfi_undefined st(4)    ; nop
201         .cfi_undefined st(5)    ; nop
202         .cfi_undefined st(6)    ; nop
203         .cfi_undefined st(7)    ; nop
204
205         .cfi_undefined mm0      ; nop
206         .cfi_undefined mm1      ; nop
207         .cfi_undefined mm2      ; nop
208         .cfi_undefined mm3      ; nop
209         .cfi_undefined mm4      ; nop
210         .cfi_undefined mm5      ; nop
211         .cfi_undefined mm6      ; nop
212         .cfi_undefined mm7      ; nop
213
214         .cfi_endproc