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/archDesc.hpp
+++ new/src/share/vm/adlc/archDesc.hpp
1 1 /*
2 - * Copyright (c) 1997, 2007, 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 // Definitions for Error Flags
26 26 #define WARN 0
27 27 #define SYNERR 1
28 28 #define SEMERR 2
29 29 #define INTERNAL_ERR 3
30 30
31 31 // Minimal declarations for include files
32 32 class OutputMap;
33 33 class ProductionState;
34 34 class Expr;
35 35
36 36 // STRUCTURE FOR HANDLING INPUT AND OUTPUT FILES
37 37 typedef BufferedFile ADLFILE;
38 38
39 39 //---------------------------ChainList-----------------------------------------
40 40 class ChainList {
41 41 NameList _name;
42 42 NameList _cost;
43 43 NameList _rule;
44 44
45 45 public:
46 46 void insert(const char *name, const char *cost, const char *rule);
47 47 bool search(const char *name);
48 48
49 49 void reset();
50 50 bool iter(const char * &name, const char * &cost, const char * &rule);
51 51
52 52 void dump();
53 53 void output(FILE *fp);
54 54
55 55 ChainList();
56 56 ~ChainList();
57 57 };
58 58
59 59 //---------------------------MatchList-----------------------------------------
60 60 class MatchList {
61 61 private:
62 62 MatchList *_next;
63 63 Predicate *_pred; // Predicate which applies to this match rule
64 64 const char *_cost;
65 65
66 66 public:
67 67 const char *_opcode;
68 68 const char *_resultStr;
69 69 const char *_lchild;
70 70 const char *_rchild;
71 71
72 72 MatchList(MatchList *nxt, Predicate *prd): _next(nxt), _pred(prd), _cost(NULL){
73 73 _resultStr = _lchild = _rchild = _opcode = NULL; }
74 74
75 75 MatchList(MatchList *nxt, Predicate *prd, const char *cost,
76 76 const char *opcode, const char *resultStr, const char *lchild,
77 77 const char *rchild)
78 78 : _next(nxt), _pred(prd), _cost(cost), _opcode(opcode),
79 79 _resultStr(resultStr), _lchild(lchild), _rchild(rchild) { }
80 80
81 81 MatchList *get_next(void) { return _next; }
82 82 char *get_pred(void) { return (_pred?_pred->_pred:NULL); }
83 83 Predicate *get_pred_obj(void) { return _pred; }
84 84 const char *get_cost(void) { return _cost == NULL ? "0" :_cost; }
85 85 bool search(const char *opc, const char *res, const char *lch,
86 86 const char *rch, Predicate *pr);
87 87
88 88 void dump();
89 89 void output(FILE *fp);
90 90 };
91 91
92 92 //---------------------------ArchDesc------------------------------------------
93 93 class ArchDesc {
94 94 private:
95 95 FormDict _globalNames; // Global names
96 96 Dict _idealIndex; // Map ideal names to index in enumeration
97 97 ExprDict _globalDefs; // Global definitions, #defines
98 98 int _internalOpCounter; // Internal Operand Counter
99 99
100 100 FormList _header; // List of Source Code Forms for hpp file
101 101 FormList _pre_header; // ditto for the very top of the hpp file
102 102 FormList _source; // List of Source Code Forms for output
103 103 FormList _instructions; // List of Instruction Forms for output
104 104 FormList _machnodes; // List of Node Classes (special for pipelining)
105 105 FormList _operands; // List of Operand Forms for output
106 106 FormList _opclass; // List of Operand Class Forms for output
107 107 FormList _attributes; // List of Attribute Forms for parsing
108 108 RegisterForm *_register; // Only one Register Form allowed
109 109 FrameForm *_frame; // Describe stack-frame layout
110 110 EncodeForm *_encode; // Only one Encode Form allowed
111 111 PipelineForm *_pipeline; // Pipeline Form for output
112 112
113 113 bool _has_match_rule[_last_opcode]; // found AD rule for ideal node in <arch>.ad
114 114
115 115 MatchList *_mlistab[_last_opcode]; // Array of MatchLists
↓ open down ↓ |
103 lines elided |
↑ open up ↑ |
116 116
117 117 // The Architecture Description identifies which user-defined operand can be used
118 118 // to access [stack_pointer + offset]
119 119 OperandForm *_cisc_spill_operand;
120 120
121 121 // Methods for outputting the DFA
122 122 void gen_match(FILE *fp, MatchList &mlist, ProductionState &status, Dict &operands_chained_from);
123 123 void chain_rule(FILE *fp, const char *indent, const char *ideal,
124 124 const Expr *icost, const char *irule,
125 125 Dict &operands_chained_from, ProductionState &status);
126 - void chain_rule_c(FILE *fp, char *indent, char *ideal, char *irule); // %%%%% TODO: remove this
127 126 void expand_opclass(FILE *fp, const char *indent, const Expr *cost,
128 127 const char *result_type, ProductionState &status);
129 128 Expr *calc_cost(FILE *fp, const char *spaces, MatchList &mList, ProductionState &status);
130 129 void prune_matchlist(Dict &minimize, MatchList &mlist);
131 130
132 131 // Helper function that outputs code to generate an instruction in MachNodeGenerator
133 132 void buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *indent);
134 133
135 134 public:
136 135 ArchDesc();
137 136 ~ArchDesc();
138 137
139 138 // Option flags which control miscellaneous behaviors throughout the code
140 139 int _TotalLines; // Line Counter
141 140 int _no_output; // Flag to disable output of DFA, etc.
142 141 int _quiet_mode; // Do not output banner messages, etc.
143 142 int _disable_warnings; // Do not output warning messages
144 143 int _dfa_debug; // Debug Flag for generated DFA
145 144 int _dfa_small; // Debug Flag for generated DFA
146 145 int _adl_debug; // Debug Flag for ADLC
147 146 int _adlocation_debug; // Debug Flag to use ad file locations
148 147 bool _cisc_spill_debug; // Debug Flag to see cisc-spill-instructions
149 148 bool _short_branch_debug; // Debug Flag to see short branch instructions
150 149
151 150 // Error/Warning Counts
152 151 int _syntax_errs; // Count of syntax errors
153 152 int _semantic_errs; // Count of semantic errors
154 153 int _warnings; // Count warnings
155 154 int _internal_errs; // Count of internal errors
156 155
157 156 // Accessor for private data.
158 157 void has_match_rule(int opc, const bool b) { _has_match_rule[opc] = b; }
159 158
160 159 // I/O Files
161 160 ADLFILE _ADL_file; // Input Architecture Description File
162 161 // Machine dependent files, built from architecture definition
163 162 ADLFILE _DFA_file; // File for definition of Matcher::DFA
164 163 ADLFILE _HPP_file; // File for ArchNode class declarations
165 164 ADLFILE _CPP_file; // File for ArchNode class defintions
166 165 ADLFILE _CPP_CLONE_file; // File for MachNode/Oper clone defintions
167 166 ADLFILE _CPP_EXPAND_file; // File for MachNode expand methods
168 167 ADLFILE _CPP_FORMAT_file; // File for MachNode/Oper format defintions
169 168 ADLFILE _CPP_GEN_file; // File for MachNode/Oper generator methods
170 169 ADLFILE _CPP_MISC_file; // File for miscellaneous MachNode/Oper tables & methods
171 170 ADLFILE _CPP_PEEPHOLE_file; // File for MachNode peephole methods
172 171 ADLFILE _CPP_PIPELINE_file; // File for MachNode pipeline defintions
173 172 ADLFILE _VM_file; // File for constants needed in VM code
174 173 ADLFILE _bug_file; // DFA debugging file
175 174
176 175 // I/O helper methods
177 176 int open_file(bool required, ADLFILE & adf, const char *action);
178 177 void close_file(int delete_out, ADLFILE & adf);
179 178 int open_files(void);
180 179 void close_files(int delete_out);
181 180
182 181 Dict _chainRules; // Maps user operand names to ChainRules
183 182 Dict _internalOps; // Maps match strings to internal operand names
184 183 NameList _internalOpNames; // List internal operand names
185 184 Dict _internalMatch; // Map internal name to its MatchNode
186 185
187 186 NameList _preproc_list; // Preprocessor flag names
188 187 FormDict _preproc_table;// Preprocessor flag bindings
189 188 char* get_preproc_def(const char* flag);
190 189 void set_preproc_def(const char* flag, const char* def);
191 190
192 191 FormDict& globalNames() {return _globalNames;} // map global names to forms
193 192 void initKeywords(FormDict& globals); // Add keywords to global name table
194 193
195 194 ExprDict& globalDefs() {return _globalDefs;} // map global names to expressions
196 195
197 196 OperandForm *constructOperand(const char *ident, bool ideal_only);
198 197 void initBaseOpTypes(); // Import predefined base types.
199 198
200 199 void addForm(PreHeaderForm *ptr); // Add objects to pre-header list
201 200 void addForm(HeaderForm *ptr); // Add objects to header list
202 201 void addForm(SourceForm *ptr); // Add objects to source list
203 202 void addForm(EncodeForm *ptr); // Add objects to encode list
204 203 void addForm(InstructForm *ptr); // Add objects to the instruct list
205 204 void addForm(OperandForm *ptr); // Add objects to the operand list
206 205 void addForm(OpClassForm *ptr); // Add objects to the opclasss list
207 206 void addForm(AttributeForm *ptr); // Add objects to the attributes list
208 207 void addForm(RegisterForm *ptr); // Add objects to the register list
209 208 void addForm(FrameForm *ptr); // Add objects to the frame list
210 209 void addForm(PipelineForm *ptr); // Add objects to the pipeline list
211 210 void addForm(MachNodeForm *ptr); // Add objects to the machnode list
212 211
213 212 int operandFormCount(); // Count number of OperandForms defined
214 213 int opclassFormCount(); // Count number of OpClassForms defined
215 214 int instructFormCount(); // Count number of InstructForms defined
216 215
217 216 inline void getForm(EncodeForm **ptr) { *ptr = _encode; }
218 217
219 218 bool verify();
220 219 void dump();
221 220
222 221 // Helper utility that gets MatchList components from inside MatchRule
223 222 void check_optype(MatchRule *mrule);
224 223 void build_chain_rule(OperandForm *oper);
225 224 void add_chain_rule_entry(const char *src, const char *cost,
226 225 const char *result);
227 226 const char *getMatchListIndex(MatchRule &mrule);
228 227 void generateMatchLists(); // Build MatchList array and populate it
229 228 void inspectOperands(); // Build MatchLists for all operands
230 229 void inspectOpClasses(); // Build MatchLists for all operands
231 230 void inspectInstructions(); // Build MatchLists for all operands
232 231 void buildDFA(FILE *fp); // Driver for constructing the DFA
233 232 void gen_dfa_state_body(FILE *fp, Dict &minmize, ProductionState &status, Dict &chained, int i); // Driver for constructing the DFA state bodies
234 233
235 234 // Helper utilities to generate reduction maps for internal operands
236 235 const char *reduceLeft (char *internalName);
237 236 const char *reduceRight(char *internalName);
238 237
239 238 // Build enumerations, (1) dense operand index, (2) operands and opcodes
240 239 const char *machOperEnum(const char *opName); // create dense index names using static function
241 240 static const char *getMachOperEnum(const char *opName);// create dense index name
242 241 void buildMachOperEnum(FILE *fp_hpp);// dense enumeration for operands
243 242 void buildMachOpcodesEnum(FILE *fp_hpp);// enumeration for MachOpers & MachNodes
244 243
245 244 // Helper utilities to generate Register Masks
246 245 RegisterForm *get_registers() { return _register; }
247 246 const char *reg_mask(OperandForm &opForm);
248 247 const char *reg_mask(InstructForm &instForm);
249 248 const char *reg_class_to_reg_mask(const char *reg_class);
250 249 char *stack_or_reg_mask(OperandForm &opForm); // name of cisc_spillable version
251 250 // This register class should also generate a stack_or_reg_mask
252 251 void set_stack_or_reg(const char *reg_class_name); // for cisc-spillable reg classes
253 252 // Generate an enumeration of register mask names and the RegMask objects.
254 253 void declare_register_masks(FILE *fp_cpp);
255 254 void build_register_masks(FILE *fp_cpp);
256 255 // Generate enumeration of machine register numbers
257 256 void buildMachRegisterNumbers(FILE *fp_hpp);
258 257 // Generate enumeration of machine register encodings
259 258 void buildMachRegisterEncodes(FILE *fp_hpp);
260 259 // Generate Regsiter Size Array
261 260 void declareRegSizes(FILE *fp_hpp);
262 261 // Generate Pipeline Class information
263 262 void declare_pipe_classes(FILE *fp_hpp);
264 263 // Generate Pipeline definitions
265 264 void build_pipeline_enums(FILE *fp_cpp);
266 265 // Generate Pipeline Class information
267 266 void build_pipe_classes(FILE *fp_cpp);
268 267
269 268 // Declare and define mappings from rules to result and input types
270 269 void build_map(OutputMap &map);
271 270 void buildReduceMaps(FILE *fp_hpp, FILE *fp_cpp);
272 271 // build flags for signaling that our machine needs this instruction cloned
273 272 void buildMustCloneMap(FILE *fp_hpp, FILE *fp_cpp);
274 273
275 274 // output SUN copyright info
276 275 void addSunCopyright(char* legal, int size, FILE *fp);
277 276 // output #include declarations for machine specific files
278 277 void machineDependentIncludes(ADLFILE &adlfile);
279 278 // Output C preprocessor code to verify the backend compilation environment.
280 279 void addPreprocessorChecks(FILE *fp);
281 280 // Output C source and header (source_hpp) blocks.
282 281 void addPreHeaderBlocks(FILE *fp_hpp);
283 282 void addHeaderBlocks(FILE *fp_hpp);
284 283 void addSourceBlocks(FILE *fp_cpp);
285 284 void generate_adlc_verification(FILE *fp_cpp);
↓ open down ↓ |
149 lines elided |
↑ open up ↑ |
286 285
287 286 // output declaration of class State
288 287 void defineStateClass(FILE *fp);
289 288
290 289 // Generator for MachOper objects given integer type
291 290 void buildMachOperGenerator(FILE *fp_cpp);
292 291 // Generator for MachNode objects given integer type
293 292 void buildMachNodeGenerator(FILE *fp_cpp);
294 293
295 294 // Generator for Expand methods for instructions with expand rules
296 - void defineExpand(FILE *fp, InstructForm *node);
295 + void defineExpand (FILE *fp, InstructForm *node);
297 296 // Generator for Peephole methods for instructions with peephole rules
298 - void definePeephole(FILE *fp, InstructForm *node);
297 + void definePeephole (FILE *fp, InstructForm *node);
299 298 // Generator for Size methods for instructions
300 - void defineSize(FILE *fp, InstructForm &node);
299 + void defineSize (FILE *fp, InstructForm &node);
300 +
301 +public:
302 + // Generator for EvalConstantValue methods for instructions
303 + void defineEvalConstant(FILE *fp, InstructForm &node);
301 304 // Generator for Emit methods for instructions
302 - void defineEmit(FILE *fp, InstructForm &node);
305 + void defineEmit (FILE *fp, InstructForm &node);
306 +
303 307 // Define a MachOper encode method
304 308 void define_oper_interface(FILE *fp, OperandForm &oper, FormDict &globals,
305 309 const char *name, const char *encoding);
306 310
307 311 // Methods to construct the MachNode class hierarchy
308 312 // Return the type signature for the ideal operation
309 313 const char *getIdealType(const char *idealOp);
310 314 // Declare and define the classes derived from MachOper and MachNode
311 315 void declareClasses(FILE *fp_hpp);
312 316 void defineClasses(FILE *fp_cpp);
313 317
314 318 // Emit an ADLC message
315 319 void internal_err( const char *fmt, ...);
316 320 void syntax_err ( int lineno, const char *fmt, ...);
317 321 int emit_msg(int quiet, int flag, int linenum, const char *fmt,
318 322 va_list args);
319 323
320 324 // Generator for has_match_rule methods
321 325 void buildInstructMatchCheck(FILE *fp_cpp) const;
322 326
323 327 // Generator for Frame Methods
324 328 void buildFrameMethods(FILE *fp_cpp);
325 329
326 330 // Generate CISC_spilling oracle and MachNode::cisc_spill() methods
327 331 void build_cisc_spill_instructions(FILE *fp_hpp, FILE *fp_cpp);
328 332 void identify_cisc_spill_instructions();
329 333 void identify_short_branches();
330 334 void identify_unique_operands();
331 335 void set_cisc_spill_operand(OperandForm *opForm) { _cisc_spill_operand = opForm; }
332 336 OperandForm *cisc_spill_operand() { return _cisc_spill_operand; }
333 337 bool can_cisc_spill() { return _cisc_spill_operand != NULL; }
334 338
335 339
336 340 protected:
337 341 // build MatchList from MatchRule
338 342 void buildMatchList(MatchRule *mrule, const char *resultStr,
339 343 const char *rootOp, Predicate *pred, const char *cost);
340 344
341 345 void buildMList(MatchNode *node, const char *rootOp, const char *resultOp,
342 346 Predicate *pred, const char *cost);
343 347
344 348 friend class ADLParser;
345 349
346 350 };
347 351
348 352
349 353 // -------------------------------- maps ------------------------------------
350 354
351 355 // Base class for generating a mapping from rule number to value.
352 356 // Used with ArchDesc::build_map() for all maps except "enum MachOperands"
353 357 // A derived class defines the appropriate output for a specific mapping.
354 358 class OutputMap {
355 359 protected:
356 360 FILE *_hpp;
357 361 FILE *_cpp;
358 362 FormDict &_globals;
359 363 ArchDesc &_AD;
360 364 public:
361 365 OutputMap (FILE *decl_file, FILE *def_file, FormDict &globals, ArchDesc &AD)
362 366 : _hpp(decl_file), _cpp(def_file), _globals(globals), _AD(AD) {};
363 367 // Access files used by this routine
364 368 FILE *decl_file() { return _hpp; }
365 369 FILE *def_file() { return _cpp; }
366 370 // Positions in iteration that derived class will be told about
367 371 enum position { BEGIN_OPERANDS,
368 372 BEGIN_OPCLASSES,
369 373 BEGIN_INTERNALS,
370 374 BEGIN_INSTRUCTIONS,
371 375 BEGIN_INST_CHAIN_RULES,
372 376 END_INST_CHAIN_RULES,
373 377 BEGIN_REMATERIALIZE,
374 378 END_REMATERIALIZE,
375 379 END_INSTRUCTIONS
376 380 };
377 381 // Output routines specific to the derived class
378 382 virtual void declaration() {}
379 383 virtual void definition() {}
380 384 virtual void closing() { fprintf(_cpp, "};\n"); }
381 385 virtual void map(OperandForm &oper) { }
382 386 virtual void map(OpClassForm &opc) { }
383 387 virtual void map(char *internal_name) { }
384 388 // Allow enum-MachOperands to turn-off instructions
385 389 virtual bool do_instructions() { return true; }
386 390 virtual void map(InstructForm &inst) { }
387 391 // Allow derived class to output name and position specific info
388 392 virtual void record_position(OutputMap::position place, int index) {}
389 393 };
↓ open down ↓ |
77 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX