asm.h revision 1.19 1 /* $NetBSD: asm.h,v 1.19 2025/01/04 21:10:19 skrll Exp $ */
2
3 /* $OpenBSD: asm.h,v 1.12 2001/03/29 02:15:57 mickey Exp $ */
4
5 /*
6 * Copyright (c) 1990,1991,1994 The University of Utah and
7 * the Computer Systems Laboratory (CSL). All rights reserved.
8 *
9 * Permission to use, copy, modify and distribute this software is hereby
10 * granted provided that (1) source code retains these copyright, permission,
11 * and disclaimer notices, and (2) redistributions including binaries
12 * reproduce the notices in supporting documentation, and (3) all advertising
13 * materials mentioning features or use of this software display the following
14 * acknowledgement: ``This product includes software developed by the
15 * Computer Systems Laboratory at the University of Utah.''
16 *
17 * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
18 * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
19 * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20 *
21 * CSL requests users of this software to return to csl-dist (at) cs.utah.edu any
22 * improvements that they make and grant CSL redistribution rights.
23 *
24 * Utah $Hdr: asm.h 1.8 94/12/14$
25 */
26
27 #ifndef _HPPA_ASM_H_
28 #define _HPPA_ASM_H_
29
30 #include <machine/frame.h>
31 /*
32 * hppa assembler definitions
33 */
34
35 #ifdef __STDC__
36 #define __CONCAT(a,b) a ## b
37 #else
38 #define __CONCAT(a,b) a/**/b
39 #endif
40
41 #define _C_LABEL(x) x
42
43 #define _ASM_LS_CHAR !
44
45 #define _ENTRY(x) \
46 ! .text ! .align 4 !\
47 .export x, entry ! .label x ! .proc
48
49 #define LEAF_ENTRY_NOPROFILE(x) !\
50 _ENTRY(x) !\
51 .callinfo frame=0, no_calls, save_rp !\
52 .entry
53
54 #define ENTRY_NOPROFILE(x,n) !\
55 _ENTRY(x) !\
56 .callinfo frame=n, calls, save_rp, save_sp !\
57 .entry
58
59 #ifdef GPROF
60
61 #define _PROF_PROLOGUE !\
62 1: !\
63 stw %rp, HPPA_FRAME_CRP(%sp) !\
64 stw %arg0, HPPA_FRAME_ARG(0)(%sp) !\
65 stw %arg1, HPPA_FRAME_ARG(1)(%sp) !\
66 stw %arg2, HPPA_FRAME_ARG(2)(%sp) !\
67 stw %arg3, HPPA_FRAME_ARG(3)(%sp) !\
68 ldo HPPA_FRAME_SIZE(%sp), %sp !\
69 copy %rp, %arg0 !\
70 bl 2f, %arg1 !\
71 depi 0, 31, 2, %arg1 !\
72 2: !\
73 bl _mcount, %rp !\
74 ldo 1b - 2b(%arg1), %arg1 !\
75 ldo -HPPA_FRAME_SIZE(%sp), %sp !\
76 ldw HPPA_FRAME_ARG(3)(%sp), %arg3 !\
77 ldw HPPA_FRAME_ARG(2)(%sp), %arg2 !\
78 ldw HPPA_FRAME_ARG(1)(%sp), %arg1 !\
79 ldw HPPA_FRAME_ARG(0)(%sp), %arg0 !\
80 ldw HPPA_FRAME_CRP(%sp), %rp !\
81
82 #define LEAF_ENTRY(x) !\
83 ENTRY_NOPROFILE(x,HPPA_FRAME_SIZE) !\
84 _PROF_PROLOGUE
85
86 #else /* GPROF */
87
88 #define _PROF_PROLOGUE
89
90 #define LEAF_ENTRY(x) !\
91 LEAF_ENTRY_NOPROFILE(x)
92
93 #endif /* GPROF */
94
95 #define ENTRY(x,n) !\
96 ENTRY_NOPROFILE(x,n) !\
97 _PROF_PROLOGUE
98
99 #define ALTENTRY(x) ! .export x, entry ! .label x
100 #define EXIT(x) ! .exit ! .procend ! .size x, .-x
101
102 #ifdef _NETBSD_REVISIONID
103 #define RCSID(x) .pushsection ".ident","MS",@progbits,1; \
104 .asciz "$" "NetBSD: " __FILE__ \
105 " " _NETBSD_REVISIONID " $"; \
106 .popsection
107 #else
108 #define RCSID(x) .pushsection ".ident","MS",@progbits,1; \
109 .asciz x; \
110 .popsection
111 #endif
112
113 #define WEAK_ALIAS(alias,sym) \
114 .weak alias ! \
115 alias = sym
116
117 /*
118 * STRONG_ALIAS: create a strong alias.
119 */
120 #define STRONG_ALIAS(alias,sym) \
121 .globl alias ! \
122 alias = sym
123
124 #define CALL(func,tmp) !\
125 ldil L%func, tmp !\
126 ldo R%func(tmp), tmp !\
127 .call !\
128 blr %r0, %rp !\
129 bv,n %r0(tmp) !\
130 nop
131
132 #ifdef __PIC__
133 #define PIC_CALL(func) !\
134 addil LT%func, %r19 !\
135 ldw RT%func(%r1), %r1 !\
136 .call !\
137 blr %r0, %rp !\
138 bv,n %r0(%r1) !\
139 nop
140 #else
141 #define PIC_CALL(func) !\
142 CALL(func,%r1)
143 #endif
144
145 #ifdef __STDC__
146 #define WARN_REFERENCES(sym,msg) \
147 .pushsection .gnu.warning. ## sym; \
148 .ascii msg; \
149 .popsection
150 #else
151 #define WARN_REFERENCES(sym,msg) \
152 .pushsection .gnu.warning./**/sym; \
153 .ascii msg; \
154 .popsection
155 #endif /* __STDC__ */
156
157 #define BSS(n,s) .comm n, s
158 #define SZREG 4
159
160 #endif /* _HPPA_ASM_H_ */
161