hotspot/src/share/vm/adlc/formssel.hpp
author xdono
Mon, 15 Dec 2008 16:55:11 -0800
changeset 1623 a0dd9009e992
parent 1495 128fe18951ed
child 2125 592f115cc6b4
permissions -rw-r--r--
6785258: Update copyright year Summary: Update copyright for files that have been modified starting July 2008 to Dec 2008 Reviewed-by: katleman, ohair, tbell
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
1623
a0dd9009e992 6785258: Update copyright year
xdono
parents: 1495
diff changeset
     2
 * Copyright 1998-2008 Sun Microsystems, Inc.  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
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    19
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    20
 * CA 95054 USA or visit www.sun.com if you need additional information or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    21
 * have any questions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
489c9b5090e2 Initial load
duke
parents:
diff changeset
    25
// FORMSSEL.HPP - ADL Parser Instruction Selection Forms Classes
489c9b5090e2 Initial load
duke
parents:
diff changeset
    26
489c9b5090e2 Initial load
duke
parents:
diff changeset
    27
// Class List
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
class Form;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
class InstructForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
class MachNodeForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
class OperandForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class OpClassForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
class AttributeForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class RegisterForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class PipelineForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class SourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class EncodeForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class Component;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class Constraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class Predicate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class MatchRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
class Attribute;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class Effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class ExpandRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class RewriteRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class ConstructRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class FormatRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class Peephole;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class EncClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class Interface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class RegInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class ConstInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
class MemInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class CondInterface;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
class Opcode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    56
class InsEncode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    57
class RegDef;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class RegClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
class AllocClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
class ResourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    61
class PipeDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    62
class PipeClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    63
class PeepMatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
class PeepConstraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class PeepReplace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class MatchList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
class ArchDesc;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
//==============================Instructions===================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//------------------------------InstructForm-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class InstructForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  bool          _ideal_only;       // Not a user-defined instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  // Members used for tracking CISC-spilling
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  uint          _cisc_spill_operand;// Which operand may cisc-spill
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  void           set_cisc_spill_operand(uint op_index) { _cisc_spill_operand = op_index; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
  bool          _is_cisc_alternate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  InstructForm  *_cisc_spill_alternate;// cisc possible replacement
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  const char    *_cisc_reg_mask_name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  InstructForm  *_short_branch_form;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool           _is_short_branch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  uint           _alignment;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  const char    *_ident;           // Name of this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  NameList       _parameters;      // Locally defined names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  FormDict       _localNames;      // Table of operands & their types
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  MatchRule     *_matrule;         // Matching rule for this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  Opcode        *_opcode;          // Encoding of the opcode for instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  char          *_size;            // Size of instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  InsEncode     *_insencode;       // Encoding class instruction belongs to
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  Attribute     *_attribs;         // List of Attribute rules
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  Predicate     *_predicate;       // Predicate test for this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  FormDict       _effects;         // Dictionary of effect rules
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  ExpandRule    *_exprule;         // Expand rule for this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  RewriteRule   *_rewrule;         // Rewrite rule for this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
    99
  FormatRule    *_format;          // Format for assembly generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  Peephole      *_peephole;        // List of peephole rules for instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  const char    *_ins_pipe;        // Instruction Scheduline description class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  uint          *_uniq_idx;        // Indexes of unique operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  uint           _num_uniq;        // Number  of unique operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  ComponentList  _components;      // List of Components matches MachNode's
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
                                   // operand structure
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  InstructForm(const char *id, bool ideal_only = false);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  InstructForm(const char *id, InstructForm *instr, MatchRule *rule);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
  ~InstructForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  // Dynamic type check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  virtual InstructForm *is_instruction() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  virtual bool        ideal_only() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  // This instruction sets a result
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  virtual bool        sets_result() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  // This instruction needs projections for additional DEFs or KILLs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  virtual bool        needs_projections();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  // This instruction needs extra nodes for temporary inputs
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  virtual bool        has_temps();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  // This instruction defines or kills more than one object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  virtual uint        num_defs_or_kills();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
  // This instruction has an expand rule?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  virtual bool        expands() const ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  // Return this instruction's first peephole rule, or NULL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  virtual Peephole   *peepholes() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   130
  // Add a peephole rule to this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  virtual void        append_peephole(Peephole *peep);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  virtual bool        is_pinned(FormDict &globals); // should be pinned inside block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  virtual bool        is_projection(FormDict &globals); // node requires projection
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
  virtual bool        is_parm(FormDict &globals); // node matches ideal 'Parm'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // ideal opcode enumeration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  virtual const char *ideal_Opcode(FormDict &globals)  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  virtual int         is_expensive() const;     // node matches ideal 'CosD'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  virtual int         is_empty_encoding() const; // _size=0 and/or _insencode empty
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
  virtual int         is_tls_instruction() const; // tlsLoadP rule or ideal ThreadLocal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  virtual int         is_ideal_copy() const;    // node matches ideal 'Copy*'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  virtual bool        is_ideal_unlock() const;  // node matches ideal 'Unlock'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  virtual bool        is_ideal_call_leaf() const; // node matches ideal 'CallLeaf'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  virtual bool        is_ideal_if()   const;    // node matches ideal 'If'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
  virtual bool        is_ideal_fastlock() const; // node matches 'FastLock'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  virtual bool        is_ideal_membar() const;  // node matches ideal 'MemBarXXX'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  virtual bool        is_ideal_loadPC() const;  // node matches ideal 'LoadPC'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
  virtual bool        is_ideal_box() const;     // node matches ideal 'Box'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  virtual bool        is_ideal_goto() const;    // node matches ideal 'Goto'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  virtual bool        is_ideal_branch() const;  // "" 'If' | 'Goto' | 'LoopEnd' | 'Jump'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  virtual bool        is_ideal_jump() const;    // node matches ideal 'Jump'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  virtual bool        is_ideal_return() const;  // node matches ideal 'Return'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  virtual bool        is_ideal_halt() const;    // node matches ideal 'Halt'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
  virtual bool        is_ideal_safepoint() const; // node matches 'SafePoint'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  virtual bool        is_ideal_nop() const;     // node matches 'Nop'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
  virtual bool        is_ideal_control() const; // control node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  virtual Form::CallType is_ideal_call() const; // matches ideal 'Call'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  virtual Form::DataType is_ideal_load() const; // node matches ideal 'LoadXNode'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   160
  virtual Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   161
          bool        is_ideal_mem() const { return is_ideal_load() != Form::none || is_ideal_store() != Form::none; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   162
  virtual uint        two_address(FormDict &globals); // output reg must match input reg
489c9b5090e2 Initial load
duke
parents:
diff changeset
   163
  // when chaining a constant to an instruction, return 'true' and set opType
489c9b5090e2 Initial load
duke
parents:
diff changeset
   164
  virtual Form::DataType is_chain_of_constant(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   165
  virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   166
  virtual Form::DataType is_chain_of_constant(FormDict &globals, const char * &opType, const char * &result_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   167
489c9b5090e2 Initial load
duke
parents:
diff changeset
   168
  // Check if a simple chain rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  virtual bool        is_simple_chain_rule(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  // check for structural rematerialization
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  virtual bool        rematerialize(FormDict &globals, RegisterForm *registers);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
489c9b5090e2 Initial load
duke
parents:
diff changeset
   174
  // loads from memory, so must check for anti-dependence
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
  virtual bool        needs_anti_dependence_check(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  virtual int         memory_operand(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   177
          bool        is_wide_memory_kill(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  enum memory_operand_type {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
    NO_MEMORY_OPERAND = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
    MANY_MEMORY_OPERANDS = 999999
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // This instruction captures the machine-independent bottom_type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  // Expected use is for pointer vs oop determination for LoadP
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
  virtual bool        captures_bottom_type() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
  virtual const char *cost();      // Access ins_cost attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
  virtual uint        num_opnds(); // Count of num_opnds for MachNode class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
  virtual uint        num_post_match_opnds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
  virtual uint        num_consts(FormDict &globals) const;// Constants in match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  // Constants in match rule with specified type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  virtual uint        num_consts(FormDict &globals, Form::DataType type) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
  // Return the register class associated with 'leaf'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
  virtual const char *out_reg_class(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
  // number of ideal node inputs to skip
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
  virtual uint        oper_input_base(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  // Does this instruction need a base-oop edge?
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  int needs_base_oop_edge(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
  // Build instruction predicates.  If the user uses the same operand name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
  // twice, we need to check that the operands are pointer-eequivalent in
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  // the DFA during the labeling process.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  Predicate *build_predicate();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
  virtual void        build_components(); // top-level operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  // Return zero-based position in component list; -1 if not in list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  virtual int         operand_position(const char *name, int usedef);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  virtual int         operand_position_format(const char *name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // Return zero-based position in component list; -1 if not in list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
  virtual int         label_position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  virtual int         method_position();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  // Return number of relocation entries needed for this instruction.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
  virtual uint        reloc(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  const char         *reduce_result();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  // Return the name of the operand on the right hand side of the binary match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  // Return NULL if there is no right hand side
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  const char         *reduce_right(FormDict &globals)  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  const char         *reduce_left(FormDict &globals)   const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  // Base class for this instruction, MachNode except for calls
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  virtual const char *mach_base_class()  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // Check if this instruction can cisc-spill to 'alternate'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  bool                cisc_spills_to(ArchDesc &AD, InstructForm *alternate);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  InstructForm       *cisc_spill_alternate() { return _cisc_spill_alternate; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  uint                cisc_spill_operand() const { return _cisc_spill_operand; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  bool                is_cisc_alternate() const { return _is_cisc_alternate; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  void                set_cisc_alternate(bool val) { _is_cisc_alternate = val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
  const char         *cisc_reg_mask_name() const { return _cisc_reg_mask_name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  void                set_cisc_reg_mask_name(const char *rm_name) { _cisc_reg_mask_name = rm_name; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   238
  // Output cisc-method prototypes and method bodies
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  void                declare_cisc_version(ArchDesc &AD, FILE *fp_cpp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  bool                define_cisc_version (ArchDesc &AD, FILE *fp_cpp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   241
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  bool                check_branch_variant(ArchDesc &AD, InstructForm *short_branch);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  bool                is_short_branch() { return _is_short_branch; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  void                set_short_branch(bool val) { _is_short_branch = val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  InstructForm       *short_branch_form() { return _short_branch_form; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  bool                has_short_branch_form() { return _short_branch_form != NULL; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   249
  // Output short branch prototypes and method bodies
489c9b5090e2 Initial load
duke
parents:
diff changeset
   250
  void                declare_short_branch_methods(FILE *fp_cpp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   251
  bool                define_short_branch_methods(FILE *fp_cpp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   252
489c9b5090e2 Initial load
duke
parents:
diff changeset
   253
  uint                alignment() { return _alignment; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
  void                set_alignment(uint val) { _alignment = val; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  // Seach through operands to determine operands unique positions.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  void                set_unique_opnds();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  uint                num_unique_opnds() { return _num_uniq; }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  uint                unique_opnds_idx(int idx) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
                        if( _uniq_idx != NULL && idx > 0 )
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
                          return _uniq_idx[idx];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
                        else
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
                          return idx;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
                      }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // Operands which are only KILLs aren't part of the input array and
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  // require special handling in some cases.  Their position in this
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  // operand list is higher than the number of unique operands.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  bool is_noninput_operand(uint idx) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
    return (idx >= num_unique_opnds());
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  // --------------------------- FILE *output_routines
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
  // Generate the format call for the replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
  void                rep_var_format(FILE *fp, const char *rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
  // Generate index values needed for determing the operand position
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  void                index_temps   (FILE *fp, FormDict &globals, const char *prefix = "", const char *receiver = "");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  // ---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  virtual bool verify();           // Check consistency after parsing
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
489c9b5090e2 Initial load
duke
parents:
diff changeset
   283
  virtual void dump();             // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
  virtual void output(FILE *fp);   // Write to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
//------------------------------EncodeForm-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   288
class EncodeForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
489c9b5090e2 Initial load
duke
parents:
diff changeset
   291
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   292
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   293
  NameList  _eclasses;            // List of encode class names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   294
  Dict      _encClass;            // Map encode class names to EncClass objects
489c9b5090e2 Initial load
duke
parents:
diff changeset
   295
489c9b5090e2 Initial load
duke
parents:
diff changeset
   296
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   297
  EncodeForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   298
  ~EncodeForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   299
489c9b5090e2 Initial load
duke
parents:
diff changeset
   300
  EncClass   *add_EncClass(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   301
  EncClass   *encClass(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   302
489c9b5090e2 Initial load
duke
parents:
diff changeset
   303
  const char *encClassPrototype(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   304
  const char *encClassBody(const char *className);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   305
489c9b5090e2 Initial load
duke
parents:
diff changeset
   306
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   307
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   308
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   309
489c9b5090e2 Initial load
duke
parents:
diff changeset
   310
//------------------------------EncClass---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   311
class EncClass : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   312
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   313
  // NameList for parameter type and name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   314
  NameList       _parameter_type;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   315
  NameList       _parameter_name;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   316
489c9b5090e2 Initial load
duke
parents:
diff changeset
   317
  // Breakdown the encoding into strings separated by $replacement_variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   318
  // There is an entry in _strings, perhaps NULL, that precedes each _rep_vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
   319
  NameList       _code;            // Strings passed through to tty->print
489c9b5090e2 Initial load
duke
parents:
diff changeset
   320
  NameList       _rep_vars;        // replacement variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
   321
489c9b5090e2 Initial load
duke
parents:
diff changeset
   322
  NameList       _parameters;      // Locally defined names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   323
  FormDict       _localNames;      // Table of components & their types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   324
489c9b5090e2 Initial load
duke
parents:
diff changeset
   325
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   326
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   327
  const char    *_name;            // encoding class name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   328
489c9b5090e2 Initial load
duke
parents:
diff changeset
   329
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   330
  EncClass(const char *name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   331
  ~EncClass();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   332
489c9b5090e2 Initial load
duke
parents:
diff changeset
   333
  // --------------------------- Parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   334
  // Add a parameter <type,name> pair
489c9b5090e2 Initial load
duke
parents:
diff changeset
   335
  void add_parameter(const char *parameter_type, const char *parameter_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   336
  // Verify operand types in parameter list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   337
  bool check_parameter_types(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   338
  // Obtain the zero-based index corresponding to a replacement variable
489c9b5090e2 Initial load
duke
parents:
diff changeset
   339
  int         rep_var_index(const char *rep_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   340
  int         num_args() { return _parameter_name.count(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   341
489c9b5090e2 Initial load
duke
parents:
diff changeset
   342
  // --------------------------- Code Block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   343
  // Add code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   344
  void add_code(const char *string_preceeding_replacement_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   345
  // Add a replacement variable or one of its subfields
489c9b5090e2 Initial load
duke
parents:
diff changeset
   346
  // Subfields are stored with a leading '$'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   347
  void add_rep_var(char *replacement_var);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   348
489c9b5090e2 Initial load
duke
parents:
diff changeset
   349
  bool verify();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   350
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   351
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   352
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   353
489c9b5090e2 Initial load
duke
parents:
diff changeset
   354
//------------------------------MachNode---------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   355
class MachNodeForm: public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   356
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   357
489c9b5090e2 Initial load
duke
parents:
diff changeset
   358
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   359
  char          *_ident;           // Name of this instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   360
  const char    *_machnode_pipe;   // Instruction Scheduline description class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   361
489c9b5090e2 Initial load
duke
parents:
diff changeset
   362
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   363
  MachNodeForm(char *id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   364
  ~MachNodeForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   365
489c9b5090e2 Initial load
duke
parents:
diff changeset
   366
  virtual MachNodeForm *is_machnode() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   367
489c9b5090e2 Initial load
duke
parents:
diff changeset
   368
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   369
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   370
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   371
489c9b5090e2 Initial load
duke
parents:
diff changeset
   372
//------------------------------Opcode-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   373
class Opcode : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   374
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   375
489c9b5090e2 Initial load
duke
parents:
diff changeset
   376
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   377
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   378
  // Strings representing instruction opcodes, user defines placement in emit
489c9b5090e2 Initial load
duke
parents:
diff changeset
   379
  char *_primary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   380
  char *_secondary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   381
  char *_tertiary;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   382
489c9b5090e2 Initial load
duke
parents:
diff changeset
   383
  enum opcode_type {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   384
    NOT_AN_OPCODE = -1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   385
    PRIMARY   = 1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   386
    SECONDARY = 2,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   387
    TERTIARY  = 3
489c9b5090e2 Initial load
duke
parents:
diff changeset
   388
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   389
489c9b5090e2 Initial load
duke
parents:
diff changeset
   390
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   391
  Opcode(char *primary, char *secondary, char *tertiary);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   392
  ~Opcode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   393
489c9b5090e2 Initial load
duke
parents:
diff changeset
   394
  static Opcode::opcode_type as_opcode_type(const char *designator);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   395
489c9b5090e2 Initial load
duke
parents:
diff changeset
   396
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   397
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   398
489c9b5090e2 Initial load
duke
parents:
diff changeset
   399
  // --------------------------- FILE *output_routines
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   400
  bool print_opcode(FILE *fp, Opcode::opcode_type desired_opcode);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   401
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   402
489c9b5090e2 Initial load
duke
parents:
diff changeset
   403
//------------------------------InsEncode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   404
class InsEncode : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   405
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   406
  // Public Data (access directly only for reads)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   407
  // The encodings can only have the values predefined by the ADLC:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   408
  // blank, RegReg, RegMem, MemReg, ...
489c9b5090e2 Initial load
duke
parents:
diff changeset
   409
  NameList    _encoding;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   410
  // NameList    _parameter;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   411
  // The parameters for each encoding are preceeded by a NameList::_signal
489c9b5090e2 Initial load
duke
parents:
diff changeset
   412
  // and follow the parameters for the previous encoding.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   413
489c9b5090e2 Initial load
duke
parents:
diff changeset
   414
  // char *_encode;                  // Type of instruction encoding
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
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   418
  InsEncode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   419
  ~InsEncode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   420
489c9b5090e2 Initial load
duke
parents:
diff changeset
   421
  // Add "encode class name" and its parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   422
  NameAndList  *add_encode(char *encode_method_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   423
  // Parameters are added to the returned "NameAndList" by the parser
489c9b5090e2 Initial load
duke
parents:
diff changeset
   424
489c9b5090e2 Initial load
duke
parents:
diff changeset
   425
  // Access the list of encodings
489c9b5090e2 Initial load
duke
parents:
diff changeset
   426
  void          reset();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   427
  const char   *encode_class_iter();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   428
489c9b5090e2 Initial load
duke
parents:
diff changeset
   429
  // Returns the number of arguments to the current encoding in the iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   430
  int current_encoding_num_args() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   431
    return ((NameAndList*)_encoding.current())->count();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   432
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   433
489c9b5090e2 Initial load
duke
parents:
diff changeset
   434
  // --------------------------- Parameters
489c9b5090e2 Initial load
duke
parents:
diff changeset
   435
  // The following call depends upon position within encode_class_iteration
489c9b5090e2 Initial load
duke
parents:
diff changeset
   436
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   437
  // Obtain parameter name from zero based index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   438
  const char   *rep_var_name(InstructForm &inst, uint param_no);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   439
  // ---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   440
489c9b5090e2 Initial load
duke
parents:
diff changeset
   441
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   442
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   443
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   444
489c9b5090e2 Initial load
duke
parents:
diff changeset
   445
//------------------------------Effect-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   446
class Effect : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   447
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   448
489c9b5090e2 Initial load
duke
parents:
diff changeset
   449
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   450
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   451
  const char  *_name;            // Pre-defined name for effect
489c9b5090e2 Initial load
duke
parents:
diff changeset
   452
  int         _use_def;          // Enumeration value of effect
489c9b5090e2 Initial load
duke
parents:
diff changeset
   453
489c9b5090e2 Initial load
duke
parents:
diff changeset
   454
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   455
  Effect(const char *name);      // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   456
  ~Effect();                     // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   457
489c9b5090e2 Initial load
duke
parents:
diff changeset
   458
  // Dynamic type check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   459
  virtual Effect *is_effect() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   460
489c9b5090e2 Initial load
duke
parents:
diff changeset
   461
  // Return 'true' if this use def info equals the parameter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   462
  bool  is(int use_def_kill_enum) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   463
  // Return 'true' if this use def info is a superset of parameter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   464
  bool  isa(int use_def_kill_enum) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   465
489c9b5090e2 Initial load
duke
parents:
diff changeset
   466
  void dump();                   // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   467
  void output(FILE *fp);         // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   468
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   469
489c9b5090e2 Initial load
duke
parents:
diff changeset
   470
//------------------------------ExpandRule-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   471
class ExpandRule : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   472
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   473
  NameList _expand_instrs;        // ordered list of instructions and operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   474
489c9b5090e2 Initial load
duke
parents:
diff changeset
   475
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   476
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   477
  NameList _newopers;             // List of newly created operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   478
  Dict     _newopconst;           // Map new operands to their constructors
489c9b5090e2 Initial load
duke
parents:
diff changeset
   479
489c9b5090e2 Initial load
duke
parents:
diff changeset
   480
  void     add_instruction(NameAndList *instruction_name_and_operand_list);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   481
  void     reset_instructions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   482
  NameAndList *iter_instructions();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   483
489c9b5090e2 Initial load
duke
parents:
diff changeset
   484
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   485
  ExpandRule();                   // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   486
  ~ExpandRule();                  // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   487
489c9b5090e2 Initial load
duke
parents:
diff changeset
   488
  void dump();                    // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   489
  void output(FILE *fp);          // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   490
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   491
489c9b5090e2 Initial load
duke
parents:
diff changeset
   492
//------------------------------RewriteRule------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   493
class RewriteRule : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   494
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   495
489c9b5090e2 Initial load
duke
parents:
diff changeset
   496
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   497
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   498
  SourceForm     *_condition;      // Rewrite condition code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   499
  InstructForm   *_instrs;         // List of instructions to expand to
489c9b5090e2 Initial load
duke
parents:
diff changeset
   500
  OperandForm    *_opers;          // List of operands generated by expand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   501
  char           *_tempParams;     // Hold string until parser is finished.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   502
  char           *_tempBlock;      // Hold string until parser is finished.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   503
489c9b5090e2 Initial load
duke
parents:
diff changeset
   504
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   505
  RewriteRule(char* params, char* block) ;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   506
  ~RewriteRule();                  // Destructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   507
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   508
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   509
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   510
489c9b5090e2 Initial load
duke
parents:
diff changeset
   511
489c9b5090e2 Initial load
duke
parents:
diff changeset
   512
//==============================Operands=======================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   513
//------------------------------OpClassForm------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   514
class OpClassForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   515
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   516
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   517
  const char    *_ident;           // Name of this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   518
  NameList       _oplst;           // List of operand forms included in class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   519
489c9b5090e2 Initial load
duke
parents:
diff changeset
   520
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   521
  OpClassForm(const char *id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   522
  ~OpClassForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   523
489c9b5090e2 Initial load
duke
parents:
diff changeset
   524
  // dynamic type check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   525
  virtual OpClassForm         *is_opclass() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   526
  virtual Form::InterfaceType  interface_type(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   527
  virtual bool                 stack_slots_only(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   528
489c9b5090e2 Initial load
duke
parents:
diff changeset
   529
  virtual bool                 is_cisc_mem(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   530
489c9b5090e2 Initial load
duke
parents:
diff changeset
   531
489c9b5090e2 Initial load
duke
parents:
diff changeset
   532
  // Min and Max opcodes of operands in this operand class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   533
  int _minCode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   534
  int _maxCode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   535
489c9b5090e2 Initial load
duke
parents:
diff changeset
   536
  virtual bool ideal_only() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   537
  virtual void dump();             // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   538
  virtual void output(FILE *fp);   // Write to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   539
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   540
489c9b5090e2 Initial load
duke
parents:
diff changeset
   541
//------------------------------OperandForm------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   542
class OperandForm : public OpClassForm {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   543
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   544
  bool         _ideal_only; // Not a user-defined instruction
489c9b5090e2 Initial load
duke
parents:
diff changeset
   545
489c9b5090e2 Initial load
duke
parents:
diff changeset
   546
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   547
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   548
  NameList       _parameters; // Locally defined names
489c9b5090e2 Initial load
duke
parents:
diff changeset
   549
  FormDict       _localNames; // Table of components & their types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   550
  MatchRule     *_matrule;    // Matching rule for this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   551
  Interface     *_interface;  // Encoding interface for this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   552
  Attribute     *_attribs;    // List of Attribute rules
489c9b5090e2 Initial load
duke
parents:
diff changeset
   553
  Predicate     *_predicate;  // Predicate test for this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   554
  Constraint    *_constraint; // Constraint Rule for this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   555
  ConstructRule *_construct;  // Construction of operand data after matching
489c9b5090e2 Initial load
duke
parents:
diff changeset
   556
  FormatRule    *_format;     // Format for assembly generation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   557
  NameList       _classes;    // List of opclasses which contain this oper
489c9b5090e2 Initial load
duke
parents:
diff changeset
   558
489c9b5090e2 Initial load
duke
parents:
diff changeset
   559
  ComponentList _components;  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   560
489c9b5090e2 Initial load
duke
parents:
diff changeset
   561
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   562
  OperandForm(const char *id);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   563
  OperandForm(const char *id, bool ideal_only);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   564
  ~OperandForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   565
489c9b5090e2 Initial load
duke
parents:
diff changeset
   566
  // Dynamic type check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   567
  virtual OperandForm *is_operand() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   568
489c9b5090e2 Initial load
duke
parents:
diff changeset
   569
  virtual bool        ideal_only() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   570
  virtual Form::InterfaceType interface_type(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   571
  virtual bool                 stack_slots_only(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   572
489c9b5090e2 Initial load
duke
parents:
diff changeset
   573
  virtual const char *cost();  // Access ins_cost attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   574
  virtual uint        num_leaves() const;// Leaves in complex operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   575
  // Constants in operands' match rules
489c9b5090e2 Initial load
duke
parents:
diff changeset
   576
  virtual uint        num_consts(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   577
  // Constants in operand's match rule with specified type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   578
  virtual uint        num_consts(FormDict &globals, Form::DataType type) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   579
  // Pointer Constants in operands' match rules
489c9b5090e2 Initial load
duke
parents:
diff changeset
   580
  virtual uint        num_const_ptrs(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   581
  // The number of input edges in the machine world == num_leaves - num_consts
489c9b5090e2 Initial load
duke
parents:
diff changeset
   582
  virtual uint        num_edges(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   583
489c9b5090e2 Initial load
duke
parents:
diff changeset
   584
  // Check if this operand is usable for cisc-spilling
489c9b5090e2 Initial load
duke
parents:
diff changeset
   585
  virtual bool        is_cisc_reg(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   586
489c9b5090e2 Initial load
duke
parents:
diff changeset
   587
  // node matches ideal 'Bool', grab condition codes from the ideal world
489c9b5090e2 Initial load
duke
parents:
diff changeset
   588
  virtual bool        is_ideal_bool()  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   589
489c9b5090e2 Initial load
duke
parents:
diff changeset
   590
  // Has an integer constant suitable for spill offsets
489c9b5090e2 Initial load
duke
parents:
diff changeset
   591
  bool has_conI(FormDict &globals) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   592
    return (num_consts(globals,idealI) == 1) && !is_ideal_bool(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   593
  bool has_conL(FormDict &globals) const {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   594
    return (num_consts(globals,idealL) == 1) && !is_ideal_bool(); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   595
489c9b5090e2 Initial load
duke
parents:
diff changeset
   596
  // Node is user-defined operand for an sRegX
489c9b5090e2 Initial load
duke
parents:
diff changeset
   597
  virtual Form::DataType is_user_name_for_sReg() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   598
489c9b5090e2 Initial load
duke
parents:
diff changeset
   599
  // Return ideal type, if there is a single ideal type for this operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   600
  virtual const char *ideal_type(FormDict &globals, RegisterForm *registers = NULL) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   601
  // If there is a single ideal type for this interface field, return it.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   602
  virtual const char *interface_ideal_type(FormDict   &globals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   603
                                           const char *field_name) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   604
489c9b5090e2 Initial load
duke
parents:
diff changeset
   605
  // Return true if this operand represents a bound register class
489c9b5090e2 Initial load
duke
parents:
diff changeset
   606
  bool is_bound_register() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   607
489c9b5090e2 Initial load
duke
parents:
diff changeset
   608
  // Return the Register class for this operand.  Returns NULL if
489c9b5090e2 Initial load
duke
parents:
diff changeset
   609
  // operand isn't a register form.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   610
  RegClass* get_RegClass() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   611
489c9b5090e2 Initial load
duke
parents:
diff changeset
   612
  virtual       bool  is_interface_field(const char   *field_name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   613
                                         const char   * &value) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   614
489c9b5090e2 Initial load
duke
parents:
diff changeset
   615
  // If this operand has a single ideal type, return its type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   616
  virtual Form::DataType simple_type(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   617
  // If this operand is an ideal constant, return its type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   618
  virtual Form::DataType is_base_constant(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   619
489c9b5090e2 Initial load
duke
parents:
diff changeset
   620
  // "true" if this operand is a simple type that is swallowed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   621
  virtual bool        swallowed(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   622
489c9b5090e2 Initial load
duke
parents:
diff changeset
   623
  // Return register class name if a constraint specifies the register class.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   624
  virtual const char *constrained_reg_class() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   625
  // Return the register class associated with 'leaf'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   626
  virtual const char *in_reg_class(uint leaf, FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   627
489c9b5090e2 Initial load
duke
parents:
diff changeset
   628
  // Build component list from MatchRule and operand's parameter list
489c9b5090e2 Initial load
duke
parents:
diff changeset
   629
  virtual void        build_components(); // top-level operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   630
489c9b5090e2 Initial load
duke
parents:
diff changeset
   631
  // Return zero-based position in component list; -1 if not in list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   632
  virtual int         operand_position(const char *name, int usedef);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   633
489c9b5090e2 Initial load
duke
parents:
diff changeset
   634
  // Return zero-based position in component list; -1 if not in list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   635
  virtual int         constant_position(FormDict &globals, const Component *comp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   636
  virtual int         constant_position(FormDict &globals, const char *local_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   637
  // Return the operand form corresponding to the given index, else NULL.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   638
  virtual OperandForm *constant_operand(FormDict &globals, uint const_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   639
489c9b5090e2 Initial load
duke
parents:
diff changeset
   640
  // Return zero-based position in component list; -1 if not in list.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   641
  virtual int         register_position(FormDict &globals, const char *regname);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   642
489c9b5090e2 Initial load
duke
parents:
diff changeset
   643
  const char         *reduce_result() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   644
  // Return the name of the operand on the right hand side of the binary match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   645
  // Return NULL if there is no right hand side
489c9b5090e2 Initial load
duke
parents:
diff changeset
   646
  const char         *reduce_right(FormDict &globals)  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   647
  const char         *reduce_left(FormDict &globals)   const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   648
489c9b5090e2 Initial load
duke
parents:
diff changeset
   649
489c9b5090e2 Initial load
duke
parents:
diff changeset
   650
  // --------------------------- FILE *output_routines
489c9b5090e2 Initial load
duke
parents:
diff changeset
   651
  //
489c9b5090e2 Initial load
duke
parents:
diff changeset
   652
  // Output code for disp_is_oop, if true.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   653
  void                disp_is_oop(FILE *fp, FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   654
  // Generate code for internal and external format methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   655
  void                int_format(FILE *fp, FormDict &globals, uint index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   656
  void                ext_format(FILE *fp, FormDict &globals, uint index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   657
  void                format_constant(FILE *fp, uint con_index, uint con_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   658
  // Output code to access the value of the index'th constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   659
  void                access_constant(FILE *fp, FormDict &globals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   660
                                      uint con_index);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   661
  // ---------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   662
489c9b5090e2 Initial load
duke
parents:
diff changeset
   663
489c9b5090e2 Initial load
duke
parents:
diff changeset
   664
  virtual void dump();             // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   665
  virtual void output(FILE *fp);   // Write to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   666
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   667
489c9b5090e2 Initial load
duke
parents:
diff changeset
   668
//------------------------------Constraint-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   669
class Constraint : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   670
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   671
489c9b5090e2 Initial load
duke
parents:
diff changeset
   672
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   673
  const char      *_func;          // Constraint function
489c9b5090e2 Initial load
duke
parents:
diff changeset
   674
  const char      *_arg;           // function's argument
489c9b5090e2 Initial load
duke
parents:
diff changeset
   675
489c9b5090e2 Initial load
duke
parents:
diff changeset
   676
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   677
  Constraint(const char *func, const char *arg); // Constructor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   678
  ~Constraint();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   679
489c9b5090e2 Initial load
duke
parents:
diff changeset
   680
  bool stack_slots_only() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   681
489c9b5090e2 Initial load
duke
parents:
diff changeset
   682
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   683
  void output(FILE *fp);           // Write info to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   684
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   685
489c9b5090e2 Initial load
duke
parents:
diff changeset
   686
//------------------------------Predicate--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   687
class Predicate : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   688
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   689
489c9b5090e2 Initial load
duke
parents:
diff changeset
   690
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   691
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   692
  char *_pred;                     // C++ source string for predicate
489c9b5090e2 Initial load
duke
parents:
diff changeset
   693
489c9b5090e2 Initial load
duke
parents:
diff changeset
   694
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   695
  Predicate(char *pr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   696
  ~Predicate();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   697
489c9b5090e2 Initial load
duke
parents:
diff changeset
   698
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   699
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   700
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   701
489c9b5090e2 Initial load
duke
parents:
diff changeset
   702
//------------------------------Interface--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   703
class Interface : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   704
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   705
489c9b5090e2 Initial load
duke
parents:
diff changeset
   706
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   707
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   708
  const char *_name;               // String representing the interface name
489c9b5090e2 Initial load
duke
parents:
diff changeset
   709
489c9b5090e2 Initial load
duke
parents:
diff changeset
   710
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   711
  Interface(const char *name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   712
  ~Interface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   713
489c9b5090e2 Initial load
duke
parents:
diff changeset
   714
  virtual Form::InterfaceType interface_type(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   715
489c9b5090e2 Initial load
duke
parents:
diff changeset
   716
  RegInterface   *is_RegInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   717
  MemInterface   *is_MemInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   718
  ConstInterface *is_ConstInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   719
  CondInterface  *is_CondInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   720
489c9b5090e2 Initial load
duke
parents:
diff changeset
   721
489c9b5090e2 Initial load
duke
parents:
diff changeset
   722
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   723
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   724
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   725
489c9b5090e2 Initial load
duke
parents:
diff changeset
   726
//------------------------------RegInterface-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   727
class RegInterface : public Interface {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   728
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   729
489c9b5090e2 Initial load
duke
parents:
diff changeset
   730
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   731
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   732
  RegInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   733
  ~RegInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   734
489c9b5090e2 Initial load
duke
parents:
diff changeset
   735
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   736
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   737
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   738
489c9b5090e2 Initial load
duke
parents:
diff changeset
   739
//------------------------------ConstInterface---------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   740
class ConstInterface : public Interface {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   741
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   742
489c9b5090e2 Initial load
duke
parents:
diff changeset
   743
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   744
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   745
  ConstInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   746
  ~ConstInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   747
489c9b5090e2 Initial load
duke
parents:
diff changeset
   748
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   749
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   750
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   751
489c9b5090e2 Initial load
duke
parents:
diff changeset
   752
//------------------------------MemInterface-----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   753
class MemInterface : public Interface {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   754
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   755
489c9b5090e2 Initial load
duke
parents:
diff changeset
   756
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   757
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   758
  char *_base;                     // Base address
489c9b5090e2 Initial load
duke
parents:
diff changeset
   759
  char *_index;                    // index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   760
  char *_scale;                    // scaling factor
489c9b5090e2 Initial load
duke
parents:
diff changeset
   761
  char *_disp;                     // displacement
489c9b5090e2 Initial load
duke
parents:
diff changeset
   762
489c9b5090e2 Initial load
duke
parents:
diff changeset
   763
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   764
  MemInterface(char *base, char *index, char *scale, char *disp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   765
  ~MemInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   766
489c9b5090e2 Initial load
duke
parents:
diff changeset
   767
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   768
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   769
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   770
489c9b5090e2 Initial load
duke
parents:
diff changeset
   771
//------------------------------CondInterface----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   772
class CondInterface : public Interface {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   773
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   774
489c9b5090e2 Initial load
duke
parents:
diff changeset
   775
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   776
  const char *_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   777
  const char *_not_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   778
  const char *_less;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   779
  const char *_greater_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   780
  const char *_less_equal;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   781
  const char *_greater;
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   782
  const char *_equal_format;
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   783
  const char *_not_equal_format;
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   784
  const char *_less_format;
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   785
  const char *_greater_equal_format;
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   786
  const char *_less_equal_format;
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   787
  const char *_greater_format;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   788
489c9b5090e2 Initial load
duke
parents:
diff changeset
   789
  // Public Methods
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   790
  CondInterface(const char* equal,         const char* equal_format,
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   791
                const char* not_equal,     const char* not_equal_format,
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   792
                const char* less,          const char* less_format,
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   793
                const char* greater_equal, const char* greater_equal_format,
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   794
                const char* less_equal,    const char* less_equal_format,
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   795
                const char* greater,       const char* greater_format);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   796
  ~CondInterface();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   797
489c9b5090e2 Initial load
duke
parents:
diff changeset
   798
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   799
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   800
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   801
489c9b5090e2 Initial load
duke
parents:
diff changeset
   802
//------------------------------ConstructRule----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   803
class ConstructRule : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   804
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   805
489c9b5090e2 Initial load
duke
parents:
diff changeset
   806
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   807
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   808
  char *_expr;                     // String representing the match expression
489c9b5090e2 Initial load
duke
parents:
diff changeset
   809
  char *_construct;                // String representing C++ constructor code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   810
489c9b5090e2 Initial load
duke
parents:
diff changeset
   811
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   812
  ConstructRule(char *cnstr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   813
  ~ConstructRule();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   814
489c9b5090e2 Initial load
duke
parents:
diff changeset
   815
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   816
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   817
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   818
489c9b5090e2 Initial load
duke
parents:
diff changeset
   819
489c9b5090e2 Initial load
duke
parents:
diff changeset
   820
//==============================Shared=========================================
489c9b5090e2 Initial load
duke
parents:
diff changeset
   821
//------------------------------AttributeForm----------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   822
class AttributeForm : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   823
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   824
  // counters for unique instruction or operand ID
489c9b5090e2 Initial load
duke
parents:
diff changeset
   825
  static int   _insId;             // user-defined machine instruction types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   826
  static int   _opId;              // user-defined operand types
489c9b5090e2 Initial load
duke
parents:
diff changeset
   827
489c9b5090e2 Initial load
duke
parents:
diff changeset
   828
  int  id;                         // hold type for this object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   829
489c9b5090e2 Initial load
duke
parents:
diff changeset
   830
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   831
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   832
  char *_attrname;                 // Name of attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
   833
  int   _atype;                    // Either INS_ATTR or OP_ATTR
489c9b5090e2 Initial load
duke
parents:
diff changeset
   834
  char *_attrdef;                  // C++ source which evaluates to constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
   835
489c9b5090e2 Initial load
duke
parents:
diff changeset
   836
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   837
  AttributeForm(char *attr, int type, char *attrdef);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   838
  ~AttributeForm();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   839
489c9b5090e2 Initial load
duke
parents:
diff changeset
   840
  // Dynamic type check
489c9b5090e2 Initial load
duke
parents:
diff changeset
   841
  virtual AttributeForm *is_attribute() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   842
489c9b5090e2 Initial load
duke
parents:
diff changeset
   843
  int  type() { return id;}        // return this object's "id"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   844
489c9b5090e2 Initial load
duke
parents:
diff changeset
   845
  static const char* _ins_cost;        // "ins_cost"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   846
  static const char* _ins_pc_relative; // "ins_pc_relative"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   847
  static const char* _op_cost;         // "op_cost"
489c9b5090e2 Initial load
duke
parents:
diff changeset
   848
489c9b5090e2 Initial load
duke
parents:
diff changeset
   849
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   850
  void output(FILE *fp);           // Write output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   851
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   852
489c9b5090e2 Initial load
duke
parents:
diff changeset
   853
//------------------------------Component--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   854
class Component : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   855
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   856
489c9b5090e2 Initial load
duke
parents:
diff changeset
   857
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   858
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   859
  const char *_name;              // Name of this component
489c9b5090e2 Initial load
duke
parents:
diff changeset
   860
  const char *_type;              // Type of this component
489c9b5090e2 Initial load
duke
parents:
diff changeset
   861
  int         _usedef;            // Value of component
489c9b5090e2 Initial load
duke
parents:
diff changeset
   862
489c9b5090e2 Initial load
duke
parents:
diff changeset
   863
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   864
  Component(const char *name, const char *type, int usedef);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   865
  ~Component();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   866
489c9b5090e2 Initial load
duke
parents:
diff changeset
   867
489c9b5090e2 Initial load
duke
parents:
diff changeset
   868
  // Return 'true' if this use def info equals the parameter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   869
  bool  is(int use_def_kill_enum) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   870
  // Return 'true' if this use def info is a superset of parameter
489c9b5090e2 Initial load
duke
parents:
diff changeset
   871
  bool  isa(int use_def_kill_enum) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   872
  int   promote_use_def_info(int new_use_def);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   873
  const char *base_type(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   874
  // Form::DataType is_base_constant(FormDict &globals);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   875
489c9b5090e2 Initial load
duke
parents:
diff changeset
   876
  void dump();                     // Debug printer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   877
  void output(FILE *fp);           // Write to output files
489c9b5090e2 Initial load
duke
parents:
diff changeset
   878
489c9b5090e2 Initial load
duke
parents:
diff changeset
   879
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   880
  // Implementation depends upon working bit intersection and union.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   881
  enum use_def_enum {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   882
    INVALID = 0x0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   883
    USE     = 0x1,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   884
    DEF     = 0x2, USE_DEF   = 0x3,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   885
    KILL    = 0x4, USE_KILL  = 0x5,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   886
    SYNTHETIC = 0x8,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   887
    TEMP = USE | SYNTHETIC
489c9b5090e2 Initial load
duke
parents:
diff changeset
   888
  };
489c9b5090e2 Initial load
duke
parents:
diff changeset
   889
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   890
489c9b5090e2 Initial load
duke
parents:
diff changeset
   891
489c9b5090e2 Initial load
duke
parents:
diff changeset
   892
//------------------------------MatchNode--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   893
class MatchNode : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   894
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   895
489c9b5090e2 Initial load
duke
parents:
diff changeset
   896
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   897
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   898
  const char  *_result;            // The name of the output of this node
489c9b5090e2 Initial load
duke
parents:
diff changeset
   899
  const char  *_name;              // The name that appeared in the match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   900
  const char  *_opType;            // The Operation/Type matched
489c9b5090e2 Initial load
duke
parents:
diff changeset
   901
  MatchNode   *_lChild;            // Left child in expression tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   902
  MatchNode   *_rChild;            // Right child in expression tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   903
  int         _numleaves;          // Sum of numleaves for all direct children
489c9b5090e2 Initial load
duke
parents:
diff changeset
   904
  ArchDesc    &_AD;                // Reference to ArchDesc object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   905
  char        *_internalop;        // String representing internal operand
489c9b5090e2 Initial load
duke
parents:
diff changeset
   906
  int         _commutative_id;     // id of commutative operation
489c9b5090e2 Initial load
duke
parents:
diff changeset
   907
489c9b5090e2 Initial load
duke
parents:
diff changeset
   908
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   909
  MatchNode(ArchDesc &ad, const char *result = 0, const char *expr = 0,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   910
            const char *opType=0, MatchNode *lChild=NULL,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   911
            MatchNode *rChild=NULL);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   912
  MatchNode(ArchDesc &ad, MatchNode& mNode); // Shallow copy constructor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   913
  MatchNode(ArchDesc &ad, MatchNode& mNode, int clone); // Construct clone
489c9b5090e2 Initial load
duke
parents:
diff changeset
   914
  ~MatchNode();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   915
489c9b5090e2 Initial load
duke
parents:
diff changeset
   916
  // return 0 if not found:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   917
  // return 1 if found and position is incremented by operand offset in rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   918
  bool       find_name(const char *str, int &position) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   919
  bool       find_type(const char *str, int &position) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   920
  void       append_components(FormDict &locals, ComponentList &components,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   921
                               bool def_flag) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   922
  bool       base_operand(uint &position, FormDict &globals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   923
                         const char * &result, const char * &name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   924
                         const char * &opType) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   925
  // recursive count on operands
489c9b5090e2 Initial load
duke
parents:
diff changeset
   926
  uint       num_consts(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   927
  uint       num_const_ptrs(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   928
  // recursive count of constants with specified type
489c9b5090e2 Initial load
duke
parents:
diff changeset
   929
  uint       num_consts(FormDict &globals, Form::DataType type) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   930
  // uint       num_consts() const;   // Local inspection only
489c9b5090e2 Initial load
duke
parents:
diff changeset
   931
  int        needs_ideal_memory_edge(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   932
  int        needs_base_oop_edge() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   933
489c9b5090e2 Initial load
duke
parents:
diff changeset
   934
  // Help build instruction predicates.  Search for operand names.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   935
  void count_instr_names( Dict &names );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   936
  int build_instr_pred( char *buf, const char *name, int cnt );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   937
  void build_internalop( );
489c9b5090e2 Initial load
duke
parents:
diff changeset
   938
489c9b5090e2 Initial load
duke
parents:
diff changeset
   939
  // Return the name of the operands associated with reducing to this operand:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   940
  // The result type, plus the left and right sides of the binary match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   941
  // Return NULL if there is no left or right hand side
489c9b5090e2 Initial load
duke
parents:
diff changeset
   942
  bool       sets_result()   const;    // rule "Set"s result of match
489c9b5090e2 Initial load
duke
parents:
diff changeset
   943
  const char *reduce_right(FormDict &globals)  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   944
  const char *reduce_left (FormDict &globals)  const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   945
489c9b5090e2 Initial load
duke
parents:
diff changeset
   946
  // Recursive version of check in MatchRule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   947
  int        cisc_spill_match(FormDict &globals, RegisterForm *registers,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   948
                              MatchNode *mRule2, const char * &operand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   949
                              const char * &reg_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   950
  int        cisc_spill_merge(int left_result, int right_result);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   951
489c9b5090e2 Initial load
duke
parents:
diff changeset
   952
  bool       equivalent(FormDict &globals, MatchNode *mNode2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   953
489c9b5090e2 Initial load
duke
parents:
diff changeset
   954
  void       count_commutative_op(int& count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   955
  void       swap_commutative_op(bool atroot, int count);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   956
489c9b5090e2 Initial load
duke
parents:
diff changeset
   957
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   958
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   959
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
   960
489c9b5090e2 Initial load
duke
parents:
diff changeset
   961
//------------------------------MatchRule--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
   962
class MatchRule : public MatchNode {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   963
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   964
489c9b5090e2 Initial load
duke
parents:
diff changeset
   965
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   966
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
   967
  const char *_machType;            // Machine type index
489c9b5090e2 Initial load
duke
parents:
diff changeset
   968
  int         _depth;               // Expression tree depth
489c9b5090e2 Initial load
duke
parents:
diff changeset
   969
  char       *_construct;           // String representing C++ constructor code
489c9b5090e2 Initial load
duke
parents:
diff changeset
   970
  int         _numchilds;           // Number of direct children
489c9b5090e2 Initial load
duke
parents:
diff changeset
   971
  MatchRule  *_next;                // Pointer to next match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   972
489c9b5090e2 Initial load
duke
parents:
diff changeset
   973
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
   974
  MatchRule(ArchDesc &ad);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   975
  MatchRule(ArchDesc &ad, MatchRule* mRule); // Shallow copy constructor;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   976
  MatchRule(ArchDesc &ad, MatchNode* mroot, int depth, char* construct, int numleaves);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   977
  ~MatchRule();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   978
489c9b5090e2 Initial load
duke
parents:
diff changeset
   979
  void       append_components(FormDict &locals, ComponentList &components) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   980
  // Recursive call on all operands' match rules in my match rule.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   981
  bool       base_operand(uint &position, FormDict &globals,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   982
                         const char * &result, const char * &name,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   983
                         const char * &opType) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   984
489c9b5090e2 Initial load
duke
parents:
diff changeset
   985
489c9b5090e2 Initial load
duke
parents:
diff changeset
   986
  bool       is_base_register(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   987
  Form::DataType is_base_constant(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   988
  bool       is_chain_rule(FormDict &globals) const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   989
  int        is_ideal_copy() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   990
  int        is_expensive() const;     // node matches ideal 'CosD'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   991
  bool       is_ideal_unlock() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   992
  bool       is_ideal_call_leaf() const;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   993
  bool       is_ideal_if()   const;    // node matches ideal 'If'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   994
  bool       is_ideal_fastlock() const; // node matches ideal 'FastLock'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   995
  bool       is_ideal_jump()   const;  // node matches ideal 'Jump'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   996
  bool       is_ideal_membar() const;  // node matches ideal 'MemBarXXX'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   997
  bool       is_ideal_loadPC() const;  // node matches ideal 'LoadPC'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   998
  bool       is_ideal_box() const;     // node matches ideal 'Box'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   999
  bool       is_ideal_goto() const;    // node matches ideal 'Goto'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1000
  bool       is_ideal_loopEnd() const; // node matches ideal 'LoopEnd'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1001
  bool       is_ideal_bool() const;    // node matches ideal 'Bool'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1002
  Form::DataType is_ideal_load() const;// node matches ideal 'LoadXNode'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1003
  Form::DataType is_ideal_store() const;// node matches ideal 'StoreXNode'
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1004
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1005
  // Check if 'mRule2' is a cisc-spill variant of this MatchRule
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1006
  int        cisc_spill_match(FormDict &globals, RegisterForm *registers,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1007
                              MatchRule *mRule2, const char * &operand,
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1008
                              const char * &reg_type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1009
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1010
  // Check if 'mRule2' is equivalent to this MatchRule
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1011
  bool       equivalent(FormDict &globals, MatchRule *mRule2);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1012
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1013
  void       swap_commutative_op(const char* instr_ident, int count, int& match_rules_cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1014
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1015
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1016
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1017
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1018
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1019
//------------------------------Attribute--------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1020
class Attribute : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1021
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1022
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1023
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1024
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1025
  char *_ident;                    // Name of predefined attribute
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1026
  char *_val;                      // C++ source which evaluates to constant
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1027
  int   _atype;                    // Either INS_ATTR or OP_ATTR
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1028
  int   int_val(ArchDesc &ad);     // Return atoi(_val), ensuring syntax.
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1029
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1030
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1031
  Attribute(char *id, char* val, int type);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1032
  ~Attribute();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1033
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1034
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1035
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1036
};
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1037
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1038
//------------------------------FormatRule-------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1039
class FormatRule : public Form {
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1040
private:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1041
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1042
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1043
  // Public Data
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1044
  // There is an entry in _strings, perhaps NULL, that precedes each _rep_vars
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1045
  NameList  _strings;              // Strings passed through to tty->print
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1046
  NameList  _rep_vars;             // replacement variables
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1047
  char     *_temp;                 // String representing the assembly code
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1048
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1049
  // Public Methods
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1050
  FormatRule(char *temp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1051
  ~FormatRule();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1052
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1053
  void dump();
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1054
  void output(FILE *fp);
489c9b5090e2 Initial load
duke
parents:
diff changeset
  1055
};