asm.h revision 103436
166458Sdfr/* $FreeBSD: head/sys/ia64/include/asm.h 103436 2002-09-17 01:49:00Z peter $ */
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
3866458Sdfr/*
3966458Sdfr * Macro to make a local label name.
4066458Sdfr */
4166458Sdfr#define	LLABEL(name,num)	L ## name ## num
4266458Sdfr
4366458Sdfr/*
4466458Sdfr * MCOUNT
4566458Sdfr */
4666458Sdfr
4766458Sdfr#if !defined(GPROF) && !defined(PROF)
4866458Sdfr#define MCOUNT	/* nothing */
4966458Sdfr#else
5066458Sdfr#define MCOUNT					\
5184801Sdfr	br.call.sptk.many b7=_mcount
5266458Sdfr#endif
5366458Sdfr
5466458Sdfr/*
5566633Sdfr * ENTRY
5666458Sdfr *	Declare a global leaf function.
5766458Sdfr *	A leaf function does not call other functions.
5866458Sdfr */
5966633Sdfr#define	ENTRY(_name_, _n_args_)			\
6066458Sdfr	.global	_name_;				\
6166633Sdfr	.align	16;				\
6266458Sdfr	.proc	_name_;				\
6366458Sdfr_name_:;					\
6466458Sdfr	.regstk	_n_args_, 0, 0, 0		\
6566458Sdfr	MCOUNT
6666458Sdfr
6766633Sdfr#define	ENTRY_NOPROFILE(_name_, _n_args_)	\
6866458Sdfr	.global	_name_;				\
6966633Sdfr	.align	16;				\
7066458Sdfr	.proc	_name_;				\
7166458Sdfr_name_:;					\
7266458Sdfr	.regstk	_n_args_, 0, 0, 0
7366458Sdfr
7466458Sdfr/*
7566633Sdfr * STATIC_ENTRY
7666458Sdfr *	Declare a local leaf function.
7766458Sdfr */
7866633Sdfr#define STATIC_ENTRY(_name_, _n_args_)		\
7966633Sdfr	.align	16;				\
8066458Sdfr	.proc	_name_;				\
8166458Sdfr_name_:;					\
8266458Sdfr	.regstk	_n_args_, 0, 0, 0		\
8366458Sdfr	MCOUNT
8466458Sdfr/*
8566633Sdfr * XENTRY
8666458Sdfr *	Global alias for a leaf function, or alternate entry point
8766458Sdfr */
8866633Sdfr#define	XENTRY(_name_)				\
8966458Sdfr	.globl	_name_;				\
9066458Sdfr_name_:
9166458Sdfr
9266458Sdfr/*
9366633Sdfr * STATIC_XENTRY
9466458Sdfr *	Local alias for a leaf function, or alternate entry point
9566458Sdfr */
9666633Sdfr#define	STATIC_XENTRY(_name_)			\
9766458Sdfr_name_:
9866458Sdfr
9966458Sdfr
10066458Sdfr/*
10166458Sdfr * END
10266458Sdfr *	Function delimiter
10366458Sdfr */
10466458Sdfr#define	END(_name_)						\
10566458Sdfr	.endp	_name_
10666458Sdfr
10766458Sdfr
10866458Sdfr/*
10966458Sdfr * EXPORT
11066458Sdfr *	Export a symbol
11166458Sdfr */
11266458Sdfr#define	EXPORT(_name_)						\
11366458Sdfr	.global	_name_;						\
11466458Sdfr_name_:
11566458Sdfr
11666458Sdfr
11766458Sdfr/*
11866458Sdfr * IMPORT
11966458Sdfr *	Make an external name visible, typecheck the size
12066458Sdfr */
12166458Sdfr#define	IMPORT(_name_, _size_)					\
12266458Sdfr	/* .extern	_name_,_size_ */
12366458Sdfr
12466458Sdfr
12566458Sdfr/*
12666458Sdfr * ABS
12766458Sdfr *	Define an absolute symbol
12866458Sdfr */
12966458Sdfr#define	ABS(_name_, _value_)					\
13066458Sdfr	.globl	_name_;						\
13166458Sdfr_name_	=	_value_
13266458Sdfr
13366458Sdfr
13466458Sdfr/*
13566458Sdfr * BSS
13666458Sdfr *	Allocate un-initialized space for a global symbol
13766458Sdfr */
13866458Sdfr#define	BSS(_name_,_numbytes_)					\
13966458Sdfr	.comm	_name_,_numbytes_
14066458Sdfr
14166458Sdfr
14266458Sdfr/*
14366458Sdfr * MSG
14466458Sdfr *	Allocate space for a message (a read-only ascii string)
14566458Sdfr */
14666458Sdfr#define	ASCIZ	.asciz
14766633Sdfr#define	MSG(msg,reg,label)			\
14866633Sdfr	addl reg,@ltoff(label),gp;;		\
14966633Sdfr	ld8 reg=[reg];;				\
15066633Sdfr	.data;					\
15166633Sdfrlabel:	ASCIZ msg;				\
15266458Sdfr	.text;
15366458Sdfr
15466458Sdfr/*
15566458Sdfr * System call glue.
15666458Sdfr */
15766458Sdfr#define	SYSCALLNUM(name)			\
15866458Sdfr	SYS_ ## name
15966458Sdfr
16066458Sdfr#define	CALLSYS_NOERROR(name)			\
16166458Sdfr	mov	r15=SYSCALLNUM(name);		\
16266458Sdfr	break	0x100000 ;;
16366458Sdfr
16466458Sdfr/*
16566458Sdfr * WEAK_ALIAS: create a weak alias (ELF only).
16666458Sdfr */
16766458Sdfr#define WEAK_ALIAS(alias,sym)					\
16866458Sdfr	.weak alias;						\
16966458Sdfr	alias = sym
17066458Sdfr
17166458Sdfr/*
172103436Speter * ID tag macros
17366458Sdfr */
17492998Sobrien#if !defined(lint) && !defined(STRIP_FBSDID)
17592998Sobrien#define __FBSDID(s)	.ident s
17692998Sobrien#else
17792998Sobrien#define __FBSDID(s)	/* nothing */
17892998Sobrien#endif /* not lint and not STRIP_FBSDID */
179