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_OPTO_REGMASK_HPP
26 #define SHARE_VM_OPTO_REGMASK_HPP
27
28 #include "code/vmreg.hpp"
29 #include "opto/optoreg.hpp"
30
31 // Some fun naming (textual) substitutions:
32 //
33 // RegMask::get_low_elem() ==> RegMask::find_first_elem()
34 // RegMask::Special ==> RegMask::Empty
35 // RegMask::_flags ==> RegMask::is_AllStack()
36 // RegMask::operator<<=() ==> RegMask::Insert()
37 // RegMask::operator>>=() ==> RegMask::Remove()
38 // RegMask::Union() ==> RegMask::OR
39 // RegMask::Inter() ==> RegMask::AND
40 //
41 // OptoRegister::RegName ==> OptoReg::Name
42 //
43 // OptoReg::stack0() ==> _last_Mach_Reg or ZERO in core version
44 //
45 // numregs in chaitin ==> proper degree in chaitin
46
47 //-------------Non-zero bit search methods used by RegMask---------------------
48 // Find lowest 1, or return 32 if empty
177 // HIGHEST register number in the pair, or BAD if no pairs.
178 // Assert that the mask contains only bit pairs.
179 OptoReg::Name find_first_pair() const;
180
181 // Clear out partial bits; leave only aligned adjacent bit pairs.
182 void clear_to_pairs();
183 // Smear out partial bits; leave only aligned adjacent bit pairs.
184 void smear_to_pairs();
185 // Verify that the mask contains only aligned adjacent bit pairs
186 void verify_pairs() const { assert( is_aligned_pairs(), "mask is not aligned, adjacent pairs" ); }
187 // Test that the mask contains only aligned adjacent bit pairs
188 bool is_aligned_pairs() const;
189
190 // mask is a pair of misaligned registers
191 bool is_misaligned_pair() const { return Size()==2 && !is_aligned_pairs(); }
192 // Test for single register
193 int is_bound1() const;
194 // Test for a single adjacent pair
195 int is_bound_pair() const;
196 // Test for a single adjacent set of ideal register's size.
197 int is_bound(uint ireg) const {
198 if (is_vector(ireg)) {
199 if (is_bound_set(num_registers(ireg)))
200 return true;
201 } else if (is_bound1() || is_bound_pair()) {
202 return true;
203 }
204 return false;
205 }
206
207 // Find the lowest-numbered register set in the mask. Return the
208 // HIGHEST register number in the set, or BAD if no sets.
209 // Assert that the mask contains only bit sets.
210 OptoReg::Name find_first_set(const int size) const;
211
212 // Clear out partial bits; leave only aligned adjacent bit sets of size.
213 void clear_to_sets(const int size);
214 // Smear out partial bits to aligned adjacent bit sets.
215 void smear_to_sets(const int size);
216 // Verify that the mask contains only aligned adjacent bit sets
217 void verify_sets(int size) const { assert(is_aligned_sets(size), "mask is not aligned, adjacent sets"); }
218 // Test that the mask contains only aligned adjacent bit sets
219 bool is_aligned_sets(const int size) const;
220
221 // mask is a set of misaligned registers
222 bool is_misaligned_set(int size) const { return (int)Size()==size && !is_aligned_sets(size);}
223
224 // Test for a single adjacent set
225 int is_bound_set(const int size) const;
226
227 static bool is_vector(uint ireg);
228 static int num_registers(uint ireg);
229
230 // Fast overlap test. Non-zero if any registers in common.
231 int overlap( const RegMask &rm ) const {
232 return
233 # define BODY(I) (_A[I] & rm._A[I]) |
234 FORALL_BODY
235 # undef BODY
236 0 ;
237 }
238
239 // Special test for register pressure based splitting
240 // UP means register only, Register plus stack, or stack only is DOWN
241 bool is_UP() const;
242
243 // Clear a register mask
244 void Clear( ) {
245 # define BODY(I) _A[I] = 0;
246 FORALL_BODY
247 # undef BODY
248 }
|
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_OPTO_REGMASK_HPP
26 #define SHARE_VM_OPTO_REGMASK_HPP
27
28 #include "code/vmreg.hpp"
29 #include "opto/opcodes.hpp"
30 #include "opto/optoreg.hpp"
31
32 // Some fun naming (textual) substitutions:
33 //
34 // RegMask::get_low_elem() ==> RegMask::find_first_elem()
35 // RegMask::Special ==> RegMask::Empty
36 // RegMask::_flags ==> RegMask::is_AllStack()
37 // RegMask::operator<<=() ==> RegMask::Insert()
38 // RegMask::operator>>=() ==> RegMask::Remove()
39 // RegMask::Union() ==> RegMask::OR
40 // RegMask::Inter() ==> RegMask::AND
41 //
42 // OptoRegister::RegName ==> OptoReg::Name
43 //
44 // OptoReg::stack0() ==> _last_Mach_Reg or ZERO in core version
45 //
46 // numregs in chaitin ==> proper degree in chaitin
47
48 //-------------Non-zero bit search methods used by RegMask---------------------
49 // Find lowest 1, or return 32 if empty
178 // HIGHEST register number in the pair, or BAD if no pairs.
179 // Assert that the mask contains only bit pairs.
180 OptoReg::Name find_first_pair() const;
181
182 // Clear out partial bits; leave only aligned adjacent bit pairs.
183 void clear_to_pairs();
184 // Smear out partial bits; leave only aligned adjacent bit pairs.
185 void smear_to_pairs();
186 // Verify that the mask contains only aligned adjacent bit pairs
187 void verify_pairs() const { assert( is_aligned_pairs(), "mask is not aligned, adjacent pairs" ); }
188 // Test that the mask contains only aligned adjacent bit pairs
189 bool is_aligned_pairs() const;
190
191 // mask is a pair of misaligned registers
192 bool is_misaligned_pair() const { return Size()==2 && !is_aligned_pairs(); }
193 // Test for single register
194 int is_bound1() const;
195 // Test for a single adjacent pair
196 int is_bound_pair() const;
197 // Test for a single adjacent set of ideal register's size.
198 int is_bound(Opcodes ireg) const {
199 if (is_vector(ireg)) {
200 if (is_bound_set(num_registers(ireg)))
201 return true;
202 } else if (is_bound1() || is_bound_pair()) {
203 return true;
204 }
205 return false;
206 }
207
208 // Find the lowest-numbered register set in the mask. Return the
209 // HIGHEST register number in the set, or BAD if no sets.
210 // Assert that the mask contains only bit sets.
211 OptoReg::Name find_first_set(const int size) const;
212
213 // Clear out partial bits; leave only aligned adjacent bit sets of size.
214 void clear_to_sets(const int size);
215 // Smear out partial bits to aligned adjacent bit sets.
216 void smear_to_sets(const int size);
217 // Verify that the mask contains only aligned adjacent bit sets
218 void verify_sets(int size) const { assert(is_aligned_sets(size), "mask is not aligned, adjacent sets"); }
219 // Test that the mask contains only aligned adjacent bit sets
220 bool is_aligned_sets(const int size) const;
221
222 // mask is a set of misaligned registers
223 bool is_misaligned_set(int size) const { return (int)Size()==size && !is_aligned_sets(size);}
224
225 // Test for a single adjacent set
226 int is_bound_set(const int size) const;
227
228 static bool is_vector(Opcodes ireg);
229 static int num_registers(Opcodes ireg);
230
231 // Fast overlap test. Non-zero if any registers in common.
232 int overlap( const RegMask &rm ) const {
233 return
234 # define BODY(I) (_A[I] & rm._A[I]) |
235 FORALL_BODY
236 # undef BODY
237 0 ;
238 }
239
240 // Special test for register pressure based splitting
241 // UP means register only, Register plus stack, or stack only is DOWN
242 bool is_UP() const;
243
244 // Clear a register mask
245 void Clear( ) {
246 # define BODY(I) _A[I] = 0;
247 FORALL_BODY
248 # undef BODY
249 }
|