hotspot/src/share/vm/opto/matcher.hpp
author kvn
Thu, 13 Mar 2008 16:06:34 -0700
changeset 236 9a04268c8eea
parent 1 489c9b5090e2
child 594 9f4474e5dbaf
permissions -rw-r--r--
6671807: (Escape Analysis) Add new ideal node to represent the state of a scalarized object at a safepoint Summary: Values of non-static fields of a scalarized object should be saved in debug info to reallocate the object during deoptimization. Reviewed-by: never
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 1997-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
class Compile;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
class Node;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
class MachNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class MachTypeNode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class MachOper;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
//---------------------------Matcher-------------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class Matcher : public PhaseTransform {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
  friend class VMStructs;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
  // Private arena of State objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
  ResourceArea _states_arena;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
  VectorSet   _visited;         // Visit bits
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
  // Used to control the Label pass
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
  VectorSet   _shared;          // Shared Ideal Node
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
  VectorSet   _dontcare;        // Nothing the matcher cares about
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
  // Private methods which perform the actual matching and reduction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
  // Walks the label tree, generating machine nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
  MachNode *ReduceInst( State *s, int rule, Node *&mem);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
  void ReduceInst_Chain_Rule( State *s, int rule, Node *&mem, MachNode *mach);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
  uint ReduceInst_Interior(State *s, int rule, Node *&mem, MachNode *mach, uint num_opnds);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
  void ReduceOper( State *s, int newrule, Node *&mem, MachNode *mach );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
  // If this node already matched using "rule", return the MachNode for it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
  MachNode* find_shared_constant(Node* con, uint rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
  // Convert a dense opcode number to an expanded rule number
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
  const int *_reduceOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
  const int *_leftOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
  const int *_rightOp;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
  // Map dense opcode number to info on when rule is swallowed constant.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
  const bool *_swallowed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
  // Map dense rule number to determine if this is an instruction chain rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
  const uint _begin_inst_chain_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
  const uint _end_inst_chain_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
  // We want to clone constants and possible CmpI-variants.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
  // If we do not clone CmpI, then we can have many instances of
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
  // condition codes alive at once.  This is OK on some chips and
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
  // bad on others.  Hence the machine-dependent table lookup.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
  const char *_must_clone;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
  // Find shared Nodes, or Nodes that otherwise are Matcher roots
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
  void find_shared( Node *n );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  // Debug and profile information for nodes in old space:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  GrowableArray<Node_Notes*>* _old_node_note_array;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  // Node labeling iterator for instruction selection
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  Node *Label_Root( const Node *n, State *svec, Node *control, const Node *mem );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  Node *transform( Node *dummy );
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  Node_List &_proj_list;        // For Machine nodes killing many values
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  Node_Array _shared_constants;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  debug_only(Node_Array _old2new_map;)   // Map roots of ideal-trees to machine-roots
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  // Accessors for the inherited field PhaseTransform::_nodes:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  void   grow_new_node_array(uint idx_limit) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
    _nodes.map(idx_limit-1, NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  bool    has_new_node(const Node* n) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
    return _nodes.at(n->_idx) != NULL;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  Node*       new_node(const Node* n) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
    assert(has_new_node(n), "set before get");
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
    return _nodes.at(n->_idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void    set_new_node(const Node* n, Node *nn) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
    assert(!has_new_node(n), "set only once");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
    _nodes.map(n->_idx, nn);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // Make sure only new nodes are reachable from this node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void verify_new_nodes_only(Node* root);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  int LabelRootDepth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  static const int base2reg[];        // Map Types to machine register types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Convert ideal machine register to a register mask for spill-loads
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  static const RegMask *idealreg2regmask[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  RegMask *idealreg2spillmask[_last_machine_leaf];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  RegMask *idealreg2debugmask[_last_machine_leaf];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  void init_spill_mask( Node *ret );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  // Convert machine register number to register mask
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  static uint mreg2regmask_max;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  static RegMask mreg2regmask[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  static RegMask STACK_ONLY_mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  bool    is_shared( Node *n ) { return _shared.test(n->_idx) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  void   set_shared( Node *n ) {  _shared.set(n->_idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  bool   is_visited( Node *n ) { return _visited.test(n->_idx) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  void  set_visited( Node *n ) { _visited.set(n->_idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  bool  is_dontcare( Node *n ) { return _dontcare.test(n->_idx) != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  void set_dontcare( Node *n ) {  _dontcare.set(n->_idx); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // Mode bit to tell DFA and expand rules whether we are running after
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // (or during) register selection.  Usually, the matcher runs before,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  // but it will also get called to generate post-allocation spill code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  // In this situation, it is a deadly error to attempt to allocate more
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // temporary registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  bool _allocation_started;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // Machine register names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  static const char *regName[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // Machine register encodings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  static const unsigned char _regEncode[];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  // Machine Node names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  const char **_ruleName;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // Rules that are cheaper to rematerialize than to spill
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  static const uint _begin_rematerialize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  static const uint _end_rematerialize;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // An array of chars, from 0 to _last_Mach_Reg.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // No Save       = 'N' (for register windows)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  // Save on Entry = 'E'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Save on Call  = 'C'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // Always Save   = 'A' (same as SOE + SOC)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  const char *_register_save_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  const char *_c_reg_save_policy;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  // Convert a machine register to a machine register type, so-as to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  // properly match spill code.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  const int *_register_save_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  // Maps from machine register to boolean; true if machine register can
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
  // be holding a call argument in some signature.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  static bool can_be_java_arg( int reg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Maps from machine register to boolean; true if machine register holds
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  // a spillable argument.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  static bool is_spillable_arg( int reg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // List of IfFalse or IfTrue Nodes that indicate a taken null test.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  // List is valid in the post-matching space.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  Node_List _null_check_tests;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  void collect_null_checks( Node *proj );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  void validate_null_checks( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  Matcher( Node_List &proj_list );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Select instructions for entire method
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  void  match( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  // Helper for match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  OptoReg::Name warp_incoming_stk_arg( VMReg reg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // Transform, then walk.  Does implicit DCE while walking.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  // Name changed from "transform" to avoid it being virtual.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  Node *xform( Node *old_space_node, int Nodes );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  // Match a single Ideal Node - turn it into a 1-Node tree; Label & Reduce.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  MachNode *match_tree( const Node *n );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  MachNode *match_sfpt( SafePointNode *sfpt );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  // Helper for match_sfpt
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  OptoReg::Name warp_outgoing_stk_arg( VMReg reg, OptoReg::Name begin_out_arg_area, OptoReg::Name &out_arg_limit_per_call );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Initialize first stack mask and related masks.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  void init_first_stack_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  // If we should save-on-entry this register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  bool is_save_on_entry( int reg );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  // Fixup the save-on-entry registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  void Fixup_Save_On_Entry( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  // --- Frame handling ---
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  // Register number of the stack slot corresponding to the incoming SP.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // Per the Big Picture in the AD file, it is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  //   SharedInfo::stack0 + locks + in_preserve_stack_slots + pad2.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  OptoReg::Name _old_SP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // Register number of the stack slot corresponding to the highest incoming
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  // argument on the stack.  Per the Big Picture in the AD file, it is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  //   _old_SP + out_preserve_stack_slots + incoming argument size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  OptoReg::Name _in_arg_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // Register number of the stack slot corresponding to the new SP.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  // Per the Big Picture in the AD file, it is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
  //   _in_arg_limit + pad0
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  OptoReg::Name _new_SP;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // Register number of the stack slot corresponding to the highest outgoing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  // argument on the stack.  Per the Big Picture in the AD file, it is:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
  //   _new_SP + max outgoing arguments of all calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  OptoReg::Name _out_arg_limit;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  OptoRegPair *_parm_regs;        // Array of machine registers per argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  RegMask *_calling_convention_mask; // Array of RegMasks per argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // Does matcher support this ideal node?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  static const bool has_match_rule(int opcode);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  static const bool _hasMatchRule[_last_opcode];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  // Used to determine if we have fast l2f conversion
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  // USII has it, USIII doesn't
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  static const bool convL2FSupported(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // Vector width in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  static const uint vector_width_in_bytes(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  // Vector ideal reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  static const uint vector_ideal_reg(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // Used to determine a "low complexity" 64-bit constant.  (Zero is simple.)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  // The standard of comparison is one (StoreL ConL) vs. two (StoreI ConI).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // Depends on the details of 64-bit constant generation on the CPU.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  static const bool isSimpleConstant64(jlong con);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // These calls are all generated by the ADLC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  // TRUE - grows up, FALSE - grows down (Intel)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  virtual bool stack_direction() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // Java-Java calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  // (what you use when Java calls Java)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // Alignment of stack in bytes, standard Intel word alignment is 4.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  // Sparc probably wants at least double-word (8).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  static uint stack_alignment_in_bytes();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  // Alignment of stack, measured in stack slots.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // The size of stack slots is defined by VMRegImpl::stack_slot_size.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  static uint stack_alignment_in_slots() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
    return stack_alignment_in_bytes() / (VMRegImpl::stack_slot_size);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // Array mapping arguments to registers.  Argument 0 is usually the 'this'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // pointer.  Registers can include stack-slots and regular registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  static void calling_convention( BasicType *, VMRegPair *, uint len, bool is_outgoing );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // Convert a sig into a calling convention register layout
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  // and find interesting things about it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  static OptoReg::Name  find_receiver( bool is_outgoing );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  // Return address register.  On Intel it is a stack-slot.  On PowerPC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  // it is the Link register.  On Sparc it is r31?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  virtual OptoReg::Name return_addr() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  RegMask              _return_addr_mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  // Return value register.  On Intel it is EAX.  On Sparc i0/o0.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  static OptoRegPair   return_value(int ideal_reg, bool is_outgoing);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  static OptoRegPair c_return_value(int ideal_reg, bool is_outgoing);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  RegMask                     _return_value_mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  // Inline Cache Register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  static OptoReg::Name  inline_cache_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  static const RegMask &inline_cache_reg_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  static int            inline_cache_reg_encode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // Register for DIVI projection of divmodI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  static RegMask divI_proj_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  // Register for MODI projection of divmodI
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  static RegMask modI_proj_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  // Register for DIVL projection of divmodL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
  static RegMask divL_proj_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  // Register for MODL projection of divmodL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  static RegMask modL_proj_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  // Java-Interpreter calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  // (what you use when calling between compiled-Java and Interpreted-Java
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  // Number of callee-save + always-save registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // Ignores frame pointer and "special" registers
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  static int  number_of_saved_registers();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  // The Method-klass-holder may be passed in the inline_cache_reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  // and then expanded into the inline_cache_reg and a method_oop register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  static OptoReg::Name  interpreter_method_oop_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  static const RegMask &interpreter_method_oop_reg_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  static int            interpreter_method_oop_reg_encode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  static OptoReg::Name  compiler_method_oop_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  static const RegMask &compiler_method_oop_reg_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  static int            compiler_method_oop_reg_encode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  // Interpreter's Frame Pointer Register
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
  static OptoReg::Name  interpreter_frame_pointer_reg();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  static const RegMask &interpreter_frame_pointer_reg_mask();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
  // Java-Native calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
  // (what you use when intercalling between Java and C++ code)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // Array mapping arguments to registers.  Argument 0 is usually the 'this'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  // pointer.  Registers can include stack-slots and regular registers.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  static void c_calling_convention( BasicType*, VMRegPair *, uint );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  // Frame pointer. The frame pointer is kept at the base of the stack
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  // and so is probably the stack pointer for most machines.  On Intel
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  // it is ESP.  On the PowerPC it is R1.  On Sparc it is SP.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  OptoReg::Name  c_frame_pointer() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  static RegMask c_frame_ptr_mask;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  // !!!!! Special stuff for building ScopeDescs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  virtual int      regnum_to_fpu_offset(int regnum);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  // Is this branch offset small enough to be addressed by a short branch?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  bool is_short_branch_offset(int offset);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  // Optional scaling for the parameter to the ClearArray/CopyArray node.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  static const bool init_array_count_is_in_bytes;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  // Threshold small size (in bytes) for a ClearArray/CopyArray node.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  // Anything this size or smaller may get converted to discrete scalar stores.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  static const int init_array_short_size;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // Should the Matcher clone shifts on addressing modes, expecting them to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // be subsumed into complex addressing expressions or compute them into
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  // registers?  True for Intel but false for most RISCs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  static const bool clone_shift_expressions;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // Is it better to copy float constants, or load them directly from memory?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  // Intel can load a float constant from a direct address, requiring no
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  // extra registers.  Most RISCs will have to materialize an address into a
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // register first, so they may as well materialize the constant immediately.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  static const bool rematerialize_float_constants;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  // If CPU can load and store mis-aligned doubles directly then no fixup is
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  // needed.  Else we split the double into 2 integer pieces and move it
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  // piece-by-piece.  Only happens when passing doubles into C code or when
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  // calling i2c adapters as the Java calling convention forces doubles to be
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  // aligned.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  static const bool misaligned_doubles_ok;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  // Perform a platform dependent implicit null fixup.  This is needed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  // on windows95 to take care of some unusual register constraints.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  void pd_implicit_null_fixup(MachNode *load, uint idx);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  // Advertise here if the CPU requires explicit rounding operations
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  // to implement the UseStrictFP mode.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  static const bool strict_fp_requires_explicit_rounding;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  // Do floats take an entire double register or just half?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  static const bool float_in_double;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  // Do ints take an entire long register or just half?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  static const bool int_in_long;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  // This routine is run whenever a graph fails to match.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  // If it returns, the compiler should bailout to interpreter without error.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  // In non-product mode, SoftMatchFailure is false to detect non-canonical
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  // graphs.  Print a message and exit.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  static void soft_match_failure() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
    if( SoftMatchFailure ) return;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
    else { fatal("SoftMatchFailure is not allowed except in product"); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  // Used by the DFA in dfa_sparc.cpp.  Check for a prior FastLock
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  // acting as an Acquire and thus we don't need an Acquire here.  We
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  // retain the Node to act as a compiler ordering barrier.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  static bool prior_fast_lock( const Node *acq );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  // Used by the DFA in dfa_sparc.cpp.  Check for a following
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  // FastUnLock acting as a Release and thus we don't need a Release
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  // here.  We retain the Node to act as a compiler ordering barrier.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  static bool post_fast_unlock( const Node *rel );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  // Check for a following volatile memory barrier without an
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  // intervening load and thus we don't need a barrier here.  We
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  // retain the Node to act as a compiler ordering barrier.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  static bool post_store_load_barrier(const Node* mb);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
#ifdef ASSERT
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  void dump_old2new_map();      // machine-independent to machine-dependent
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
#endif
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
};