1 /*
2 * Copyright (c) 1998, 2008, 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 */
24
25 //------------------------------VMReg------------------------------------------
26 // The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots.
27 // Register numbers below VMRegImpl::stack0 are the same for both. Register
28 // numbers above stack0 are either warped (in the compiler) or unwarped
29 // (in the VM). Unwarped numbers represent stack indices, offsets from
30 // the current stack pointer. Warped numbers are required during compilation
31 // when we do not yet know how big the frame will be.
32
33 class VMRegImpl;
34 typedef VMRegImpl* VMReg;
35
36 class VMRegImpl {
37 // friend class OopMap;
38 friend class VMStructs;
39 friend class OptoReg;
40 // friend class Location;
41 private:
42 enum {
43 BAD = -1
44 };
107 VMReg bias(int offset) {
108 assert(is_stack(), "must be");
109 // VMReg res = VMRegImpl::as_VMReg(value() + offset);
110 VMReg res = stack2reg(reg2stack() + offset);
111 assert(res->is_stack(), "must be");
112 return res;
113 }
114
115 // Convert register numbers to stack slots and vice versa
116 static VMReg stack2reg( int idx ) {
117 return (VMReg) (intptr_t) (stack0->value() + idx);
118 }
119
120 uintptr_t reg2stack() {
121 assert( is_stack(), "Not a stack-based register" );
122 return value() - stack0->value();
123 }
124
125 static void set_regName();
126
127 #include "incls/_vmreg_pd.hpp.incl"
128
129 };
130
131 //---------------------------VMRegPair-------------------------------------------
132 // Pairs of 32-bit registers for arguments.
133 // SharedRuntime::java_calling_convention will overwrite the structs with
134 // the calling convention's registers. VMRegImpl::Bad is returned for any
135 // unused 32-bit register. This happens for the unused high half of Int
136 // arguments, or for 32-bit pointers or for longs in the 32-bit sparc build
137 // (which are passed to natives in low 32-bits of e.g. O0/O1 and the high
138 // 32-bits of O0/O1 are set to VMRegImpl::Bad). Longs in one register & doubles
139 // always return a high and a low register, as do 64-bit pointers.
140 //
141 class VMRegPair {
142 private:
143 VMReg _second;
144 VMReg _first;
145 public:
146 void set_bad ( ) { _second=VMRegImpl::Bad(); _first=VMRegImpl::Bad(); }
147 void set1 ( VMReg v ) { _second=VMRegImpl::Bad(); _first=v; }
164 bool is_adjacent_on_stack(int alignment) const {
165 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
166 }
167
168 // Return true if single stack based "register" where the slot alignment matches input alignment
169 bool is_adjacent_aligned_on_stack(int alignment) const {
170 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
171 }
172
173 // Return true if single register but adjacent stack slots do not count
174 bool is_single_phys_reg() const {
175 return (_first->is_reg() && (_first->value() + 1 == _second->value()));
176 }
177
178 VMReg second() const { return _second; }
179 VMReg first() const { return _first; }
180 VMRegPair(VMReg s, VMReg f) { _second = s; _first = f; }
181 VMRegPair(VMReg f) { _second = VMRegImpl::Bad(); _first = f; }
182 VMRegPair() { _second = VMRegImpl::Bad(); _first = VMRegImpl::Bad(); }
183 };
|
1 /*
2 * Copyright (c) 1998, 2010, 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 */
24
25 #ifndef SHARE_VM_CODE_VMREG_HPP
26 #define SHARE_VM_CODE_VMREG_HPP
27
28 #include "memory/allocation.hpp"
29 #include "utilities/globalDefinitions.hpp"
30 #ifdef TARGET_ARCH_x86
31 # include "register_x86.hpp"
32 #endif
33 #ifdef TARGET_ARCH_sparc
34 # include "register_sparc.hpp"
35 #endif
36 #ifdef TARGET_ARCH_zero
37 # include "register_zero.hpp"
38 #endif
39 #ifdef COMPILER2
40 #include "opto/adlcVMDeps.hpp"
41 #include "utilities/ostream.hpp"
42 #ifdef TARGET_ARCH_MODEL_x86_32
43 # include "adfiles/adGlobals_x86_32.hpp"
44 #endif
45 #ifdef TARGET_ARCH_MODEL_x86_64
46 # include "adfiles/adGlobals_x86_64.hpp"
47 #endif
48 #ifdef TARGET_ARCH_MODEL_sparc
49 # include "adfiles/adGlobals_sparc.hpp"
50 #endif
51 #ifdef TARGET_ARCH_MODEL_zero
52 # include "adfiles/adGlobals_zero.hpp"
53 #endif
54 #endif
55
56 //------------------------------VMReg------------------------------------------
57 // The VM uses 'unwarped' stack slots; the compiler uses 'warped' stack slots.
58 // Register numbers below VMRegImpl::stack0 are the same for both. Register
59 // numbers above stack0 are either warped (in the compiler) or unwarped
60 // (in the VM). Unwarped numbers represent stack indices, offsets from
61 // the current stack pointer. Warped numbers are required during compilation
62 // when we do not yet know how big the frame will be.
63
64 class VMRegImpl;
65 typedef VMRegImpl* VMReg;
66
67 class VMRegImpl {
68 // friend class OopMap;
69 friend class VMStructs;
70 friend class OptoReg;
71 // friend class Location;
72 private:
73 enum {
74 BAD = -1
75 };
138 VMReg bias(int offset) {
139 assert(is_stack(), "must be");
140 // VMReg res = VMRegImpl::as_VMReg(value() + offset);
141 VMReg res = stack2reg(reg2stack() + offset);
142 assert(res->is_stack(), "must be");
143 return res;
144 }
145
146 // Convert register numbers to stack slots and vice versa
147 static VMReg stack2reg( int idx ) {
148 return (VMReg) (intptr_t) (stack0->value() + idx);
149 }
150
151 uintptr_t reg2stack() {
152 assert( is_stack(), "Not a stack-based register" );
153 return value() - stack0->value();
154 }
155
156 static void set_regName();
157
158 #ifdef TARGET_ARCH_x86
159 # include "vmreg_x86.hpp"
160 #endif
161 #ifdef TARGET_ARCH_sparc
162 # include "vmreg_sparc.hpp"
163 #endif
164 #ifdef TARGET_ARCH_zero
165 # include "vmreg_zero.hpp"
166 #endif
167
168
169 };
170
171 //---------------------------VMRegPair-------------------------------------------
172 // Pairs of 32-bit registers for arguments.
173 // SharedRuntime::java_calling_convention will overwrite the structs with
174 // the calling convention's registers. VMRegImpl::Bad is returned for any
175 // unused 32-bit register. This happens for the unused high half of Int
176 // arguments, or for 32-bit pointers or for longs in the 32-bit sparc build
177 // (which are passed to natives in low 32-bits of e.g. O0/O1 and the high
178 // 32-bits of O0/O1 are set to VMRegImpl::Bad). Longs in one register & doubles
179 // always return a high and a low register, as do 64-bit pointers.
180 //
181 class VMRegPair {
182 private:
183 VMReg _second;
184 VMReg _first;
185 public:
186 void set_bad ( ) { _second=VMRegImpl::Bad(); _first=VMRegImpl::Bad(); }
187 void set1 ( VMReg v ) { _second=VMRegImpl::Bad(); _first=v; }
204 bool is_adjacent_on_stack(int alignment) const {
205 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
206 }
207
208 // Return true if single stack based "register" where the slot alignment matches input alignment
209 bool is_adjacent_aligned_on_stack(int alignment) const {
210 return (_first->is_stack() && (_first->value() + 1 == _second->value()) && ((_first->value() & (alignment-1)) == 0));
211 }
212
213 // Return true if single register but adjacent stack slots do not count
214 bool is_single_phys_reg() const {
215 return (_first->is_reg() && (_first->value() + 1 == _second->value()));
216 }
217
218 VMReg second() const { return _second; }
219 VMReg first() const { return _first; }
220 VMRegPair(VMReg s, VMReg f) { _second = s; _first = f; }
221 VMRegPair(VMReg f) { _second = VMRegImpl::Bad(); _first = f; }
222 VMRegPair() { _second = VMRegImpl::Bad(); _first = VMRegImpl::Bad(); }
223 };
224
225 #endif // SHARE_VM_CODE_VMREG_HPP
|