asm.h revision 141085
1/* $FreeBSD: head/sys/ia64/include/asm.h 141085 2005-01-31 08:16:45Z imp $ */ 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 38/* 39 * Macro to make a local label name. 40 */ 41#define LLABEL(name,num) L ## name ## num 42 43/* 44 * MCOUNT 45 */ 46#if defined(GPROF) 47#define MCOUNT \ 48 alloc out0 = ar.pfs, 8, 0, 4, 0; \ 49 mov out1 = r1; \ 50 mov out2 = b0;; \ 51 mov out3 = r0; \ 52 br.call.sptk b0 = _mcount;; 53#else 54#define MCOUNT /* nothing */ 55#endif 56 57/* 58 * ENTRY 59 * Declare a global leaf function. 60 * A leaf function does not call other functions. 61 */ 62#define ENTRY(_name_, _n_args_) \ 63 .global _name_; \ 64 .align 16; \ 65 .proc _name_; \ 66_name_:; \ 67 .regstk _n_args_, 0, 0, 0; \ 68 MCOUNT 69 70#define ENTRY_NOPROFILE(_name_, _n_args_) \ 71 .global _name_; \ 72 .align 16; \ 73 .proc _name_; \ 74_name_:; \ 75 .regstk _n_args_, 0, 0, 0 76 77/* 78 * STATIC_ENTRY 79 * Declare a local leaf function. 80 */ 81#define STATIC_ENTRY(_name_, _n_args_) \ 82 .align 16; \ 83 .proc _name_; \ 84_name_:; \ 85 .regstk _n_args_, 0, 0, 0 \ 86 MCOUNT 87/* 88 * XENTRY 89 * Global alias for a leaf function, or alternate entry point 90 */ 91#define XENTRY(_name_) \ 92 .globl _name_; \ 93_name_: 94 95/* 96 * STATIC_XENTRY 97 * Local alias for a leaf function, or alternate entry point 98 */ 99#define STATIC_XENTRY(_name_) \ 100_name_: 101 102 103/* 104 * END 105 * Function delimiter 106 */ 107#define END(_name_) \ 108 .endp _name_ 109 110 111/* 112 * EXPORT 113 * Export a symbol 114 */ 115#define EXPORT(_name_) \ 116 .global _name_; \ 117_name_: 118 119 120/* 121 * IMPORT 122 * Make an external name visible, typecheck the size 123 */ 124#define IMPORT(_name_, _size_) \ 125 /* .extern _name_,_size_ */ 126 127 128/* 129 * ABS 130 * Define an absolute symbol 131 */ 132#define ABS(_name_, _value_) \ 133 .globl _name_; \ 134_name_ = _value_ 135 136 137/* 138 * BSS 139 * Allocate un-initialized space for a global symbol 140 */ 141#define BSS(_name_,_numbytes_) \ 142 .comm _name_,_numbytes_ 143 144 145/* 146 * MSG 147 * Allocate space for a message (a read-only ascii string) 148 */ 149#define ASCIZ .asciz 150#define MSG(msg,reg,label) \ 151 addl reg,@ltoff(label),gp;; \ 152 ld8 reg=[reg];; \ 153 .data; \ 154label: ASCIZ msg; \ 155 .text; 156 157 158/* 159 * System call glue. 160 */ 161#define SYSCALLNUM(name) SYS_ ## name 162 163#define CALLSYS_NOERROR(name) \ 164{ .mmi ; \ 165 alloc r9 = ar.pfs, 0, 0, 8, 0 ; \ 166 mov r31 = ar.k5 ; \ 167 mov r10 = b0 ;; } \ 168{ .mib ; \ 169 mov r8 = SYSCALLNUM(name) ; \ 170 mov b7 = r31 ; \ 171 br.call.sptk b0 = b7 ;; } 172 173 174/* 175 * WEAK_ALIAS: create a weak alias (ELF only). 176 */ 177#define WEAK_ALIAS(alias,sym) \ 178 .weak alias; \ 179 alias = sym 180 181/* 182 * ID tag macros 183 */ 184#if !defined(lint) && !defined(STRIP_FBSDID) 185#define __FBSDID(s) .ident s 186#else 187#define __FBSDID(s) /* nothing */ 188#endif /* not lint and not STRIP_FBSDID */ 189