xref: /netbsd-src/sys/arch/hppa/include/asm.h (revision 3dc08fb5f4d7b90747a75b174b7d0c0370c06766)
1*3dc08fb5Smartin /*	$NetBSD: asm.h,v 1.20 2025/01/06 10:46:43 martin Exp $	*/
2f4f0d8a3Sfredette 
3f4f0d8a3Sfredette /*	$OpenBSD: asm.h,v 1.12 2001/03/29 02:15:57 mickey Exp $	*/
4f4f0d8a3Sfredette 
5f4f0d8a3Sfredette /*
6f4f0d8a3Sfredette  * Copyright (c) 1990,1991,1994 The University of Utah and
7f4f0d8a3Sfredette  * the Computer Systems Laboratory (CSL).  All rights reserved.
8f4f0d8a3Sfredette  *
9f4f0d8a3Sfredette  * Permission to use, copy, modify and distribute this software is hereby
10f4f0d8a3Sfredette  * granted provided that (1) source code retains these copyright, permission,
11f4f0d8a3Sfredette  * and disclaimer notices, and (2) redistributions including binaries
12f4f0d8a3Sfredette  * reproduce the notices in supporting documentation, and (3) all advertising
13f4f0d8a3Sfredette  * materials mentioning features or use of this software display the following
14f4f0d8a3Sfredette  * acknowledgement: ``This product includes software developed by the
15f4f0d8a3Sfredette  * Computer Systems Laboratory at the University of Utah.''
16f4f0d8a3Sfredette  *
17f4f0d8a3Sfredette  * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS
18f4f0d8a3Sfredette  * IS" CONDITION.  THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF
19f4f0d8a3Sfredette  * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
20f4f0d8a3Sfredette  *
21f4f0d8a3Sfredette  * CSL requests users of this software to return to csl-dist@cs.utah.edu any
22f4f0d8a3Sfredette  * improvements that they make and grant CSL redistribution rights.
23f4f0d8a3Sfredette  *
24f4f0d8a3Sfredette  *	Utah $Hdr: asm.h 1.8 94/12/14$
25f4f0d8a3Sfredette  */
26f4f0d8a3Sfredette 
27f4f0d8a3Sfredette #ifndef _HPPA_ASM_H_
28f4f0d8a3Sfredette #define _HPPA_ASM_H_
29f4f0d8a3Sfredette 
30c1e4ee94Sskrll #include <machine/frame.h>
31f4f0d8a3Sfredette /*
32f4f0d8a3Sfredette  *	hppa assembler definitions
33f4f0d8a3Sfredette  */
34f4f0d8a3Sfredette 
35f4f0d8a3Sfredette #ifdef __STDC__
36f4f0d8a3Sfredette #define	__CONCAT(a,b)	a ## b
37f4f0d8a3Sfredette #else
38f4f0d8a3Sfredette #define	__CONCAT(a,b)	a/**/b
39f4f0d8a3Sfredette #endif
40f4f0d8a3Sfredette 
41e151146bSskrll #define _C_LABEL(x)	x
42e151146bSskrll 
43ad5c6971Sskrll #define _ASM_LS_CHAR	!
44ad5c6971Sskrll 
4553f3286eSskrll #define	_ENTRY(x) \
46c1e4ee94Sskrll 	 ! .text ! .align 4				!\
4753f3286eSskrll 	.export x, entry ! .label x ! .proc
4853f3286eSskrll 
4953f3286eSskrll #define	LEAF_ENTRY_NOPROFILE(x)				!\
5053f3286eSskrll 	_ENTRY(x)					!\
51f4f0d8a3Sfredette 	.callinfo frame=0, no_calls, save_rp		!\
52c1e4ee94Sskrll 	.entry
53f4f0d8a3Sfredette 
54c1e4ee94Sskrll #define	ENTRY_NOPROFILE(x,n)				!\
5553f3286eSskrll 	_ENTRY(x)					!\
569759b269Sthorpej 	.callinfo frame=n, calls, save_rp, save_sp	!\
579759b269Sthorpej 	.entry
589759b269Sthorpej 
59c1e4ee94Sskrll #ifdef GPROF
60c1e4ee94Sskrll 
61c1e4ee94Sskrll #define	_PROF_PROLOGUE				!\
62c1e4ee94Sskrll 1:						!\
63c1e4ee94Sskrll 	stw	%rp, HPPA_FRAME_CRP(%sp)	!\
64c1e4ee94Sskrll 	stw	%arg0, HPPA_FRAME_ARG(0)(%sp)	!\
65c1e4ee94Sskrll 	stw	%arg1, HPPA_FRAME_ARG(1)(%sp)	!\
66c1e4ee94Sskrll 	stw	%arg2, HPPA_FRAME_ARG(2)(%sp)	!\
67c1e4ee94Sskrll 	stw	%arg3, HPPA_FRAME_ARG(3)(%sp)	!\
68c1e4ee94Sskrll 	ldo	HPPA_FRAME_SIZE(%sp), %sp	!\
69c1e4ee94Sskrll 	copy	%rp, %arg0			!\
70c1e4ee94Sskrll 	bl	2f, %arg1			!\
71c1e4ee94Sskrll 	 depi	0, 31, 2, %arg1			!\
72c1e4ee94Sskrll 2:						!\
73c1e4ee94Sskrll 	bl	_mcount, %rp			!\
74c1e4ee94Sskrll 	 ldo	1b - 2b(%arg1), %arg1		!\
75c1e4ee94Sskrll 	ldo	-HPPA_FRAME_SIZE(%sp), %sp	!\
76c1e4ee94Sskrll 	ldw	HPPA_FRAME_ARG(3)(%sp), %arg3	!\
77c1e4ee94Sskrll 	ldw	HPPA_FRAME_ARG(2)(%sp), %arg2	!\
78c1e4ee94Sskrll 	ldw	HPPA_FRAME_ARG(1)(%sp), %arg1	!\
79c1e4ee94Sskrll 	ldw	HPPA_FRAME_ARG(0)(%sp), %arg0	!\
80c1e4ee94Sskrll 	ldw	HPPA_FRAME_CRP(%sp), %rp	!\
81c1e4ee94Sskrll 
82c1e4ee94Sskrll #define LEAF_ENTRY(x) 				!\
83c1e4ee94Sskrll 	ENTRY_NOPROFILE(x,HPPA_FRAME_SIZE)	!\
84c1e4ee94Sskrll 	_PROF_PROLOGUE
85c1e4ee94Sskrll 
86c1e4ee94Sskrll #else /* GPROF */
87c1e4ee94Sskrll 
88c1e4ee94Sskrll #define _PROF_PROLOGUE
89c1e4ee94Sskrll 
90c1e4ee94Sskrll #define LEAF_ENTRY(x) 				!\
91c1e4ee94Sskrll 	LEAF_ENTRY_NOPROFILE(x)
92c1e4ee94Sskrll 
93c1e4ee94Sskrll #endif /* GPROF */
94c1e4ee94Sskrll 
95c1e4ee94Sskrll #define ENTRY(x,n) 				!\
96c1e4ee94Sskrll 	ENTRY_NOPROFILE(x,n)			!\
97c1e4ee94Sskrll 	_PROF_PROLOGUE
98c1e4ee94Sskrll 
99f4f0d8a3Sfredette #define ALTENTRY(x) ! .export x, entry ! .label x
1003581d4c5Sskrll #define EXIT(x) ! .exit ! .procend ! .size x, .-x
101f4f0d8a3Sfredette 
102d6a549d8Sskrll #ifdef _NETBSD_REVISIONID
103d6a549d8Sskrll #define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
104*3dc08fb5Smartin 			.asciz x;					\
105*3dc08fb5Smartin 			.ascii "$"; .ascii "NetBSD: "; .ascii __FILE__;	\
106*3dc08fb5Smartin 			.ascii " "; .ascii _NETBSD_REVISIONID;		\
107*3dc08fb5Smartin 			.asciz " $";					\
108d6a549d8Sskrll 			.popsection
109d6a549d8Sskrll #else
110628289e3Sjoerg #define RCSID(x)	.pushsection ".ident","MS",@progbits,1;		\
111628289e3Sjoerg 			.asciz x;					\
112a5e30beaSmatt 			.popsection
113d6a549d8Sskrll #endif
114f4f0d8a3Sfredette 
115f4f0d8a3Sfredette #define WEAK_ALIAS(alias,sym)				\
116f4f0d8a3Sfredette 	.weak alias !					\
117f4f0d8a3Sfredette 	alias = sym
118f4f0d8a3Sfredette 
1193ffa241fSchristos /*
1203ffa241fSchristos  * STRONG_ALIAS: create a strong alias.
1213ffa241fSchristos  */
1223ffa241fSchristos #define STRONG_ALIAS(alias,sym)				\
1233ffa241fSchristos 	.globl alias !					\
1243ffa241fSchristos 	alias = sym
1253ffa241fSchristos 
1260d86a5cdSchs #define CALL(func,tmp)					!\
1270d86a5cdSchs 	ldil	L%func, tmp				!\
1280d86a5cdSchs 	ldo	R%func(tmp), tmp			!\
1290d86a5cdSchs 	.call						!\
1300d86a5cdSchs 	blr	%r0, %rp				!\
1310d86a5cdSchs 	bv,n	%r0(tmp)				!\
1320d86a5cdSchs 	nop
1330d86a5cdSchs 
1344d12bfcdSjoerg #ifdef __PIC__
1350d86a5cdSchs #define PIC_CALL(func)					!\
1360d86a5cdSchs 	addil	LT%func, %r19				!\
1370d86a5cdSchs 	ldw	RT%func(%r1), %r1			!\
1380d86a5cdSchs 	.call						!\
1390d86a5cdSchs 	blr	%r0, %rp				!\
1400d86a5cdSchs 	bv,n	%r0(%r1)				!\
1410d86a5cdSchs 	nop
1420d86a5cdSchs #else
1430d86a5cdSchs #define PIC_CALL(func)					!\
1440d86a5cdSchs 	CALL(func,%r1)
1450d86a5cdSchs #endif
1460d86a5cdSchs 
1473581d4c5Sskrll #ifdef __STDC__
1483581d4c5Sskrll #define	WARN_REFERENCES(sym,msg)					\
1493e11e269Sjoerg 	.pushsection .gnu.warning. ## sym;				\
1503e11e269Sjoerg 	.ascii msg;							\
1513e11e269Sjoerg 	.popsection
1523581d4c5Sskrll #else
1533581d4c5Sskrll #define	WARN_REFERENCES(sym,msg)					\
1543e11e269Sjoerg 	.pushsection .gnu.warning./**/sym;				\
1553e11e269Sjoerg 	.ascii msg;							\
1563e11e269Sjoerg 	.popsection
1573e11e269Sjoerg #endif /* __STDC__ */
158f4f0d8a3Sfredette 
159e15992e3Sskrll #define	BSS(n,s)	.comm n, s
1600d86a5cdSchs #define	SZREG	4
1610d86a5cdSchs 
162f4f0d8a3Sfredette #endif /* _HPPA_ASM_H_ */
163