annotate src/share/vm/adlc/archDesc.hpp @ 17716:cdb71841f4bc

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