Wed, 03 Jul 2019 20:42:37 +0800
Merge
1 /*
2 * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
25 /*
26 * This file has been modified by Loongson Technology in 2015. These
27 * modifications are Copyright (c) 2015 Loongson Technology, and are made
28 * available on the same license terms set forth above.
29 */
31 #ifndef SHARE_VM_ASM_REGISTER_HPP
32 #define SHARE_VM_ASM_REGISTER_HPP
34 #include "utilities/top.hpp"
36 // Use AbstractRegister as shortcut
37 class AbstractRegisterImpl;
38 typedef AbstractRegisterImpl* AbstractRegister;
41 // The super class for platform specific registers. Instead of using value objects,
42 // registers are implemented as pointers. Subclassing is used so all registers can
43 // use the debugging suport below. No virtual functions are used for efficiency.
44 // They are canonicalized; i.e., registers are equal if their pointers are equal,
45 // and vice versa. A concrete implementation may just map the register onto 'this'.
47 class AbstractRegisterImpl {
48 protected:
49 int value() const { return (int)(intx)this; }
50 };
53 //
54 // Macros for use in defining Register instances. We'd like to be
55 // able to simply define const instances of the RegisterImpl* for each
56 // of the registers needed on a system in a header file. However many
57 // compilers don't handle this very well and end up producing a
58 // private definition in every file which includes the header file.
59 // Along with the static constructors necessary for initialization it
60 // can consume a significant amount of space in the result library.
61 //
62 // The following macros allow us to declare the instance in a .hpp and
63 // produce an enumeration value which has the same number. Then in a
64 // .cpp the the register instance can be defined using the enumeration
65 // value. This avoids the use of static constructors and multiple
66 // definitions per .cpp. In addition #defines for the register can be
67 // produced so that the constant registers can be inlined. These
68 // macros should not be used inside other macros, because you may get
69 // multiple evaluations of the macros which can give bad results.
70 //
71 // Here are some example uses and expansions. Note that the macro
72 // invocation is terminated with a ;.
73 //
74 // CONSTANT_REGISTER_DECLARATION(Register, G0, 0);
75 //
76 // extern const Register G0 ;
77 // enum { G0_RegisterEnumValue = 0 } ;
78 //
79 // REGISTER_DECLARATION(Register, Gmethod, G5);
80 //
81 // extern const Register Gmethod ;
82 // enum { Gmethod_RegisterEnumValue = G5_RegisterEnumValue } ;
83 //
84 // REGISTER_DEFINITION(Register, G0);
85 //
86 // const Register G0 = ( ( Register ) G0_RegisterEnumValue ) ;
87 //
89 #define AS_REGISTER(type,name) ((type)name##_##type##EnumValue)
91 #define CONSTANT_REGISTER_DECLARATION(type, name, value) \
92 extern const type name; \
93 enum { name##_##type##EnumValue = (value) }
95 #define REGISTER_DECLARATION(type, name, value) \
96 extern const type name; \
97 enum { name##_##type##EnumValue = value##_##type##EnumValue }
99 #define REGISTER_DEFINITION(type, name) \
100 const type name = ((type)name##_##type##EnumValue)
102 #ifdef TARGET_ARCH_x86
103 # include "register_x86.hpp"
104 #endif
105 #ifdef TARGET_ARCH_sparc
106 # include "register_sparc.hpp"
107 #endif
108 #ifdef TARGET_ARCH_zero
109 # include "register_zero.hpp"
110 #endif
111 #ifdef TARGET_ARCH_arm
112 # include "register_arm.hpp"
113 #endif
114 #ifdef TARGET_ARCH_ppc
115 # include "register_ppc.hpp"
116 #endif
117 #ifdef TARGET_ARCH_mips
118 # include "register_mips.hpp"
119 #endif
122 // Debugging support
124 inline void assert_different_registers(
125 AbstractRegister a,
126 AbstractRegister b
127 ) {
128 assert(
129 a != b,
130 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT "",
131 p2i(a), p2i(b))
132 );
133 }
136 inline void assert_different_registers(
137 AbstractRegister a,
138 AbstractRegister b,
139 AbstractRegister c
140 ) {
141 assert(
142 a != b && a != c
143 && b != c,
144 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
145 ", c=" INTPTR_FORMAT "",
146 p2i(a), p2i(b), p2i(c))
147 );
148 }
151 inline void assert_different_registers(
152 AbstractRegister a,
153 AbstractRegister b,
154 AbstractRegister c,
155 AbstractRegister d
156 ) {
157 assert(
158 a != b && a != c && a != d
159 && b != c && b != d
160 && c != d,
161 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
162 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT "",
163 p2i(a), p2i(b), p2i(c), p2i(d))
164 );
165 }
168 inline void assert_different_registers(
169 AbstractRegister a,
170 AbstractRegister b,
171 AbstractRegister c,
172 AbstractRegister d,
173 AbstractRegister e
174 ) {
175 assert(
176 a != b && a != c && a != d && a != e
177 && b != c && b != d && b != e
178 && c != d && c != e
179 && d != e,
180 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
181 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT "",
182 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e))
183 );
184 }
187 inline void assert_different_registers(
188 AbstractRegister a,
189 AbstractRegister b,
190 AbstractRegister c,
191 AbstractRegister d,
192 AbstractRegister e,
193 AbstractRegister f
194 ) {
195 assert(
196 a != b && a != c && a != d && a != e && a != f
197 && b != c && b != d && b != e && b != f
198 && c != d && c != e && c != f
199 && d != e && d != f
200 && e != f,
201 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
202 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
203 ", f=" INTPTR_FORMAT "",
204 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f))
205 );
206 }
209 inline void assert_different_registers(
210 AbstractRegister a,
211 AbstractRegister b,
212 AbstractRegister c,
213 AbstractRegister d,
214 AbstractRegister e,
215 AbstractRegister f,
216 AbstractRegister g
217 ) {
218 assert(
219 a != b && a != c && a != d && a != e && a != f && a != g
220 && b != c && b != d && b != e && b != f && b != g
221 && c != d && c != e && c != f && c != g
222 && d != e && d != f && d != g
223 && e != f && e != g
224 && f != g,
225 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
226 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
227 ", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT "",
228 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g))
229 );
230 }
233 inline void assert_different_registers(
234 AbstractRegister a,
235 AbstractRegister b,
236 AbstractRegister c,
237 AbstractRegister d,
238 AbstractRegister e,
239 AbstractRegister f,
240 AbstractRegister g,
241 AbstractRegister h
242 ) {
243 assert(
244 a != b && a != c && a != d && a != e && a != f && a != g && a != h
245 && b != c && b != d && b != e && b != f && b != g && b != h
246 && c != d && c != e && c != f && c != g && c != h
247 && d != e && d != f && d != g && d != h
248 && e != f && e != g && e != h
249 && f != g && f != h
250 && g != h,
251 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
252 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
253 ", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT ", h=" INTPTR_FORMAT "",
254 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g), p2i(h))
255 );
256 }
259 inline void assert_different_registers(
260 AbstractRegister a,
261 AbstractRegister b,
262 AbstractRegister c,
263 AbstractRegister d,
264 AbstractRegister e,
265 AbstractRegister f,
266 AbstractRegister g,
267 AbstractRegister h,
268 AbstractRegister i
269 ) {
270 assert(
271 a != b && a != c && a != d && a != e && a != f && a != g && a != h && a != i
272 && b != c && b != d && b != e && b != f && b != g && b != h && b != i
273 && c != d && c != e && c != f && c != g && c != h && c != i
274 && d != e && d != f && d != g && d != h && d != i
275 && e != f && e != g && e != h && e != i
276 && f != g && f != h && f != i
277 && g != h && g != i
278 && h != i,
279 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
280 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
281 ", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT ", h=" INTPTR_FORMAT
282 ", i=" INTPTR_FORMAT "",
283 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g), p2i(h), p2i(i))
284 );
285 }
287 inline void assert_different_registers(
288 AbstractRegister a,
289 AbstractRegister b,
290 AbstractRegister c,
291 AbstractRegister d,
292 AbstractRegister e,
293 AbstractRegister f,
294 AbstractRegister g,
295 AbstractRegister h,
296 AbstractRegister i,
297 AbstractRegister j
298 ) {
299 assert(
300 a != b && a != c && a != d && a != e && a != f && a != g && a != h && a != i && a != j
301 && b != c && b != d && b != e && b != f && b != g && b != h && b != i && b != j
302 && c != d && c != e && c != f && c != g && c != h && c != i && c != j
303 && d != e && d != f && d != g && d != h && d != i && d != j
304 && e != f && e != g && e != h && e != i && e != j
305 && f != g && f != h && f != i && f != j
306 && g != h && g != i && g != j
307 && h != i && h != j
308 && i != j,
309 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
310 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
311 ", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT ", h=" INTPTR_FORMAT
312 ", i=" INTPTR_FORMAT ", j=" INTPTR_FORMAT "",
313 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g), p2i(h), p2i(i), p2i(j))
314 );
315 }
317 inline void assert_different_registers(
318 AbstractRegister a,
319 AbstractRegister b,
320 AbstractRegister c,
321 AbstractRegister d,
322 AbstractRegister e,
323 AbstractRegister f,
324 AbstractRegister g,
325 AbstractRegister h,
326 AbstractRegister i,
327 AbstractRegister j,
328 AbstractRegister k
329 ) {
330 assert(
331 a != b && a != c && a != d && a != e && a != f && a != g && a != h && a != i && a != j && a !=k
332 && b != c && b != d && b != e && b != f && b != g && b != h && b != i && b != j && b !=k
333 && c != d && c != e && c != f && c != g && c != h && c != i && c != j && c !=k
334 && d != e && d != f && d != g && d != h && d != i && d != j && d !=k
335 && e != f && e != g && e != h && e != i && e != j && e !=k
336 && f != g && f != h && f != i && f != j && f !=k
337 && g != h && g != i && g != j && g !=k
338 && h != i && h != j && h !=k
339 && i != j && i !=k
340 && j !=k,
341 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
342 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
343 ", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT ", h=" INTPTR_FORMAT
344 ", i=" INTPTR_FORMAT ", j=" INTPTR_FORMAT ", k=" INTPTR_FORMAT "",
345 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g), p2i(h), p2i(i), p2i(j), p2i(k))
346 );
347 }
349 inline void assert_different_registers(
350 AbstractRegister a,
351 AbstractRegister b,
352 AbstractRegister c,
353 AbstractRegister d,
354 AbstractRegister e,
355 AbstractRegister f,
356 AbstractRegister g,
357 AbstractRegister h,
358 AbstractRegister i,
359 AbstractRegister j,
360 AbstractRegister k,
361 AbstractRegister l
362 ) {
363 assert(
364 a != b && a != c && a != d && a != e && a != f && a != g && a != h && a != i && a != j && a !=k && a !=l
365 && b != c && b != d && b != e && b != f && b != g && b != h && b != i && b != j && b !=k && b !=l
366 && c != d && c != e && c != f && c != g && c != h && c != i && c != j && c !=k && c !=l
367 && d != e && d != f && d != g && d != h && d != i && d != j && d !=k && d !=l
368 && e != f && e != g && e != h && e != i && e != j && e !=k && e !=l
369 && f != g && f != h && f != i && f != j && f !=k && f !=l
370 && g != h && g != i && g != j && g !=k && g !=l
371 && h != i && h != j && h !=k && h !=l
372 && i != j && i !=k && i !=l
373 && j !=k && j !=l
374 && k !=l,
375 err_msg_res("registers must be different: a=" INTPTR_FORMAT ", b=" INTPTR_FORMAT
376 ", c=" INTPTR_FORMAT ", d=" INTPTR_FORMAT ", e=" INTPTR_FORMAT
377 ", f=" INTPTR_FORMAT ", g=" INTPTR_FORMAT ", h=" INTPTR_FORMAT
378 ", i=" INTPTR_FORMAT ", j=" INTPTR_FORMAT ", k=" INTPTR_FORMAT
379 ", l=" INTPTR_FORMAT "",
380 p2i(a), p2i(b), p2i(c), p2i(d), p2i(e), p2i(f), p2i(g), p2i(h), p2i(i), p2i(j), p2i(k), p2i(l))
381 );
382 }
384 #endif // SHARE_VM_ASM_REGISTER_HPP