xref: /openbsd-src/sys/arch/powerpc/include/asm.h (revision 99fd087599a8791921855f21bd7e36130f39aadc)
1 /*	$OpenBSD: asm.h,v 1.14 2017/06/29 17:36:16 deraadt Exp $	*/
2 /*	$NetBSD: asm.h,v 1.1 1996/09/30 16:34:20 ws Exp $	*/
3 
4 /*
5  * Copyright (C) 1995, 1996 Wolfgang Solfrank.
6  * Copyright (C) 1995, 1996 TooLs GmbH.
7  * All rights reserved.
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *	This product includes software developed by TooLs GmbH.
20  * 4. The name of TooLs GmbH may not be used to endorse or promote products
21  *    derived from this software without specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``AS IS'' AND ANY EXPRESS OR
24  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26  * IN NO EVENT SHALL TOOLS GMBH BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
28  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
29  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
30  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
31  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
32  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _POWERPC_ASM_H_
36 #define _POWERPC_ASM_H_
37 
38 /* XXX */
39 #define TARGET_ELF
40 
41 #ifdef __PIC__
42 #define PIC_PROLOGUE	XXX
43 #define PIC_EPILOGUE	XXX
44 #ifdef	__STDC__
45 #define PIC_PLT(x)	x ## @plt
46 #define PIC_GOT(x)	XXX
47 #define PIC_GOTOFF(x)	XXX
48 #else	/* not __STDC__ */
49 #define PIC_PLT(x)	x/**/@plt
50 #define PIC_GOT(x)	XXX
51 #define PIC_GOTOFF(x)	XXX
52 #endif	/* __STDC__ */
53 #else
54 #define PIC_PROLOGUE
55 #define PIC_EPILOGUE
56 #define PIC_PLT(x)	x
57 #define PIC_GOT(x)	x
58 #define PIC_GOTOFF(x)	x
59 #endif
60 
61 #ifdef TARGET_ELF
62 # define _C_LABEL(x)	x
63 #endif
64 #define	_ASM_LABEL(x)	x
65 
66 #ifdef __STDC__
67 # define _TMP_LABEL(x)	.L_ ## x
68 #else
69 # define _TMP_LABEL(x)	.L_/**/x
70 #endif
71 
72 #define _ENTRY(x) \
73 	.text; .align 2; .globl x; .type x,@function; x:
74 
75 #if defined(PROF) || defined(GPROF)
76 # define _PROF_PROLOGUE(y)	\
77 	.section ".data"; \
78 	.align 2; \
79 _TMP_LABEL(y):; \
80 	.long 0; \
81 	.section ".text"; \
82 	mflr 0; \
83 	addis 11, 11, _TMP_LABEL(y)@ha; \
84 	stw 0, 4(1); \
85 	addi 0, 11,_TMP_LABEL(y)@l; \
86 	bl _mcount;
87 #else
88 # define _PROF_PROLOGUE(y)
89 #endif
90 
91 #define	ENTRY(y)	_ENTRY(_C_LABEL(y)); _PROF_PROLOGUE(y)
92 #define	ASENTRY(y)	_ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE(y)
93 #define	END(y)		.size y, . - y
94 
95 #define STRONG_ALIAS(alias,sym) \
96 	.global alias; .set alias,sym
97 #define WEAK_ALIAS(alias,sym) \
98 	.weak alias; .set alias,sym
99 
100 #endif /* !_POWERPC_ASM_H_ */
101