hotspot/src/share/vm/opto/regmask.hpp
author goetz
Fri, 04 Jul 2014 11:46:01 +0200
changeset 25715 d5a8dbdc5150
parent 24425 53764d2358f9
child 30624 2e1803c8a26d
permissions -rw-r--r--
8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Summary: Introduce and clean up umbrella headers for the files in the cpu subdirectories. Reviewed-by: lfoltan, coleenp, dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
25715
d5a8dbdc5150 8049325: Introduce and clean up umbrella headers for the files in the cpu subdirectories.
goetz
parents: 24425
diff changeset
     2
 * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 1
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_OPTO_REGMASK_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_OPTO_REGMASK_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    28
#include "code/vmreg.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    29
#include "opto/optoreg.hpp"
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    30
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Some fun naming (textual) substitutions:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// RegMask::get_low_elem() ==> RegMask::find_first_elem()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
// RegMask::Special        ==> RegMask::Empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
// RegMask::_flags         ==> RegMask::is_AllStack()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
// RegMask::operator<<=()  ==> RegMask::Insert()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
// RegMask::operator>>=()  ==> RegMask::Remove()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
// RegMask::Union()        ==> RegMask::OR
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
// RegMask::Inter()        ==> RegMask::AND
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
// OptoRegister::RegName   ==> OptoReg::Name
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
// OptoReg::stack0()       ==> _last_Mach_Reg  or ZERO in core version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
// numregs in chaitin      ==> proper degree in chaitin
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
//-------------Non-zero bit search methods used by RegMask---------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
// Find lowest 1, or return 32 if empty
24425
53764d2358f9 8041415: remove port.{cpp,hpp} files
zgu
parents: 22807
diff changeset
    49
int find_lowest_bit( uint32_t mask );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
// Find highest 1, or return 32 if empty
24425
53764d2358f9 8041415: remove port.{cpp,hpp} files
zgu
parents: 22807
diff changeset
    51
int find_hihghest_bit( uint32_t mask );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
//------------------------------RegMask----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
// The ADL file describes how to print the machine-specific registers, as well
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
// as any notion of register classes.  We provide a register mask, which is
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
// just a collection of Register numbers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
// The ADLC defines 2 macros, RM_SIZE and FORALL_BODY.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
// RM_SIZE is the size of a register mask in words.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// FORALL_BODY replicates a BODY macro once per word in the register mask.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
// The usage is somewhat clumsy and limited to the regmask.[h,c]pp files.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
// However, it means the ADLC can redefine the unroll macro and all loops
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
// over register masks will be unrolled by the correct amount.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class RegMask VALUE_OBJ_CLASS_SPEC {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  union {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
    double _dummy_force_double_alignment[RM_SIZE>>1];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
    // Array of Register Mask bits.  This array is large enough to cover
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
    // all the machine registers and all parameters that need to be passed
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
    // on the stack (stack registers) up to some interesting limit.  Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
    // that need more parameters will NOT be compiled.  On Intel, the limit
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
    // is something like 90+ parameters.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
    int _A[RM_SIZE];
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
    _WordBits    = BitsPerInt,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
    _LogWordBits = LogBitsPerInt,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
    _RM_SIZE     = RM_SIZE   // local constant, imported, then hidden by #undef
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  enum { CHUNK_SIZE = RM_SIZE*_WordBits };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // SlotsPerLong is 2, since slots are 32 bits and longs are 64 bits.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // Also, consider the maximum alignment size for a normally allocated
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  // value.  Since we allocate register pairs but not register quads (at
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // present), this alignment is SlotsPerLong (== 2).  A normally
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  // aligned allocated register is either a single register, or a pair
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  // of adjacent registers, the lower-numbered being even.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  // See also is_aligned_Pairs() below, and the padding added before
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  // Matcher::_new_SP to keep allocated pairs aligned properly.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  // If we ever go to quad-word allocations, SlotsPerQuad will become
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  // the controlling alignment constraint.  Note that this alignment
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // requirement is internal to the allocator, and independent of any
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  // particular platform.
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
    97
  enum { SlotsPerLong = 2,
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
    98
         SlotsPerVecS = 1,
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
    99
         SlotsPerVecD = 2,
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   100
         SlotsPerVecX = 4,
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   101
         SlotsPerVecY = 8 };
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // A constructor only used by the ADLC output.  All mask fields are filled
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  // in directly.  Calls to this look something like RM(1,2,3,4);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  RegMask(
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
#   define BODY(I) int a##I,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
    int dummy = 0 ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
#   define BODY(I) _A[I] = a##I;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  // Handy copying constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  RegMask( RegMask *rm ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
#   define BODY(I) _A[I] = rm->_A[I];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // Construct an empty mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  RegMask( ) { Clear(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  // Construct a mask with a single bit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  RegMask( OptoReg::Name reg ) { Clear(); Insert(reg); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // Check for register being in mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  int Member( OptoReg::Name reg ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
    assert( reg < CHUNK_SIZE, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
    return _A[reg>>_LogWordBits] & (1<<(reg&(_WordBits-1)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  // The last bit in the register mask indicates that the mask should repeat
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // indefinitely with ONE bits.  Returns TRUE if mask is infinite or
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // unbounded in size.  Returns FALSE if mask is finite size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  int is_AllStack() const { return _A[RM_SIZE-1] >> (_WordBits-1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Work around an -xO3 optimization problme in WS6U1. The old way:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  //   void set_AllStack() { _A[RM_SIZE-1] |= (1<<(_WordBits-1)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // will cause _A[RM_SIZE-1] to be clobbered, not updated when set_AllStack()
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // follows an Insert() loop, like the one found in init_spill_mask(). Using
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  // Insert() instead works because the index into _A in computed instead of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // constant.  See bug 4665841.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  void set_AllStack() { Insert(OptoReg::Name(CHUNK_SIZE-1)); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // Test for being a not-empty mask.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  int is_NotEmpty( ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
    int tmp = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
#   define BODY(I) tmp |= _A[I];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
    return tmp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // Find lowest-numbered register from mask, or BAD if mask is empty.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  OptoReg::Name find_first_elem() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
    int base, bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
#   define BODY(I) if( (bits = _A[I]) != 0 ) base = I<<_LogWordBits; else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
      { base = OptoReg::Bad; bits = 1<<0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
    return OptoReg::Name(base + find_lowest_bit(bits));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  // Get highest-numbered register from mask, or BAD if mask is empty.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  OptoReg::Name find_last_elem() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
    int base, bits;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
#   define BODY(I) if( (bits = _A[RM_SIZE-1-I]) != 0 ) base = (RM_SIZE-1-I)<<_LogWordBits; else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
      { base = OptoReg::Bad; bits = 1<<0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
    return OptoReg::Name(base + find_hihghest_bit(bits));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  // Find the lowest-numbered register pair in the mask.  Return the
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // HIGHEST register number in the pair, or BAD if no pairs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Assert that the mask contains only bit pairs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  OptoReg::Name find_first_pair() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // Clear out partial bits; leave only aligned adjacent bit pairs.
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   181
  void clear_to_pairs();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  // Smear out partial bits; leave only aligned adjacent bit pairs.
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   183
  void smear_to_pairs();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  // Verify that the mask contains only aligned adjacent bit pairs
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   185
  void verify_pairs() const { assert( is_aligned_pairs(), "mask is not aligned, adjacent pairs" ); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Test that the mask contains only aligned adjacent bit pairs
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   187
  bool is_aligned_pairs() const;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // mask is a pair of misaligned registers
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   190
  bool is_misaligned_pair() const { return Size()==2 && !is_aligned_pairs(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  // Test for single register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  int is_bound1() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Test for a single adjacent pair
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   194
  int is_bound_pair() const;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   195
  // Test for a single adjacent set of ideal register's size.
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   196
  int is_bound(uint ireg) const {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   197
    if (is_vector(ireg)) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   198
      if (is_bound_set(num_registers(ireg)))
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   199
        return true;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   200
    } else if (is_bound1() || is_bound_pair()) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   201
      return true;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   202
    }
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   203
    return false;
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   204
  }
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   205
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   206
  // Find the lowest-numbered register set in the mask.  Return the
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   207
  // HIGHEST register number in the set, or BAD if no sets.
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   208
  // Assert that the mask contains only bit sets.
15614
3d9afca22dc7 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 15241
diff changeset
   209
  OptoReg::Name find_first_set(const int size) const;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   210
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   211
  // Clear out partial bits; leave only aligned adjacent bit sets of size.
15614
3d9afca22dc7 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 15241
diff changeset
   212
  void clear_to_sets(const int size);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   213
  // Smear out partial bits to aligned adjacent bit sets.
15614
3d9afca22dc7 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 15241
diff changeset
   214
  void smear_to_sets(const int size);
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   215
  // Verify that the mask contains only aligned adjacent bit sets
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   216
  void verify_sets(int size) const { assert(is_aligned_sets(size), "mask is not aligned, adjacent sets"); }
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   217
  // Test that the mask contains only aligned adjacent bit sets
15614
3d9afca22dc7 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 15241
diff changeset
   218
  bool is_aligned_sets(const int size) const;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   219
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   220
  // mask is a set of misaligned registers
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   221
  bool is_misaligned_set(int size) const { return (int)Size()==size && !is_aligned_sets(size);}
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   222
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   223
  // Test for a single adjacent set
15614
3d9afca22dc7 8007402: Code cleanup to remove Parfait false positive
drchase
parents: 15241
diff changeset
   224
  int is_bound_set(const int size) const;
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   225
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   226
  static bool is_vector(uint ireg);
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   227
  static int num_registers(uint ireg);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  // Fast overlap test.  Non-zero if any registers in common.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  int overlap( const RegMask &rm ) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
    return
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
#   define BODY(I) (_A[I] & rm._A[I]) |
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
    0 ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  // Special test for register pressure based splitting
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // UP means register only, Register plus stack, or stack only is DOWN
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  bool is_UP() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // Clear a register mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  void Clear( ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
#   define BODY(I) _A[I] = 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  // Fill a register mask with 1's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  void Set_All( ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
#   define BODY(I) _A[I] = -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // Insert register into mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  void Insert( OptoReg::Name reg ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
    assert( reg < CHUNK_SIZE, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
    _A[reg>>_LogWordBits] |= (1<<(reg&(_WordBits-1)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  // Remove register from mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  void Remove( OptoReg::Name reg ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
    assert( reg < CHUNK_SIZE, "" );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
    _A[reg>>_LogWordBits] &= ~(1<<(reg&(_WordBits-1)));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // OR 'rm' into 'this'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  void OR( const RegMask &rm ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
#   define BODY(I) this->_A[I] |= rm._A[I];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // AND 'rm' into 'this'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  void AND( const RegMask &rm ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
#   define BODY(I) this->_A[I] &= rm._A[I];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  // Subtract 'rm' from 'this'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  void SUBTRACT( const RegMask &rm ) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
#   define BODY(I) _A[I] &= ~rm._A[I];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
    FORALL_BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
#   undef BODY
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // Compute size of register mask: number of bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  uint Size() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
#ifndef PRODUCT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  void print() const { dump(); }
15241
87d217c2d183 8005055: pass outputStream to more opto debug routines
kvn
parents: 13104
diff changeset
   294
  void dump(outputStream *st = tty) const; // Print a mask
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  static const RegMask Empty;   // Common empty mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  static bool can_represent(OptoReg::Name reg) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
    // NOTE: -1 in computation reflects the usage of the last
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   301
    //       bit of the regmask as an infinite stack flag and
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   302
    //       -7 is to keep mask aligned for largest value (VecY).
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
    return (int)reg < (int)(CHUNK_SIZE-1);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  }
13104
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   305
  static bool can_represent_arg(OptoReg::Name reg) {
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   306
    // NOTE: -SlotsPerVecY in computation reflects the need
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   307
    //       to keep mask aligned for largest value (VecY).
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   308
    return (int)reg < (int)(CHUNK_SIZE-SlotsPerVecY);
657b387034fb 7119644: Increase superword's vector size up to 256 bits
kvn
parents: 8921
diff changeset
   309
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
// Do not use this constant directly in client code!
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
#undef RM_SIZE
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   314
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   315
#endif // SHARE_VM_OPTO_REGMASK_HPP