src/share/vm/asm/register.hpp

Wed, 22 Jan 2014 17:42:23 -0800

author
kvn
date
Wed, 22 Jan 2014 17:42:23 -0800
changeset 6503
a9becfeecd1b
parent 4323
f0c2369fda5a
child 6680
78bbf4d43a14
permissions
-rw-r--r--

Merge

duke@435 1 /*
mikael@4153 2 * Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
duke@435 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
duke@435 4 *
duke@435 5 * This code is free software; you can redistribute it and/or modify it
duke@435 6 * under the terms of the GNU General Public License version 2 only, as
duke@435 7 * published by the Free Software Foundation.
duke@435 8 *
duke@435 9 * This code is distributed in the hope that it will be useful, but WITHOUT
duke@435 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
duke@435 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
duke@435 12 * version 2 for more details (a copy is included in the LICENSE file that
duke@435 13 * accompanied this code).
duke@435 14 *
duke@435 15 * You should have received a copy of the GNU General Public License version
duke@435 16 * 2 along with this work; if not, write to the Free Software Foundation,
duke@435 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
duke@435 18 *
trims@1907 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
trims@1907 20 * or visit www.oracle.com if you need additional information or have any
trims@1907 21 * questions.
duke@435 22 *
duke@435 23 */
duke@435 24
stefank@2314 25 #ifndef SHARE_VM_ASM_REGISTER_HPP
stefank@2314 26 #define SHARE_VM_ASM_REGISTER_HPP
stefank@2314 27
stefank@2314 28 #include "utilities/top.hpp"
stefank@2314 29
duke@435 30 // Use AbstractRegister as shortcut
duke@435 31 class AbstractRegisterImpl;
duke@435 32 typedef AbstractRegisterImpl* AbstractRegister;
duke@435 33
duke@435 34
duke@435 35 // The super class for platform specific registers. Instead of using value objects,
duke@435 36 // registers are implemented as pointers. Subclassing is used so all registers can
duke@435 37 // use the debugging suport below. No virtual functions are used for efficiency.
duke@435 38 // They are canonicalized; i.e., registers are equal if their pointers are equal,
duke@435 39 // and vice versa. A concrete implementation may just map the register onto 'this'.
duke@435 40
duke@435 41 class AbstractRegisterImpl {
duke@435 42 protected:
duke@435 43 int value() const { return (int)(intx)this; }
duke@435 44 };
duke@435 45
duke@435 46
duke@435 47 //
duke@435 48 // Macros for use in defining Register instances. We'd like to be
duke@435 49 // able to simply define const instances of the RegisterImpl* for each
duke@435 50 // of the registers needed on a system in a header file. However many
duke@435 51 // compilers don't handle this very well and end up producing a
duke@435 52 // private definition in every file which includes the header file.
duke@435 53 // Along with the static constructors necessary for initialization it
duke@435 54 // can consume a significant amount of space in the result library.
duke@435 55 //
duke@435 56 // The following macros allow us to declare the instance in a .hpp and
duke@435 57 // produce an enumeration value which has the same number. Then in a
duke@435 58 // .cpp the the register instance can be defined using the enumeration
duke@435 59 // value. This avoids the use of static constructors and multiple
duke@435 60 // definitions per .cpp. In addition #defines for the register can be
duke@435 61 // produced so that the constant registers can be inlined. These
duke@435 62 // macros should not be used inside other macros, because you may get
duke@435 63 // multiple evaluations of the macros which can give bad results.
duke@435 64 //
duke@435 65 // Here are some example uses and expansions. Note that the macro
duke@435 66 // invocation is terminated with a ;.
duke@435 67 //
duke@435 68 // CONSTANT_REGISTER_DECLARATION(Register, G0, 0);
duke@435 69 //
duke@435 70 // extern const Register G0 ;
duke@435 71 // enum { G0_RegisterEnumValue = 0 } ;
duke@435 72 //
duke@435 73 // REGISTER_DECLARATION(Register, Gmethod, G5);
duke@435 74 //
duke@435 75 // extern const Register Gmethod ;
duke@435 76 // enum { Gmethod_RegisterEnumValue = G5_RegisterEnumValue } ;
duke@435 77 //
duke@435 78 // REGISTER_DEFINITION(Register, G0);
duke@435 79 //
duke@435 80 // const Register G0 = ( ( Register ) G0_RegisterEnumValue ) ;
duke@435 81 //
duke@435 82
duke@435 83 #define AS_REGISTER(type,name) ((type)name##_##type##EnumValue)
duke@435 84
duke@435 85 #define CONSTANT_REGISTER_DECLARATION(type, name, value) \
duke@435 86 extern const type name; \
duke@435 87 enum { name##_##type##EnumValue = (value) }
duke@435 88
duke@435 89 #define REGISTER_DECLARATION(type, name, value) \
duke@435 90 extern const type name; \
duke@435 91 enum { name##_##type##EnumValue = value##_##type##EnumValue }
duke@435 92
duke@435 93 #define REGISTER_DEFINITION(type, name) \
duke@435 94 const type name = ((type)name##_##type##EnumValue)
duke@435 95
twisti@4323 96 #ifdef TARGET_ARCH_x86
twisti@4323 97 # include "register_x86.hpp"
twisti@4323 98 #endif
twisti@4323 99 #ifdef TARGET_ARCH_sparc
twisti@4323 100 # include "register_sparc.hpp"
twisti@4323 101 #endif
twisti@4323 102 #ifdef TARGET_ARCH_zero
twisti@4323 103 # include "register_zero.hpp"
twisti@4323 104 #endif
twisti@4323 105 #ifdef TARGET_ARCH_arm
twisti@4323 106 # include "register_arm.hpp"
twisti@4323 107 #endif
twisti@4323 108 #ifdef TARGET_ARCH_ppc
twisti@4323 109 # include "register_ppc.hpp"
twisti@4323 110 #endif
duke@435 111
duke@435 112
duke@435 113 // Debugging support
duke@435 114
duke@435 115 inline void assert_different_registers(
duke@435 116 AbstractRegister a,
duke@435 117 AbstractRegister b
duke@435 118 ) {
duke@435 119 assert(
duke@435 120 a != b,
twisti@4101 121 err_msg_res("registers must be different: a=%d, b=%d",
twisti@4101 122 a, b)
duke@435 123 );
duke@435 124 }
duke@435 125
duke@435 126
duke@435 127 inline void assert_different_registers(
duke@435 128 AbstractRegister a,
duke@435 129 AbstractRegister b,
duke@435 130 AbstractRegister c
duke@435 131 ) {
duke@435 132 assert(
duke@435 133 a != b && a != c
duke@435 134 && b != c,
twisti@4101 135 err_msg_res("registers must be different: a=%d, b=%d, c=%d",
twisti@4101 136 a, b, c)
duke@435 137 );
duke@435 138 }
duke@435 139
duke@435 140
duke@435 141 inline void assert_different_registers(
duke@435 142 AbstractRegister a,
duke@435 143 AbstractRegister b,
duke@435 144 AbstractRegister c,
duke@435 145 AbstractRegister d
duke@435 146 ) {
duke@435 147 assert(
duke@435 148 a != b && a != c && a != d
duke@435 149 && b != c && b != d
duke@435 150 && c != d,
twisti@4101 151 err_msg_res("registers must be different: a=%d, b=%d, c=%d, d=%d",
twisti@4101 152 a, b, c, d)
duke@435 153 );
duke@435 154 }
duke@435 155
duke@435 156
duke@435 157 inline void assert_different_registers(
duke@435 158 AbstractRegister a,
duke@435 159 AbstractRegister b,
duke@435 160 AbstractRegister c,
duke@435 161 AbstractRegister d,
duke@435 162 AbstractRegister e
duke@435 163 ) {
duke@435 164 assert(
duke@435 165 a != b && a != c && a != d && a != e
duke@435 166 && b != c && b != d && b != e
duke@435 167 && c != d && c != e
duke@435 168 && d != e,
twisti@4101 169 err_msg_res("registers must be different: a=%d, b=%d, c=%d, d=%d, e=%d",
twisti@4101 170 a, b, c, d, e)
duke@435 171 );
duke@435 172 }
duke@435 173
duke@435 174
duke@435 175 inline void assert_different_registers(
duke@435 176 AbstractRegister a,
duke@435 177 AbstractRegister b,
duke@435 178 AbstractRegister c,
duke@435 179 AbstractRegister d,
duke@435 180 AbstractRegister e,
duke@435 181 AbstractRegister f
duke@435 182 ) {
duke@435 183 assert(
duke@435 184 a != b && a != c && a != d && a != e && a != f
duke@435 185 && b != c && b != d && b != e && b != f
duke@435 186 && c != d && c != e && c != f
duke@435 187 && d != e && d != f
duke@435 188 && e != f,
twisti@4101 189 err_msg_res("registers must be different: a=%d, b=%d, c=%d, d=%d, e=%d, f=%d",
twisti@4101 190 a, b, c, d, e, f)
duke@435 191 );
duke@435 192 }
duke@435 193
duke@435 194
duke@435 195 inline void assert_different_registers(
duke@435 196 AbstractRegister a,
duke@435 197 AbstractRegister b,
duke@435 198 AbstractRegister c,
duke@435 199 AbstractRegister d,
duke@435 200 AbstractRegister e,
duke@435 201 AbstractRegister f,
duke@435 202 AbstractRegister g
duke@435 203 ) {
duke@435 204 assert(
duke@435 205 a != b && a != c && a != d && a != e && a != f && a != g
duke@435 206 && b != c && b != d && b != e && b != f && b != g
duke@435 207 && c != d && c != e && c != f && c != g
duke@435 208 && d != e && d != f && d != g
duke@435 209 && e != f && e != g
duke@435 210 && f != g,
twisti@4101 211 err_msg_res("registers must be different: a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d",
twisti@4101 212 a, b, c, d, e, f, g)
duke@435 213 );
duke@435 214 }
duke@435 215
duke@435 216
duke@435 217 inline void assert_different_registers(
duke@435 218 AbstractRegister a,
duke@435 219 AbstractRegister b,
duke@435 220 AbstractRegister c,
duke@435 221 AbstractRegister d,
duke@435 222 AbstractRegister e,
duke@435 223 AbstractRegister f,
duke@435 224 AbstractRegister g,
duke@435 225 AbstractRegister h
duke@435 226 ) {
duke@435 227 assert(
duke@435 228 a != b && a != c && a != d && a != e && a != f && a != g && a != h
duke@435 229 && b != c && b != d && b != e && b != f && b != g && b != h
duke@435 230 && c != d && c != e && c != f && c != g && c != h
duke@435 231 && d != e && d != f && d != g && d != h
duke@435 232 && e != f && e != g && e != h
duke@435 233 && f != g && f != h
duke@435 234 && g != h,
twisti@4101 235 err_msg_res("registers must be different: a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d, h=%d",
twisti@4101 236 a, b, c, d, e, f, g, h)
twisti@3969 237 );
twisti@3969 238 }
twisti@3969 239
twisti@3969 240
twisti@3969 241 inline void assert_different_registers(
twisti@3969 242 AbstractRegister a,
twisti@3969 243 AbstractRegister b,
twisti@3969 244 AbstractRegister c,
twisti@3969 245 AbstractRegister d,
twisti@3969 246 AbstractRegister e,
twisti@3969 247 AbstractRegister f,
twisti@3969 248 AbstractRegister g,
twisti@3969 249 AbstractRegister h,
twisti@3969 250 AbstractRegister i
twisti@3969 251 ) {
twisti@3969 252 assert(
twisti@3969 253 a != b && a != c && a != d && a != e && a != f && a != g && a != h && a != i
twisti@3969 254 && b != c && b != d && b != e && b != f && b != g && b != h && b != i
twisti@3969 255 && c != d && c != e && c != f && c != g && c != h && c != i
twisti@3969 256 && d != e && d != f && d != g && d != h && d != i
twisti@3969 257 && e != f && e != g && e != h && e != i
twisti@3969 258 && f != g && f != h && f != i
twisti@3969 259 && g != h && g != i
twisti@3969 260 && h != i,
twisti@4101 261 err_msg_res("registers must be different: a=%d, b=%d, c=%d, d=%d, e=%d, f=%d, g=%d, h=%d, i=%d",
twisti@4101 262 a, b, c, d, e, f, g, h, i)
duke@435 263 );
duke@435 264 }
stefank@2314 265
stefank@2314 266 #endif // SHARE_VM_ASM_REGISTER_HPP

mercurial