hotspot/src/cpu/sparc/vm/register_sparc.hpp
author twisti
Fri, 13 Feb 2009 09:09:35 -0800
changeset 2031 24e034f56dcb
parent 1 489c9b5090e2
child 5547 f4b087cbb361
permissions -rw-r--r--
6800154: Add comments to long_by_long_mulhi() for better understandability Summary: This patch adds a comment pointing to the Hacker's Delight version of the algorithm plus a verbatim copy of it. Furthermore it adds inline comments. Reviewed-by: kvn, jrose
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
489c9b5090e2 Initial load
duke
parents:
diff changeset
     2
 * Copyright 2000-2007 Sun Microsystems, Inc.  All Rights Reserved.
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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// forward declaration
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class Address;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class VMRegImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
typedef VMRegImpl* VMReg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Use Register as shortcut
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class RegisterImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
typedef RegisterImpl* Register;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
inline Register as_Register(int encoding) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  return (Register)(intptr_t) encoding;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
// The implementation of integer registers for the SPARC architecture
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class RegisterImpl: public AbstractRegisterImpl {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
    log_set_size        = 3,                          // the number of bits to encode the set register number
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
    number_of_sets      = 4,                          // the number of registers sets (in, local, out, global)
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
    number_of_registers = number_of_sets << log_set_size,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
    iset_no = 3,  ibase = iset_no << log_set_size,    // the in     register set
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
    lset_no = 2,  lbase = lset_no << log_set_size,    // the local  register set
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
    oset_no = 1,  obase = oset_no << log_set_size,    // the output register set
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
    gset_no = 0,  gbase = gset_no << log_set_size     // the global register set
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  friend Register as_Register(int encoding);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  // set specific construction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
  friend Register as_iRegister(int number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  friend Register as_lRegister(int number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  friend Register as_oRegister(int number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
  friend Register as_gRegister(int number);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  VMReg as_VMReg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  int   encoding() const                              { assert(is_valid(), "invalid register"); return value(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  const char* name() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // testers
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  bool is_valid() const                               { return (0 <= (value()&0x7F) && (value()&0x7F) < number_of_registers); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
  bool is_even() const                                { return (encoding() & 1) == 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  bool is_in() const                                  { return (encoding() >> log_set_size) == iset_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  bool is_local() const                               { return (encoding() >> log_set_size) == lset_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
  bool is_out() const                                 { return (encoding() >> log_set_size) == oset_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  bool is_global() const                              { return (encoding() >> log_set_size) == gset_no; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  // derived registers, offsets, and addresses
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  Register successor() const                          { return as_Register(encoding() + 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  int input_number() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
    assert(is_in(), "must be input register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
    return encoding() - ibase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  Register after_save() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
    assert(is_out() || is_global(), "register not visible after save");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
    return is_out() ? as_Register(encoding() + (ibase - obase)) : (const Register)this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  Register after_restore() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    assert(is_in() || is_global(), "register not visible after restore");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
    return is_in() ? as_Register(encoding() + (obase - ibase)) : (const Register)this;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  int sp_offset_in_saved_window() const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
    assert(is_in() || is_local(), "only i and l registers are saved in frame");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    return encoding() - lbase;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  inline Address address_in_saved_window() const;     // implemented in assembler_sparc.hpp
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
// set specific construction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
inline Register as_iRegister(int number)            { return as_Register(RegisterImpl::ibase + number); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
inline Register as_lRegister(int number)            { return as_Register(RegisterImpl::lbase + number); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
inline Register as_oRegister(int number)            { return as_Register(RegisterImpl::obase + number); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
inline Register as_gRegister(int number)            { return as_Register(RegisterImpl::gbase + number); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
// The integer registers of the SPARC architecture
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
CONSTANT_REGISTER_DECLARATION(Register, noreg , (-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
CONSTANT_REGISTER_DECLARATION(Register, G0    , (RegisterImpl::gbase + 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
CONSTANT_REGISTER_DECLARATION(Register, G1    , (RegisterImpl::gbase + 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
CONSTANT_REGISTER_DECLARATION(Register, G2    , (RegisterImpl::gbase + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
CONSTANT_REGISTER_DECLARATION(Register, G3    , (RegisterImpl::gbase + 3));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
CONSTANT_REGISTER_DECLARATION(Register, G4    , (RegisterImpl::gbase + 4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
CONSTANT_REGISTER_DECLARATION(Register, G5    , (RegisterImpl::gbase + 5));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
CONSTANT_REGISTER_DECLARATION(Register, G6    , (RegisterImpl::gbase + 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
CONSTANT_REGISTER_DECLARATION(Register, G7    , (RegisterImpl::gbase + 7));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
CONSTANT_REGISTER_DECLARATION(Register, O0    , (RegisterImpl::obase + 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
CONSTANT_REGISTER_DECLARATION(Register, O1    , (RegisterImpl::obase + 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
CONSTANT_REGISTER_DECLARATION(Register, O2    , (RegisterImpl::obase + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
CONSTANT_REGISTER_DECLARATION(Register, O3    , (RegisterImpl::obase + 3));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
CONSTANT_REGISTER_DECLARATION(Register, O4    , (RegisterImpl::obase + 4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
CONSTANT_REGISTER_DECLARATION(Register, O5    , (RegisterImpl::obase + 5));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
CONSTANT_REGISTER_DECLARATION(Register, O6    , (RegisterImpl::obase + 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
CONSTANT_REGISTER_DECLARATION(Register, O7    , (RegisterImpl::obase + 7));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
CONSTANT_REGISTER_DECLARATION(Register, L0    , (RegisterImpl::lbase + 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
CONSTANT_REGISTER_DECLARATION(Register, L1    , (RegisterImpl::lbase + 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
CONSTANT_REGISTER_DECLARATION(Register, L2    , (RegisterImpl::lbase + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
CONSTANT_REGISTER_DECLARATION(Register, L3    , (RegisterImpl::lbase + 3));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
CONSTANT_REGISTER_DECLARATION(Register, L4    , (RegisterImpl::lbase + 4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
CONSTANT_REGISTER_DECLARATION(Register, L5    , (RegisterImpl::lbase + 5));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
CONSTANT_REGISTER_DECLARATION(Register, L6    , (RegisterImpl::lbase + 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
CONSTANT_REGISTER_DECLARATION(Register, L7    , (RegisterImpl::lbase + 7));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
CONSTANT_REGISTER_DECLARATION(Register, I0    , (RegisterImpl::ibase + 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
CONSTANT_REGISTER_DECLARATION(Register, I1    , (RegisterImpl::ibase + 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
CONSTANT_REGISTER_DECLARATION(Register, I2    , (RegisterImpl::ibase + 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
CONSTANT_REGISTER_DECLARATION(Register, I3    , (RegisterImpl::ibase + 3));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
CONSTANT_REGISTER_DECLARATION(Register, I4    , (RegisterImpl::ibase + 4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
CONSTANT_REGISTER_DECLARATION(Register, I5    , (RegisterImpl::ibase + 5));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
CONSTANT_REGISTER_DECLARATION(Register, I6    , (RegisterImpl::ibase + 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
CONSTANT_REGISTER_DECLARATION(Register, I7    , (RegisterImpl::ibase + 7));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
CONSTANT_REGISTER_DECLARATION(Register, FP    , (RegisterImpl::ibase + 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
CONSTANT_REGISTER_DECLARATION(Register, SP    , (RegisterImpl::obase + 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
// Because sparc has so many registers, #define'ing values for the is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
// beneficial in code size and the cost of some of the dangers of
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
// defines.  We don't use them on Intel because win32 uses asm
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
// directives which use the same names for registers as Hotspot does,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
// so #defines would screw up the inline assembly.  If a particular
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
// file has a problem with these defines then it's possible to turn
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
// them off in that file by defining DONT_USE_REGISTER_DEFINES.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
// register_definition_sparc.cpp does that so that it's able to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
// provide real definitions of these registers for use in debuggers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
// and such.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
#ifndef DONT_USE_REGISTER_DEFINES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
#define noreg ((Register)(noreg_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
#define G0 ((Register)(G0_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
#define G1 ((Register)(G1_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
#define G2 ((Register)(G2_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
#define G3 ((Register)(G3_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
#define G4 ((Register)(G4_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
#define G5 ((Register)(G5_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
#define G6 ((Register)(G6_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
#define G7 ((Register)(G7_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
#define O0 ((Register)(O0_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
#define O1 ((Register)(O1_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
#define O2 ((Register)(O2_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
#define O3 ((Register)(O3_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
#define O4 ((Register)(O4_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
#define O5 ((Register)(O5_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
#define O6 ((Register)(O6_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
#define O7 ((Register)(O7_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
#define L0 ((Register)(L0_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
#define L1 ((Register)(L1_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
#define L2 ((Register)(L2_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
#define L3 ((Register)(L3_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
#define L4 ((Register)(L4_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
#define L5 ((Register)(L5_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
#define L6 ((Register)(L6_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
#define L7 ((Register)(L7_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
#define I0 ((Register)(I0_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
#define I1 ((Register)(I1_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
#define I2 ((Register)(I2_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
#define I3 ((Register)(I3_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
#define I4 ((Register)(I4_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
#define I5 ((Register)(I5_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
#define I6 ((Register)(I6_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
#define I7 ((Register)(I7_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
#define FP ((Register)(FP_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
#define SP ((Register)(SP_RegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
#endif // DONT_USE_REGISTER_DEFINES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
// Use FloatRegister as shortcut
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
class FloatRegisterImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
typedef FloatRegisterImpl* FloatRegister;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
// construction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
inline FloatRegister as_FloatRegister(int encoding) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  return (FloatRegister)(intptr_t)encoding;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
}
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
// The implementation of float registers for the SPARC architecture
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
class FloatRegisterImpl: public AbstractRegisterImpl {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
    number_of_registers = 64
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  enum Width {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
    S = 1,  D = 2,  Q = 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // construction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  VMReg as_VMReg( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  // accessors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  int encoding() const                                { assert(is_valid(), "invalid register"); return value(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  int encoding(Width w) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
    const int c = encoding();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
    switch (w) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
      case S:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
        assert(c < 32, "bad single float register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
        return c;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
      case D:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
        assert(c < 64  &&  (c & 1) == 0, "bad double float register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
        assert(c < 32 || VM_Version::v9_instructions_work(), "V9 float work only on V9 platform");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
        return (c & 0x1e) | ((c & 0x20) >> 5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
      case Q:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
        assert(c < 64  &&  (c & 3) == 0, "bad quad float register");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
        assert(c < 32 || VM_Version::v9_instructions_work(), "V9 float work only on V9 platform");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
        return (c & 0x1c) | ((c & 0x20) >> 5);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
    ShouldNotReachHere();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
    return -1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  bool  is_valid() const                              { return 0 <= value() && value() < number_of_registers; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  const char* name() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  FloatRegister successor() const                     { return as_FloatRegister(encoding() + 1); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
// The float registers of the SPARC architecture
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
CONSTANT_REGISTER_DECLARATION(FloatRegister, fnoreg , (-1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
CONSTANT_REGISTER_DECLARATION(FloatRegister, F0     , ( 0));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
CONSTANT_REGISTER_DECLARATION(FloatRegister, F1     , ( 1));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
CONSTANT_REGISTER_DECLARATION(FloatRegister, F2     , ( 2));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
CONSTANT_REGISTER_DECLARATION(FloatRegister, F3     , ( 3));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
CONSTANT_REGISTER_DECLARATION(FloatRegister, F4     , ( 4));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
CONSTANT_REGISTER_DECLARATION(FloatRegister, F5     , ( 5));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
CONSTANT_REGISTER_DECLARATION(FloatRegister, F6     , ( 6));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
CONSTANT_REGISTER_DECLARATION(FloatRegister, F7     , ( 7));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
CONSTANT_REGISTER_DECLARATION(FloatRegister, F8     , ( 8));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
CONSTANT_REGISTER_DECLARATION(FloatRegister, F9     , ( 9));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
CONSTANT_REGISTER_DECLARATION(FloatRegister, F10    , (10));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
CONSTANT_REGISTER_DECLARATION(FloatRegister, F11    , (11));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
CONSTANT_REGISTER_DECLARATION(FloatRegister, F12    , (12));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
CONSTANT_REGISTER_DECLARATION(FloatRegister, F13    , (13));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
CONSTANT_REGISTER_DECLARATION(FloatRegister, F14    , (14));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
CONSTANT_REGISTER_DECLARATION(FloatRegister, F15    , (15));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
CONSTANT_REGISTER_DECLARATION(FloatRegister, F16    , (16));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
CONSTANT_REGISTER_DECLARATION(FloatRegister, F17    , (17));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
CONSTANT_REGISTER_DECLARATION(FloatRegister, F18    , (18));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
CONSTANT_REGISTER_DECLARATION(FloatRegister, F19    , (19));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
CONSTANT_REGISTER_DECLARATION(FloatRegister, F20    , (20));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
CONSTANT_REGISTER_DECLARATION(FloatRegister, F21    , (21));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
CONSTANT_REGISTER_DECLARATION(FloatRegister, F22    , (22));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
CONSTANT_REGISTER_DECLARATION(FloatRegister, F23    , (23));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
CONSTANT_REGISTER_DECLARATION(FloatRegister, F24    , (24));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
CONSTANT_REGISTER_DECLARATION(FloatRegister, F25    , (25));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
CONSTANT_REGISTER_DECLARATION(FloatRegister, F26    , (26));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
CONSTANT_REGISTER_DECLARATION(FloatRegister, F27    , (27));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
CONSTANT_REGISTER_DECLARATION(FloatRegister, F28    , (28));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
CONSTANT_REGISTER_DECLARATION(FloatRegister, F29    , (29));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
CONSTANT_REGISTER_DECLARATION(FloatRegister, F30    , (30));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
CONSTANT_REGISTER_DECLARATION(FloatRegister, F31    , (31));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
CONSTANT_REGISTER_DECLARATION(FloatRegister, F32    , (32));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
CONSTANT_REGISTER_DECLARATION(FloatRegister, F34    , (34));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
CONSTANT_REGISTER_DECLARATION(FloatRegister, F36    , (36));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
CONSTANT_REGISTER_DECLARATION(FloatRegister, F38    , (38));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
CONSTANT_REGISTER_DECLARATION(FloatRegister, F40    , (40));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
CONSTANT_REGISTER_DECLARATION(FloatRegister, F42    , (42));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
CONSTANT_REGISTER_DECLARATION(FloatRegister, F44    , (44));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
CONSTANT_REGISTER_DECLARATION(FloatRegister, F46    , (46));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
CONSTANT_REGISTER_DECLARATION(FloatRegister, F48    , (48));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
CONSTANT_REGISTER_DECLARATION(FloatRegister, F50    , (50));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
CONSTANT_REGISTER_DECLARATION(FloatRegister, F52    , (52));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
CONSTANT_REGISTER_DECLARATION(FloatRegister, F54    , (54));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
CONSTANT_REGISTER_DECLARATION(FloatRegister, F56    , (56));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
CONSTANT_REGISTER_DECLARATION(FloatRegister, F58    , (58));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
CONSTANT_REGISTER_DECLARATION(FloatRegister, F60    , (60));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
CONSTANT_REGISTER_DECLARATION(FloatRegister, F62    , (62));
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
#ifndef DONT_USE_REGISTER_DEFINES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
#define fnoreg ((FloatRegister)(fnoreg_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
#define F0     ((FloatRegister)(    F0_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
#define F1     ((FloatRegister)(    F1_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
#define F2     ((FloatRegister)(    F2_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
#define F3     ((FloatRegister)(    F3_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
#define F4     ((FloatRegister)(    F4_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
#define F5     ((FloatRegister)(    F5_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
#define F6     ((FloatRegister)(    F6_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
#define F7     ((FloatRegister)(    F7_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
#define F8     ((FloatRegister)(    F8_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
#define F9     ((FloatRegister)(    F9_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
#define F10    ((FloatRegister)(   F10_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
#define F11    ((FloatRegister)(   F11_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
#define F12    ((FloatRegister)(   F12_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
#define F13    ((FloatRegister)(   F13_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
#define F14    ((FloatRegister)(   F14_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
#define F15    ((FloatRegister)(   F15_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
#define F16    ((FloatRegister)(   F16_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
#define F17    ((FloatRegister)(   F17_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
#define F18    ((FloatRegister)(   F18_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
#define F19    ((FloatRegister)(   F19_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
#define F20    ((FloatRegister)(   F20_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
#define F21    ((FloatRegister)(   F21_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
#define F22    ((FloatRegister)(   F22_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
#define F23    ((FloatRegister)(   F23_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
#define F24    ((FloatRegister)(   F24_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
#define F25    ((FloatRegister)(   F25_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
#define F26    ((FloatRegister)(   F26_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
#define F27    ((FloatRegister)(   F27_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
#define F28    ((FloatRegister)(   F28_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
#define F29    ((FloatRegister)(   F29_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
#define F30    ((FloatRegister)(   F30_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
#define F31    ((FloatRegister)(   F31_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
#define F32    ((FloatRegister)(   F32_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
#define F34    ((FloatRegister)(   F34_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
#define F36    ((FloatRegister)(   F36_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
#define F38    ((FloatRegister)(   F38_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
#define F40    ((FloatRegister)(   F40_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
#define F42    ((FloatRegister)(   F42_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
#define F44    ((FloatRegister)(   F44_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
#define F46    ((FloatRegister)(   F46_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
#define F48    ((FloatRegister)(   F48_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
#define F50    ((FloatRegister)(   F50_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
#define F52    ((FloatRegister)(   F52_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
#define F54    ((FloatRegister)(   F54_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
#define F56    ((FloatRegister)(   F56_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
#define F58    ((FloatRegister)(   F58_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
#define F60    ((FloatRegister)(   F60_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
#define F62    ((FloatRegister)(   F62_FloatRegisterEnumValue))
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
#endif // DONT_USE_REGISTER_DEFINES
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
// Maximum number of incoming arguments that can be passed in i registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
const int SPARC_ARGS_IN_REGS_NUM = 6;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
class ConcreteRegisterImpl : public AbstractRegisterImpl {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
    // This number must be large enough to cover REG_COUNT (defined by c2) registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
    // There is no requirement that any ordering here matches any ordering c2 gives
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
    // it's optoregs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
    number_of_registers = 2*RegisterImpl::number_of_registers +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
                            FloatRegisterImpl::number_of_registers +
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
                            1 + // ccr
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
                            4  //  fcc
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  static const int max_gpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  static const int max_fpr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
// Single, Double and Quad fp reg classes.  These exist to map the ADLC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
// encoding for a floating point register, to the FloatRegister number
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
// desired by the macroassembler.  A FloatRegister is a number between
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
// 0 and 63 passed around as a pointer.  For ADLC, an fp register encoding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
// is the actual bit encoding used by the sparc hardware.  When ADLC used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
// the macroassembler to generate an instruction that references, e.g., a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
// double fp reg, it passed the bit encoding to the macroassembler via
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
// as_FloatRegister, which, for double regs > 30, returns an illegal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
// register number.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
//
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
// Therefore we provide the following classes for use by ADLC.  Their
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
// sole purpose is to convert from sparc register encodings to FloatRegisters.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
// At some future time, we might replace FloatRegister with these classes,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
// hence the definitions of as_xxxFloatRegister as class methods rather
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
// than as external inline routines.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
class SingleFloatRegisterImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
typedef SingleFloatRegisterImpl *SingleFloatRegister;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
inline FloatRegister as_SingleFloatRegister(int encoding);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
class SingleFloatRegisterImpl {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  friend inline FloatRegister as_SingleFloatRegister(int encoding) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
    assert(encoding < 32, "bad single float register encoding");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
    return as_FloatRegister(encoding);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
class DoubleFloatRegisterImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
typedef DoubleFloatRegisterImpl *DoubleFloatRegister;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
inline FloatRegister as_DoubleFloatRegister(int encoding);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
class DoubleFloatRegisterImpl {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  friend inline FloatRegister as_DoubleFloatRegister(int encoding) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
    assert(encoding < 32, "bad double float register encoding");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
    return as_FloatRegister( ((encoding & 1) << 5) | (encoding & 0x1e) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
class QuadFloatRegisterImpl;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
typedef QuadFloatRegisterImpl *QuadFloatRegister;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
class QuadFloatRegisterImpl {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
 public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  friend FloatRegister as_QuadFloatRegister(int encoding) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
    assert(encoding < 32 && ((encoding & 2) == 0), "bad quad float register encoding");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
    return as_FloatRegister( ((encoding & 1) << 5) | (encoding & 0x1c) );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
};