src/hotspot/share/adlc/adlparse.hpp
author erikj
Tue, 12 Sep 2017 19:03:39 +0200
changeset 47216 71c04702a3d5
parent 30202 hotspot/src/share/vm/adlc/adlparse.hpp@6f5c48bd9b82
child 53244 9807daeb47c4
permissions -rw-r--r--
8187443: Forest Consolidation: Move files to unified layout Reviewed-by: darcy, ihse
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     1
/*
22844
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 11196
diff changeset
     2
 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     4
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
489c9b5090e2 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
489c9b5090e2 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
489c9b5090e2 Initial load
duke
parents:
diff changeset
     8
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
489c9b5090e2 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
489c9b5090e2 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
489c9b5090e2 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
489c9b5090e2 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
489c9b5090e2 Initial load
duke
parents:
diff changeset
    14
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
489c9b5090e2 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
489c9b5090e2 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
489c9b5090e2 Initial load
duke
parents:
diff changeset
    18
 *
5547
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
f4b087cbb361 6941466: Oracle rebranding changes for Hotspot repositories
trims
parents: 2105
diff changeset
    21
 * questions.
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    22
 *
489c9b5090e2 Initial load
duke
parents:
diff changeset
    23
 */
489c9b5090e2 Initial load
duke
parents:
diff changeset
    24
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    25
#ifndef SHARE_VM_ADLC_ADLPARSE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    26
#define SHARE_VM_ADLC_ADLPARSE_HPP
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
    27
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    28
// ADLPARSE.HPP - Definitions for Architecture Description Language Parser
489c9b5090e2 Initial load
duke
parents:
diff changeset
    29
// Authors: Chris Vick and Mike Paleczny
489c9b5090e2 Initial load
duke
parents:
diff changeset
    30
489c9b5090e2 Initial load
duke
parents:
diff changeset
    31
// Class List
489c9b5090e2 Initial load
duke
parents:
diff changeset
    32
class Form;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    33
// ***** Top Level, 1, classes  *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
    34
class InstructForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    35
class OperandForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    36
class OpClassForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    37
class AttributeForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    38
class RegisterForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    39
class PipelineForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    40
class SourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    41
class Peephole;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    42
// ***** Level 2 classes *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
    43
class Component;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    44
class Predicate;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    45
class MatchRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    46
class Encode;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    47
class Attribute;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    48
class Effect;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    49
class ExpandRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    50
class RewriteRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    51
class Constraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    52
class ConstructRule;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    53
// ***** Register Section *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
    54
class RegDef;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    55
class RegClass;
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 24425
diff changeset
    56
class CodeSnippetRegClass;
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 24425
diff changeset
    57
class ConditionalRegClass;
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
    58
class AllocClass;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    59
class ResourceForm;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    60
// ***** Pipeline Section *****
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 RegList;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    64
// ***** Peephole Section *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
    65
class PeepMatch;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    66
class PeepConstraint;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    67
class PeepReplace;
489c9b5090e2 Initial load
duke
parents:
diff changeset
    68
489c9b5090e2 Initial load
duke
parents:
diff changeset
    69
extern char *toUpper(const char *str);
489c9b5090e2 Initial load
duke
parents:
diff changeset
    70
489c9b5090e2 Initial load
duke
parents:
diff changeset
    71
//---------------------------ADLParser-----------------------------------------
489c9b5090e2 Initial load
duke
parents:
diff changeset
    72
class ADLParser {
489c9b5090e2 Initial load
duke
parents:
diff changeset
    73
protected:
489c9b5090e2 Initial load
duke
parents:
diff changeset
    74
  char     *_curline;           // Start of current line
489c9b5090e2 Initial load
duke
parents:
diff changeset
    75
  char     *_ptr;               // Pointer into current location in File Buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    76
  char      _curchar;           // Current character from buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
    77
  FormDict &_globalNames;       // Global names
489c9b5090e2 Initial load
duke
parents:
diff changeset
    78
489c9b5090e2 Initial load
duke
parents:
diff changeset
    79
  enum { _preproc_limit = 20 };
489c9b5090e2 Initial load
duke
parents:
diff changeset
    80
  int       _preproc_depth;                 // How deep are we into ifdefs?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    81
  int       _preproc_not_taken;             // How deep in not-taken ifdefs?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    82
  bool      _preproc_taken[_preproc_limit]; // Are we taking this ifdef level?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    83
  bool      _preproc_else[_preproc_limit];  // Did this level have an else yet?
489c9b5090e2 Initial load
duke
parents:
diff changeset
    84
489c9b5090e2 Initial load
duke
parents:
diff changeset
    85
  // ***** Level 1 Parse functions *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
    86
  void instr_parse(void);       // Parse instruction definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    87
  void oper_parse(void);        // Parse operand definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    88
  void opclass_parse(void);     // Parse operand class definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    89
  void ins_attr_parse(void);    // Parse instruction attrubute definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    90
  void op_attr_parse(void);     // Parse operand attrubute definitions
489c9b5090e2 Initial load
duke
parents:
diff changeset
    91
  void source_parse(void);      // Parse source section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    92
  void source_hpp_parse(void);  // Parse source_hpp section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    93
  void reg_parse(void);         // Parse register section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    94
  void encode_parse(void);      // Parse encoding section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    95
  void frame_parse(void);       // Parse frame section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    96
  void pipe_parse(void);        // Parse pipeline section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    97
  void definitions_parse(void); // Parse definitions section
489c9b5090e2 Initial load
duke
parents:
diff changeset
    98
  void peep_parse(void);        // Parse peephole rule definitions
1662
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
    99
  void preproc_line(void);      // Parse a #line statement
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   100
  void preproc_define(void);    // Parse a #define statement
489c9b5090e2 Initial load
duke
parents:
diff changeset
   101
  void preproc_undef(void);     // Parse an #undef statement
489c9b5090e2 Initial load
duke
parents:
diff changeset
   102
489c9b5090e2 Initial load
duke
parents:
diff changeset
   103
  // Helper functions for instr_parse().
489c9b5090e2 Initial load
duke
parents:
diff changeset
   104
  void adjust_set_rule(InstructForm *instr);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   105
  void matchrule_clone_and_swap(MatchRule *rule, const char* instr_ident, int& match_rules_cnt);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   106
489c9b5090e2 Initial load
duke
parents:
diff changeset
   107
  // ***** Level 2 Parse functions *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
   108
  // Parse the components of the encode section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   109
  void enc_class_parse(void);   // Parse encoding class definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   110
  void enc_class_parse_block(EncClass* encoding, char* ec_name);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   111
489c9b5090e2 Initial load
duke
parents:
diff changeset
   112
  // Parse the components of the frame section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   113
  void stack_dir_parse(FrameForm *frame);   // Parse the stack direction entry
489c9b5090e2 Initial load
duke
parents:
diff changeset
   114
  void sync_stack_slots_parse(FrameForm *frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   115
  void frame_pointer_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   116
  void interpreter_frame_pointer_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   117
  void inline_cache_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   118
  void interpreter_arg_ptr_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   119
  void interpreter_method_oop_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   120
  void cisc_spilling_operand_name_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   121
  void stack_alignment_parse(FrameForm *frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   122
  void return_addr_parse(FrameForm *frame, bool native);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   123
  void preserve_stack_parse(FrameForm *frame);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   124
  char *calling_convention_parse();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   125
  char *return_value_parse();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   126
489c9b5090e2 Initial load
duke
parents:
diff changeset
   127
  // Parse components of the register section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   128
  void reg_def_parse(void);              // Parse register definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   129
  void reg_class_parse(void);            // Parse register class definition
30202
6f5c48bd9b82 8075798: Allow ADLC register class to depend on runtime conditions also for cisc-spillable classes
zmajo
parents: 24425
diff changeset
   130
  void reg_class_dynamic_parse(void);    // Parse dynamic register class definition
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   131
  void alloc_class_parse(void);          // Parse allocation class definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   132
489c9b5090e2 Initial load
duke
parents:
diff changeset
   133
  // Parse components of the definition section
489c9b5090e2 Initial load
duke
parents:
diff changeset
   134
  void int_def_parse(void);              // Parse an integer definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   135
489c9b5090e2 Initial load
duke
parents:
diff changeset
   136
  // Parse components of a pipeline rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   137
  void resource_parse(PipelineForm &pipe);   // Parse resource definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   138
  void pipe_desc_parse(PipelineForm &pipe);  // Parse pipeline description definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   139
  void pipe_class_parse(PipelineForm &pipe); // Parse pipeline class definition
489c9b5090e2 Initial load
duke
parents:
diff changeset
   140
489c9b5090e2 Initial load
duke
parents:
diff changeset
   141
  // Parse components of a peephole rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   142
  void peep_match_parse(Peephole &peep);     // Parse the peephole match rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   143
  void peep_constraint_parse(Peephole &peep);// Parse the peephole constraints
489c9b5090e2 Initial load
duke
parents:
diff changeset
   144
  void peep_replace_parse(Peephole &peep);   // Parse peephole replacement rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   145
489c9b5090e2 Initial load
duke
parents:
diff changeset
   146
  // Parse the peep match rule tree
489c9b5090e2 Initial load
duke
parents:
diff changeset
   147
  InstructForm *peep_match_child_parse(PeepMatch &match, int parent, int &position, int input);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   148
489c9b5090e2 Initial load
duke
parents:
diff changeset
   149
  // Parse components of an operand and/or instruction form
489c9b5090e2 Initial load
duke
parents:
diff changeset
   150
  Predicate     *pred_parse(void);       // Parse predicate rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   151
  // Parse match rule, and internal nodes
489c9b5090e2 Initial load
duke
parents:
diff changeset
   152
  MatchRule     *match_parse(FormDict &operands);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   153
  MatchNode     *matchNode_parse(FormDict &operands, int &depth,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   154
                                 int &numleaves, bool atroot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   155
  MatchNode     *matchChild_parse(FormDict &operands, int &depth,
489c9b5090e2 Initial load
duke
parents:
diff changeset
   156
                                  int &numleaves, bool atroot);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   157
489c9b5090e2 Initial load
duke
parents:
diff changeset
   158
  Attribute     *attr_parse(char *ident);// Parse instr/operand attribute rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   159
  // Parse instruction encode rule
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   160
  void           ins_encode_parse(InstructForm &inst);
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   161
  void           ins_encode_parse_block(InstructForm &inst);
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   162
  void           ins_encode_parse_block_impl(InstructForm& inst, EncClass* encoding, char* ec_name);
22844
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 11196
diff changeset
   163
  // Parse instruction postalloc expand rule.
90f76a40ed8a 8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents: 11196
diff changeset
   164
  void           postalloc_expand_parse(InstructForm &inst);
7433
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   165
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   166
  void           constant_parse(InstructForm& inst);
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   167
  void           constant_parse_expression(EncClass* encoding, char* ec_name);
b418028612ad 6961690: load oops from constant table on SPARC
twisti
parents: 7397
diff changeset
   168
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   169
  Opcode        *opcode_parse(InstructForm *insr); // Parse instruction opcode
489c9b5090e2 Initial load
duke
parents:
diff changeset
   170
  char          *size_parse(InstructForm *insr); // Parse instruction size
489c9b5090e2 Initial load
duke
parents:
diff changeset
   171
  Interface     *interface_parse();      // Parse operand interface rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   172
  Interface     *mem_interface_parse();  // Parse memory interface rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   173
  Interface     *cond_interface_parse(); // Parse conditional interface rule
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   174
  char          *interface_field_parse(const char** format = NULL);// Parse field contents
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   175
489c9b5090e2 Initial load
duke
parents:
diff changeset
   176
  FormatRule    *format_parse(void);     // Parse format rule
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   177
  FormatRule    *template_parse(void);     // Parse format rule
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   178
  void           effect_parse(InstructForm *instr); // Parse effect rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   179
  ExpandRule    *expand_parse(InstructForm *instr); // Parse expand rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   180
  RewriteRule   *rewrite_parse(void);    // Parse rewrite rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   181
  Constraint    *constraint_parse(void); // Parse constraint rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   182
  ConstructRule *construct_parse(void);  // Parse construct rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   183
  void           ins_pipe_parse(InstructForm &instr); // Parse ins_pipe rule
489c9b5090e2 Initial load
duke
parents:
diff changeset
   184
489c9b5090e2 Initial load
duke
parents:
diff changeset
   185
  // ***** Preprocessor functions *****
489c9b5090e2 Initial load
duke
parents:
diff changeset
   186
  void begin_if_def(bool taken) {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   187
    assert(_preproc_depth < _preproc_limit, "#ifdef nesting limit");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   188
    int ppn = _preproc_depth++;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   189
    _preproc_taken[ppn] = taken;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   190
    // Invariant:  _preproc_not_taken = SUM !_preproc_taken[0.._preproc_depth)
489c9b5090e2 Initial load
duke
parents:
diff changeset
   191
    if (!_preproc_taken[ppn])  _preproc_not_taken += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   192
    _preproc_else[ppn] = false;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   193
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   194
  void invert_if_def() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   195
    assert(_preproc_depth > 0, "#ifdef matching");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   196
    int ppn = _preproc_depth - 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   197
    assert(!_preproc_else[ppn], "multiple #else lines");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   198
    _preproc_else[ppn] = true;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   199
    if (!_preproc_taken[ppn])  _preproc_not_taken -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   200
    _preproc_taken[ppn] = !_preproc_taken[ppn];
489c9b5090e2 Initial load
duke
parents:
diff changeset
   201
    if (!_preproc_taken[ppn])  _preproc_not_taken += 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   202
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   203
  void end_if_def() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   204
    assert(_preproc_depth > 0, "#ifdef matching");
489c9b5090e2 Initial load
duke
parents:
diff changeset
   205
    int ppn = --_preproc_depth;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   206
    if (!_preproc_taken[ppn])  _preproc_not_taken -= 1;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   207
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   208
  bool preproc_taken() {
489c9b5090e2 Initial load
duke
parents:
diff changeset
   209
    // Return true only if there is no directive hiding this text position.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   210
    return _preproc_not_taken == 0;
489c9b5090e2 Initial load
duke
parents:
diff changeset
   211
  }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   212
  // Handle a '#' token.  Return true if it disappeared.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   213
  bool handle_preproc_token();
489c9b5090e2 Initial load
duke
parents:
diff changeset
   214
489c9b5090e2 Initial load
duke
parents:
diff changeset
   215
  // ***** Utility Functions for ADL Parser ******
489c9b5090e2 Initial load
duke
parents:
diff changeset
   216
489c9b5090e2 Initial load
duke
parents:
diff changeset
   217
  // Parse one string argument inside parens:  '(' string ')' ';'
489c9b5090e2 Initial load
duke
parents:
diff changeset
   218
  char *parse_one_arg(const char *description);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   219
489c9b5090e2 Initial load
duke
parents:
diff changeset
   220
  // Return the next identifier given a pointer into a line of the buffer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   221
  char *get_ident()            { return get_ident_common(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   222
  char *get_ident_no_preproc() { return get_ident_common(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   223
  char *get_ident_common(bool do_preproc);      // Grab it from the file buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   224
  char *get_ident_dup(void);    // Grab a duplicate of the identifier
489c9b5090e2 Initial load
duke
parents:
diff changeset
   225
  char *get_ident_or_literal_constant(const char* description);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   226
  // Grab unique identifier from file buffer
489c9b5090e2 Initial load
duke
parents:
diff changeset
   227
  char *get_unique_ident(FormDict &dict, const char *nameDescription);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   228
  // Return the next replacement variable identifier
489c9b5090e2 Initial load
duke
parents:
diff changeset
   229
  char *get_rep_var_ident(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   230
  // Skip first '$' and make a duplicate of the string
489c9b5090e2 Initial load
duke
parents:
diff changeset
   231
  char *get_rep_var_ident_dup(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   232
  // Return the next token given as a signed integer.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   233
  int   get_int(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   234
  // Return the next token, a relational operator { ==, !=, <=, >= }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   235
  char *get_relation_dup(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   236
489c9b5090e2 Initial load
duke
parents:
diff changeset
   237
  void  get_oplist(NameList &parameters, FormDict &operands);// Parse type-operand pairs
11196
a310a659c580 7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents: 7433
diff changeset
   238
  void  get_effectlist(FormDict &effects, FormDict &operands, bool& has_call); // Parse effect-operand pairs
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   239
  // Return the contents of a parenthesized expression.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   240
  // Requires initial '(' and consumes final ')', which is replaced by '\0'.
1662
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   241
  char *get_paren_expr(const char *description, bool include_location = false);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   242
  // Return expression up to next stop-char, which terminator replaces.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   243
  // Does not require initial '('.  Does not consume final stop-char.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   244
  // Final stop-char is left in _curchar, but is also is replaced by '\0'.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   245
  char *get_expr(const char *description, const char *stop_chars);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   246
  char *find_cpp_block(const char *description); // Parse a C++ code block
489c9b5090e2 Initial load
duke
parents:
diff changeset
   247
  // Issue parser error message & go to EOL
489c9b5090e2 Initial load
duke
parents:
diff changeset
   248
  void parse_err(int flag, const char *fmt, ...);
1662
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   249
  // Create a location marker for this file and line.
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   250
  char *get_line_string(int linenum = 0);
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   251
  // Return a location marker which tells the C preprocessor to
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   252
  // forget the previous location marker.  (Requires awk postprocessing.)
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   253
  char *end_line_marker() { return (char*)"\n#line 999999\n"; }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   254
489c9b5090e2 Initial load
duke
parents:
diff changeset
   255
  // Return pointer to current character
489c9b5090e2 Initial load
duke
parents:
diff changeset
   256
  inline char  cur_char(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   257
  // Advance to next character, assign this to _curchar
489c9b5090e2 Initial load
duke
parents:
diff changeset
   258
  inline void  next_char(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   259
  inline void  next_char_or_line(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   260
  // Advance File Buffer to next line, updating _curline
489c9b5090e2 Initial load
duke
parents:
diff changeset
   261
  inline void  next_line(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   262
  // Issue an error if we are not at the beginning of a line (exc. whitespace).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   263
  void ensure_start_of_line(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   264
  // Issue an error if we are not at the end of a line (exc. whitespace).
489c9b5090e2 Initial load
duke
parents:
diff changeset
   265
  void ensure_end_of_line(void);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   266
  // Skip whitespace, leaving ptr pointing to first non-whitespace character
489c9b5090e2 Initial load
duke
parents:
diff changeset
   267
  // Also handle preprocessor constructs like "#ifdef".
489c9b5090e2 Initial load
duke
parents:
diff changeset
   268
  void skipws()                { skipws_common(true); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   269
  // Skip comments and spaces but not newlines or preprocessor constructs.
489c9b5090e2 Initial load
duke
parents:
diff changeset
   270
  void skipws_no_preproc()     { skipws_common(false); }
489c9b5090e2 Initial load
duke
parents:
diff changeset
   271
  void skipws_common(bool do_preproc);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   272
489c9b5090e2 Initial load
duke
parents:
diff changeset
   273
  FileBuff &_buf;               // File buffer to be parsed
489c9b5090e2 Initial load
duke
parents:
diff changeset
   274
  ArchDesc &_AD;                // Architecture Description being built
489c9b5090e2 Initial load
duke
parents:
diff changeset
   275
489c9b5090e2 Initial load
duke
parents:
diff changeset
   276
public:
489c9b5090e2 Initial load
duke
parents:
diff changeset
   277
489c9b5090e2 Initial load
duke
parents:
diff changeset
   278
  ADLParser(FileBuff &buf, ArchDesc &archDesc); // Create new ADLParser object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   279
  ~ADLParser();                 // Destroy ADLParser object
489c9b5090e2 Initial load
duke
parents:
diff changeset
   280
489c9b5090e2 Initial load
duke
parents:
diff changeset
   281
  void parse(void);             // Do the parsing & build forms lists
489c9b5090e2 Initial load
duke
parents:
diff changeset
   282
1495
128fe18951ed 6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents: 1
diff changeset
   283
  int linenum() { return _buf.linenum(); }
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   284
489c9b5090e2 Initial load
duke
parents:
diff changeset
   285
  static bool is_literal_constant(const char *hex_string);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   286
  static bool is_hex_digit(char digit);
489c9b5090e2 Initial load
duke
parents:
diff changeset
   287
  static bool is_int_token(const char* token, int& intval);
1662
76a93a5fb765 6771309: debugging AD files is difficult without #line directives in generated code
jrose
parents: 1495
diff changeset
   288
  static bool equivalent_expressions(const char* str1, const char* str2);
1
489c9b5090e2 Initial load
duke
parents:
diff changeset
   289
  static void trim(char* &token);  // trim leading & trailing spaces
489c9b5090e2 Initial load
duke
parents:
diff changeset
   290
};
7397
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   291
5b173b4ca846 6989984: Use standard include model for Hospot
stefank
parents: 5547
diff changeset
   292
#endif // SHARE_VM_ADLC_ADLPARSE_HPP