5a5063aca63f3fcc04a10c63dc40e8a1cf8a3525
[catacomb] / base / asm-common.h
1 /// -*- mode: asm; asm-comment-char: ?/ -*-
2 ///
3 /// Common definitions for asesembler source files
4 ///
5 /// (c) 2015 Straylight/Edgeware
6 ///
7
8 ///----- Licensing notice ---------------------------------------------------
9 ///
10 /// This file is part of Catacomb.
11 ///
12 /// Catacomb is free software; you can redistribute it and/or modify
13 /// it under the terms of the GNU Library General Public License as
14 /// published by the Free Software Foundation; either version 2 of the
15 /// License, or (at your option) any later version.
16 ///
17 /// Catacomb is distributed in the hope that it will be useful,
18 /// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 /// GNU Library General Public License for more details.
21 ///
22 /// You should have received a copy of the GNU Library General Public
23 /// License along with Catacomb; if not, write to the Free
24 /// Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
25 /// MA 02111-1307, USA.
26
27 #ifndef CATACOMB_ASM_COMMON_H
28 #define CATACOMB_ASM_COMMON_H
29
30 ///--------------------------------------------------------------------------
31 /// General definitions.
32
33 // Preprocessor hacks.
34 #define STRINGY(x) _STRINGY(x, y)
35 #define _STRINGY(x) #x
36 #define GLUE(x, y) _GLUE(x, y)
37 #define _GLUE(x, y) x##y
38 #define _EMPTY
39
40 // Some useful variables.
41 .L$_subsec = 0
42
43 // Literal pools done the hard way.
44 #define _LIT .text .L$_subsec + 1
45 #define _ENDLIT .text .L$_subsec
46 #define _LTORG .L$_subsec = .L$_subsec + 2; .text .L$_subsec
47
48 // Announcing an internal function.
49 #define INTFUNC(name) \
50 TYPE_FUNC(name); \
51 .macro ENDFUNC; _ENDFUNC(name); .endm; \
52 .L$_prologue_p = 0; .L$_frameptr_p = 0; \
53 FUNC_PREHOOK(name); \
54 name: \
55 FUNC_POSTHOOK(name)
56
57 // Announcing an external function.
58 #define FUNC(name) \
59 .globl F(name); \
60 INTFUNC(F(name))
61
62 // Marking the end of a function.
63 #define _ENDFUNC(name) \
64 .if ~ .L$_prologue_p; .error "Missing `endprologue'"; .endif; \
65 .if .L$_frameptr_p; .purgem dropfp; .endif; \
66 .purgem ENDFUNC; \
67 SIZE_OBJ(name); \
68 ENDFUNC_HOOK(name); \
69 _LTORG
70
71 // Make a helper function, if necessary.
72 #define AUXFN(name) \
73 .ifndef .L$_auxfn_def.name; \
74 .text 7128; \
75 .macro _ENDAUXFN; _ENDAUXFN_TAIL(name); .endm; \
76 FUNC_PREHOOK(name); \
77 name:
78 #define _ENDAUXFN_TAIL(name) \
79 .purgem _ENDAUXFN; \
80 .text .L$_subsec; \
81 .L$_auxfn_def.name = 1
82 #define ENDAUXFN _ENDAUXFN; .endif
83
84 ///--------------------------------------------------------------------------
85 /// ELF-specific hacking.
86
87 #if __ELF__
88
89 // Section types.
90 #if CPUFAM_ARMEL
91 # define _SECTTY(ty) %ty
92 #else
93 # define _SECTTY(ty) @ty
94 #endif
95
96 // Section selection.
97 #define RODATA .section .rodata, "a", _SECTTY(progbits)
98
99 // Additional symbol metadata.
100 #define TYPE_FUNC(name) .type name, STT_FUNC
101 #define TYPE_OBJ(name) .type name, STT_OBJECT
102 #define SIZE_OBJ(name) .size name, . - name
103
104 // Special arrangements for position-independent code.
105 #if __PIC__ || __PIE__
106 # define WANT_PIC 1
107 #endif
108
109 #endif
110
111 ///--------------------------------------------------------------------------
112 /// Windows-specific hacking.
113
114 #if ABI_WIN
115
116 // Function names need decorating on 32-bit i386.
117 #if CPUFAM_X86
118 # define F(name) _##name
119 #endif
120
121 // Section selection.
122 #define RODATA .section .rdata, "dr"
123
124 #endif
125
126 ///--------------------------------------------------------------------------
127 /// x86- and amd64-specific hacking.
128 ///
129 /// It's (slightly) easier to deal with both of these in one go.
130
131 #if CPUFAM_X86 || CPUFAM_AMD64
132
133 // Word size.
134 #if CPUFAM_X86
135 # define WORDSZ 4
136 #endif
137 #if CPUFAM_AMD64
138 # define WORDSZ 8
139 #endif
140
141 // Set the function hooks.
142 #define FUNC_PREHOOK(_) .balign 16
143
144 // On Windows, arrange to install stack-unwinding data.
145 #if CPUFAM_AMD64 && ABI_WIN
146 # define FUNC_POSTHOOK(name) .seh_proc name
147 # define ENDFUNC_HOOK(_) .seh_endproc
148 // Procedures are expected to invoke `.seh_setframe' if necessary, and
149 // `.seh_pushreg' and friends, and `.seh_endprologue'.
150 #endif
151
152 #if __ELF__
153 # define FUNC_POSTHOOK(_) .cfi_startproc
154 # define ENDFUNC_HOOK(_) .cfi_endproc
155 #endif
156
157 // Don't use the wretched AT&T syntax. It's festooned with pointless
158 // punctuation, and all of the data movement is backwards. Ugh!
159 .intel_syntax noprefix
160
161 // Call external subroutine at ADDR, possibly via PLT.
162 .macro callext addr
163 #if WANT_PIC
164 call \addr@PLT
165 #else
166 call \addr
167 #endif
168 .endm
169
170 // Do I need to arrange a spare GOT register?
171 #if WANT_PIC && CPUFAM_X86
172 # define NEED_GOT 1
173 #endif
174 #define GOTREG ebx // Not needed in AMD64 so don't care.
175
176 // Maybe load GOT address into GOT.
177 .macro ldgot got=GOTREG
178 #if WANT_PIC && CPUFAM_X86
179 AUXFN(_ldgot.\got)
180 mov \got, [esp]
181 ret
182 ENDAUXFN
183 call _ldgot.\got
184 add \got, offset _GLOBAL_OFFSET_TABLE_
185 #endif
186 .endm
187
188 // Load address of external symbol ADDR into REG, maybe using GOT.
189 .macro leaext reg, addr, got=GOTREG
190 #if WANT_PIC
191 # if CPUFAM_X86
192 mov \reg, [\got + \addr@GOT]
193 # endif
194 # if CPUFAM_AMD64
195 mov \reg, \addr@GOTPCREL[rip]
196 # endif
197 #else
198 # if CPUFAM_X86
199 mov \reg, offset \addr
200 # endif
201 # if CPUFAM_AMD64
202 lea \reg, \addr[rip]
203 # endif
204 #endif
205 .endm
206
207 // Address expression (possibly using a base register, and a displacement)
208 // referring to ADDR, which is within our module, maybe using GOT.
209 #define INTADDR(...) INTADDR__0(__VA_ARGS__, GOTREG, dummy)
210 #define INTADDR__0(addr, got, ...) INTADDR__1(addr, got)
211 #if CPUFAM_AMD64
212 # define INTADDR__1(addr, got) addr + rip
213 #elif WANT_PIC
214 # define INTADDR__1(addr, got) got + addr@GOTOFF
215 #else
216 # define INTADDR__1(addr, got) addr
217 #endif
218
219 // Permutations for SIMD instructions. SHUF(A, B, C, D) is an immediate,
220 // suitable for use in `pshufd' or `shufpd', which copies element A
221 // (0 <= A < 4) of the source to element 0 of the destination, element B to
222 // element 1, element C to element 2, and element D to element 3.
223 #define SHUF(a, b, c, d) ((a) + 4*(b) + 16*(c) + 64*(d))
224
225 // Map register names to their individual pieces.
226
227 // Apply decoration decor to (internal) register name reg of type ty.
228 //
229 // See `R_...' for internal register names. Decorations are as follows.
230 //
231 // b low byte (e.g., `al', `r8b')
232 // h high byte (e.g., `ah')
233 // w word (e.g., `ax', `r8w')
234 // d doubleword (e.g., `eax', `r8d')
235 // q quadword (e.g., `rax', `r8')
236 // r whole register (doubleword on x86, quadword on amd64)
237 //
238 // And types are as follows.
239 //
240 // abcd the four traditional registers `a', `b', `c', `d'
241 // xp the four pointer registers `si', `di', `bp', `sp'
242 // ip the instruction pointer `ip'
243 // rn the AMD64 numbered registers `r8'--`r15'
244 #define _DECOR(ty, decor, reg) _DECOR_##ty##_##decor(reg)
245
246 // Internal macros: _DECOR_ty_decor(reg) applies decoration decor to
247 // (internal) register name reg of type ty.
248
249 #define _DECOR_abcd_b(reg) reg##l
250 #define _DECOR_abcd_h(reg) reg##h
251 #define _DECOR_abcd_w(reg) reg##x
252 #define _DECOR_abcd_d(reg) e##reg##x
253 #if CPUFAM_AMD64
254 # define _DECOR_abcd_q(reg) r##reg##x
255 #endif
256
257 #define _DECOR_xp_w(reg) reg
258 #define _DECOR_xp_d(reg) e##reg
259 #if CPUFAM_AMD64
260 # define _DECOR_xp_b(reg) reg##l
261 # define _DECOR_xp_q(reg) r##reg
262 #endif
263
264 #define _DECOR_ip_w(reg) reg
265 #define _DECOR_ip_d(reg) e##reg
266 #if CPUFAM_AMD64
267 # define _DECOR_ip_q(reg) r##reg
268 #endif
269
270 #if CPUFAM_AMD64
271 # define _DECOR_rn_b(reg) reg##b
272 # define _DECOR_rn_w(reg) reg##w
273 # define _DECOR_rn_d(reg) reg##d
274 # define _DECOR_rn_q(reg) reg
275 # define _DECOR_rn_r(reg) reg
276 #endif
277
278 #define _DECOR_mem_b(addr) byte ptr addr
279 #define _DECOR_mem_w(addr) word ptr addr
280 #define _DECOR_mem_d(addr) dword ptr addr
281 #if CPUFAM_AMD64
282 # define _DECOR_mem_q(addr) qword ptr addr
283 #endif
284
285 #define _DECOR_imm_b(imm) byte imm
286 #define _DECOR_imm_w(imm) word imm
287 #define _DECOR_imm_d(imm) dword imm
288 #if CPUFAM_AMD64
289 # define _DECOR_imm_q(imm) qword imm
290 #endif
291
292 #if CPUFAM_X86
293 # define _DECOR_abcd_r(reg) e##reg##x
294 # define _DECOR_xp_r(reg) e##reg
295 # define _DECOR_ip_r(reg) e##reg
296 # define _DECOR_mem_r(addr) dword ptr addr
297 # define _DECOR_imm_r(imm) dword imm
298 #endif
299 #if CPUFAM_AMD64
300 # define _DECOR_abcd_r(reg) r##reg##x
301 # define _DECOR_xp_r(reg) r##reg
302 # define _DECOR_ip_r(reg) r##reg
303 # define _DECOR_mem_r(addr) qword ptr addr
304 # define _DECOR_imm_r(imm) qword imm
305 #endif
306
307 // R_r(decor) applies decoration decor to register r, which is an internal
308 // register name. The internal register names are: `ip', `a', `b', `c', `d',
309 // `si', `di', `bp', `sp', `r8'--`r15'.
310 #define R_nil(decor) nil
311 #define R_ip(decor) _DECOR(ip, decor, ip)
312 #define R_a(decor) _DECOR(abcd, decor, a)
313 #define R_b(decor) _DECOR(abcd, decor, b)
314 #define R_c(decor) _DECOR(abcd, decor, c)
315 #define R_d(decor) _DECOR(abcd, decor, d)
316 #define R_si(decor) _DECOR(xp, decor, si)
317 #define R_di(decor) _DECOR(xp, decor, di)
318 #define R_bp(decor) _DECOR(xp, decor, bp)
319 #define R_sp(decor) _DECOR(xp, decor, sp)
320 #if CPUFAM_AMD64
321 # define R_r8(decor) _DECOR(rn, decor, r8)
322 # define R_r9(decor) _DECOR(rn, decor, r9)
323 # define R_r10(decor) _DECOR(rn, decor, r10)
324 # define R_r11(decor) _DECOR(rn, decor, r11)
325 # define R_r12(decor) _DECOR(rn, decor, r12)
326 # define R_r13(decor) _DECOR(rn, decor, r13)
327 # define R_r14(decor) _DECOR(rn, decor, r14)
328 # define R_r15(decor) _DECOR(rn, decor, r15)
329 #endif
330
331 // Refer to an in-memory datum of the type implied by decor residing at
332 // address addr (which should supply its own square-brackets).
333 #define MEM(decor, addr) _DECOR(mem, decor, addr)
334
335 // Refer to an immediate datum of the type implied by decor.
336 #define IMM(decor, imm) _DECOR(mem, decor, imm)
337
338 // Applies decoration decor to assembler-level register name reg.
339 #define _REGFORM(reg, decor) _GLUE(_REGFORM_, reg)(decor)
340
341 // Internal macros: _REGFORM_r(decor) applies decoration decor to an
342 // assembler-level register name, in place of any decoration that register
343 // name has already.
344
345 #define _REGFORM_nil(decor) R_nil(decor)
346
347 #define _REGFORM_ip(decor) R_ip(decor)
348 #define _REGFORM_eip(decor) R_ip(decor)
349
350 #define _REGFORM_a(decor) R_a(decor)
351 #define _REGFORM_al(decor) R_a(decor)
352 #define _REGFORM_ah(decor) R_a(decor)
353 #define _REGFORM_ax(decor) R_a(decor)
354 #define _REGFORM_eax(decor) R_a(decor)
355
356 #define _REGFORM_b(decor) R_b(decor)
357 #define _REGFORM_bl(decor) R_b(decor)
358 #define _REGFORM_bh(decor) R_b(decor)
359 #define _REGFORM_bx(decor) R_b(decor)
360 #define _REGFORM_ebx(decor) R_b(decor)
361
362 #define _REGFORM_c(decor) R_c(decor)
363 #define _REGFORM_cl(decor) R_c(decor)
364 #define _REGFORM_ch(decor) R_c(decor)
365 #define _REGFORM_cx(decor) R_c(decor)
366 #define _REGFORM_ecx(decor) R_c(decor)
367
368 #define _REGFORM_d(decor) R_d(decor)
369 #define _REGFORM_dl(decor) R_d(decor)
370 #define _REGFORM_dh(decor) R_d(decor)
371 #define _REGFORM_dx(decor) R_d(decor)
372 #define _REGFORM_edx(decor) R_d(decor)
373
374 #define _REGFORM_si(decor) R_si(decor)
375 #define _REGFORM_sil(decor) R_si(decor)
376 #define _REGFORM_esi(decor) R_si(decor)
377
378 #define _REGFORM_di(decor) R_di(decor)
379 #define _REGFORM_dil(decor) R_di(decor)
380 #define _REGFORM_edi(decor) R_di(decor)
381
382 #define _REGFORM_bp(decor) R_bp(decor)
383 #define _REGFORM_bpl(decor) R_bp(decor)
384 #define _REGFORM_ebp(decor) R_bp(decor)
385
386 #define _REGFORM_sp(decor) R_sp(decor)
387 #define _REGFORM_spl(decor) R_sp(decor)
388 #define _REGFORM_esp(decor) R_sp(decor)
389
390 #if CPUFAM_AMD64
391
392 # define _REGFORM_rip(decor) R_ip(decor)
393 # define _REGFORM_rsp(decor) R_sp(decor)
394 # define _REGFORM_rbp(decor) R_bp(decor)
395 # define _REGFORM_rdi(decor) R_di(decor)
396 # define _REGFORM_rsi(decor) R_si(decor)
397 # define _REGFORM_rdx(decor) R_d(decor)
398 # define _REGFORM_rcx(decor) R_c(decor)
399 # define _REGFORM_rbx(decor) R_b(decor)
400 # define _REGFORM_rax(decor) R_a(decor)
401
402 # define _REGFORM_r8(decor) R_r8(decor)
403 # define _REGFORM_r8b(decor) R_r8(decor)
404 # define _REGFORM_r8w(decor) R_r8(decor)
405 # define _REGFORM_r8d(decor) R_r8(decor)
406
407 # define _REGFORM_r9(decor) R_r9(decor)
408 # define _REGFORM_r9b(decor) R_r9(decor)
409 # define _REGFORM_r9w(decor) R_r9(decor)
410 # define _REGFORM_r9d(decor) R_r9(decor)
411
412 # define _REGFORM_r10(decor) R_r10(decor)
413 # define _REGFORM_r10b(decor) R_r10(decor)
414 # define _REGFORM_r10w(decor) R_r10(decor)
415 # define _REGFORM_r10d(decor) R_r10(decor)
416
417 # define _REGFORM_r11(decor) R_r11(decor)
418 # define _REGFORM_r11b(decor) R_r11(decor)
419 # define _REGFORM_r11w(decor) R_r11(decor)
420 # define _REGFORM_r11d(decor) R_r11(decor)
421
422 # define _REGFORM_r12(decor) R_r12(decor)
423 # define _REGFORM_r12b(decor) R_r12(decor)
424 # define _REGFORM_r12w(decor) R_r12(decor)
425 # define _REGFORM_r12d(decor) R_r12(decor)
426
427 # define _REGFORM_r13(decor) R_r13(decor)
428 # define _REGFORM_r13b(decor) R_r13(decor)
429 # define _REGFORM_r13w(decor) R_r13(decor)
430 # define _REGFORM_r13d(decor) R_r13(decor)
431
432 # define _REGFORM_r14(decor) R_r14(decor)
433 # define _REGFORM_r14b(decor) R_r14(decor)
434 # define _REGFORM_r14w(decor) R_r14(decor)
435 # define _REGFORM_r14d(decor) R_r14(decor)
436
437 # define _REGFORM_r15(decor) R_r15(decor)
438 # define _REGFORM_r15b(decor) R_r15(decor)
439 # define _REGFORM_r15w(decor) R_r15(decor)
440 # define _REGFORM_r15d(decor) R_r15(decor)
441
442 #endif
443
444 // Macros for converting register names.
445 #define BYTE(reg) _REGFORM(reg, b)
446 #define HIBYTE(reg) _REGFORM(reg, h)
447 #define WORD(reg) _REGFORM(reg, w)
448 #define DWORD(reg) _REGFORM(reg, d)
449 #if CPUFAM_AMD64
450 # define QWORD(reg) _REGFORM(reg, q)
451 #endif
452 #define WHOLE(reg) _REGFORM(reg, r)
453
454 // Macros for some common registers.
455 #define AX R_a(r)
456 #define BX R_b(r)
457 #define CX R_c(r)
458 #define DX R_d(r)
459 #define SI R_si(r)
460 #define DI R_di(r)
461 #define BP R_bp(r)
462 #define SP R_sp(r)
463
464 // Stack management and unwinding.
465 .macro setfp fp=BP, offset=0
466 .if \offset == 0
467 mov \fp, SP
468 #if __ELF__
469 .cfi_def_cfa_register \fp
470 #endif
471 #if ABI_WIN && CPUFAM_AMD64
472 .seh_setframe \fp, 0
473 #endif
474 .else
475 lea \fp, [SP + \offset]
476 #if __ELF__
477 .cfi_def_cfa_register \fp
478 .cfi_adjust_cfa_offset -\offset
479 #endif
480 #if ABI_WIN && CPUFAM_AMD64
481 .seh_setframe \fp, \offset
482 #endif
483 .endif
484 .L$_frameptr_p = -1
485 .macro dropfp; _dropfp \fp, \offset; .endm
486 .endm
487
488 .macro _dropfp fp, offset=0
489 .if \offset == 0
490 mov SP, \fp
491 #if __ELF__
492 .cfi_def_cfa_register SP
493 #endif
494 .else
495 lea SP, [\fp - \offset]
496 #if __ELF__
497 .cfi_def_cfa_register SP
498 .cfi_adjust_cfa_offset +\offset
499 #endif
500 .endif
501 .L$_frameptr_p = 0
502 .purgem dropfp
503 .endm
504
505 .macro stalloc n
506 sub SP, \n
507 #if __ELF__
508 .cfi_adjust_cfa_offset +\n
509 #endif
510 #if ABI_WIN && CPUFAM_AMD64
511 .seh_stackalloc \n
512 #endif
513 .endm
514
515 .macro stfree n
516 add SP, \n
517 #if __ELF__
518 .cfi_adjust_cfa_offset -\n
519 #endif
520 .endm
521
522 .macro pushreg r
523 push \r
524 #if __ELF__
525 .cfi_adjust_cfa_offset +WORDSZ
526 .cfi_rel_offset \r, 0
527 #endif
528 #if ABI_WIN && CPUFAM_AMD64
529 .seh_pushreg \r
530 #endif
531 .endm
532
533 .macro popreg r
534 pop \r
535 #if __ELF__
536 .cfi_adjust_cfa_offset -WORDSZ
537 .cfi_restore \r
538 #endif
539 .endm
540
541 .macro savexmm r, offset
542 movdqa [SP + \offset], \r
543 #if ABI_WIN && CPUFAM_AMD64
544 .seh_savexmm \r, \offset
545 #endif
546 .endm
547
548 .macro rstrxmm r, offset
549 movdqa \r, [SP + \offset]
550 .endm
551
552 .macro endprologue
553 #if ABI_WIN && CPUFAM_AMD64
554 .seh_endprologue
555 #endif
556 .L$_prologue_p = -1
557 .endm
558
559 #endif
560
561 ///--------------------------------------------------------------------------
562 /// ARM-specific hacking.
563
564 #if CPUFAM_ARMEL
565
566 // ARM/Thumb mode things. Use ARM by default.
567 #define ARM .arm; .L$_pcoff = 8
568 #define THUMB .thumb; .L$_pcoff = 4
569 ARM
570
571 // Set the function hooks.
572 #define FUNC_PREHOOK(_) .balign 4; .fnstart
573 #define ENDFUNC_HOOK(_) .fnend; .ltorg
574
575 // Call external subroutine at ADDR, possibly via PLT.
576 .macro callext addr, cond=
577 #if WANT_PIC
578 bl\cond \addr(PLT)
579 #else
580 bl\cond \addr
581 #endif
582 .endm
583
584 // Do I need to arrange a spare GOT register?
585 #if WANT_PIC
586 # define NEED_GOT 1
587 #endif
588 #define GOTREG r9
589
590 // Maybe load GOT address into GOT.
591 .macro ldgot cond=, got=GOTREG
592 #if WANT_PIC
593 ldr\cond \got, .L$_ldgot$\@
594 .L$_ldgot_pc$\@:
595 add\cond \got, pc, \got
596 _LIT
597 .balign 4
598 .L$_ldgot$\@:
599 .word _GLOBAL_OFFSET_TABLE_ - .L$_ldgot_pc$\@ - .L$_pcoff
600 _ENDLIT
601 #endif
602 .endm
603
604 // Load address of external symbol ADDR into REG, maybe using GOT.
605 .macro leaext reg, addr, cond=, got=GOTREG
606 #if WANT_PIC
607 ldr\cond \reg, .L$_leaext$\@
608 ldr\cond \reg, [\got, \reg]
609 _LIT
610 .balign 4
611 .L$_leaext$\@:
612 .word \addr(GOT)
613 _ENDLIT
614 #else
615 ldr\cond \reg, =\addr
616 #endif
617 .endm
618
619 // Load address of external symbol ADDR into REG directly.
620 .macro leaextq reg, addr, cond=
621 #if WANT_PIC
622 ldr\cond \reg, .L$_leaextq$\@
623 .L$_leaextq_pc$\@:
624 .if .L$_pcoff == 8
625 ldr\cond \reg, [pc, \reg]
626 .else
627 add\cond \reg, pc
628 ldr\cond \reg, [\reg]
629 .endif
630 _LIT
631 .balign 4
632 .L$_leaextq$\@:
633 .word \addr(GOT_PREL) + (. - .L$_leaextq_pc$\@ - .L$_pcoff)
634 _ENDLIT
635 #else
636 ldr\cond \reg, =\addr
637 #endif
638 .endm
639
640 .macro vzero vz=q15
641 // Set VZ (default q15) to zero.
642 vmov.u32 \vz, #0
643 .endm
644
645 .macro vshl128 vd, vn, nbit, vz=q15
646 // Set VD to VN shifted left by NBIT. Assume VZ (default q15) is
647 // all-bits-zero. NBIT must be a multiple of 8.
648 .if \nbit&3 != 0
649 .error "shift quantity must be whole number of bytes"
650 .endif
651 vext.8 \vd, \vz, \vn, #16 - (\nbit >> 3)
652 .endm
653
654 .macro vshr128 vd, vn, nbit, vz=q15
655 // Set VD to VN shifted right by NBIT. Assume VZ (default q15) is
656 // all-bits-zero. NBIT must be a multiple of 8.
657 .if \nbit&3 != 0
658 .error "shift quantity must be whole number of bytes"
659 .endif
660 vext.8 \vd, \vn, \vz, #\nbit >> 3
661 .endm
662
663 // Apply decoration decor to register name reg.
664 #define _REGFORM(reg, decor) _GLUE(_REGFORM_, reg)(decor)
665
666 // Internal macros: `_REGFORM_r(decor)' applies decoration decor to register
667 // name r.
668
669 #define _REGFORM_nil(decor) nil
670
671 #define _REGFORM_s0(decor) _DECOR(s, decor, 0)
672 #define _REGFORM_s1(decor) _DECOR(s, decor, 1)
673 #define _REGFORM_s2(decor) _DECOR(s, decor, 2)
674 #define _REGFORM_s3(decor) _DECOR(s, decor, 3)
675 #define _REGFORM_s4(decor) _DECOR(s, decor, 4)
676 #define _REGFORM_s5(decor) _DECOR(s, decor, 5)
677 #define _REGFORM_s6(decor) _DECOR(s, decor, 6)
678 #define _REGFORM_s7(decor) _DECOR(s, decor, 7)
679 #define _REGFORM_s8(decor) _DECOR(s, decor, 8)
680 #define _REGFORM_s9(decor) _DECOR(s, decor, 9)
681 #define _REGFORM_s10(decor) _DECOR(s, decor, 10)
682 #define _REGFORM_s11(decor) _DECOR(s, decor, 11)
683 #define _REGFORM_s12(decor) _DECOR(s, decor, 12)
684 #define _REGFORM_s13(decor) _DECOR(s, decor, 13)
685 #define _REGFORM_s14(decor) _DECOR(s, decor, 14)
686 #define _REGFORM_s15(decor) _DECOR(s, decor, 15)
687 #define _REGFORM_s16(decor) _DECOR(s, decor, 16)
688 #define _REGFORM_s17(decor) _DECOR(s, decor, 17)
689 #define _REGFORM_s18(decor) _DECOR(s, decor, 18)
690 #define _REGFORM_s19(decor) _DECOR(s, decor, 19)
691 #define _REGFORM_s20(decor) _DECOR(s, decor, 20)
692 #define _REGFORM_s21(decor) _DECOR(s, decor, 21)
693 #define _REGFORM_s22(decor) _DECOR(s, decor, 22)
694 #define _REGFORM_s23(decor) _DECOR(s, decor, 23)
695 #define _REGFORM_s24(decor) _DECOR(s, decor, 24)
696 #define _REGFORM_s25(decor) _DECOR(s, decor, 25)
697 #define _REGFORM_s26(decor) _DECOR(s, decor, 26)
698 #define _REGFORM_s27(decor) _DECOR(s, decor, 27)
699 #define _REGFORM_s28(decor) _DECOR(s, decor, 28)
700 #define _REGFORM_s29(decor) _DECOR(s, decor, 29)
701 #define _REGFORM_s30(decor) _DECOR(s, decor, 30)
702 #define _REGFORM_s31(decor) _DECOR(s, decor, 31)
703
704 #define _REGFORM_d0(decor) _DECOR(d, decor, 0)
705 #define _REGFORM_d1(decor) _DECOR(d, decor, 1)
706 #define _REGFORM_d2(decor) _DECOR(d, decor, 2)
707 #define _REGFORM_d3(decor) _DECOR(d, decor, 3)
708 #define _REGFORM_d4(decor) _DECOR(d, decor, 4)
709 #define _REGFORM_d5(decor) _DECOR(d, decor, 5)
710 #define _REGFORM_d6(decor) _DECOR(d, decor, 6)
711 #define _REGFORM_d7(decor) _DECOR(d, decor, 7)
712 #define _REGFORM_d8(decor) _DECOR(d, decor, 8)
713 #define _REGFORM_d9(decor) _DECOR(d, decor, 9)
714 #define _REGFORM_d10(decor) _DECOR(d, decor, 10)
715 #define _REGFORM_d11(decor) _DECOR(d, decor, 11)
716 #define _REGFORM_d12(decor) _DECOR(d, decor, 12)
717 #define _REGFORM_d13(decor) _DECOR(d, decor, 13)
718 #define _REGFORM_d14(decor) _DECOR(d, decor, 14)
719 #define _REGFORM_d15(decor) _DECOR(d, decor, 15)
720 #define _REGFORM_d16(decor) _DECOR(d, decor, 16)
721 #define _REGFORM_d17(decor) _DECOR(d, decor, 17)
722 #define _REGFORM_d18(decor) _DECOR(d, decor, 18)
723 #define _REGFORM_d19(decor) _DECOR(d, decor, 19)
724 #define _REGFORM_d20(decor) _DECOR(d, decor, 20)
725 #define _REGFORM_d21(decor) _DECOR(d, decor, 21)
726 #define _REGFORM_d22(decor) _DECOR(d, decor, 22)
727 #define _REGFORM_d23(decor) _DECOR(d, decor, 23)
728 #define _REGFORM_d24(decor) _DECOR(d, decor, 24)
729 #define _REGFORM_d25(decor) _DECOR(d, decor, 25)
730 #define _REGFORM_d26(decor) _DECOR(d, decor, 26)
731 #define _REGFORM_d27(decor) _DECOR(d, decor, 27)
732 #define _REGFORM_d28(decor) _DECOR(d, decor, 28)
733 #define _REGFORM_d29(decor) _DECOR(d, decor, 29)
734 #define _REGFORM_d30(decor) _DECOR(d, decor, 30)
735 #define _REGFORM_d31(decor) _DECOR(d, decor, 31)
736
737 #define _REGFORM_q0(decor) _DECOR(q, decor, 0)
738 #define _REGFORM_q1(decor) _DECOR(q, decor, 1)
739 #define _REGFORM_q2(decor) _DECOR(q, decor, 2)
740 #define _REGFORM_q3(decor) _DECOR(q, decor, 3)
741 #define _REGFORM_q4(decor) _DECOR(q, decor, 4)
742 #define _REGFORM_q5(decor) _DECOR(q, decor, 5)
743 #define _REGFORM_q6(decor) _DECOR(q, decor, 6)
744 #define _REGFORM_q7(decor) _DECOR(q, decor, 7)
745 #define _REGFORM_q8(decor) _DECOR(q, decor, 8)
746 #define _REGFORM_q9(decor) _DECOR(q, decor, 9)
747 #define _REGFORM_q10(decor) _DECOR(q, decor, 10)
748 #define _REGFORM_q11(decor) _DECOR(q, decor, 11)
749 #define _REGFORM_q12(decor) _DECOR(q, decor, 12)
750 #define _REGFORM_q13(decor) _DECOR(q, decor, 13)
751 #define _REGFORM_q14(decor) _DECOR(q, decor, 14)
752 #define _REGFORM_q15(decor) _DECOR(q, decor, 15)
753
754 // `_LOPART(n)' and `_HIPART(n)' return the numbers of the register halves of
755 // register n, i.e., 2*n and 2*n + 1 respectively.
756 #define _LOPART(n) _GLUE(_LOPART_, n)
757 #define _HIPART(n) _GLUE(_HIPART_, n)
758
759 // Internal macros: `_LOPART_n' and `_HIPART_n' return the numbers of the
760 // register halves of register n, i.e., 2*n and 2*n + 1 respectively.
761
762 #define _LOPART_0 0
763 #define _HIPART_0 1
764 #define _LOPART_1 2
765 #define _HIPART_1 3
766 #define _LOPART_2 4
767 #define _HIPART_2 5
768 #define _LOPART_3 6
769 #define _HIPART_3 7
770 #define _LOPART_4 8
771 #define _HIPART_4 9
772 #define _LOPART_5 10
773 #define _HIPART_5 11
774 #define _LOPART_6 12
775 #define _HIPART_6 13
776 #define _LOPART_7 14
777 #define _HIPART_7 15
778 #define _LOPART_8 16
779 #define _HIPART_8 17
780 #define _LOPART_9 18
781 #define _HIPART_9 19
782 #define _LOPART_10 20
783 #define _HIPART_10 21
784 #define _LOPART_11 22
785 #define _HIPART_11 23
786 #define _LOPART_12 24
787 #define _HIPART_12 25
788 #define _LOPART_13 26
789 #define _HIPART_13 27
790 #define _LOPART_14 28
791 #define _HIPART_14 29
792 #define _LOPART_15 30
793 #define _HIPART_15 31
794
795 // Return the register number of the pair containing register n, i.e.,
796 // floor(n/2).
797 #define _PAIR(n) _GLUE(_PAIR_, n)
798
799 // Internal macros: `_PAIR_n' returns the register number of the pair
800 // containing register n, i.e., floor(n/2).
801 #define _PAIR_0 0
802 #define _PAIR_1 0
803 #define _PAIR_2 1
804 #define _PAIR_3 1
805 #define _PAIR_4 2
806 #define _PAIR_5 2
807 #define _PAIR_6 3
808 #define _PAIR_7 3
809 #define _PAIR_8 4
810 #define _PAIR_9 4
811 #define _PAIR_10 5
812 #define _PAIR_11 5
813 #define _PAIR_12 6
814 #define _PAIR_13 6
815 #define _PAIR_14 7
816 #define _PAIR_15 7
817 #define _PAIR_16 8
818 #define _PAIR_17 8
819 #define _PAIR_18 9
820 #define _PAIR_19 9
821 #define _PAIR_20 10
822 #define _PAIR_21 10
823 #define _PAIR_22 11
824 #define _PAIR_23 11
825 #define _PAIR_24 12
826 #define _PAIR_25 12
827 #define _PAIR_26 13
828 #define _PAIR_27 13
829 #define _PAIR_28 14
830 #define _PAIR_29 14
831 #define _PAIR_30 15
832 #define _PAIR_31 15
833
834 // Apply decoration decor to register number n of type ty. Decorations are
835 // as follows.
836 //
837 // decor types meaning
838 // Q s, d the NEON qN register containing this one
839 // D s the NEON dN register containing this one
840 // D0 q the low 64-bit half of this one
841 // D1 q the high 64-bit half of this one
842 // S0 d, q the first 32-bit piece of this one
843 // S1 d, q the second 32-bit piece of this one
844 // S2 q the third 32-bit piece of this one
845 // S3 q the fourth 32-bit piece of this one
846 // Bn q the nth byte of this register, as a scalar
847 // Hn q the nth halfword of this register, as a scalar
848 // Wn q the nth word of this register, as a scalar
849 #define _DECOR(ty, decor, n) _DECOR_##ty##_##decor(n)
850
851 // Internal macros: `_DECOR_ty_decor(n)' applies decoration decor to register
852 // number n of type ty.
853
854 #define _DECOR_s_Q(n) GLUE(q, _PAIR(_PAIR(n)))
855 #define _DECOR_s_D(n) GLUE(d, _PAIR(n))
856
857 #define _DECOR_d_Q(n) GLUE(q, _PAIR(n))
858 #define _DECOR_d_S0(n) GLUE(s, _LOPART(n))
859 #define _DECOR_d_S1(n) GLUE(s, _LOPART(n))
860
861 #define _DECOR_q_D0(n) GLUE(d, _LOPART(n))
862 #define _DECOR_q_D1(n) GLUE(d, _HIPART(n))
863 #define _DECOR_q_S0(n) GLUE(s, _LOPART(_LOPART(n)))
864 #define _DECOR_q_S1(n) GLUE(s, _HIPART(_LOPART(n)))
865 #define _DECOR_q_S2(n) GLUE(s, _LOPART(_HIPART(n)))
866 #define _DECOR_q_S3(n) GLUE(s, _HIPART(_HIPART(n)))
867 #define _DECOR_q_W0(n) GLUE(d, _LOPART(n))[0]
868 #define _DECOR_q_W1(n) GLUE(d, _LOPART(n))[1]
869 #define _DECOR_q_W2(n) GLUE(d, _HIPART(n))[0]
870 #define _DECOR_q_W3(n) GLUE(d, _HIPART(n))[1]
871 #define _DECOR_q_H0(n) GLUE(d, _LOPART(n))[0]
872 #define _DECOR_q_H1(n) GLUE(d, _LOPART(n))[1]
873 #define _DECOR_q_H2(n) GLUE(d, _LOPART(n))[2]
874 #define _DECOR_q_H3(n) GLUE(d, _LOPART(n))[3]
875 #define _DECOR_q_H4(n) GLUE(d, _HIPART(n))[0]
876 #define _DECOR_q_H5(n) GLUE(d, _HIPART(n))[1]
877 #define _DECOR_q_H6(n) GLUE(d, _HIPART(n))[2]
878 #define _DECOR_q_H7(n) GLUE(d, _HIPART(n))[3]
879 #define _DECOR_q_B0(n) GLUE(d, _LOPART(n))[0]
880 #define _DECOR_q_B1(n) GLUE(d, _LOPART(n))[1]
881 #define _DECOR_q_B2(n) GLUE(d, _LOPART(n))[2]
882 #define _DECOR_q_B3(n) GLUE(d, _LOPART(n))[3]
883 #define _DECOR_q_B4(n) GLUE(d, _LOPART(n))[4]
884 #define _DECOR_q_B5(n) GLUE(d, _LOPART(n))[5]
885 #define _DECOR_q_B6(n) GLUE(d, _LOPART(n))[6]
886 #define _DECOR_q_B7(n) GLUE(d, _LOPART(n))[7]
887 #define _DECOR_q_B8(n) GLUE(d, _HIPART(n))[0]
888 #define _DECOR_q_B9(n) GLUE(d, _HIPART(n))[1]
889 #define _DECOR_q_B10(n) GLUE(d, _HIPART(n))[2]
890 #define _DECOR_q_B11(n) GLUE(d, _HIPART(n))[3]
891 #define _DECOR_q_B12(n) GLUE(d, _HIPART(n))[4]
892 #define _DECOR_q_B13(n) GLUE(d, _HIPART(n))[5]
893 #define _DECOR_q_B14(n) GLUE(d, _HIPART(n))[6]
894 #define _DECOR_q_B15(n) GLUE(d, _HIPART(n))[7]
895
896 // Macros for navigating the NEON register hierarchy.
897 #define S0(reg) _REGFORM(reg, S0)
898 #define S1(reg) _REGFORM(reg, S1)
899 #define S2(reg) _REGFORM(reg, S2)
900 #define S3(reg) _REGFORM(reg, S3)
901 #define D(reg) _REGFORM(reg, D)
902 #define D0(reg) _REGFORM(reg, D0)
903 #define D1(reg) _REGFORM(reg, D1)
904 #define Q(reg) _REGFORM(reg, Q)
905
906 // Macros for indexing quadword registers.
907 #define QB(reg, i) _REGFORM(reg, B##i)
908 #define QH(reg, i) _REGFORM(reg, H##i)
909 #define QW(reg, i) _REGFORM(reg, W##i)
910
911 // Macros for converting vldm/vstm ranges.
912 #define QQ(qlo, qhi) D0(qlo)-D1(qhi)
913
914 // Stack management and unwinding.
915 .macro setfp fp=r11, offset=0
916 .if \offset == 0
917 mov \fp, sp
918 .setfp \fp, sp
919 .else
920 add \fp, sp, #\offset
921 .setfp \fp, sp, #\offset
922 .endif
923 .macro dropfp; _dropfp \fp, \offset; .endm
924 .L$_frameptr_p = -1
925 .endm
926
927 .macro _dropfp fp, offset=0
928 .if \offset == 0
929 mov sp, \fp
930 .else
931 sub sp, \fp, #\offset
932 .endif
933 .purgem dropfp
934 .L$_frameptr_p = 0
935 .endm
936
937 .macro stalloc n
938 sub sp, sp, #\n
939 .pad #\n
940 .endm
941
942 .macro stfree n
943 add sp, sp, #\n
944 .pad #-\n
945 .endm
946
947 .macro pushreg rr:vararg
948 push {\rr}
949 .save {\rr}
950 .endm
951
952 .macro popreg rr:vararg
953 pop {\rr}
954 .endm
955
956 .macro pushvfp rr:vararg
957 vstmdb sp!, {\rr}
958 .vsave {\rr}
959 .endm
960
961 .macro popvfp rr:vararg
962 vldmia sp!, {\rr}
963 .endm
964
965 .macro endprologue
966 .endm
967
968 // No need for prologue markers on ARM.
969 #define FUNC_POSTHOOK(_) .L$_prologue_p = -1
970
971 #endif
972
973 ///--------------------------------------------------------------------------
974 /// AArch64-specific hacking.
975
976 #if CPUFAM_ARM64
977
978 // Set the function hooks.
979 #define FUNC_PREHOOK(_) .balign 4
980 #define FUNC_POSTHOOK(_) .cfi_startproc; .L$_prologue_p = -1
981 #define ENDFUNC_HOOK(_) .cfi_endproc
982
983 // Call external subroutine at ADDR, possibly via PLT.
984 .macro callext addr
985 bl \addr
986 .endm
987
988 // Load address of external symbol ADDR into REG.
989 .macro leaext reg, addr
990 #if WANT_PIC
991 adrp \reg, :got:\addr
992 ldr \reg, [\reg, #:got_lo12:\addr]
993 #else
994 adrp \reg, \addr
995 add \reg, \reg, #:lo12:\addr
996 #endif
997 .endm
998
999 .macro vzero vz=v31
1000 // Set VZ (default v31) to zero.
1001 dup \vz\().4s, wzr
1002 .endm
1003
1004 .macro vshl128 vd, vn, nbit, vz=v31
1005 // Set VD to VN shifted left by NBIT. Assume VZ (default v31) is
1006 // all-bits-zero. NBIT must be a multiple of 8.
1007 .if \nbit&3 != 0
1008 .error "shift quantity must be whole number of bytes"
1009 .endif
1010 ext \vd\().16b, \vz\().16b, \vn\().16b, #16 - (\nbit >> 3)
1011 .endm
1012
1013 .macro vshr128 vd, vn, nbit, vz=v31
1014 // Set VD to VN shifted right by NBIT. Assume VZ (default v31) is
1015 // all-bits-zero. NBIT must be a multiple of 8.
1016 .if \nbit&3 != 0
1017 .error "shift quantity must be whole number of bytes"
1018 .endif
1019 ext \vd\().16b, \vn\().16b, \vz\().16b, #\nbit >> 3
1020 .endm
1021
1022 // Stack management and unwinding.
1023 .macro setfp fp=x29, offset=0
1024 // If you're just going through the motions with a fixed-size stack frame,
1025 // then you want to say `add x29, sp, #OFFSET' directly, which will avoid
1026 // pointlessly restoring sp later.
1027 .if \offset == 0
1028 mov \fp, sp
1029 .cfi_def_cfa_register \fp
1030 .else
1031 add \fp, sp, #\offset
1032 .cfi_def_cfa_register \fp
1033 .cfi_adjust_cfa_offset -\offset
1034 .endif
1035 .macro dropfp; _dropfp \fp, \offset; .endm
1036 .L$_frameptr_p = -1
1037 .endm
1038
1039 .macro _dropfp fp, offset=0
1040 .if \offset == 0
1041 mov sp, \fp
1042 .cfi_def_cfa_register sp
1043 .else
1044 sub sp, \fp, #\offset
1045 .cfi_def_cfa_register sp
1046 .cfi_adjust_cfa_offset +\offset
1047 .endif
1048 .purgem dropfp
1049 .L$_frameptr_p = 0
1050 .endm
1051
1052 .macro stalloc n
1053 sub sp, sp, #\n
1054 .cfi_adjust_cfa_offset +\n
1055 .endm
1056
1057 .macro stfree n
1058 add sp, sp, #\n
1059 .cfi_adjust_cfa_offset -\n
1060 .endm
1061
1062 .macro pushreg x, y=nil
1063 .ifeqs "\y", "nil"
1064 str \x, [sp, #-16]!
1065 .cfi_adjust_cfa_offset +16
1066 .cfi_rel_offset \x, 0
1067 .else
1068 stp \x, \y, [sp, #-16]!
1069 .cfi_adjust_cfa_offset +16
1070 .cfi_rel_offset \x, 0
1071 .cfi_rel_offset \y, 8
1072 .endif
1073 .endm
1074
1075 .macro popreg x, y=nil
1076 .ifeqs "\y", "nil"
1077 ldr \x, [sp], #16
1078 .cfi_restore \x
1079 .cfi_adjust_cfa_offset -16
1080 .else
1081 ldp \x, \y, [sp], #16
1082 .cfi_restore \x
1083 .cfi_restore \y
1084 .cfi_adjust_cfa_offset -16
1085 .endif
1086 .endm
1087
1088 .macro savereg x, y, z=nil
1089 .ifeqs "\z", "nil"
1090 str \x, [sp, \y]
1091 .cfi_rel_offset \x, \y
1092 .else
1093 stp \x, \y, [sp, #\z]
1094 .cfi_rel_offset \x, \z
1095 .cfi_rel_offset \y, \z + 8
1096 .endif
1097 .endm
1098
1099 .macro rstrreg x, y, z=nil
1100 .ifeqs "\z", "nil"
1101 ldr \x, [sp, \y]
1102 .cfi_restore \x
1103 .else
1104 ldp \x, \y, [sp, #\z]
1105 .cfi_restore \x
1106 .cfi_restore \y
1107 .endif
1108 .endm
1109
1110 .macro endprologue
1111 .endm
1112
1113 // cmov RD, RN, CC: set RD to RN if CC is satisfied, otherwise do nothing
1114 .macro cmov rd, rn, cc
1115 csel \rd, \rn, \rd, \cc
1116 .endm
1117
1118 // Notational improvement: write `csel.CC' etc., rather than `csel ..., CC'.
1119 #define _COND(_) \
1120 _(eq) _(ne) _(cs) _(cc) _(vs) _(vc) _(mi) _(pl) \
1121 _(ge) _(lt) _(gt) _(le) _(hi) _(ls) _(al) _(nv) \
1122 _(hs) _(lo)
1123 #define _INST(_) \
1124 _(ccmp) _(ccmn) \
1125 _(csel) _(cmov) \
1126 _(csinc) _(cinc) _(cset) \
1127 _(csneg) _(cneg) \
1128 _(csinv) _(cinv) _(csetm)
1129 #define _CONDVAR(cc) _definstvar cc;
1130 #define _INSTVARS(inst) \
1131 .macro _definstvar cc; \
1132 .macro inst.\cc args:vararg; inst \args, \cc; .endm; \
1133 .endm; \
1134 _COND(_CONDVAR); \
1135 .purgem _definstvar;
1136 _INST(_INSTVARS)
1137 #undef _COND
1138 #undef _INST
1139 #undef _CONDVAR
1140 #undef _INSTVARS
1141
1142 // Flag bits for `ccmp' and friends.
1143 #define CCMP_N 8
1144 #define CCMP_Z 4
1145 #define CCMP_C 2
1146 #define CCMP_V 1
1147
1148 // Flag settings for satisfying conditions.
1149 #define CCMP_MI CCMP_N
1150 #define CCMP_PL 0
1151 #define CCMP_EQ CCMP_Z
1152 #define CCMP_NE 0
1153 #define CCMP_CS CCMP_C
1154 #define CCMP_HS CCMP_C
1155 #define CCMP_CC 0
1156 #define CCMP_LO 0
1157 #define CCMP_VS CCMP_V
1158 #define CCMP_VC 0
1159 #define CCMP_HI CCMP_C
1160 #define CCMP_LS 0
1161 #define CCMP_LT CCMP_N
1162 #define CCMP_GE 0
1163 #define CCMP_LE CCMP_N
1164 #define CCMP_GT 0
1165
1166 #endif
1167
1168 ///--------------------------------------------------------------------------
1169 /// Final stuff.
1170
1171 // Default values for the various hooks.
1172 #ifndef FUNC_PREHOOK
1173 # define FUNC_PREHOOK(_)
1174 #endif
1175 #ifndef FUNC_POSTHOOK
1176 # define FUNC_POSTHOOK(_)
1177 #endif
1178 #ifndef ENDFUNC_HOOK
1179 # define ENDFUNC_HOOK(_)
1180 #endif
1181
1182 // Section selection.
1183 #ifndef TEXT
1184 # define TEXT .text .L$_subsec
1185 #endif
1186 #ifndef RODATA
1187 # define RODATA TEXT
1188 #endif
1189 #ifndef DATA
1190 # define DATA .data
1191 #endif
1192
1193 // Symbol decoration.
1194 #ifndef F
1195 # ifdef SYM_USCORE
1196 # define F(name) _##name
1197 # else
1198 # define F(name) name
1199 # endif
1200 #endif
1201
1202 #ifndef TYPE_FUNC
1203 # define TYPE_FUNC(name)
1204 #endif
1205 #ifndef TYPE_OBJ
1206 # define TYPE_OBJ(name)
1207 #endif
1208 #ifndef SIZE_OBJ
1209 # define SIZE_OBJ(name)
1210 #endif
1211
1212 #if __ELF__ && !defined(FORCE_EXECUTABLE_STACK)
1213 .pushsection .note.GNU-stack, "", _SECTTY(progbits)
1214 .popsection
1215 #endif
1216
1217 ///----- That's all, folks --------------------------------------------------
1218
1219 #endif