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_OPTO_REGMASK_HPP
26 #define SHARE_OPTO_REGMASK_HPP
27
28 #include "code/vmreg.hpp"
29 #include "opto/optoreg.hpp"
30 #include "utilities/count_trailing_zeros.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, undefined if empty/0
50 static int find_lowest_bit(uint32_t mask) {
51 return count_trailing_zeros(mask);
52 }
53 // Find highest 1, or return 32 if empty
54 int find_highest_bit( uint32_t mask );
55
56 //------------------------------RegMask----------------------------------------
57 // The ADL file describes how to print the machine-specific registers, as well
58 // as any notion of register classes. We provide a register mask, which is
59 // just a collection of Register numbers.
60
61 // The ADLC defines 2 macros, RM_SIZE and FORALL_BODY.
62 // RM_SIZE is the size of a register mask in words.
63 // FORALL_BODY replicates a BODY macro once per word in the register mask.
64 // The usage is somewhat clumsy and limited to the regmask.[h,c]pp files.
65 // However, it means the ADLC can redefine the unroll macro and all loops
66 // over register masks will be unrolled by the correct amount.
67
68 class RegMask {
69 union {
70 double _dummy_force_double_alignment[RM_SIZE>>1];
71 // Array of Register Mask bits. This array is large enough to cover
72 // all the machine registers and all parameters that need to be passed
73 // on the stack (stack registers) up to some interesting limit. Methods
74 // that need more parameters will NOT be compiled. On Intel, the limit
|
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_OPTO_REGMASK_HPP
26 #define SHARE_OPTO_REGMASK_HPP
27
28 #include "code/vmreg.hpp"
29 #include "opto/optoreg.hpp"
30 #include "utilities/count_leading_zeros.hpp"
31 #include "utilities/count_trailing_zeros.hpp"
32
33 // Some fun naming (textual) substitutions:
34 //
35 // RegMask::get_low_elem() ==> RegMask::find_first_elem()
36 // RegMask::Special ==> RegMask::Empty
37 // RegMask::_flags ==> RegMask::is_AllStack()
38 // RegMask::operator<<=() ==> RegMask::Insert()
39 // RegMask::operator>>=() ==> RegMask::Remove()
40 // RegMask::Union() ==> RegMask::OR
41 // RegMask::Inter() ==> RegMask::AND
42 //
43 // OptoRegister::RegName ==> OptoReg::Name
44 //
45 // OptoReg::stack0() ==> _last_Mach_Reg or ZERO in core version
46 //
47 // numregs in chaitin ==> proper degree in chaitin
48
49 //-------------Non-zero bit search methods used by RegMask---------------------
50 // Find lowest 1, undefined if empty/0
51 static int find_lowest_bit(uint32_t mask) {
52 return count_trailing_zeros(mask);
53 }
54 // Find highest 1, undefined if empty/0
55 static int find_highest_bit(uint32_t mask) {
56 return count_leading_zeros(mask) ^ 31;
57 }
58
59 //------------------------------RegMask----------------------------------------
60 // The ADL file describes how to print the machine-specific registers, as well
61 // as any notion of register classes. We provide a register mask, which is
62 // just a collection of Register numbers.
63
64 // The ADLC defines 2 macros, RM_SIZE and FORALL_BODY.
65 // RM_SIZE is the size of a register mask in words.
66 // FORALL_BODY replicates a BODY macro once per word in the register mask.
67 // The usage is somewhat clumsy and limited to the regmask.[h,c]pp files.
68 // However, it means the ADLC can redefine the unroll macro and all loops
69 // over register masks will be unrolled by the correct amount.
70
71 class RegMask {
72 union {
73 double _dummy_force_double_alignment[RM_SIZE>>1];
74 // Array of Register Mask bits. This array is large enough to cover
75 // all the machine registers and all parameters that need to be passed
76 // on the stack (stack registers) up to some interesting limit. Methods
77 // that need more parameters will NOT be compiled. On Intel, the limit
|