asm.h revision 92998
166458Sdfr/* $FreeBSD: head/sys/ia64/include/asm.h 92998 2002-03-23 02:01:27Z obrien $ */
266458Sdfr/* From: NetBSD: asm.h,v 1.18 1997/11/03 04:22:06 ross Exp */
366458Sdfr
466458Sdfr/*
566458Sdfr * Copyright (c) 1991,1990,1989,1994,1995,1996 Carnegie Mellon University
666458Sdfr * All Rights Reserved.
766458Sdfr *
866458Sdfr * Permission to use, copy, modify and distribute this software and its
966458Sdfr * documentation is hereby granted, provided that both the copyright
1066458Sdfr * notice and this permission notice appear in all copies of the
1166458Sdfr * software, derivative works or modified versions, and any portions
1266458Sdfr * thereof, and that both notices appear in supporting documentation.
1366458Sdfr *
1466458Sdfr * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
1566458Sdfr * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
1666458Sdfr * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
1766458Sdfr *
1866458Sdfr * Carnegie Mellon requests users of this software to return to
1966458Sdfr *
2066458Sdfr *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
2166458Sdfr *  School of Computer Science
2266458Sdfr *  Carnegie Mellon University
2366458Sdfr *  Pittsburgh PA 15213-3890
2466458Sdfr *
2566458Sdfr * any improvements or extensions that they make and grant Carnegie Mellon
2666458Sdfr * the rights to redistribute these changes.
2766458Sdfr */
2866458Sdfr
2966458Sdfr/*
3066458Sdfr *	Assembly coding style
3166458Sdfr *
3266458Sdfr *	This file contains macros and register defines to
3366458Sdfr *	aid in writing more readable assembly code.
3466458Sdfr *	Some rules to make assembly code understandable by
3566458Sdfr *	a debugger are also noted.
3666458Sdfr *
3766458Sdfr *	The document
3866458Sdfr *
3966458Sdfr *		"ALPHA Calling Standard", DEC 27-Apr-90
4066458Sdfr *
4166458Sdfr *	defines (a superset of) the rules and conventions
4266458Sdfr *	we use.  While we make no promise of adhering to
4366458Sdfr *	such standard and its evolution (esp where we
4466458Sdfr *	can get faster code paths) it is certainly intended
4566458Sdfr *	that we be interoperable with such standard.
4666458Sdfr *
4766458Sdfr *	In this sense, this file is a proper part of the
4866458Sdfr *	definition of the (software) Alpha architecture.
4966458Sdfr */
5066458Sdfr
5166458Sdfr/*
5266458Sdfr * Macro to make a local label name.
5366458Sdfr */
5466458Sdfr#define	LLABEL(name,num)	L ## name ## num
5566458Sdfr
5666458Sdfr/*
5766458Sdfr * MCOUNT
5866458Sdfr */
5966458Sdfr
6066458Sdfr#if !defined(GPROF) && !defined(PROF)
6166458Sdfr#define MCOUNT	/* nothing */
6266458Sdfr#else
6366458Sdfr#define MCOUNT					\
6484801Sdfr	br.call.sptk.many b7=_mcount
6566458Sdfr#endif
6666458Sdfr
6766458Sdfr/*
6866633Sdfr * ENTRY
6966458Sdfr *	Declare a global leaf function.
7066458Sdfr *	A leaf function does not call other functions.
7166458Sdfr */
7266633Sdfr#define	ENTRY(_name_, _n_args_)			\
7366458Sdfr	.global	_name_;				\
7466633Sdfr	.align	16;				\
7566458Sdfr	.proc	_name_;				\
7666458Sdfr_name_:;					\
7766458Sdfr	.regstk	_n_args_, 0, 0, 0		\
7866458Sdfr	MCOUNT
7966458Sdfr
8066633Sdfr#define	ENTRY_NOPROFILE(_name_, _n_args_)	\
8166458Sdfr	.global	_name_;				\
8266633Sdfr	.align	16;				\
8366458Sdfr	.proc	_name_;				\
8466458Sdfr_name_:;					\
8566458Sdfr	.regstk	_n_args_, 0, 0, 0
8666458Sdfr
8766458Sdfr/*
8866633Sdfr * STATIC_ENTRY
8966458Sdfr *	Declare a local leaf function.
9066458Sdfr */
9166633Sdfr#define STATIC_ENTRY(_name_, _n_args_)		\
9266633Sdfr	.align	16;				\
9366458Sdfr	.proc	_name_;				\
9466458Sdfr_name_:;					\
9566458Sdfr	.regstk	_n_args_, 0, 0, 0		\
9666458Sdfr	MCOUNT
9766458Sdfr/*
9866633Sdfr * XENTRY
9966458Sdfr *	Global alias for a leaf function, or alternate entry point
10066458Sdfr */
10166633Sdfr#define	XENTRY(_name_)				\
10266458Sdfr	.globl	_name_;				\
10366458Sdfr_name_:
10466458Sdfr
10566458Sdfr/*
10666633Sdfr * STATIC_XENTRY
10766458Sdfr *	Local alias for a leaf function, or alternate entry point
10866458Sdfr */
10966633Sdfr#define	STATIC_XENTRY(_name_)			\
11066458Sdfr_name_:
11166458Sdfr
11266458Sdfr
11366458Sdfr/*
11466458Sdfr * END
11566458Sdfr *	Function delimiter
11666458Sdfr */
11766458Sdfr#define	END(_name_)						\
11866458Sdfr	.endp	_name_
11966458Sdfr
12066458Sdfr
12166458Sdfr/*
12266458Sdfr * EXPORT
12366458Sdfr *	Export a symbol
12466458Sdfr */
12566458Sdfr#define	EXPORT(_name_)						\
12666458Sdfr	.global	_name_;						\
12766458Sdfr_name_:
12866458Sdfr
12966458Sdfr
13066458Sdfr/*
13166458Sdfr * IMPORT
13266458Sdfr *	Make an external name visible, typecheck the size
13366458Sdfr */
13466458Sdfr#define	IMPORT(_name_, _size_)					\
13566458Sdfr	/* .extern	_name_,_size_ */
13666458Sdfr
13766458Sdfr
13866458Sdfr/*
13966458Sdfr * ABS
14066458Sdfr *	Define an absolute symbol
14166458Sdfr */
14266458Sdfr#define	ABS(_name_, _value_)					\
14366458Sdfr	.globl	_name_;						\
14466458Sdfr_name_	=	_value_
14566458Sdfr
14666458Sdfr
14766458Sdfr/*
14866458Sdfr * BSS
14966458Sdfr *	Allocate un-initialized space for a global symbol
15066458Sdfr */
15166458Sdfr#define	BSS(_name_,_numbytes_)					\
15266458Sdfr	.comm	_name_,_numbytes_
15366458Sdfr
15466458Sdfr
15566458Sdfr/*
15666458Sdfr * MSG
15766458Sdfr *	Allocate space for a message (a read-only ascii string)
15866458Sdfr */
15966458Sdfr#define	ASCIZ	.asciz
16066633Sdfr#define	MSG(msg,reg,label)			\
16166633Sdfr	addl reg,@ltoff(label),gp;;		\
16266633Sdfr	ld8 reg=[reg];;				\
16366633Sdfr	.data;					\
16466633Sdfrlabel:	ASCIZ msg;				\
16566458Sdfr	.text;
16666458Sdfr
16766458Sdfr/*
16866458Sdfr * System call glue.
16966458Sdfr */
17066458Sdfr#define	SYSCALLNUM(name)			\
17166458Sdfr	SYS_ ## name
17266458Sdfr
17366458Sdfr#define	CALLSYS_NOERROR(name)			\
17466458Sdfr	mov	r15=SYSCALLNUM(name);		\
17566458Sdfr	break	0x100000 ;;
17666458Sdfr
17766458Sdfr/*
17866458Sdfr * WEAK_ALIAS: create a weak alias (ELF only).
17966458Sdfr */
18066458Sdfr#ifdef __ELF__
18166458Sdfr#define WEAK_ALIAS(alias,sym)					\
18266458Sdfr	.weak alias;						\
18366458Sdfr	alias = sym
18466458Sdfr#endif
18566458Sdfr
18666458Sdfr/*
18766458Sdfr * Kernel RCS ID tag and copyright macros
18866458Sdfr */
18966458Sdfr
19066458Sdfr#ifdef _KERNEL
19166458Sdfr
19266458Sdfr#ifdef __ELF__
19366458Sdfr#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
19466458Sdfr	.section _sec ; .asciz _str ; .text
19566458Sdfr#else /* __ELF__ */
19666458Sdfr#define	__KERNEL_SECTIONSTRING(_sec, _str)				\
19766458Sdfr	.data ; .asciz _str ; .align 3 ; .text
19866458Sdfr#endif /* __ELF__ */
19966458Sdfr
20066458Sdfr#define	__KERNEL_RCSID(_n, _s)		__KERNEL_SECTIONSTRING(.ident, _s)
20166458Sdfr#define	__KERNEL_COPYRIGHT(_n, _s)	__KERNEL_SECTIONSTRING(.copyright, _s)
20266458Sdfr
20366458Sdfr#ifdef NO_KERNEL_RCSIDS
20466458Sdfr#undef __KERNEL_RCSID
20566458Sdfr#define	__KERNEL_RCSID(_n, _s)		/* nothing */
20666458Sdfr#endif
20766458Sdfr
20866458Sdfr#endif /* _KERNEL */
20992998Sobrien
21092998Sobrien#if !defined(lint) && !defined(STRIP_FBSDID)
21192998Sobrien#define __FBSDID(s)	.ident s
21292998Sobrien#else
21392998Sobrien#define __FBSDID(s)	/* nothing */
21492998Sobrien#endif /* not lint and not STRIP_FBSDID */
215