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