]> git.proxmox.com Git - mirror_edk2.git/blob - StdLib/Include/Ipf/machine/asm.h
SourceLevelDebugPkg: Removing ipf from edk2.
[mirror_edk2.git] / StdLib / Include / Ipf / machine / asm.h
1 /* $NetBSD: asm.h,v 1.4 2006/08/30 11:14:23 cherry Exp $ */
2
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.
12 *
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.
16 *
17 * Carnegie Mellon requests users of this software to return to
18 *
19 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
20 * School of Computer Science
21 * Carnegie Mellon University
22 * Pittsburgh PA 15213-3890
23 *
24 * any improvements or extensions that they make and grant Carnegie Mellon
25 * the rights to redistribute these changes.
26 */
27
28 /*
29 * Assembly coding style
30 *
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.
35 */
36
37 /*
38 * Macro to make a local label name.
39 */
40 #define LLABEL(name,num) L ## name ## num
41
42 /*
43 * MCOUNT
44 */
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
55
56 /*
57 * ENTRY
58 * Declare a global leaf function.
59 * A leaf function does not call other functions.
60 */
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
68
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
75
76 /*
77 * STATIC_ENTRY
78 * Declare a local leaf function.
79 */
80 #define STATIC_ENTRY(_name_, _n_args_) \
81 .align 16; \
82 .proc _name_; \
83 _name_:; \
84 .regstk _n_args_, 0, 0, 0 \
85 MCOUNT
86 /*
87 * XENTRY
88 * Global alias for a leaf function, or alternate entry point
89 */
90 #define XENTRY(_name_) \
91 .globl _name_; \
92 _name_:
93
94 /*
95 * STATIC_XENTRY
96 * Local alias for a leaf function, or alternate entry point
97 */
98 #define STATIC_XENTRY(_name_) \
99 _name_:
100
101
102 /*
103 * END
104 * Function delimiter
105 */
106 #define END(_name_) \
107 .endp _name_
108
109
110 /*
111 * EXPORT
112 * Export a symbol
113 */
114 #define EXPORT(_name_) \
115 .global _name_; \
116 _name_:
117
118
119 /*
120 * IMPORT
121 * Make an external name visible, typecheck the size
122 */
123 #define IMPORT(_name_, _size_) \
124 /* .extern _name_,_size_ */
125
126
127 /*
128 * ABS
129 * Define an absolute symbol
130 */
131 #define ABS(_name_, _value_) \
132 .globl _name_; \
133 _name_ = _value_
134
135
136 /*
137 * BSS
138 * Allocate un-initialized space for a global symbol
139 */
140 #define BSS(_name_,_numbytes_) \
141 .comm _name_,_numbytes_
142
143
144 /*
145 * MSG
146 * Allocate space for a message (a read-only ascii string)
147 */
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;
155
156
157 /*
158 * System call glue.
159 */
160 #define SYSCALLNUM(name) ___CONCAT(SYS_,name)
161
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 ;; }
171
172
173 /*
174 * WEAK_ALIAS: create a weak alias (ELF only).
175 */
176 #define WEAK_ALIAS(alias,sym) \
177 .weak alias; \
178 alias = sym
179
180 /*
181 * STRONG_ALIAS: create a strong alias.
182 */
183 #define STRONG_ALIAS(alias,sym) \
184 .globl alias; \
185 alias = sym