Expand PMF_FN_* macros.
[netbsd-mini2440.git] / sys / arch / ia64 / include / asm.h
blob29d677a194c21a6e43184b18749baf90136d9ed7
1 /* $NetBSD: asm.h,v 1.3 2006/07/07 06:42:32 cherry Exp $ */
3 /* -
4 * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
5 * All Rights Reserved.
6 *
7 * Permission to use, copy, modify and distribute this software and its
8 * documentation is hereby granted, provided that both the copyright
9 * notice and this permission notice appear in all copies of the
10 * software, derivative works or modified versions, and any portions
11 * thereof, and that both notices appear in supporting documentation.
13 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
14 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
15 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 * Carnegie Mellon requests users of this software to return to
19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
20 * School of Computer Science
21 * Carnegie Mellon University
22 * Pittsburgh PA 15213-3890
24 * any improvements or extensions that they make and grant Carnegie Mellon
25 * the rights to redistribute these changes.
29 * Assembly coding style
31 * This file contains macros and register defines to
32 * aid in writing more readable assembly code.
33 * Some rules to make assembly code understandable by
34 * a debugger are also noted.
38 * Macro to make a local label name.
40 #define LLABEL(name,num) L ## name ## num
43 * MCOUNT
45 #if defined(GPROF)
46 #define MCOUNT \
47 alloc out0 = ar.pfs, 8, 0, 4, 0; \
48 mov out1 = r1; \
49 mov out2 = b0;; \
50 mov out3 = r0; \
51 br.call.sptk b0 = _mcount;;
52 #else
53 #define MCOUNT /* nothing */
54 #endif
57 * ENTRY
58 * Declare a global leaf function.
59 * A leaf function does not call other functions.
61 #define ENTRY(_name_, _n_args_) \
62 .global _name_; \
63 .align 16; \
64 .proc _name_; \
65 _name_:; \
66 .regstk _n_args_, 0, 0, 0; \
67 MCOUNT
69 #define ENTRY_NOPROFILE(_name_, _n_args_) \
70 .global _name_; \
71 .align 16; \
72 .proc _name_; \
73 _name_:; \
74 .regstk _n_args_, 0, 0, 0
77 * STATIC_ENTRY
78 * Declare a local leaf function.
80 #define STATIC_ENTRY(_name_, _n_args_) \
81 .align 16; \
82 .proc _name_; \
83 _name_:; \
84 .regstk _n_args_, 0, 0, 0 \
85 MCOUNT
87 * XENTRY
88 * Global alias for a leaf function, or alternate entry point
90 #define XENTRY(_name_) \
91 .globl _name_; \
92 _name_:
95 * STATIC_XENTRY
96 * Local alias for a leaf function, or alternate entry point
98 #define STATIC_XENTRY(_name_) \
99 _name_:
103 * END
104 * Function delimiter
106 #define END(_name_) \
107 .endp _name_
111 * EXPORT
112 * Export a symbol
114 #define EXPORT(_name_) \
115 .global _name_; \
116 _name_:
120 * IMPORT
121 * Make an external name visible, typecheck the size
123 #define IMPORT(_name_, _size_) \
124 /* .extern _name_,_size_ */
128 * ABS
129 * Define an absolute symbol
131 #define ABS(_name_, _value_) \
132 .globl _name_; \
133 _name_ = _value_
137 * BSS
138 * Allocate un-initialized space for a global symbol
140 #define BSS(_name_,_numbytes_) \
141 .comm _name_,_numbytes_
145 * MSG
146 * Allocate space for a message (a read-only ascii string)
148 #define ASCIZ .asciz
149 #define MSG(msg,reg,label) \
150 addl reg,@ltoff(label),gp;; \
151 ld8 reg=[reg];; \
152 .data; \
153 label: ASCIZ msg; \
154 .text;
158 * System call glue.
160 #define SYSCALLNUM(name) ___CONCAT(SYS_,name)
162 #define CALLSYS_NOERROR(name) \
163 { .mmi ; \
164 alloc r9 = ar.pfs, 0, 0, 8, 0 ; \
165 mov r31 = ar.k5 ; \
166 mov r10 = b0 ;; } \
167 { .mib ; \
168 mov r8 = SYSCALLNUM(name) ; \
169 mov b7 = r31 ; \
170 br.call.sptk b0 = b7 ;; }
174 * WEAK_ALIAS: create a weak alias (ELF only).
176 #define WEAK_ALIAS(alias,sym) \
177 .weak alias; \
178 alias = sym
181 * STRONG_ALIAS: create a strong alias.
183 #define STRONG_ALIAS(alias,sym) \
184 .globl alias; \
185 alias = sym