src/hotspot/share/adlc/formsopt.hpp
author coleenp
Thu, 10 Jan 2019 15:13:51 -0500
changeset 53244 9807daeb47c4
parent 47216 71c04702a3d5
child 53841 48b50573dee4
permissions -rw-r--r--
8216167: Update include guards to reflect correct directories Summary: Use script and some manual fixup to fix directores names in include guards. Reviewed-by: lfoltan, eosterlund, kbarrett
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
     2
 * Copyright (c) 1998, 2019, 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
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    25
#ifndef SHARE_ADLC_FORMSOPT_HPP
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
    26
#define SHARE_ADLC_FORMSOPT_HPP
7397
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;
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
    63
class CodeSnippetRegClass;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
    64
class ConditionalRegClass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class AllocClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class ResourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class PipeClassForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class PipeClassOperandForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
class PipeClassResourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
class PeepMatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
class PeepConstraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class PeepReplace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
class MatchList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
class ArchDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
//==============================Register Allocation============================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
//------------------------------RegisterForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
class RegisterForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  AllocClass *_current_ac;         // State used by iter_RegDefs()
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  NameList    _rdefs;              // List of register definition names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  Dict        _regDef;             // map register name to RegDef*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  NameList    _rclasses;           // List of register class names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  Dict        _regClass;           // map register class name to RegClass*
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  NameList    _aclasses;           // List of allocation class names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  Dict        _allocClass;         // Dictionary of allocation classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  static int  _reg_ctr;         // Register counter
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  static int  RegMask_Size();   // Compute RegMask size
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  RegisterForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  ~RegisterForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void        addRegDef(char *regName, char *callingConv, char *c_conv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
                        char * idealtype, char *encoding, char* concreteName);
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   103
  template<typename T> T* addRegClass(const char* className);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   104
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  AllocClass *addAllocClass(char *allocName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
  void        addSpillRegClass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // Provide iteration over all register definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  // in the order used by the register allocator
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  void        reset_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  RegDef     *iter_RegDefs();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  RegDef     *getRegDef  (const char *regName);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  RegClass   *getRegClass(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  // Return register mask, compressed chunk and register #
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  uint       reg_mask(char *register_class);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  // Check that register classes are compatible with chunks
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  bool       verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
//------------------------------RegDef-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
class RegDef : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  const char *_regname;            // ADLC (Opto) Register name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  const char *_callconv;           // Calling convention
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
  const char *_c_conv;             // Native calling convention, 'C'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  const char *_idealtype;          // Ideal Type for register save/restore
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  const char *_concrete;           // concrete register name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  const char *_register_encode;   // The register encoding
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  // The chunk and register mask bits define info for register allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  uint32      _register_num;      // Which register am I
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  RegDef(char  *regname, char *callconv, char *c_conv,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
         char *idealtype, char *encoding, char *concrete);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  ~RegDef();                       // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  // Interface to define/redefine the register number
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  void     set_register_num(uint32 new_register_num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  // Bit pattern used for generating machine code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  const char *register_encode()   const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  // Register number used in machine-independent code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  uint32   register_num()      const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
//------------------------------RegClass---------------------------------------
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   160
// Generic register class. This register class is the internal representation
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   161
// for the following .ad file format:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   162
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   163
//  reg_class ptr(RAX, RBX, ...);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   164
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   165
// where ptr is the name of the register class, RAX and RBX are registers.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   166
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   167
// This register class allows registers to be spilled onto the stack. Spilling
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   168
// is allowed is field _stack_or_reg is true.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
class RegClass : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  const char *_classid;         // Name of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  NameList    _regDefs;         // List of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  Dict        _regDef;          // Dictionary of registers in class
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   175
protected:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  bool        _stack_or_reg;    // Allowed on any stack slot
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   178
public:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  RegClass(const char *classid);// Constructor
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   181
  virtual ~RegClass();
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  void addReg(RegDef *regDef);  // Add a register to this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  uint size() const;            // Number of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  int regs_in_word( int wordnum, bool stack_also );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
  const RegDef *get_RegDef(const char *regDef_name) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  // Returns the lowest numbered register in the mask.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  const RegDef* find_first_elem();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Iteration support
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void          reset();        // Reset the following two iterators
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
  RegDef       *RegDef_iter();  // which move jointly,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  const char   *rd_name_iter(); // invoking either advances both.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
  void dump();                  // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  void output(FILE *fp);        // Write info to output files
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   200
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   201
  virtual bool has_stack_version() {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   202
    return _stack_or_reg;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   203
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   204
  virtual void set_stack_version(bool flag) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   205
    _stack_or_reg = flag;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   206
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   207
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   208
  virtual void declare_register_masks(FILE* fp);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   209
  virtual void build_register_masks(FILE* fp);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   210
};
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   211
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   212
//------------------------------CodeSnippetRegClass----------------------------
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   213
// Register class that has an user-defined C++ code snippet attached to it
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   214
// to determine at runtime which register class to use. This register class is
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   215
// the internal representation for the following .ad file format:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   216
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   217
//  reg_class actual_dflt_reg %{
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   218
//      if (VM_Version::has_vfp3_32()) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   219
//          return DFLT_REG_mask();
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   220
//      } else {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   221
//          return DFLT_LOW_REG_mask();
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   222
//      }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   223
//  %}
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   224
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   225
// where DFLT_REG_mask() and DFLT_LOW_REG_mask() are the internal names of the
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   226
// masks of register classes dflt_reg and dflt_low_reg.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   227
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   228
// The attached code snippet can select also between more than two register classes.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   229
// This register class can be, however, used only if the register class is not
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   230
// cisc-spillable (i.e., the registers of this class are not allowed on the stack,
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   231
// which is equivalent with _stack_or_reg being false).
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   232
class CodeSnippetRegClass : public RegClass {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   233
protected:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   234
  char* _code_snippet;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   235
public:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   236
  CodeSnippetRegClass(const char* classid);// Constructor
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   237
  ~CodeSnippetRegClass();
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   238
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   239
  void set_code_snippet(char* code) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   240
    _code_snippet = code;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   241
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   242
  char* code_snippet() {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   243
    return _code_snippet;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   244
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   245
  void set_stack_version(bool flag) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   246
    assert(false, "User defined register classes are not allowed to spill to the stack.");
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   247
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   248
  void declare_register_masks(FILE* fp);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   249
  void build_register_masks(FILE* fp) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   250
    // We do not need to generate register masks because we select at runtime
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   251
    // between register masks generated for other register classes.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   252
    return;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   253
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   254
};
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   255
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   256
//------------------------------ConditionalRegClass----------------------------
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   257
// Register class that has two register classes and a runtime condition attached
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   258
// to it. The condition is evaluated at runtime and either one of the register
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   259
// attached register classes is selected. This register class is the internal
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   260
// representation for the following .ad format:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   261
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   262
//  reg_class_dynamic actual_dflt_reg(dflt_reg, low_reg,
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   263
//                                    %{ VM_Version::has_vfp3_32() }%
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   264
//                                    );
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   265
//
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   266
// This example is equivalent to the example used with the CodeSnippetRegClass
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   267
// register class. A ConditionalRegClass works also if a register class is cisc-spillable
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   268
// (i.e., _stack_or_reg is true), but if can select only between two register classes.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   269
class ConditionalRegClass : public RegClass {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   270
protected:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   271
  // reference to condition code
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   272
  char* _condition_code;  // C++ condition code to dynamically determine which register class to use.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   273
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   274
                          // Example syntax (equivalent to previous example):
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   275
                          //
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   276
                          //  reg_class actual_dflt_reg(dflt_reg, low_reg,
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   277
                          //                            %{ VM_Version::has_vfp3_32() }%
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   278
                          //                            );
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   279
  // reference to conditional register classes
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   280
  RegClass* _rclasses[2]; // 0 is the register class selected if the condition code returns true
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   281
                          // 1 is the register class selected if the condition code returns false
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   282
public:
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   283
  ConditionalRegClass(const char* classid);// Constructor
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   284
  ~ConditionalRegClass();
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   285
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   286
  virtual void set_stack_version(bool flag) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   287
    RegClass::set_stack_version(flag);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   288
    assert((_rclasses[0] != NULL), "Register class NULL for condition code == true");
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   289
    assert((_rclasses[1] != NULL), "Register class NULL for condition code == false");
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   290
    _rclasses[0]->set_stack_version(flag);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   291
    _rclasses[1]->set_stack_version(flag);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   292
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   293
  void declare_register_masks(FILE* fp);
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   294
  void build_register_masks(FILE* fp) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   295
    // We do not need to generate register masks because we select at runtime
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   296
    // between register masks generated for other register classes.
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   297
    return;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   298
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   299
  void set_rclass_at_index(int index, RegClass* rclass) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   300
    assert((0 <= index && index < 2), "Condition code can select only between two register classes");
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   301
    _rclasses[index] = rclass;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   302
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   303
  void set_condition_code(char* code) {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   304
    _condition_code = code;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   305
  }
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   306
  char* condition_code() {
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   307
    return _condition_code;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 11197
diff changeset
   308
  }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
//------------------------------AllocClass-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
class AllocClass : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  char    *_classid;            // Name of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  NameList _regDefs;            // List of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  Dict     _regDef;             // Dictionary of registers in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  AllocClass(char *classid);    // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
  void addReg(RegDef *regDef);  // Add a register to this class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
  uint size() {return _regDef.Size();} // Number of registers in class
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
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
//==============================Frame Handling================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
//------------------------------FrameForm-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
class FrameForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  bool  _direction;                // Direction of stack growth
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  char *_sync_stack_slots;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
  char *_inline_cache_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  char *_interpreter_method_oop_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  char *_interpreter_frame_pointer_reg;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  char *_cisc_spilling_operand_name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  char *_frame_pointer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  char *_c_frame_pointer;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  char *_alignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
  bool  _return_addr_loc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  bool  _c_return_addr_loc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  char *_return_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  char *_c_return_addr;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
  char *_in_preserve_slots;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
  char *_varargs_C_out_slots_killed;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
  char *_calling_convention;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
  char *_c_calling_convention;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
  char *_return_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
  char *_c_return_value;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  FrameForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
  ~FrameForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
//==============================Scheduling=====================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
//------------------------------PipelineForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
class PipelineForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
  NameList   _reslist;            // List of pipeline resources
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
  FormDict   _resdict;            // Resource Name -> ResourceForm mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  int        _rescount;           // Number of resources (ignores OR cases)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  int        _maxcycleused;       // Largest cycle used relative to beginning of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  NameList   _stages;             // List of pipeline stages on architecture
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  int        _stagecnt;           // Number of stages listed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  NameList   _classlist;          // List of pipeline classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
  FormDict   _classdict;          // Class Name -> PipeClassForm mapping
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
  int        _classcnt;           // Number of classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
  NameList   _noplist;            // List of NOP instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  int        _nopcnt;             // Number of nop instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  bool       _variableSizeInstrs; // Indicates if this architecture has variable sized instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  bool       _branchHasDelaySlot; // Indicates that branches have delay slot instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  int        _maxInstrsPerBundle; // Indicates the maximum number of instructions for ILP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
  int        _maxBundlesPerCycle; // Indicates the maximum number of bundles for ILP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  int        _instrUnitSize;      // The minimum instruction unit size, in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
  int        _bundleUnitSize;     // The bundle unit size, in bytes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  int        _instrFetchUnitSize; // The size of the I-fetch unit, in bytes [must be power of 2]
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  int        _instrFetchUnits;    // The number of I-fetch units processed per cycle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   400
  PipelineForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
  ~PipelineForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
//------------------------------ResourceForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
class ResourceForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  unsigned mask() const { return _resmask; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  unsigned _resmask;         // Resource Mask (OR of resource specifier bits)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   415
489c9b5090e2 Initial load
duke
parents:
diff changeset
   416
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   417
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  // Virtual Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  virtual ResourceForm  *is_resource()    const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  ResourceForm(unsigned resmask); // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  ~ResourceForm();                // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
//------------------------------PipeClassOperandForm-----------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
class PipeClassOperandForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  const char *_stage;             // Name of Stage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  unsigned _iswrite;              // Read or Write
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  unsigned _more_instrs;          // Additional Instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
  PipeClassOperandForm(const char *stage, unsigned iswrite, unsigned more_instrs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  : _stage(stage)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  , _iswrite(iswrite)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
  , _more_instrs(more_instrs)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
 {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
  ~PipeClassOperandForm() {};     // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
  bool isWrite() const { return _iswrite != 0; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
//------------------------------PipeClassResourceForm--------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
class PipeClassResourceForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
  const char *_resource;          // Resource
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  const char *_stage;             // Stage the resource is used in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  int         _cycles;            // Number of cycles the resource is used
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
  PipeClassResourceForm(const char *resource, const char *stage, int cycles)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
                                  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
    : _resource(resource)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
    , _stage(stage)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
    , _cycles(cycles)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
    {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
  ~PipeClassResourceForm() {};    // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
//------------------------------PipeClassForm----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
class PipeClassForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  const char       *_ident;             // Name of class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  int               _num;               // Used in name of MachNode subclass
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
  NameList          _parameters;        // Locally defined names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  FormDict          _localNames;        // Table of operands & their types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  FormDict          _localUsage;        // Table of operand usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
  FormList          _resUsage;          // List of resource usage
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
  NameList          _instructs;         // List of instructions and machine nodes that use this pipeline class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
  bool              _has_fixed_latency; // Always takes this number of cycles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
  int               _fixed_latency;     // Always takes this number of cycles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
  int               _instruction_count; // Number of instructions in first bundle
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
  bool              _has_multiple_bundles;  // Indicates if 1 or multiple bundles
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
  bool              _has_branch_delay_slot; // Has branch delay slot as last instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  bool              _force_serialization;   // This node serializes relative to surrounding nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  bool              _may_have_no_code;      // This node may generate no code based on register allocation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  // Virtual Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  virtual PipeClassForm  *is_pipeclass()    const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  PipeClassForm(const char *id, int num);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
                                  // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  ~PipeClassForm();               // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  bool hasFixedLatency() { return _has_fixed_latency; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
  int fixedLatency() { return _fixed_latency; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
  void setFixedLatency(int fixed_latency) { _has_fixed_latency = 1; _fixed_latency = fixed_latency; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
  void setInstructionCount(int i)    { _instruction_count = i; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
  void setMultipleBundles(bool b)    { _has_multiple_bundles = b; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
  void setBranchDelay(bool s)        { _has_branch_delay_slot = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  void setForceSerialization(bool s) { _force_serialization = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  void setMayHaveNoCode(bool s)      { _may_have_no_code = s; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
  int  InstructionCount()   const { return _instruction_count; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  bool hasMultipleBundles() const { return _has_multiple_bundles; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  bool hasBranchDelay()     const { return _has_branch_delay_slot; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  bool forceSerialization() const { return _force_serialization; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
  bool mayHaveNoCode()      const { return _may_have_no_code; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
//==============================Peephole Optimization==========================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
//------------------------------Peephole---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
class Peephole : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  static int      _peephole_counter;// Incremented by each peephole rule parsed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
  int             _peephole_number;// Remember my order in architecture description
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  PeepMatch      *_match;          // Instruction pattern to match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  PeepConstraint *_constraint;     // List of additional constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  PeepReplace    *_replace;        // Instruction pattern to substitute in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
  Peephole *_next;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  Peephole();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
  ~Peephole();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  // Append a peephole rule with the same root instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  void append_peephole(Peephole *next_peephole);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  // Store the components of this peephole rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  void add_match(PeepMatch *only_one_match);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  void append_constraint(PeepConstraint *next_constraint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  void add_replace(PeepReplace *only_one_replacement);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  // Access the components of this peephole rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  int             peephole_number() { return _peephole_number; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  PeepMatch      *match()       { return _match; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
  PeepConstraint *constraints() { return _constraint; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  PeepReplace    *replacement() { return _replace; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
  Peephole       *next()        { return _next; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
class PeepMatch : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  char *_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  // NameList  _depth;                // Depth of this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  NameList  _parent;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
  NameList  _position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  NameList  _instrs;               // List of instructions in match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  NameList  _input;                // input position in parent's instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  int       _max_position;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  PeepMatch(char *rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  ~PeepMatch();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  // Insert info into the match-rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
  void  add_instruction(int parent, int position, const char *name, int input);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  // Access info about instructions in the peep-match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
  int   max_position();
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   587
  const char *instruction_name(int position);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  // Iterate through all info on matched instructions
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
  void  reset();
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   590
  void  next_instruction(int &parent, int &position, const char* &name, int &input);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  // 'true' if current position in iteration is a placeholder, not matched.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
  bool  is_placeholder();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
class PeepConstraint : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  PeepConstraint *_next;           // Additional constraints ANDed together
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
public:
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   604
  const int   _left_inst;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   605
  const char* _left_op;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   606
  const char* _relation;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   607
  const int   _right_inst;
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   608
  const char* _right_op;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
  // Public Methods
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   612
  PeepConstraint(int left_inst,  char* left_op, char* relation,
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   613
                 int right_inst, char* right_op);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
  ~PeepConstraint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  // Check if constraints use instruction at position
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   617
  bool constrains_instruction(int position);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
  // Add another constraint
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  void append(PeepConstraint *next_peep_constraint);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  // Access the next constraint in the list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
  PeepConstraint *next();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
class PeepReplace : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  char *_rule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  NameList _instruction;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
  NameList _operand_inst_num;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  NameList _operand_op_name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
  PeepReplace(char *rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  ~PeepReplace();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
  // Add contents of peepreplace
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  void  add_instruction(char *root);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  void  add_operand( int inst_num, char *inst_operand );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  // Access contents of peepreplace
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  void  reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
  void  next_instruction(const char * &root);
2129
e810a33b5c67 6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents: 1
diff changeset
   649
  void  next_operand(int &inst_num, const char * &inst_operand );
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  // Utilities
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
class PeepChild : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  const int   _inst_num;         // Number of instruction (-1 if only named)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
  const char *_inst_op;          // Instruction's operand, NULL if number == -1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  const char *_inst_name;        // Name of the instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  PeepChild(char *inst_name)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
    : _inst_num(-1), _inst_op(NULL), _inst_name(inst_name) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
  PeepChild(int inst_num, char *inst_op, char *inst_name)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
    : _inst_num(inst_num), _inst_op(inst_op), _inst_name(inst_name) {};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
  ~PeepChild();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
  bool  use_leaf_operand()        { return _inst_num != -1; };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
  bool  generate_an_instruction() { return _inst_num == -1; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   676
53244
9807daeb47c4 8216167: Update include guards to reflect correct directories
coleenp
parents: 47216
diff changeset
   677
#endif // SHARE_ADLC_FORMSOPT_HPP