annotate src/share/vm/adlc/adlparse.hpp @ 1972:f95d63e2154a

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