annotate src/share/vm/asm/register.hpp @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
a61af66fc99e Initial load
duke
parents:
diff changeset
2 * Copyright 2000-2002 Sun Microsystems, Inc. All Rights Reserved.
a61af66fc99e Initial load
duke
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
a61af66fc99e Initial load
duke
parents:
diff changeset
4 *
a61af66fc99e Initial load
duke
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
a61af66fc99e Initial load
duke
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
a61af66fc99e Initial load
duke
parents:
diff changeset
7 * published by the Free Software Foundation.
a61af66fc99e Initial load
duke
parents:
diff changeset
8 *
a61af66fc99e Initial load
duke
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
a61af66fc99e Initial load
duke
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
a61af66fc99e Initial load
duke
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a61af66fc99e Initial load
duke
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
a61af66fc99e Initial load
duke
parents:
diff changeset
13 * accompanied this code).
a61af66fc99e Initial load
duke
parents:
diff changeset
14 *
a61af66fc99e Initial load
duke
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
a61af66fc99e Initial load
duke
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
a61af66fc99e Initial load
duke
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
a61af66fc99e Initial load
duke
parents:
diff changeset
18 *
a61af66fc99e Initial load
duke
parents:
diff changeset
19 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
a61af66fc99e Initial load
duke
parents:
diff changeset
20 * CA 95054 USA or visit www.sun.com if you need additional information or
a61af66fc99e Initial load
duke
parents:
diff changeset
21 * have any questions.
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
a61af66fc99e Initial load
duke
parents:
diff changeset
25 // Use AbstractRegister as shortcut
a61af66fc99e Initial load
duke
parents:
diff changeset
26 class AbstractRegisterImpl;
a61af66fc99e Initial load
duke
parents:
diff changeset
27 typedef AbstractRegisterImpl* AbstractRegister;
a61af66fc99e Initial load
duke
parents:
diff changeset
28
a61af66fc99e Initial load
duke
parents:
diff changeset
29
a61af66fc99e Initial load
duke
parents:
diff changeset
30 // The super class for platform specific registers. Instead of using value objects,
a61af66fc99e Initial load
duke
parents:
diff changeset
31 // registers are implemented as pointers. Subclassing is used so all registers can
a61af66fc99e Initial load
duke
parents:
diff changeset
32 // use the debugging suport below. No virtual functions are used for efficiency.
a61af66fc99e Initial load
duke
parents:
diff changeset
33 // They are canonicalized; i.e., registers are equal if their pointers are equal,
a61af66fc99e Initial load
duke
parents:
diff changeset
34 // and vice versa. A concrete implementation may just map the register onto 'this'.
a61af66fc99e Initial load
duke
parents:
diff changeset
35
a61af66fc99e Initial load
duke
parents:
diff changeset
36 class AbstractRegisterImpl {
a61af66fc99e Initial load
duke
parents:
diff changeset
37 protected:
a61af66fc99e Initial load
duke
parents:
diff changeset
38 int value() const { return (int)(intx)this; }
a61af66fc99e Initial load
duke
parents:
diff changeset
39 };
a61af66fc99e Initial load
duke
parents:
diff changeset
40
a61af66fc99e Initial load
duke
parents:
diff changeset
41
a61af66fc99e Initial load
duke
parents:
diff changeset
42 //
a61af66fc99e Initial load
duke
parents:
diff changeset
43 // Macros for use in defining Register instances. We'd like to be
a61af66fc99e Initial load
duke
parents:
diff changeset
44 // able to simply define const instances of the RegisterImpl* for each
a61af66fc99e Initial load
duke
parents:
diff changeset
45 // of the registers needed on a system in a header file. However many
a61af66fc99e Initial load
duke
parents:
diff changeset
46 // compilers don't handle this very well and end up producing a
a61af66fc99e Initial load
duke
parents:
diff changeset
47 // private definition in every file which includes the header file.
a61af66fc99e Initial load
duke
parents:
diff changeset
48 // Along with the static constructors necessary for initialization it
a61af66fc99e Initial load
duke
parents:
diff changeset
49 // can consume a significant amount of space in the result library.
a61af66fc99e Initial load
duke
parents:
diff changeset
50 //
a61af66fc99e Initial load
duke
parents:
diff changeset
51 // The following macros allow us to declare the instance in a .hpp and
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // produce an enumeration value which has the same number. Then in a
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // .cpp the the register instance can be defined using the enumeration
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // value. This avoids the use of static constructors and multiple
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // definitions per .cpp. In addition #defines for the register can be
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // produced so that the constant registers can be inlined. These
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // macros should not be used inside other macros, because you may get
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // multiple evaluations of the macros which can give bad results.
a61af66fc99e Initial load
duke
parents:
diff changeset
59 //
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // Here are some example uses and expansions. Note that the macro
a61af66fc99e Initial load
duke
parents:
diff changeset
61 // invocation is terminated with a ;.
a61af66fc99e Initial load
duke
parents:
diff changeset
62 //
a61af66fc99e Initial load
duke
parents:
diff changeset
63 // CONSTANT_REGISTER_DECLARATION(Register, G0, 0);
a61af66fc99e Initial load
duke
parents:
diff changeset
64 //
a61af66fc99e Initial load
duke
parents:
diff changeset
65 // extern const Register G0 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
66 // enum { G0_RegisterEnumValue = 0 } ;
a61af66fc99e Initial load
duke
parents:
diff changeset
67 //
a61af66fc99e Initial load
duke
parents:
diff changeset
68 // REGISTER_DECLARATION(Register, Gmethod, G5);
a61af66fc99e Initial load
duke
parents:
diff changeset
69 //
a61af66fc99e Initial load
duke
parents:
diff changeset
70 // extern const Register Gmethod ;
a61af66fc99e Initial load
duke
parents:
diff changeset
71 // enum { Gmethod_RegisterEnumValue = G5_RegisterEnumValue } ;
a61af66fc99e Initial load
duke
parents:
diff changeset
72 //
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // REGISTER_DEFINITION(Register, G0);
a61af66fc99e Initial load
duke
parents:
diff changeset
74 //
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // const Register G0 = ( ( Register ) G0_RegisterEnumValue ) ;
a61af66fc99e Initial load
duke
parents:
diff changeset
76 //
a61af66fc99e Initial load
duke
parents:
diff changeset
77
a61af66fc99e Initial load
duke
parents:
diff changeset
78 #define AS_REGISTER(type,name) ((type)name##_##type##EnumValue)
a61af66fc99e Initial load
duke
parents:
diff changeset
79
a61af66fc99e Initial load
duke
parents:
diff changeset
80 #define CONSTANT_REGISTER_DECLARATION(type, name, value) \
a61af66fc99e Initial load
duke
parents:
diff changeset
81 extern const type name; \
a61af66fc99e Initial load
duke
parents:
diff changeset
82 enum { name##_##type##EnumValue = (value) }
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 #define REGISTER_DECLARATION(type, name, value) \
a61af66fc99e Initial load
duke
parents:
diff changeset
85 extern const type name; \
a61af66fc99e Initial load
duke
parents:
diff changeset
86 enum { name##_##type##EnumValue = value##_##type##EnumValue }
a61af66fc99e Initial load
duke
parents:
diff changeset
87
a61af66fc99e Initial load
duke
parents:
diff changeset
88 #define REGISTER_DEFINITION(type, name) \
a61af66fc99e Initial load
duke
parents:
diff changeset
89 const type name = ((type)name##_##type##EnumValue)
a61af66fc99e Initial load
duke
parents:
diff changeset
90
a61af66fc99e Initial load
duke
parents:
diff changeset
91
a61af66fc99e Initial load
duke
parents:
diff changeset
92
a61af66fc99e Initial load
duke
parents:
diff changeset
93 // Debugging support
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
96 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 AbstractRegister b
a61af66fc99e Initial load
duke
parents:
diff changeset
98 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
99 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
100 a != b,
a61af66fc99e Initial load
duke
parents:
diff changeset
101 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
102 );
a61af66fc99e Initial load
duke
parents:
diff changeset
103 }
a61af66fc99e Initial load
duke
parents:
diff changeset
104
a61af66fc99e Initial load
duke
parents:
diff changeset
105
a61af66fc99e Initial load
duke
parents:
diff changeset
106 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
107 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
108 AbstractRegister b,
a61af66fc99e Initial load
duke
parents:
diff changeset
109 AbstractRegister c
a61af66fc99e Initial load
duke
parents:
diff changeset
110 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
111 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
112 a != b && a != c
a61af66fc99e Initial load
duke
parents:
diff changeset
113 && b != c,
a61af66fc99e Initial load
duke
parents:
diff changeset
114 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
115 );
a61af66fc99e Initial load
duke
parents:
diff changeset
116 }
a61af66fc99e Initial load
duke
parents:
diff changeset
117
a61af66fc99e Initial load
duke
parents:
diff changeset
118
a61af66fc99e Initial load
duke
parents:
diff changeset
119 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
120 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
121 AbstractRegister b,
a61af66fc99e Initial load
duke
parents:
diff changeset
122 AbstractRegister c,
a61af66fc99e Initial load
duke
parents:
diff changeset
123 AbstractRegister d
a61af66fc99e Initial load
duke
parents:
diff changeset
124 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
125 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
126 a != b && a != c && a != d
a61af66fc99e Initial load
duke
parents:
diff changeset
127 && b != c && b != d
a61af66fc99e Initial load
duke
parents:
diff changeset
128 && c != d,
a61af66fc99e Initial load
duke
parents:
diff changeset
129 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
130 );
a61af66fc99e Initial load
duke
parents:
diff changeset
131 }
a61af66fc99e Initial load
duke
parents:
diff changeset
132
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
135 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
136 AbstractRegister b,
a61af66fc99e Initial load
duke
parents:
diff changeset
137 AbstractRegister c,
a61af66fc99e Initial load
duke
parents:
diff changeset
138 AbstractRegister d,
a61af66fc99e Initial load
duke
parents:
diff changeset
139 AbstractRegister e
a61af66fc99e Initial load
duke
parents:
diff changeset
140 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
141 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
142 a != b && a != c && a != d && a != e
a61af66fc99e Initial load
duke
parents:
diff changeset
143 && b != c && b != d && b != e
a61af66fc99e Initial load
duke
parents:
diff changeset
144 && c != d && c != e
a61af66fc99e Initial load
duke
parents:
diff changeset
145 && d != e,
a61af66fc99e Initial load
duke
parents:
diff changeset
146 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
147 );
a61af66fc99e Initial load
duke
parents:
diff changeset
148 }
a61af66fc99e Initial load
duke
parents:
diff changeset
149
a61af66fc99e Initial load
duke
parents:
diff changeset
150
a61af66fc99e Initial load
duke
parents:
diff changeset
151 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
152 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
153 AbstractRegister b,
a61af66fc99e Initial load
duke
parents:
diff changeset
154 AbstractRegister c,
a61af66fc99e Initial load
duke
parents:
diff changeset
155 AbstractRegister d,
a61af66fc99e Initial load
duke
parents:
diff changeset
156 AbstractRegister e,
a61af66fc99e Initial load
duke
parents:
diff changeset
157 AbstractRegister f
a61af66fc99e Initial load
duke
parents:
diff changeset
158 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
159 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
160 a != b && a != c && a != d && a != e && a != f
a61af66fc99e Initial load
duke
parents:
diff changeset
161 && b != c && b != d && b != e && b != f
a61af66fc99e Initial load
duke
parents:
diff changeset
162 && c != d && c != e && c != f
a61af66fc99e Initial load
duke
parents:
diff changeset
163 && d != e && d != f
a61af66fc99e Initial load
duke
parents:
diff changeset
164 && e != f,
a61af66fc99e Initial load
duke
parents:
diff changeset
165 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
166 );
a61af66fc99e Initial load
duke
parents:
diff changeset
167 }
a61af66fc99e Initial load
duke
parents:
diff changeset
168
a61af66fc99e Initial load
duke
parents:
diff changeset
169
a61af66fc99e Initial load
duke
parents:
diff changeset
170 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
171 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
172 AbstractRegister b,
a61af66fc99e Initial load
duke
parents:
diff changeset
173 AbstractRegister c,
a61af66fc99e Initial load
duke
parents:
diff changeset
174 AbstractRegister d,
a61af66fc99e Initial load
duke
parents:
diff changeset
175 AbstractRegister e,
a61af66fc99e Initial load
duke
parents:
diff changeset
176 AbstractRegister f,
a61af66fc99e Initial load
duke
parents:
diff changeset
177 AbstractRegister g
a61af66fc99e Initial load
duke
parents:
diff changeset
178 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
179 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
180 a != b && a != c && a != d && a != e && a != f && a != g
a61af66fc99e Initial load
duke
parents:
diff changeset
181 && b != c && b != d && b != e && b != f && b != g
a61af66fc99e Initial load
duke
parents:
diff changeset
182 && c != d && c != e && c != f && c != g
a61af66fc99e Initial load
duke
parents:
diff changeset
183 && d != e && d != f && d != g
a61af66fc99e Initial load
duke
parents:
diff changeset
184 && e != f && e != g
a61af66fc99e Initial load
duke
parents:
diff changeset
185 && f != g,
a61af66fc99e Initial load
duke
parents:
diff changeset
186 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
187 );
a61af66fc99e Initial load
duke
parents:
diff changeset
188 }
a61af66fc99e Initial load
duke
parents:
diff changeset
189
a61af66fc99e Initial load
duke
parents:
diff changeset
190
a61af66fc99e Initial load
duke
parents:
diff changeset
191 inline void assert_different_registers(
a61af66fc99e Initial load
duke
parents:
diff changeset
192 AbstractRegister a,
a61af66fc99e Initial load
duke
parents:
diff changeset
193 AbstractRegister b,
a61af66fc99e Initial load
duke
parents:
diff changeset
194 AbstractRegister c,
a61af66fc99e Initial load
duke
parents:
diff changeset
195 AbstractRegister d,
a61af66fc99e Initial load
duke
parents:
diff changeset
196 AbstractRegister e,
a61af66fc99e Initial load
duke
parents:
diff changeset
197 AbstractRegister f,
a61af66fc99e Initial load
duke
parents:
diff changeset
198 AbstractRegister g,
a61af66fc99e Initial load
duke
parents:
diff changeset
199 AbstractRegister h
a61af66fc99e Initial load
duke
parents:
diff changeset
200 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
201 assert(
a61af66fc99e Initial load
duke
parents:
diff changeset
202 a != b && a != c && a != d && a != e && a != f && a != g && a != h
a61af66fc99e Initial load
duke
parents:
diff changeset
203 && b != c && b != d && b != e && b != f && b != g && b != h
a61af66fc99e Initial load
duke
parents:
diff changeset
204 && c != d && c != e && c != f && c != g && c != h
a61af66fc99e Initial load
duke
parents:
diff changeset
205 && d != e && d != f && d != g && d != h
a61af66fc99e Initial load
duke
parents:
diff changeset
206 && e != f && e != g && e != h
a61af66fc99e Initial load
duke
parents:
diff changeset
207 && f != g && f != h
a61af66fc99e Initial load
duke
parents:
diff changeset
208 && g != h,
a61af66fc99e Initial load
duke
parents:
diff changeset
209 "registers must be different"
a61af66fc99e Initial load
duke
parents:
diff changeset
210 );
a61af66fc99e Initial load
duke
parents:
diff changeset
211 }