hotspot/src/share/vm/adlc/formsopt.hpp
author roland
Tue, 22 Nov 2011 09:45:57 +0100
changeset 11197 158eecd6b330
parent 7397 5b173b4ca846
child 30202 6f5c48bd9b82
permissions -rw-r--r--
7090968: Allow adlc register class to depend on runtime conditions Summary: allow reg_class definition as a function. Reviewed-by: kvn, never
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
     2
 * Copyright (c) 1998, 2010, 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: 2129
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2129
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: 2129
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_ADLC_FORMSOPT_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_ADLC_FORMSOPT_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// FORMSOPT.HPP - ADL Parser Target Specific Optimization Forms Classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
// Class List
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class Form;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class InstructForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class OperandForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class OpClassForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class AttributeForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class RegisterForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class PipelineForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class SourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class EncodeForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class Component;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class Constraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class Predicate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class MatchRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class Attribute;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class Effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class ExpandRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class RewriteRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class ConstructRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class FormatRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class Peephole;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class PeepMatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class PeepConstraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class EncClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class Interface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
class RegInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class ConstInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class MemInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class CondInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
class Opcode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
class InsEncode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class RegDef;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class RegClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class AllocClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
class ResourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class PipeClassForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class PipeClassOperandForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class PipeClassResourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class PeepMatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
class PeepConstraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
class PeepReplace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class MatchList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class ArchDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
//==============================Register Allocation============================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
//------------------------------RegisterForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
class RegisterForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  AllocClass *_current_ac;         // State used by iter_RegDefs()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  NameList    _rdefs;              // List of register definition names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  Dict        _regDef;             // map register name to RegDef*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  NameList    _rclasses;           // List of register class names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  Dict        _regClass;           // map register class name to RegClass*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  NameList    _aclasses;           // List of allocation class names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  Dict        _allocClass;         // Dictionary of allocation classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  static int  _reg_ctr;         // Register counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  static int  RegMask_Size();   // Compute RegMask size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  RegisterForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  ~RegisterForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  void        addRegDef(char *regName, char *callingConv, char *c_conv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
                        char * idealtype, char *encoding, char* concreteName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  RegClass   *addRegClass(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
  AllocClass *addAllocClass(char *allocName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  void        addSpillRegClass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  // Provide iteration over all register definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  // in the order used by the register allocator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  void        reset_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  RegDef     *iter_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  RegDef     *getRegDef  (const char *regName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  RegClass   *getRegClass(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Return register mask, compressed chunk and register #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  uint       reg_mask(char *register_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // Check that register classes are compatible with chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  bool       verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
//------------------------------RegDef-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
class RegDef : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  const char *_regname;            // ADLC (Opto) Register name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  const char *_callconv;           // Calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  const char *_c_conv;             // Native calling convention, 'C'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  const char *_idealtype;          // Ideal Type for register save/restore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  const char *_concrete;           // concrete register name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  const char *_register_encode;   // The register encoding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  // The chunk and register mask bits define info for register allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  uint32      _register_num;      // Which register am I
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  RegDef(char  *regname, char *callconv, char *c_conv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
         char *idealtype, char *encoding, char *concrete);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  ~RegDef();                       // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  // Interface to define/redefine the register number
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  void     set_register_num(uint32 new_register_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // Bit pattern used for generating machine code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  const char *register_encode()   const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Register number used in machine-independent code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  uint32   register_num()      const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
//------------------------------RegClass---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
class RegClass : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  const char *_classid;         // Name of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
  NameList    _regDefs;         // List of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  Dict        _regDef;          // Dictionary of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  bool        _stack_or_reg;    // Allowed on any stack slot
11197
158eecd6b330 7090968: Allow adlc register class to depend on runtime conditions
roland
parents: 7397
diff changeset
   164
  char*       _user_defined;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
  RegClass(const char *classid);// Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  void addReg(RegDef *regDef);  // Add a register to this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  uint size() const;            // Number of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  int regs_in_word( int wordnum, bool stack_also );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  const RegDef *get_RegDef(const char *regDef_name) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  // Returns the lowest numbered register in the mask.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
  const RegDef* find_first_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Iteration support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  void          reset();        // Reset the following two iterators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  RegDef       *RegDef_iter();  // which move jointly,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  const char   *rd_name_iter(); // invoking either advances both.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
  void dump();                  // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  void output(FILE *fp);        // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
//------------------------------AllocClass-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
class AllocClass : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  char    *_classid;            // Name of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  NameList _regDefs;            // List of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  Dict     _regDef;             // Dictionary of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  AllocClass(char *classid);    // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
  void addReg(RegDef *regDef);  // Add a register to this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  uint size() {return _regDef.Size();} // Number of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
  void dump();                  // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  void output(FILE *fp);        // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
//==============================Frame Handling================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
//------------------------------FrameForm-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
class FrameForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  bool  _direction;                // Direction of stack growth
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  char *_sync_stack_slots;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  char *_inline_cache_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  char *_interpreter_method_oop_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  char *_interpreter_frame_pointer_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  char *_cisc_spilling_operand_name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  char *_frame_pointer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  char *_c_frame_pointer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  char *_alignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  bool  _return_addr_loc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  bool  _c_return_addr_loc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  char *_return_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  char *_c_return_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  char *_in_preserve_slots;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  char *_varargs_C_out_slots_killed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  char *_calling_convention;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  char *_c_calling_convention;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  char *_return_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  char *_c_return_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  FrameForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  ~FrameForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
//==============================Scheduling=====================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
//------------------------------PipelineForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
class PipelineForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
  NameList   _reslist;            // List of pipeline resources
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  FormDict   _resdict;            // Resource Name -> ResourceForm mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  int        _rescount;           // Number of resources (ignores OR cases)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  int        _maxcycleused;       // Largest cycle used relative to beginning of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  NameList   _stages;             // List of pipeline stages on architecture
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  int        _stagecnt;           // Number of stages listed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  NameList   _classlist;          // List of pipeline classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  FormDict   _classdict;          // Class Name -> PipeClassForm mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  int        _classcnt;           // Number of classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  NameList   _noplist;            // List of NOP instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  int        _nopcnt;             // Number of nop instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  bool       _variableSizeInstrs; // Indicates if this architecture has variable sized instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  bool       _branchHasDelaySlot; // Indicates that branches have delay slot instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  int        _maxInstrsPerBundle; // Indicates the maximum number of instructions for ILP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  int        _maxBundlesPerCycle; // Indicates the maximum number of bundles for ILP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  int        _instrUnitSize;      // The minimum instruction unit size, in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
  int        _bundleUnitSize;     // The bundle unit size, in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  int        _instrFetchUnitSize; // The size of the I-fetch unit, in bytes [must be power of 2]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  int        _instrFetchUnits;    // The number of I-fetch units processed per cycle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  PipelineForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  ~PipelineForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
//------------------------------ResourceForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
class ResourceForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  unsigned mask() const { return _resmask; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
  unsigned _resmask;         // Resource Mask (OR of resource specifier bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
  // Virtual Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  virtual ResourceForm  *is_resource()    const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
  ResourceForm(unsigned resmask); // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  ~ResourceForm();                // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
//------------------------------PipeClassOperandForm-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
class PipeClassOperandForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
  const char *_stage;             // Name of Stage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  unsigned _iswrite;              // Read or Write
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  unsigned _more_instrs;          // Additional Instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  PipeClassOperandForm(const char *stage, unsigned iswrite, unsigned more_instrs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  : _stage(stage)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  , _iswrite(iswrite)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  , _more_instrs(more_instrs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
 {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  ~PipeClassOperandForm() {};     // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  bool isWrite() const { return _iswrite != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
//------------------------------PipeClassResourceForm--------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
class PipeClassResourceForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  const char *_resource;          // Resource
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  const char *_stage;             // Stage the resource is used in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  int         _cycles;            // Number of cycles the resource is used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  PipeClassResourceForm(const char *resource, const char *stage, int cycles)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
                                  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
    : _resource(resource)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
    , _stage(stage)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
    , _cycles(cycles)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
    {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  ~PipeClassResourceForm() {};    // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
//------------------------------PipeClassForm----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
class PipeClassForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  const char       *_ident;             // Name of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  int               _num;               // Used in name of MachNode subclass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  NameList          _parameters;        // Locally defined names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
  FormDict          _localNames;        // Table of operands & their types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  FormDict          _localUsage;        // Table of operand usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
  FormList          _resUsage;          // List of resource usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  NameList          _instructs;         // List of instructions and machine nodes that use this pipeline class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  bool              _has_fixed_latency; // Always takes this number of cycles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
  int               _fixed_latency;     // Always takes this number of cycles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
  int               _instruction_count; // Number of instructions in first bundle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
  bool              _has_multiple_bundles;  // Indicates if 1 or multiple bundles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
  bool              _has_branch_delay_slot; // Has branch delay slot as last instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  bool              _force_serialization;   // This node serializes relative to surrounding nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  bool              _may_have_no_code;      // This node may generate no code based on register allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // Virtual Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  virtual PipeClassForm  *is_pipeclass()    const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  PipeClassForm(const char *id, int num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
                                  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  ~PipeClassForm();               // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  bool hasFixedLatency() { return _has_fixed_latency; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
  int fixedLatency() { return _fixed_latency; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  void setFixedLatency(int fixed_latency) { _has_fixed_latency = 1; _fixed_latency = fixed_latency; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  void setInstructionCount(int i)    { _instruction_count = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  void setMultipleBundles(bool b)    { _has_multiple_bundles = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  void setBranchDelay(bool s)        { _has_branch_delay_slot = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  void setForceSerialization(bool s) { _force_serialization = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  void setMayHaveNoCode(bool s)      { _may_have_no_code = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  int  InstructionCount()   const { return _instruction_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  bool hasMultipleBundles() const { return _has_multiple_bundles; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
  bool hasBranchDelay()     const { return _has_branch_delay_slot; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  bool forceSerialization() const { return _force_serialization; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  bool mayHaveNoCode()      const { return _may_have_no_code; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
//==============================Peephole Optimization==========================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
//------------------------------Peephole---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
class Peephole : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  static int      _peephole_counter;// Incremented by each peephole rule parsed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  int             _peephole_number;// Remember my order in architecture description
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  PeepMatch      *_match;          // Instruction pattern to match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  PeepConstraint *_constraint;     // List of additional constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
  PeepReplace    *_replace;        // Instruction pattern to substitute in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
  Peephole *_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  Peephole();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  ~Peephole();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
  // Append a peephole rule with the same root instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  void append_peephole(Peephole *next_peephole);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  // Store the components of this peephole rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
  void add_match(PeepMatch *only_one_match);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  void append_constraint(PeepConstraint *next_constraint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  void add_replace(PeepReplace *only_one_replacement);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  // Access the components of this peephole rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
  int             peephole_number() { return _peephole_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  PeepMatch      *match()       { return _match; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  PeepConstraint *constraints() { return _constraint; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  PeepReplace    *replacement() { return _replace; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  Peephole       *next()        { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
class PeepMatch : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  char *_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
  // NameList  _depth;                // Depth of this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  NameList  _parent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
  NameList  _position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  NameList  _instrs;               // List of instructions in match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  NameList  _input;                // input position in parent's instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  int       _max_position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  PeepMatch(char *rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
  ~PeepMatch();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Insert info into the match-rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  void  add_instruction(int parent, int position, const char *name, int input);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  // Access info about instructions in the peep-match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  int   max_position();
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   464
  const char *instruction_name(int position);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  // Iterate through all info on matched instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  void  reset();
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   467
  void  next_instruction(int &parent, int &position, const char* &name, int &input);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
  // 'true' if current position in iteration is a placeholder, not matched.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
  bool  is_placeholder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
class PeepConstraint : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  PeepConstraint *_next;           // Additional constraints ANDed together
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
public:
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   481
  const int   _left_inst;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   482
  const char* _left_op;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   483
  const char* _relation;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   484
  const int   _right_inst;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   485
  const char* _right_op;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  // Public Methods
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   489
  PeepConstraint(int left_inst,  char* left_op, char* relation,
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   490
                 int right_inst, char* right_op);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  ~PeepConstraint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  // Check if constraints use instruction at position
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   494
  bool constrains_instruction(int position);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  // Add another constraint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  void append(PeepConstraint *next_peep_constraint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  // Access the next constraint in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  PeepConstraint *next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
class PeepReplace : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  char *_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  NameList _instruction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
  NameList _operand_inst_num;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  NameList _operand_op_name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  PeepReplace(char *rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  ~PeepReplace();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  // Add contents of peepreplace
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  void  add_instruction(char *root);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  void  add_operand( int inst_num, char *inst_operand );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  // Access contents of peepreplace
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  void  reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  void  next_instruction(const char * &root);
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   526
  void  next_operand(int &inst_num, const char * &inst_operand );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
  // Utilities
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
class PeepChild : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  const int   _inst_num;         // Number of instruction (-1 if only named)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  const char *_inst_op;          // Instruction's operand, NULL if number == -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  const char *_inst_name;        // Name of the instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
  PeepChild(char *inst_name)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
    : _inst_num(-1), _inst_op(NULL), _inst_name(inst_name) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  PeepChild(int inst_num, char *inst_op, char *inst_name)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
    : _inst_num(inst_num), _inst_op(inst_op), _inst_name(inst_name) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  ~PeepChild();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  bool  use_leaf_operand()        { return _inst_num != -1; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  bool  generate_an_instruction() { return _inst_num == -1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   553
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   554
#endif // SHARE_VM_ADLC_FORMSOPT_HPP