asm.h revision 1.6.12.2 1 /* $NetBSD: asm.h,v 1.6.12.2 2007/09/03 14:23:18 yamt Exp $ */
2
3 /*
4 * Copyright (c) 1990 The Regents of the University of California.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to Berkeley by
8 * William Jolitz.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 * from: @(#)asm.h 5.5 (Berkeley) 5/7/91
35 */
36
37 #ifndef _ARM32_ASM_H_
38 #define _ARM32_ASM_H_
39
40 #include <arm/cdefs.h>
41
42 #ifdef __ELF__
43 # define _C_LABEL(x) x
44 #else
45 # ifdef __STDC__
46 # define _C_LABEL(x) _ ## x
47 # else
48 # define _C_LABEL(x) _/**/x
49 # endif
50 #endif
51 #define _ASM_LABEL(x) x
52
53 #ifdef __STDC__
54 # define __CONCAT(x,y) x ## y
55 # define __STRING(x) #x
56 #else
57 # define __CONCAT(x,y) x/**/y
58 # define __STRING(x) "x"
59 #endif
60
61 #ifndef _ALIGN_TEXT
62 # define _ALIGN_TEXT .align 0
63 #endif
64
65 /*
66 * gas/arm uses @ as a single comment character and thus cannot be used here
67 * Instead it recognised the # instead of an @ symbols in .type directives
68 * We define a couple of macros so that assembly code will not be dependant
69 * on one or the other.
70 */
71 #define _ASM_TYPE_FUNCTION %function
72 #define _ASM_TYPE_OBJECT %object
73 #define _ENTRY(x) \
74 .text; _ALIGN_TEXT; .globl x; .type x,_ASM_TYPE_FUNCTION; x:
75 #define _END(x) .size x,.-x
76 #define END(y) _END(_C_LABEL(y))
77 #define ASEND(y) _END(_ASM_LABEL(y))
78
79
80 #ifdef GPROF
81 # ifdef __ELF__
82 # define _PROF_PROLOGUE \
83 mov ip, lr; bl __mcount
84 # else
85 # define _PROF_PROLOGUE \
86 mov ip,lr; bl mcount
87 # endif
88 #else
89 # define _PROF_PROLOGUE
90 #endif
91
92 #define ENTRY(y) _ENTRY(_C_LABEL(y)); _PROF_PROLOGUE
93 #define ENTRY_NP(y) _ENTRY(_C_LABEL(y))
94 #define ASENTRY(y) _ENTRY(_ASM_LABEL(y)); _PROF_PROLOGUE
95 #define ASENTRY_NP(y) _ENTRY(_ASM_LABEL(y))
96 #define END(y) _END(_C_LABEL(y))
97 #define ASEND(y) _END(_ASM_LABEL(y))
98
99 #define ASMSTR .asciz
100
101 #if defined(__ELF__) && defined(PIC)
102 #ifdef __STDC__
103 #define PIC_SYM(x,y) x ## ( ## y ## )
104 #else
105 #define PIC_SYM(x,y) x/**/(/**/y/**/)
106 #endif
107 #else
108 #define PIC_SYM(x,y) x
109 #endif
110
111 #ifdef __ELF__
112 #define RCSID(x) .section ".ident"; .asciz x
113 #else
114 #define RCSID(x) .text; .asciz x
115 #endif
116
117 #ifdef __ELF__
118 #define WEAK_ALIAS(alias,sym) \
119 .weak alias; \
120 alias = sym
121 #endif
122
123 /*
124 * STRONG_ALIAS: create a strong alias.
125 */
126 #define STRONG_ALIAS(alias,sym) \
127 .globl alias; \
128 alias = sym
129
130 #ifdef __STDC__
131 #define WARN_REFERENCES(sym,msg) \
132 .stabs msg ## ,30,0,0,0 ; \
133 .stabs __STRING(_C_LABEL(sym)) ## ,1,0,0,0
134 #elif defined(__ELF__)
135 #define WARN_REFERENCES(sym,msg) \
136 .stabs msg,30,0,0,0 ; \
137 .stabs __STRING(sym),1,0,0,0
138 #else
139 #define WARN_REFERENCES(sym,msg) \
140 .stabs msg,30,0,0,0 ; \
141 .stabs __STRING(_/**/sym),1,0,0,0
142 #endif /* __STDC__ */
143
144 #if defined (_ARM_ARCH_6)
145 #define GET_CPUINFO(rX) mrc p15, 0, rX, c13, c0, 4
146 #endif
147
148 #if defined (_ARM_ARCH_4T)
149 # define RET bx lr
150 # ifdef __STDC__
151 # define RETc(c) bx##c lr
152 # else
153 # define RETc(c) bx/**/c lr
154 # endif
155 #else
156 # define RET mov pc, lr
157 # ifdef __STDC__
158 # define RETc(c) mov##c pc, lr
159 # else
160 # define RETc(c) mov/**/c pc, lr
161 # endif
162 #endif
163
164 #endif /* !_ARM_ASM_H_ */
165