1 /*
2 * Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
106 FormList _opclass; // List of Operand Class Forms for output
107 FormList _attributes; // List of Attribute Forms for parsing
108 RegisterForm *_register; // Only one Register Form allowed
109 FrameForm *_frame; // Describe stack-frame layout
110 EncodeForm *_encode; // Only one Encode Form allowed
111 PipelineForm *_pipeline; // Pipeline Form for output
112
113 bool _has_match_rule[_last_opcode]; // found AD rule for ideal node in <arch>.ad
114
115 MatchList *_mlistab[_last_opcode]; // Array of MatchLists
116
117 // The Architecture Description identifies which user-defined operand can be used
118 // to access [stack_pointer + offset]
119 OperandForm *_cisc_spill_operand;
120
121 // Methods for outputting the DFA
122 void gen_match(FILE *fp, MatchList &mlist, ProductionState &status, Dict &operands_chained_from);
123 void chain_rule(FILE *fp, const char *indent, const char *ideal,
124 const Expr *icost, const char *irule,
125 Dict &operands_chained_from, ProductionState &status);
126 void chain_rule_c(FILE *fp, char *indent, char *ideal, char *irule); // %%%%% TODO: remove this
127 void expand_opclass(FILE *fp, const char *indent, const Expr *cost,
128 const char *result_type, ProductionState &status);
129 Expr *calc_cost(FILE *fp, const char *spaces, MatchList &mList, ProductionState &status);
130 void prune_matchlist(Dict &minimize, MatchList &mlist);
131
132 // Helper function that outputs code to generate an instruction in MachNodeGenerator
133 void buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *indent);
134
135 public:
136 ArchDesc();
137 ~ArchDesc();
138
139 // Option flags which control miscellaneous behaviors throughout the code
140 int _TotalLines; // Line Counter
141 int _no_output; // Flag to disable output of DFA, etc.
142 int _quiet_mode; // Do not output banner messages, etc.
143 int _disable_warnings; // Do not output warning messages
144 int _dfa_debug; // Debug Flag for generated DFA
145 int _dfa_small; // Debug Flag for generated DFA
146 int _adl_debug; // Debug Flag for ADLC
276 void addSunCopyright(char* legal, int size, FILE *fp);
277 // output #include declarations for machine specific files
278 void machineDependentIncludes(ADLFILE &adlfile);
279 // Output C preprocessor code to verify the backend compilation environment.
280 void addPreprocessorChecks(FILE *fp);
281 // Output C source and header (source_hpp) blocks.
282 void addPreHeaderBlocks(FILE *fp_hpp);
283 void addHeaderBlocks(FILE *fp_hpp);
284 void addSourceBlocks(FILE *fp_cpp);
285 void generate_adlc_verification(FILE *fp_cpp);
286
287 // output declaration of class State
288 void defineStateClass(FILE *fp);
289
290 // Generator for MachOper objects given integer type
291 void buildMachOperGenerator(FILE *fp_cpp);
292 // Generator for MachNode objects given integer type
293 void buildMachNodeGenerator(FILE *fp_cpp);
294
295 // Generator for Expand methods for instructions with expand rules
296 void defineExpand(FILE *fp, InstructForm *node);
297 // Generator for Peephole methods for instructions with peephole rules
298 void definePeephole(FILE *fp, InstructForm *node);
299 // Generator for Size methods for instructions
300 void defineSize(FILE *fp, InstructForm &node);
301 // Generator for Emit methods for instructions
302 void defineEmit(FILE *fp, InstructForm &node);
303 // Define a MachOper encode method
304 void define_oper_interface(FILE *fp, OperandForm &oper, FormDict &globals,
305 const char *name, const char *encoding);
306
307 // Methods to construct the MachNode class hierarchy
308 // Return the type signature for the ideal operation
309 const char *getIdealType(const char *idealOp);
310 // Declare and define the classes derived from MachOper and MachNode
311 void declareClasses(FILE *fp_hpp);
312 void defineClasses(FILE *fp_cpp);
313
314 // Emit an ADLC message
315 void internal_err( const char *fmt, ...);
316 void syntax_err ( int lineno, const char *fmt, ...);
317 int emit_msg(int quiet, int flag, int linenum, const char *fmt,
318 va_list args);
319
320 // Generator for has_match_rule methods
321 void buildInstructMatchCheck(FILE *fp_cpp) const;
322
|
1 /*
2 * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
106 FormList _opclass; // List of Operand Class Forms for output
107 FormList _attributes; // List of Attribute Forms for parsing
108 RegisterForm *_register; // Only one Register Form allowed
109 FrameForm *_frame; // Describe stack-frame layout
110 EncodeForm *_encode; // Only one Encode Form allowed
111 PipelineForm *_pipeline; // Pipeline Form for output
112
113 bool _has_match_rule[_last_opcode]; // found AD rule for ideal node in <arch>.ad
114
115 MatchList *_mlistab[_last_opcode]; // Array of MatchLists
116
117 // The Architecture Description identifies which user-defined operand can be used
118 // to access [stack_pointer + offset]
119 OperandForm *_cisc_spill_operand;
120
121 // Methods for outputting the DFA
122 void gen_match(FILE *fp, MatchList &mlist, ProductionState &status, Dict &operands_chained_from);
123 void chain_rule(FILE *fp, const char *indent, const char *ideal,
124 const Expr *icost, const char *irule,
125 Dict &operands_chained_from, ProductionState &status);
126 void expand_opclass(FILE *fp, const char *indent, const Expr *cost,
127 const char *result_type, ProductionState &status);
128 Expr *calc_cost(FILE *fp, const char *spaces, MatchList &mList, ProductionState &status);
129 void prune_matchlist(Dict &minimize, MatchList &mlist);
130
131 // Helper function that outputs code to generate an instruction in MachNodeGenerator
132 void buildMachNode(FILE *fp_cpp, InstructForm *inst, const char *indent);
133
134 public:
135 ArchDesc();
136 ~ArchDesc();
137
138 // Option flags which control miscellaneous behaviors throughout the code
139 int _TotalLines; // Line Counter
140 int _no_output; // Flag to disable output of DFA, etc.
141 int _quiet_mode; // Do not output banner messages, etc.
142 int _disable_warnings; // Do not output warning messages
143 int _dfa_debug; // Debug Flag for generated DFA
144 int _dfa_small; // Debug Flag for generated DFA
145 int _adl_debug; // Debug Flag for ADLC
275 void addSunCopyright(char* legal, int size, FILE *fp);
276 // output #include declarations for machine specific files
277 void machineDependentIncludes(ADLFILE &adlfile);
278 // Output C preprocessor code to verify the backend compilation environment.
279 void addPreprocessorChecks(FILE *fp);
280 // Output C source and header (source_hpp) blocks.
281 void addPreHeaderBlocks(FILE *fp_hpp);
282 void addHeaderBlocks(FILE *fp_hpp);
283 void addSourceBlocks(FILE *fp_cpp);
284 void generate_adlc_verification(FILE *fp_cpp);
285
286 // output declaration of class State
287 void defineStateClass(FILE *fp);
288
289 // Generator for MachOper objects given integer type
290 void buildMachOperGenerator(FILE *fp_cpp);
291 // Generator for MachNode objects given integer type
292 void buildMachNodeGenerator(FILE *fp_cpp);
293
294 // Generator for Expand methods for instructions with expand rules
295 void defineExpand (FILE *fp, InstructForm *node);
296 // Generator for Peephole methods for instructions with peephole rules
297 void definePeephole (FILE *fp, InstructForm *node);
298 // Generator for Size methods for instructions
299 void defineSize (FILE *fp, InstructForm &node);
300
301 public:
302 // Generator for EvalConstantValue methods for instructions
303 void defineEvalConstant(FILE *fp, InstructForm &node);
304 // Generator for Emit methods for instructions
305 void defineEmit (FILE *fp, InstructForm &node);
306
307 // Define a MachOper encode method
308 void define_oper_interface(FILE *fp, OperandForm &oper, FormDict &globals,
309 const char *name, const char *encoding);
310
311 // Methods to construct the MachNode class hierarchy
312 // Return the type signature for the ideal operation
313 const char *getIdealType(const char *idealOp);
314 // Declare and define the classes derived from MachOper and MachNode
315 void declareClasses(FILE *fp_hpp);
316 void defineClasses(FILE *fp_cpp);
317
318 // Emit an ADLC message
319 void internal_err( const char *fmt, ...);
320 void syntax_err ( int lineno, const char *fmt, ...);
321 int emit_msg(int quiet, int flag, int linenum, const char *fmt,
322 va_list args);
323
324 // Generator for has_match_rule methods
325 void buildInstructMatchCheck(FILE *fp_cpp) const;
326
|