asm.h revision 93256
1/* $FreeBSD: head/sys/ia64/include/asm.h 93256 2002-03-27 02:20:09Z marcel $ */
2/* From: NetBSD: asm.h,v 1.18 1997/11/03 04:22:06 ross Exp */
3
4/*
5 * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
6 * All Rights Reserved.
7 *
8 * Permission to use, copy, modify and distribute this software and its
9 * documentation is hereby granted, provided that both the copyright
10 * notice and this permission notice appear in all copies of the
11 * software, derivative works or modified versions, and any portions
12 * thereof, and that both notices appear in supporting documentation.
13 *
14 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
15 * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
16 * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
17 *
18 * Carnegie Mellon requests users of this software to return to
19 *
20 *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
21 *  School of Computer Science
22 *  Carnegie Mellon University
23 *  Pittsburgh PA 15213-3890
24 *
25 * any improvements or extensions that they make and grant Carnegie Mellon
26 * the rights to redistribute these changes.
27 */
28
29/*
30 *	Assembly coding style
31 *
32 *	This file contains macros and register defines to
33 *	aid in writing more readable assembly code.
34 *	Some rules to make assembly code understandable by
35 *	a debugger are also noted.
36 *
37 *	The document
38 *
39 *		"ALPHA Calling Standard", DEC 27-Apr-90
40 *
41 *	defines (a superset of) the rules and conventions
42 *	we use.  While we make no promise of adhering to
43 *	such standard and its evolution (esp where we
44 *	can get faster code paths) it is certainly intended
45 *	that we be interoperable with such standard.
46 *
47 *	In this sense, this file is a proper part of the
48 *	definition of the (software) Alpha architecture.
49 */
50
51/*
52 * Macro to make a local label name.
53 */
54#define	LLABEL(name,num)	L ## name ## num
55
56/*
57 * MCOUNT
58 */
59
60#if !defined(GPROF) && !defined(PROF)
61#define MCOUNT	/* nothing */
62#else
63#define MCOUNT					\
64	br.call.sptk.many b7=_mcount
65#endif
66
67/*
68 * ENTRY
69 *	Declare a global leaf function.
70 *	A leaf function does not call other functions.
71 */
72#define	ENTRY(_name_, _n_args_)			\
73	.global	_name_;				\
74	.align	16;				\
75	.proc	_name_;				\
76_name_:;					\
77	.regstk	_n_args_, 0, 0, 0		\
78	MCOUNT
79
80#define	ENTRY_NOPROFILE(_name_, _n_args_)	\
81	.global	_name_;				\
82	.align	16;				\
83	.proc	_name_;				\
84_name_:;					\
85	.regstk	_n_args_, 0, 0, 0
86
87/*
88 * STATIC_ENTRY
89 *	Declare a local leaf function.
90 */
91#define STATIC_ENTRY(_name_, _n_args_)		\
92	.align	16;				\
93	.proc	_name_;				\
94_name_:;					\
95	.regstk	_n_args_, 0, 0, 0		\
96	MCOUNT
97/*
98 * XENTRY
99 *	Global alias for a leaf function, or alternate entry point
100 */
101#define	XENTRY(_name_)				\
102	.globl	_name_;				\
103_name_:
104
105/*
106 * STATIC_XENTRY
107 *	Local alias for a leaf function, or alternate entry point
108 */
109#define	STATIC_XENTRY(_name_)			\
110_name_:
111
112
113/*
114 * END
115 *	Function delimiter
116 */
117#define	END(_name_)						\
118	.endp	_name_
119
120
121/*
122 * EXPORT
123 *	Export a symbol
124 */
125#define	EXPORT(_name_)						\
126	.global	_name_;						\
127_name_:
128
129
130/*
131 * IMPORT
132 *	Make an external name visible, typecheck the size
133 */
134#define	IMPORT(_name_, _size_)					\
135	/* .extern	_name_,_size_ */
136
137
138/*
139 * ABS
140 *	Define an absolute symbol
141 */
142#define	ABS(_name_, _value_)					\
143	.globl	_name_;						\
144_name_	=	_value_
145
146
147/*
148 * BSS
149 *	Allocate un-initialized space for a global symbol
150 */
151#define	BSS(_name_,_numbytes_)					\
152	.comm	_name_,_numbytes_
153
154
155/*
156 * MSG
157 *	Allocate space for a message (a read-only ascii string)
158 */
159#define	ASCIZ	.asciz
160#define	MSG(msg,reg,label)			\
161	addl reg,@ltoff(label),gp;;		\
162	ld8 reg=[reg];;				\
163	.data;					\
164label:	ASCIZ msg;				\
165	.text;
166
167/*
168 * System call glue.
169 */
170#define	SYSCALLNUM(name)			\
171	SYS_ ## name
172
173#define	CALLSYS_NOERROR(name)			\
174	mov	r15=SYSCALLNUM(name);		\
175	break	0x100000 ;;
176
177/*
178 * WEAK_ALIAS: create a weak alias (ELF only).
179 */
180#ifdef __ELF__
181#define WEAK_ALIAS(alias,sym)					\
182	.weak alias;						\
183	alias = sym
184#endif
185
186/*
187 * Kernel RCS ID tag and copyright macros
188 */
189
190#ifdef _KERNEL
191
192#ifdef __ELF__
193#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
194	.section _sec ; .asciz _str ; .text
195#else /* __ELF__ */
196#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
197	.data ; .asciz _str ; .align 3 ; .text
198#endif /* __ELF__ */
199
200#define	__KERNEL_RCSID(_n, _s)		__KERNEL_SECTIONSTRING(.ident, _s)
201#define	__KERNEL_COPYRIGHT(_n, _s)	__KERNEL_SECTIONSTRING(.copyright, _s)
202
203#ifdef NO_KERNEL_RCSIDS
204#undef __KERNEL_RCSID
205#define	__KERNEL_RCSID(_n, _s)		/* nothing */
206#endif
207
208#endif /* _KERNEL */
209
210#if !defined(lint) && !defined(STRIP_FBSDID)
211#define __FBSDID(s)	.ident s
212#else
213#define __FBSDID(s)	/* nothing */
214#endif /* not lint and not STRIP_FBSDID */
215