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