annotate src/share/vm/opto/regmask.hpp @ 10185:d50cc62e94ff

8012715: G1: GraphKit accesses PtrQueue::_index as int but is size_t Summary: In graphKit INT operations were generated to access PtrQueue::_index which has type size_t. This is 64 bit on 64-bit machines. No problems occur on little endian machines as long as the index fits into 32 bit, but on big endian machines the upper part is read, which is zero. This leads to unnecessary branches to the slow path in the runtime. Reviewed-by: twisti, johnc Contributed-by: Martin Doerr <martin.doerr@sap.com>
author johnc
date Wed, 24 Apr 2013 14:48:43 -0700
parents 2c673161698a
children d2907f74462e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a61af66fc99e Initial load
duke
parents:
diff changeset
1 /*
8044
2c673161698a 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 7636
diff changeset
2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
0
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 *
1552
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
c18cbe5936b8 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 0
diff changeset
21 * questions.
0
a61af66fc99e Initial load
duke
parents:
diff changeset
22 *
a61af66fc99e Initial load
duke
parents:
diff changeset
23 */
a61af66fc99e Initial load
duke
parents:
diff changeset
24
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
25 #ifndef SHARE_VM_OPTO_REGMASK_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
26 #define SHARE_VM_OPTO_REGMASK_HPP
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
27
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
28 #include "code/vmreg.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
29 #include "libadt/port.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
30 #include "opto/optoreg.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
31 #ifdef TARGET_ARCH_MODEL_x86_32
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
32 # include "adfiles/adGlobals_x86_32.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
33 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
34 #ifdef TARGET_ARCH_MODEL_x86_64
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
35 # include "adfiles/adGlobals_x86_64.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
36 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
37 #ifdef TARGET_ARCH_MODEL_sparc
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
38 # include "adfiles/adGlobals_sparc.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
39 #endif
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
40 #ifdef TARGET_ARCH_MODEL_zero
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
41 # include "adfiles/adGlobals_zero.hpp"
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
42 #endif
2192
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
43 #ifdef TARGET_ARCH_MODEL_arm
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
44 # include "adfiles/adGlobals_arm.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
45 #endif
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
46 #ifdef TARGET_ARCH_MODEL_ppc
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
47 # include "adfiles/adGlobals_ppc.hpp"
b92c45f2bc75 7016023: Enable building ARM and PPC from src/closed repository
bobv
parents: 1972
diff changeset
48 #endif
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
49
0
a61af66fc99e Initial load
duke
parents:
diff changeset
50 // Some fun naming (textual) substitutions:
a61af66fc99e Initial load
duke
parents:
diff changeset
51 //
a61af66fc99e Initial load
duke
parents:
diff changeset
52 // RegMask::get_low_elem() ==> RegMask::find_first_elem()
a61af66fc99e Initial load
duke
parents:
diff changeset
53 // RegMask::Special ==> RegMask::Empty
a61af66fc99e Initial load
duke
parents:
diff changeset
54 // RegMask::_flags ==> RegMask::is_AllStack()
a61af66fc99e Initial load
duke
parents:
diff changeset
55 // RegMask::operator<<=() ==> RegMask::Insert()
a61af66fc99e Initial load
duke
parents:
diff changeset
56 // RegMask::operator>>=() ==> RegMask::Remove()
a61af66fc99e Initial load
duke
parents:
diff changeset
57 // RegMask::Union() ==> RegMask::OR
a61af66fc99e Initial load
duke
parents:
diff changeset
58 // RegMask::Inter() ==> RegMask::AND
a61af66fc99e Initial load
duke
parents:
diff changeset
59 //
a61af66fc99e Initial load
duke
parents:
diff changeset
60 // OptoRegister::RegName ==> OptoReg::Name
a61af66fc99e Initial load
duke
parents:
diff changeset
61 //
a61af66fc99e Initial load
duke
parents:
diff changeset
62 // OptoReg::stack0() ==> _last_Mach_Reg or ZERO in core version
a61af66fc99e Initial load
duke
parents:
diff changeset
63 //
a61af66fc99e Initial load
duke
parents:
diff changeset
64 // numregs in chaitin ==> proper degree in chaitin
a61af66fc99e Initial load
duke
parents:
diff changeset
65
a61af66fc99e Initial load
duke
parents:
diff changeset
66 //-------------Non-zero bit search methods used by RegMask---------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
67 // Find lowest 1, or return 32 if empty
a61af66fc99e Initial load
duke
parents:
diff changeset
68 int find_lowest_bit( uint32 mask );
a61af66fc99e Initial load
duke
parents:
diff changeset
69 // Find highest 1, or return 32 if empty
a61af66fc99e Initial load
duke
parents:
diff changeset
70 int find_hihghest_bit( uint32 mask );
a61af66fc99e Initial load
duke
parents:
diff changeset
71
a61af66fc99e Initial load
duke
parents:
diff changeset
72 //------------------------------RegMask----------------------------------------
a61af66fc99e Initial load
duke
parents:
diff changeset
73 // The ADL file describes how to print the machine-specific registers, as well
a61af66fc99e Initial load
duke
parents:
diff changeset
74 // as any notion of register classes. We provide a register mask, which is
a61af66fc99e Initial load
duke
parents:
diff changeset
75 // just a collection of Register numbers.
a61af66fc99e Initial load
duke
parents:
diff changeset
76
a61af66fc99e Initial load
duke
parents:
diff changeset
77 // The ADLC defines 2 macros, RM_SIZE and FORALL_BODY.
a61af66fc99e Initial load
duke
parents:
diff changeset
78 // RM_SIZE is the size of a register mask in words.
a61af66fc99e Initial load
duke
parents:
diff changeset
79 // FORALL_BODY replicates a BODY macro once per word in the register mask.
a61af66fc99e Initial load
duke
parents:
diff changeset
80 // The usage is somewhat clumsy and limited to the regmask.[h,c]pp files.
a61af66fc99e Initial load
duke
parents:
diff changeset
81 // However, it means the ADLC can redefine the unroll macro and all loops
a61af66fc99e Initial load
duke
parents:
diff changeset
82 // over register masks will be unrolled by the correct amount.
a61af66fc99e Initial load
duke
parents:
diff changeset
83
a61af66fc99e Initial load
duke
parents:
diff changeset
84 class RegMask VALUE_OBJ_CLASS_SPEC {
a61af66fc99e Initial load
duke
parents:
diff changeset
85 union {
a61af66fc99e Initial load
duke
parents:
diff changeset
86 double _dummy_force_double_alignment[RM_SIZE>>1];
a61af66fc99e Initial load
duke
parents:
diff changeset
87 // Array of Register Mask bits. This array is large enough to cover
a61af66fc99e Initial load
duke
parents:
diff changeset
88 // all the machine registers and all parameters that need to be passed
a61af66fc99e Initial load
duke
parents:
diff changeset
89 // on the stack (stack registers) up to some interesting limit. Methods
a61af66fc99e Initial load
duke
parents:
diff changeset
90 // that need more parameters will NOT be compiled. On Intel, the limit
a61af66fc99e Initial load
duke
parents:
diff changeset
91 // is something like 90+ parameters.
a61af66fc99e Initial load
duke
parents:
diff changeset
92 int _A[RM_SIZE];
a61af66fc99e Initial load
duke
parents:
diff changeset
93 };
a61af66fc99e Initial load
duke
parents:
diff changeset
94
a61af66fc99e Initial load
duke
parents:
diff changeset
95 enum {
a61af66fc99e Initial load
duke
parents:
diff changeset
96 _WordBits = BitsPerInt,
a61af66fc99e Initial load
duke
parents:
diff changeset
97 _LogWordBits = LogBitsPerInt,
a61af66fc99e Initial load
duke
parents:
diff changeset
98 _RM_SIZE = RM_SIZE // local constant, imported, then hidden by #undef
a61af66fc99e Initial load
duke
parents:
diff changeset
99 };
a61af66fc99e Initial load
duke
parents:
diff changeset
100
a61af66fc99e Initial load
duke
parents:
diff changeset
101 public:
a61af66fc99e Initial load
duke
parents:
diff changeset
102 enum { CHUNK_SIZE = RM_SIZE*_WordBits };
a61af66fc99e Initial load
duke
parents:
diff changeset
103
a61af66fc99e Initial load
duke
parents:
diff changeset
104 // SlotsPerLong is 2, since slots are 32 bits and longs are 64 bits.
a61af66fc99e Initial load
duke
parents:
diff changeset
105 // Also, consider the maximum alignment size for a normally allocated
a61af66fc99e Initial load
duke
parents:
diff changeset
106 // value. Since we allocate register pairs but not register quads (at
a61af66fc99e Initial load
duke
parents:
diff changeset
107 // present), this alignment is SlotsPerLong (== 2). A normally
a61af66fc99e Initial load
duke
parents:
diff changeset
108 // aligned allocated register is either a single register, or a pair
a61af66fc99e Initial load
duke
parents:
diff changeset
109 // of adjacent registers, the lower-numbered being even.
a61af66fc99e Initial load
duke
parents:
diff changeset
110 // See also is_aligned_Pairs() below, and the padding added before
a61af66fc99e Initial load
duke
parents:
diff changeset
111 // Matcher::_new_SP to keep allocated pairs aligned properly.
a61af66fc99e Initial load
duke
parents:
diff changeset
112 // If we ever go to quad-word allocations, SlotsPerQuad will become
a61af66fc99e Initial load
duke
parents:
diff changeset
113 // the controlling alignment constraint. Note that this alignment
a61af66fc99e Initial load
duke
parents:
diff changeset
114 // requirement is internal to the allocator, and independent of any
a61af66fc99e Initial load
duke
parents:
diff changeset
115 // particular platform.
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
116 enum { SlotsPerLong = 2,
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
117 SlotsPerVecS = 1,
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
118 SlotsPerVecD = 2,
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
119 SlotsPerVecX = 4,
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
120 SlotsPerVecY = 8 };
0
a61af66fc99e Initial load
duke
parents:
diff changeset
121
a61af66fc99e Initial load
duke
parents:
diff changeset
122 // A constructor only used by the ADLC output. All mask fields are filled
a61af66fc99e Initial load
duke
parents:
diff changeset
123 // in directly. Calls to this look something like RM(1,2,3,4);
a61af66fc99e Initial load
duke
parents:
diff changeset
124 RegMask(
a61af66fc99e Initial load
duke
parents:
diff changeset
125 # define BODY(I) int a##I,
a61af66fc99e Initial load
duke
parents:
diff changeset
126 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
127 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
128 int dummy = 0 ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
129 # define BODY(I) _A[I] = a##I;
a61af66fc99e Initial load
duke
parents:
diff changeset
130 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
131 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
132 }
a61af66fc99e Initial load
duke
parents:
diff changeset
133
a61af66fc99e Initial load
duke
parents:
diff changeset
134 // Handy copying constructor
a61af66fc99e Initial load
duke
parents:
diff changeset
135 RegMask( RegMask *rm ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
136 # define BODY(I) _A[I] = rm->_A[I];
a61af66fc99e Initial load
duke
parents:
diff changeset
137 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
138 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
139 }
a61af66fc99e Initial load
duke
parents:
diff changeset
140
a61af66fc99e Initial load
duke
parents:
diff changeset
141 // Construct an empty mask
a61af66fc99e Initial load
duke
parents:
diff changeset
142 RegMask( ) { Clear(); }
a61af66fc99e Initial load
duke
parents:
diff changeset
143
a61af66fc99e Initial load
duke
parents:
diff changeset
144 // Construct a mask with a single bit
a61af66fc99e Initial load
duke
parents:
diff changeset
145 RegMask( OptoReg::Name reg ) { Clear(); Insert(reg); }
a61af66fc99e Initial load
duke
parents:
diff changeset
146
a61af66fc99e Initial load
duke
parents:
diff changeset
147 // Check for register being in mask
a61af66fc99e Initial load
duke
parents:
diff changeset
148 int Member( OptoReg::Name reg ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
149 assert( reg < CHUNK_SIZE, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
150 return _A[reg>>_LogWordBits] & (1<<(reg&(_WordBits-1)));
a61af66fc99e Initial load
duke
parents:
diff changeset
151 }
a61af66fc99e Initial load
duke
parents:
diff changeset
152
a61af66fc99e Initial load
duke
parents:
diff changeset
153 // The last bit in the register mask indicates that the mask should repeat
a61af66fc99e Initial load
duke
parents:
diff changeset
154 // indefinitely with ONE bits. Returns TRUE if mask is infinite or
a61af66fc99e Initial load
duke
parents:
diff changeset
155 // unbounded in size. Returns FALSE if mask is finite size.
a61af66fc99e Initial load
duke
parents:
diff changeset
156 int is_AllStack() const { return _A[RM_SIZE-1] >> (_WordBits-1); }
a61af66fc99e Initial load
duke
parents:
diff changeset
157
a61af66fc99e Initial load
duke
parents:
diff changeset
158 // Work around an -xO3 optimization problme in WS6U1. The old way:
a61af66fc99e Initial load
duke
parents:
diff changeset
159 // void set_AllStack() { _A[RM_SIZE-1] |= (1<<(_WordBits-1)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
160 // will cause _A[RM_SIZE-1] to be clobbered, not updated when set_AllStack()
a61af66fc99e Initial load
duke
parents:
diff changeset
161 // follows an Insert() loop, like the one found in init_spill_mask(). Using
a61af66fc99e Initial load
duke
parents:
diff changeset
162 // Insert() instead works because the index into _A in computed instead of
a61af66fc99e Initial load
duke
parents:
diff changeset
163 // constant. See bug 4665841.
a61af66fc99e Initial load
duke
parents:
diff changeset
164 void set_AllStack() { Insert(OptoReg::Name(CHUNK_SIZE-1)); }
a61af66fc99e Initial load
duke
parents:
diff changeset
165
a61af66fc99e Initial load
duke
parents:
diff changeset
166 // Test for being a not-empty mask.
a61af66fc99e Initial load
duke
parents:
diff changeset
167 int is_NotEmpty( ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
168 int tmp = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
169 # define BODY(I) tmp |= _A[I];
a61af66fc99e Initial load
duke
parents:
diff changeset
170 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
171 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
172 return tmp;
a61af66fc99e Initial load
duke
parents:
diff changeset
173 }
a61af66fc99e Initial load
duke
parents:
diff changeset
174
a61af66fc99e Initial load
duke
parents:
diff changeset
175 // Find lowest-numbered register from mask, or BAD if mask is empty.
a61af66fc99e Initial load
duke
parents:
diff changeset
176 OptoReg::Name find_first_elem() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
177 int base, bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
178 # define BODY(I) if( (bits = _A[I]) != 0 ) base = I<<_LogWordBits; else
a61af66fc99e Initial load
duke
parents:
diff changeset
179 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
180 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
181 { base = OptoReg::Bad; bits = 1<<0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
182 return OptoReg::Name(base + find_lowest_bit(bits));
a61af66fc99e Initial load
duke
parents:
diff changeset
183 }
a61af66fc99e Initial load
duke
parents:
diff changeset
184 // Get highest-numbered register from mask, or BAD if mask is empty.
a61af66fc99e Initial load
duke
parents:
diff changeset
185 OptoReg::Name find_last_elem() const {
a61af66fc99e Initial load
duke
parents:
diff changeset
186 int base, bits;
a61af66fc99e Initial load
duke
parents:
diff changeset
187 # define BODY(I) if( (bits = _A[RM_SIZE-1-I]) != 0 ) base = (RM_SIZE-1-I)<<_LogWordBits; else
a61af66fc99e Initial load
duke
parents:
diff changeset
188 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
189 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
190 { base = OptoReg::Bad; bits = 1<<0; }
a61af66fc99e Initial load
duke
parents:
diff changeset
191 return OptoReg::Name(base + find_hihghest_bit(bits));
a61af66fc99e Initial load
duke
parents:
diff changeset
192 }
a61af66fc99e Initial load
duke
parents:
diff changeset
193
a61af66fc99e Initial load
duke
parents:
diff changeset
194 // Find the lowest-numbered register pair in the mask. Return the
a61af66fc99e Initial load
duke
parents:
diff changeset
195 // HIGHEST register number in the pair, or BAD if no pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
196 // Assert that the mask contains only bit pairs.
a61af66fc99e Initial load
duke
parents:
diff changeset
197 OptoReg::Name find_first_pair() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
198
a61af66fc99e Initial load
duke
parents:
diff changeset
199 // Clear out partial bits; leave only aligned adjacent bit pairs.
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
200 void clear_to_pairs();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
201 // Smear out partial bits; leave only aligned adjacent bit pairs.
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
202 void smear_to_pairs();
0
a61af66fc99e Initial load
duke
parents:
diff changeset
203 // Verify that the mask contains only aligned adjacent bit pairs
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
204 void verify_pairs() const { assert( is_aligned_pairs(), "mask is not aligned, adjacent pairs" ); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
205 // Test that the mask contains only aligned adjacent bit pairs
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
206 bool is_aligned_pairs() const;
0
a61af66fc99e Initial load
duke
parents:
diff changeset
207
a61af66fc99e Initial load
duke
parents:
diff changeset
208 // mask is a pair of misaligned registers
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
209 bool is_misaligned_pair() const { return Size()==2 && !is_aligned_pairs(); }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
210 // Test for single register
a61af66fc99e Initial load
duke
parents:
diff changeset
211 int is_bound1() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
212 // Test for a single adjacent pair
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
213 int is_bound_pair() const;
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
214 // Test for a single adjacent set of ideal register's size.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
215 int is_bound(uint ireg) const {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
216 if (is_vector(ireg)) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
217 if (is_bound_set(num_registers(ireg)))
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
218 return true;
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
219 } else if (is_bound1() || is_bound_pair()) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
220 return true;
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
221 }
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
222 return false;
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
223 }
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
224
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
225 // Find the lowest-numbered register set in the mask. Return the
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
226 // HIGHEST register number in the set, or BAD if no sets.
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
227 // Assert that the mask contains only bit sets.
8044
2c673161698a 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 7636
diff changeset
228 OptoReg::Name find_first_set(const int size) const;
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
229
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
230 // Clear out partial bits; leave only aligned adjacent bit sets of size.
8044
2c673161698a 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 7636
diff changeset
231 void clear_to_sets(const int size);
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
232 // Smear out partial bits to aligned adjacent bit sets.
8044
2c673161698a 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 7636
diff changeset
233 void smear_to_sets(const int size);
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
234 // Verify that the mask contains only aligned adjacent bit sets
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
235 void verify_sets(int size) const { assert(is_aligned_sets(size), "mask is not aligned, adjacent sets"); }
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
236 // Test that the mask contains only aligned adjacent bit sets
8044
2c673161698a 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 7636
diff changeset
237 bool is_aligned_sets(const int size) const;
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
238
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
239 // mask is a set of misaligned registers
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
240 bool is_misaligned_set(int size) const { return (int)Size()==size && !is_aligned_sets(size);}
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
241
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
242 // Test for a single adjacent set
8044
2c673161698a 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 7636
diff changeset
243 int is_bound_set(const int size) const;
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
244
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
245 static bool is_vector(uint ireg);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
246 static int num_registers(uint ireg);
0
a61af66fc99e Initial load
duke
parents:
diff changeset
247
a61af66fc99e Initial load
duke
parents:
diff changeset
248 // Fast overlap test. Non-zero if any registers in common.
a61af66fc99e Initial load
duke
parents:
diff changeset
249 int overlap( const RegMask &rm ) const {
a61af66fc99e Initial load
duke
parents:
diff changeset
250 return
a61af66fc99e Initial load
duke
parents:
diff changeset
251 # define BODY(I) (_A[I] & rm._A[I]) |
a61af66fc99e Initial load
duke
parents:
diff changeset
252 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
253 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
254 0 ;
a61af66fc99e Initial load
duke
parents:
diff changeset
255 }
a61af66fc99e Initial load
duke
parents:
diff changeset
256
a61af66fc99e Initial load
duke
parents:
diff changeset
257 // Special test for register pressure based splitting
a61af66fc99e Initial load
duke
parents:
diff changeset
258 // UP means register only, Register plus stack, or stack only is DOWN
a61af66fc99e Initial load
duke
parents:
diff changeset
259 bool is_UP() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
260
a61af66fc99e Initial load
duke
parents:
diff changeset
261 // Clear a register mask
a61af66fc99e Initial load
duke
parents:
diff changeset
262 void Clear( ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
263 # define BODY(I) _A[I] = 0;
a61af66fc99e Initial load
duke
parents:
diff changeset
264 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
265 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
266 }
a61af66fc99e Initial load
duke
parents:
diff changeset
267
a61af66fc99e Initial load
duke
parents:
diff changeset
268 // Fill a register mask with 1's
a61af66fc99e Initial load
duke
parents:
diff changeset
269 void Set_All( ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
270 # define BODY(I) _A[I] = -1;
a61af66fc99e Initial load
duke
parents:
diff changeset
271 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
272 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
273 }
a61af66fc99e Initial load
duke
parents:
diff changeset
274
a61af66fc99e Initial load
duke
parents:
diff changeset
275 // Insert register into mask
a61af66fc99e Initial load
duke
parents:
diff changeset
276 void Insert( OptoReg::Name reg ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
277 assert( reg < CHUNK_SIZE, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
278 _A[reg>>_LogWordBits] |= (1<<(reg&(_WordBits-1)));
a61af66fc99e Initial load
duke
parents:
diff changeset
279 }
a61af66fc99e Initial load
duke
parents:
diff changeset
280
a61af66fc99e Initial load
duke
parents:
diff changeset
281 // Remove register from mask
a61af66fc99e Initial load
duke
parents:
diff changeset
282 void Remove( OptoReg::Name reg ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
283 assert( reg < CHUNK_SIZE, "" );
a61af66fc99e Initial load
duke
parents:
diff changeset
284 _A[reg>>_LogWordBits] &= ~(1<<(reg&(_WordBits-1)));
a61af66fc99e Initial load
duke
parents:
diff changeset
285 }
a61af66fc99e Initial load
duke
parents:
diff changeset
286
a61af66fc99e Initial load
duke
parents:
diff changeset
287 // OR 'rm' into 'this'
a61af66fc99e Initial load
duke
parents:
diff changeset
288 void OR( const RegMask &rm ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
289 # define BODY(I) this->_A[I] |= rm._A[I];
a61af66fc99e Initial load
duke
parents:
diff changeset
290 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
291 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
292 }
a61af66fc99e Initial load
duke
parents:
diff changeset
293
a61af66fc99e Initial load
duke
parents:
diff changeset
294 // AND 'rm' into 'this'
a61af66fc99e Initial load
duke
parents:
diff changeset
295 void AND( const RegMask &rm ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
296 # define BODY(I) this->_A[I] &= rm._A[I];
a61af66fc99e Initial load
duke
parents:
diff changeset
297 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
298 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
299 }
a61af66fc99e Initial load
duke
parents:
diff changeset
300
a61af66fc99e Initial load
duke
parents:
diff changeset
301 // Subtract 'rm' from 'this'
a61af66fc99e Initial load
duke
parents:
diff changeset
302 void SUBTRACT( const RegMask &rm ) {
a61af66fc99e Initial load
duke
parents:
diff changeset
303 # define BODY(I) _A[I] &= ~rm._A[I];
a61af66fc99e Initial load
duke
parents:
diff changeset
304 FORALL_BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
305 # undef BODY
a61af66fc99e Initial load
duke
parents:
diff changeset
306 }
a61af66fc99e Initial load
duke
parents:
diff changeset
307
a61af66fc99e Initial load
duke
parents:
diff changeset
308 // Compute size of register mask: number of bits
a61af66fc99e Initial load
duke
parents:
diff changeset
309 uint Size() const;
a61af66fc99e Initial load
duke
parents:
diff changeset
310
a61af66fc99e Initial load
duke
parents:
diff changeset
311 #ifndef PRODUCT
a61af66fc99e Initial load
duke
parents:
diff changeset
312 void print() const { dump(); }
7636
a7114d3d712e 8005055: pass outputStream to more opto debug routines
kvn
parents: 6179
diff changeset
313 void dump(outputStream *st = tty) const; // Print a mask
0
a61af66fc99e Initial load
duke
parents:
diff changeset
314 #endif
a61af66fc99e Initial load
duke
parents:
diff changeset
315
a61af66fc99e Initial load
duke
parents:
diff changeset
316 static const RegMask Empty; // Common empty mask
a61af66fc99e Initial load
duke
parents:
diff changeset
317
a61af66fc99e Initial load
duke
parents:
diff changeset
318 static bool can_represent(OptoReg::Name reg) {
a61af66fc99e Initial load
duke
parents:
diff changeset
319 // NOTE: -1 in computation reflects the usage of the last
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
320 // bit of the regmask as an infinite stack flag and
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
321 // -7 is to keep mask aligned for largest value (VecY).
0
a61af66fc99e Initial load
duke
parents:
diff changeset
322 return (int)reg < (int)(CHUNK_SIZE-1);
a61af66fc99e Initial load
duke
parents:
diff changeset
323 }
6179
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
324 static bool can_represent_arg(OptoReg::Name reg) {
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
325 // NOTE: -SlotsPerVecY in computation reflects the need
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
326 // to keep mask aligned for largest value (VecY).
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
327 return (int)reg < (int)(CHUNK_SIZE-SlotsPerVecY);
8c92982cbbc4 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 2426
diff changeset
328 }
0
a61af66fc99e Initial load
duke
parents:
diff changeset
329 };
a61af66fc99e Initial load
duke
parents:
diff changeset
330
a61af66fc99e Initial load
duke
parents:
diff changeset
331 // Do not use this constant directly in client code!
a61af66fc99e Initial load
duke
parents:
diff changeset
332 #undef RM_SIZE
1972
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
333
f95d63e2154a 6989984: Use standard include model for Hospot
stefank
parents: 1552
diff changeset
334 #endif // SHARE_VM_OPTO_REGMASK_HPP