Mercurial > hg > truffle
annotate src/share/vm/adlc/output_h.cpp @ 14714:b602356a9cfc
additional canonicalizers for accesses and value nodes (improves number of implicit null checks)
author | Lukas Stadler <lukas.stadler@oracle.com> |
---|---|
date | Thu, 20 Mar 2014 17:15:36 +0100 |
parents | abec000618bf |
children | 4ca6dc0799b6 17b2fbdb6637 |
rev | line source |
---|---|
0 | 1 /* |
14223
de6a9e811145
8029233: Update copyright year to match last edit in jdk8 hotspot repository for 2013
mikael
parents:
12323
diff
changeset
|
2 * Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1541
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
1541
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:
1541
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
25 // output_h.cpp - Class HPP file output routines for architecture definition | |
26 #include "adlc.hpp" | |
27 | |
6850 | 28 // The comment delimiter used in format statements after assembler instructions. |
14437
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
14434
diff
changeset
|
29 #if defined(PPC64) |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
14434
diff
changeset
|
30 #define commentSeperator "\t//" |
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
14434
diff
changeset
|
31 #else |
6850 | 32 #define commentSeperator "!" |
14437
15120a36272d
8028767: PPC64: (part 121): smaller shared changes needed to build C2
goetz
parents:
14434
diff
changeset
|
33 #endif |
0 | 34 |
35 // Generate the #define that describes the number of registers. | |
36 static void defineRegCount(FILE *fp, RegisterForm *registers) { | |
37 if (registers) { | |
38 int regCount = AdlcVMDeps::Physical + registers->_rdefs.count(); | |
39 fprintf(fp,"\n"); | |
40 fprintf(fp,"// the number of reserved registers + machine registers.\n"); | |
41 fprintf(fp,"#define REG_COUNT %d\n", regCount); | |
42 } | |
43 } | |
44 | |
45 // Output enumeration of machine register numbers | |
46 // (1) | |
47 // // Enumerate machine registers starting after reserved regs. | |
48 // // in the order of occurrence in the register block. | |
49 // enum MachRegisterNumbers { | |
50 // EAX_num = 0, | |
51 // ... | |
52 // _last_Mach_Reg | |
53 // } | |
54 void ArchDesc::buildMachRegisterNumbers(FILE *fp_hpp) { | |
55 if (_register) { | |
56 RegDef *reg_def = NULL; | |
57 | |
58 // Output a #define for the number of machine registers | |
59 defineRegCount(fp_hpp, _register); | |
60 | |
61 // Count all the Save_On_Entry and Always_Save registers | |
62 int saved_on_entry = 0; | |
63 int c_saved_on_entry = 0; | |
64 _register->reset_RegDefs(); | |
65 while( (reg_def = _register->iter_RegDefs()) != NULL ) { | |
66 if( strcmp(reg_def->_callconv,"SOE") == 0 || | |
67 strcmp(reg_def->_callconv,"AS") == 0 ) ++saved_on_entry; | |
68 if( strcmp(reg_def->_c_conv,"SOE") == 0 || | |
69 strcmp(reg_def->_c_conv,"AS") == 0 ) ++c_saved_on_entry; | |
70 } | |
71 fprintf(fp_hpp, "\n"); | |
72 fprintf(fp_hpp, "// the number of save_on_entry + always_saved registers.\n"); | |
73 fprintf(fp_hpp, "#define MAX_SAVED_ON_ENTRY_REG_COUNT %d\n", max(saved_on_entry,c_saved_on_entry)); | |
74 fprintf(fp_hpp, "#define SAVED_ON_ENTRY_REG_COUNT %d\n", saved_on_entry); | |
75 fprintf(fp_hpp, "#define C_SAVED_ON_ENTRY_REG_COUNT %d\n", c_saved_on_entry); | |
76 | |
77 // (1) | |
78 // Build definition for enumeration of register numbers | |
79 fprintf(fp_hpp, "\n"); | |
80 fprintf(fp_hpp, "// Enumerate machine register numbers starting after reserved regs.\n"); | |
81 fprintf(fp_hpp, "// in the order of occurrence in the register block.\n"); | |
82 fprintf(fp_hpp, "enum MachRegisterNumbers {\n"); | |
83 | |
84 // Output the register number for each register in the allocation classes | |
85 _register->reset_RegDefs(); | |
86 int i = 0; | |
87 while( (reg_def = _register->iter_RegDefs()) != NULL ) { | |
6850 | 88 fprintf(fp_hpp," %s_num,", reg_def->_regname); |
89 for (int j = 0; j < 20-(int)strlen(reg_def->_regname); j++) fprintf(fp_hpp, " "); | |
90 fprintf(fp_hpp," // enum %3d, regnum %3d, reg encode %3s\n", | |
91 i++, | |
92 reg_def->register_num(), | |
93 reg_def->register_encode()); | |
0 | 94 } |
95 // Finish defining enumeration | |
6850 | 96 fprintf(fp_hpp, " _last_Mach_Reg // %d\n", i); |
0 | 97 fprintf(fp_hpp, "};\n"); |
98 } | |
99 | |
100 fprintf(fp_hpp, "\n// Size of register-mask in ints\n"); | |
101 fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size()); | |
102 fprintf(fp_hpp, "// Unroll factor for loops over the data in a RegMask\n"); | |
103 fprintf(fp_hpp, "#define FORALL_BODY "); | |
104 int len = RegisterForm::RegMask_Size(); | |
105 for( int i = 0; i < len; i++ ) | |
106 fprintf(fp_hpp, "BODY(%d) ",i); | |
107 fprintf(fp_hpp, "\n\n"); | |
108 | |
109 fprintf(fp_hpp,"class RegMask;\n"); | |
110 // All RegMasks are declared "extern const ..." in ad_<arch>.hpp | |
111 // fprintf(fp_hpp,"extern RegMask STACK_OR_STACK_SLOTS_mask;\n\n"); | |
112 } | |
113 | |
114 | |
115 // Output enumeration of machine register encodings | |
116 // (2) | |
117 // // Enumerate machine registers starting after reserved regs. | |
118 // // in the order of occurrence in the alloc_class(es). | |
119 // enum MachRegisterEncodes { | |
120 // EAX_enc = 0x00, | |
121 // ... | |
122 // } | |
123 void ArchDesc::buildMachRegisterEncodes(FILE *fp_hpp) { | |
124 if (_register) { | |
125 RegDef *reg_def = NULL; | |
126 RegDef *reg_def_next = NULL; | |
127 | |
128 // (2) | |
129 // Build definition for enumeration of encode values | |
130 fprintf(fp_hpp, "\n"); | |
131 fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n"); | |
132 fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n"); | |
133 fprintf(fp_hpp, "enum MachRegisterEncodes {\n"); | |
134 | |
6850 | 135 // Find max enum string length. |
136 size_t maxlen = 0; | |
137 _register->reset_RegDefs(); | |
138 reg_def = _register->iter_RegDefs(); | |
139 while (reg_def != NULL) { | |
140 size_t len = strlen(reg_def->_regname); | |
141 if (len > maxlen) maxlen = len; | |
142 reg_def = _register->iter_RegDefs(); | |
143 } | |
144 | |
0 | 145 // Output the register encoding for each register in the allocation classes |
146 _register->reset_RegDefs(); | |
147 reg_def_next = _register->iter_RegDefs(); | |
148 while( (reg_def = reg_def_next) != NULL ) { | |
149 reg_def_next = _register->iter_RegDefs(); | |
6850 | 150 fprintf(fp_hpp," %s_enc", reg_def->_regname); |
151 for (size_t i = strlen(reg_def->_regname); i < maxlen; i++) fprintf(fp_hpp, " "); | |
152 fprintf(fp_hpp," = %3s%s\n", reg_def->register_encode(), reg_def_next == NULL? "" : "," ); | |
0 | 153 } |
154 // Finish defining enumeration | |
155 fprintf(fp_hpp, "};\n"); | |
156 | |
157 } // Done with register form | |
158 } | |
159 | |
160 | |
161 // Declare an array containing the machine register names, strings. | |
162 static void declareRegNames(FILE *fp, RegisterForm *registers) { | |
163 if (registers) { | |
164 // fprintf(fp,"\n"); | |
165 // fprintf(fp,"// An array of character pointers to machine register names.\n"); | |
166 // fprintf(fp,"extern const char *regName[];\n"); | |
167 } | |
168 } | |
169 | |
170 // Declare an array containing the machine register sizes in 32-bit words. | |
171 void ArchDesc::declareRegSizes(FILE *fp) { | |
172 // regSize[] is not used | |
173 } | |
174 | |
175 // Declare an array containing the machine register encoding values | |
176 static void declareRegEncodes(FILE *fp, RegisterForm *registers) { | |
177 if (registers) { | |
178 // // // | |
179 // fprintf(fp,"\n"); | |
180 // fprintf(fp,"// An array containing the machine register encode values\n"); | |
181 // fprintf(fp,"extern const char regEncode[];\n"); | |
182 } | |
183 } | |
184 | |
185 | |
186 // --------------------------------------------------------------------------- | |
187 //------------------------------Utilities to build Instruction Classes-------- | |
188 // --------------------------------------------------------------------------- | |
189 static void out_RegMask(FILE *fp) { | |
190 fprintf(fp," virtual const RegMask &out_RegMask() const;\n"); | |
191 } | |
192 | |
193 // --------------------------------------------------------------------------- | |
194 //--------Utilities to build MachOper and MachNode derived Classes------------ | |
195 // --------------------------------------------------------------------------- | |
196 | |
197 //------------------------------Utilities to build Operand Classes------------ | |
198 static void in_RegMask(FILE *fp) { | |
199 fprintf(fp," virtual const RegMask *in_RegMask(int index) const;\n"); | |
200 } | |
201 | |
202 static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) { | |
203 int i = 0; | |
204 Component *comp; | |
205 | |
206 if (oper->num_consts(globals) == 0) return; | |
207 // Iterate over the component list looking for constants | |
208 oper->_components.reset(); | |
209 if ((comp = oper->_components.iter()) == NULL) { | |
210 assert(oper->num_consts(globals) == 1, "Bad component list detected.\n"); | |
211 const char *type = oper->ideal_type(globals); | |
212 if (!strcmp(type, "ConI")) { | |
213 if (i > 0) fprintf(fp,", "); | |
214 fprintf(fp," int32 _c%d;\n", i); | |
215 } | |
216 else if (!strcmp(type, "ConP")) { | |
217 if (i > 0) fprintf(fp,", "); | |
218 fprintf(fp," const TypePtr *_c%d;\n", i); | |
219 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
220 else if (!strcmp(type, "ConN")) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
221 if (i > 0) fprintf(fp,", "); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
222 fprintf(fp," const TypeNarrowOop *_c%d;\n", i); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
223 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
224 else if (!strcmp(type, "ConNKlass")) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
225 if (i > 0) fprintf(fp,", "); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
226 fprintf(fp," const TypeNarrowKlass *_c%d;\n", i); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
227 } |
0 | 228 else if (!strcmp(type, "ConL")) { |
229 if (i > 0) fprintf(fp,", "); | |
230 fprintf(fp," jlong _c%d;\n", i); | |
231 } | |
232 else if (!strcmp(type, "ConF")) { | |
233 if (i > 0) fprintf(fp,", "); | |
234 fprintf(fp," jfloat _c%d;\n", i); | |
235 } | |
236 else if (!strcmp(type, "ConD")) { | |
237 if (i > 0) fprintf(fp,", "); | |
238 fprintf(fp," jdouble _c%d;\n", i); | |
239 } | |
240 else if (!strcmp(type, "Bool")) { | |
241 fprintf(fp,"private:\n"); | |
242 fprintf(fp," BoolTest::mask _c%d;\n", i); | |
243 fprintf(fp,"public:\n"); | |
244 } | |
245 else { | |
246 assert(0, "Non-constant operand lacks component list."); | |
247 } | |
248 } // end if NULL | |
249 else { | |
250 oper->_components.reset(); | |
251 while ((comp = oper->_components.iter()) != NULL) { | |
252 if (!strcmp(comp->base_type(globals), "ConI")) { | |
253 fprintf(fp," jint _c%d;\n", i); | |
254 i++; | |
255 } | |
256 else if (!strcmp(comp->base_type(globals), "ConP")) { | |
257 fprintf(fp," const TypePtr *_c%d;\n", i); | |
258 i++; | |
259 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
260 else if (!strcmp(comp->base_type(globals), "ConN")) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
261 fprintf(fp," const TypePtr *_c%d;\n", i); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
262 i++; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
263 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
264 else if (!strcmp(comp->base_type(globals), "ConNKlass")) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
265 fprintf(fp," const TypePtr *_c%d;\n", i); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
266 i++; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
267 } |
0 | 268 else if (!strcmp(comp->base_type(globals), "ConL")) { |
269 fprintf(fp," jlong _c%d;\n", i); | |
270 i++; | |
271 } | |
272 else if (!strcmp(comp->base_type(globals), "ConF")) { | |
273 fprintf(fp," jfloat _c%d;\n", i); | |
274 i++; | |
275 } | |
276 else if (!strcmp(comp->base_type(globals), "ConD")) { | |
277 fprintf(fp," jdouble _c%d;\n", i); | |
278 i++; | |
279 } | |
280 } | |
281 } | |
282 } | |
283 | |
284 // Declare constructor. | |
285 // Parameters start with condition code, then all other constants | |
286 // | |
287 // (0) public: | |
288 // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn) | |
289 // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { } | |
290 // | |
291 static void defineConstructor(FILE *fp, const char *name, uint num_consts, | |
292 ComponentList &lst, bool is_ideal_bool, | |
293 Form::DataType constant_type, FormDict &globals) { | |
294 fprintf(fp,"public:\n"); | |
295 // generate line (1) | |
296 fprintf(fp," %sOper(", name); | |
297 if( num_consts == 0 ) { | |
298 fprintf(fp,") {}\n"); | |
299 return; | |
300 } | |
301 | |
302 // generate parameters for constants | |
303 uint i = 0; | |
304 Component *comp; | |
305 lst.reset(); | |
306 if ((comp = lst.iter()) == NULL) { | |
307 assert(num_consts == 1, "Bad component list detected.\n"); | |
308 switch( constant_type ) { | |
309 case Form::idealI : { | |
310 fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i); | |
311 break; | |
312 } | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
313 case Form::idealN : { fprintf(fp,"const TypeNarrowOop *c%d", i); break; } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
314 case Form::idealNKlass : { fprintf(fp,"const TypeNarrowKlass *c%d", i); break; } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
315 case Form::idealP : { fprintf(fp,"const TypePtr *c%d", i); break; } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
316 case Form::idealL : { fprintf(fp,"jlong c%d", i); break; } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
317 case Form::idealF : { fprintf(fp,"jfloat c%d", i); break; } |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
318 case Form::idealD : { fprintf(fp,"jdouble c%d", i); break; } |
0 | 319 default: |
320 assert(!is_ideal_bool, "Non-constant operand lacks component list."); | |
321 break; | |
322 } | |
323 } // end if NULL | |
324 else { | |
325 lst.reset(); | |
326 while((comp = lst.iter()) != NULL) { | |
327 if (!strcmp(comp->base_type(globals), "ConI")) { | |
328 if (i > 0) fprintf(fp,", "); | |
329 fprintf(fp,"int32 c%d", i); | |
330 i++; | |
331 } | |
332 else if (!strcmp(comp->base_type(globals), "ConP")) { | |
333 if (i > 0) fprintf(fp,", "); | |
334 fprintf(fp,"const TypePtr *c%d", i); | |
335 i++; | |
336 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
337 else if (!strcmp(comp->base_type(globals), "ConN")) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
338 if (i > 0) fprintf(fp,", "); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
339 fprintf(fp,"const TypePtr *c%d", i); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
340 i++; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
341 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
342 else if (!strcmp(comp->base_type(globals), "ConNKlass")) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
343 if (i > 0) fprintf(fp,", "); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
344 fprintf(fp,"const TypePtr *c%d", i); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
345 i++; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
346 } |
0 | 347 else if (!strcmp(comp->base_type(globals), "ConL")) { |
348 if (i > 0) fprintf(fp,", "); | |
349 fprintf(fp,"jlong c%d", i); | |
350 i++; | |
351 } | |
352 else if (!strcmp(comp->base_type(globals), "ConF")) { | |
353 if (i > 0) fprintf(fp,", "); | |
354 fprintf(fp,"jfloat c%d", i); | |
355 i++; | |
356 } | |
357 else if (!strcmp(comp->base_type(globals), "ConD")) { | |
358 if (i > 0) fprintf(fp,", "); | |
359 fprintf(fp,"jdouble c%d", i); | |
360 i++; | |
361 } | |
362 else if (!strcmp(comp->base_type(globals), "Bool")) { | |
363 if (i > 0) fprintf(fp,", "); | |
364 fprintf(fp,"BoolTest::mask c%d", i); | |
365 i++; | |
366 } | |
367 } | |
368 } | |
369 // finish line (1) and start line (2) | |
370 fprintf(fp,") : "); | |
371 // generate initializers for constants | |
372 i = 0; | |
373 fprintf(fp,"_c%d(c%d)", i, i); | |
374 for( i = 1; i < num_consts; ++i) { | |
375 fprintf(fp,", _c%d(c%d)", i, i); | |
376 } | |
377 // The body for the constructor is empty | |
378 fprintf(fp," {}\n"); | |
379 } | |
380 | |
381 // --------------------------------------------------------------------------- | |
382 // Utilities to generate format rules for machine operands and instructions | |
383 // --------------------------------------------------------------------------- | |
384 | |
385 // Generate the format rule for condition codes | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
386 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
387 assert(oper != NULL, "what"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
388 CondInterface* cond = oper->_interface->is_CondInterface(); |
6850 | 389 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format); |
390 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format); | |
391 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format); | |
392 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format); | |
393 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format); | |
394 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format); | |
12323 | 395 fprintf(fp, " else if( _c%d == BoolTest::overflow ) st->print(\"%s\");\n",i,cond->_overflow_format); |
396 fprintf(fp, " else if( _c%d == BoolTest::no_overflow ) st->print(\"%s\");\n",i,cond->_no_overflow_format); | |
0 | 397 } |
398 | |
399 // Output code that dumps constant values, increment "i" if type is constant | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
400 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) { |
0 | 401 if (!strcmp(ideal_type, "ConI")) { |
402 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i); | |
6850 | 403 fprintf(fp," st->print(\"/0x%%08x\", _c%d);\n", i); |
0 | 404 ++i; |
405 } | |
406 else if (!strcmp(ideal_type, "ConP")) { | |
407 fprintf(fp," _c%d->dump_on(st);\n", i); | |
408 ++i; | |
409 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
410 else if (!strcmp(ideal_type, "ConN")) { |
417 | 411 fprintf(fp," _c%d->dump_on(st);\n", i); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
412 ++i; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
413 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
414 else if (!strcmp(ideal_type, "ConNKlass")) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
415 fprintf(fp," _c%d->dump_on(st);\n", i); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
416 ++i; |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
417 } |
0 | 418 else if (!strcmp(ideal_type, "ConL")) { |
419 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i); | |
6850 | 420 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%d);\n", i); |
0 | 421 ++i; |
422 } | |
423 else if (!strcmp(ideal_type, "ConF")) { | |
424 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); | |
6850 | 425 fprintf(fp," jint _c%di = JavaValue(_c%d).get_jint();\n", i, i); |
426 fprintf(fp," st->print(\"/0x%%x/\", _c%di);\n", i); | |
0 | 427 ++i; |
428 } | |
429 else if (!strcmp(ideal_type, "ConD")) { | |
430 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); | |
6850 | 431 fprintf(fp," jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i); |
432 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%dl);\n", i); | |
0 | 433 ++i; |
434 } | |
435 else if (!strcmp(ideal_type, "Bool")) { | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
436 defineCCodeDump(oper, fp,i); |
0 | 437 ++i; |
438 } | |
439 | |
440 return i; | |
441 } | |
442 | |
443 // Generate the format rule for an operand | |
444 void gen_oper_format(FILE *fp, FormDict &globals, OperandForm &oper, bool for_c_file = false) { | |
445 if (!for_c_file) { | |
446 // invoked after output #ifndef PRODUCT to ad_<arch>.hpp | |
447 // compile the bodies separately, to cut down on recompilations | |
448 fprintf(fp," virtual void int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const;\n"); | |
449 fprintf(fp," virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n"); | |
450 return; | |
451 } | |
452 | |
453 // Local pointer indicates remaining part of format rule | |
6850 | 454 int idx = 0; // position of operand in match rule |
0 | 455 |
456 // Generate internal format function, used when stored locally | |
457 fprintf(fp, "\n#ifndef PRODUCT\n"); | |
458 fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident); | |
459 // Generate the user-defined portion of the format | |
460 if (oper._format) { | |
461 if ( oper._format->_strings.count() != 0 ) { | |
462 // No initialization code for int_format | |
463 | |
464 // Build the format from the entries in strings and rep_vars | |
465 const char *string = NULL; | |
466 oper._format->_rep_vars.reset(); | |
467 oper._format->_strings.reset(); | |
468 while ( (string = oper._format->_strings.iter()) != NULL ) { | |
469 | |
470 // Check if this is a standard string or a replacement variable | |
471 if ( string != NameList::_signal ) { | |
472 // Normal string | |
473 // Pass through to st->print | |
6850 | 474 fprintf(fp," st->print(\"%s\");\n", string); |
0 | 475 } else { |
476 // Replacement variable | |
477 const char *rep_var = oper._format->_rep_vars.iter(); | |
478 // Check that it is a local name, and an operand | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
479 const Form* form = oper._localNames[rep_var]; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
480 if (form == NULL) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
481 globalAD->syntax_err(oper._linenum, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
482 "\'%s\' not found in format for %s\n", rep_var, oper._ident); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
483 assert(form, "replacement variable was not found in local names"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
484 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
485 OperandForm *op = form->is_operand(); |
0 | 486 // Get index if register or constant |
487 if ( op->_matrule && op->_matrule->is_base_register(globals) ) { | |
488 idx = oper.register_position( globals, rep_var); | |
489 } | |
490 else if (op->_matrule && op->_matrule->is_base_constant(globals)) { | |
491 idx = oper.constant_position( globals, rep_var); | |
492 } else { | |
493 idx = 0; | |
494 } | |
495 | |
496 // output invocation of "$..."s format function | |
6850 | 497 if ( op != NULL ) op->int_format(fp, globals, idx); |
0 | 498 |
499 if ( idx == -1 ) { | |
500 fprintf(stderr, | |
501 "Using a name, %s, that isn't in match rule\n", rep_var); | |
502 assert( strcmp(op->_ident,"label")==0, "Unimplemented"); | |
503 } | |
504 } // Done with a replacement variable | |
505 } // Done with all format strings | |
506 } else { | |
507 // Default formats for base operands (RegI, RegP, ConI, ConP, ...) | |
508 oper.int_format(fp, globals, 0); | |
509 } | |
510 | |
511 } else { // oper._format == NULL | |
512 // Provide a few special case formats where the AD writer cannot. | |
513 if ( strcmp(oper._ident,"Universe")==0 ) { | |
514 fprintf(fp, " st->print(\"$$univ\");\n"); | |
515 } | |
516 // labelOper::int_format is defined in ad_<...>.cpp | |
517 } | |
518 // ALWAYS! Provide a special case output for condition codes. | |
519 if( oper.is_ideal_bool() ) { | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
520 defineCCodeDump(&oper, fp,0); |
0 | 521 } |
522 fprintf(fp,"}\n"); | |
523 | |
524 // Generate external format function, when data is stored externally | |
525 fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident); | |
526 // Generate the user-defined portion of the format | |
527 if (oper._format) { | |
528 if ( oper._format->_strings.count() != 0 ) { | |
529 | |
530 // Check for a replacement string "$..." | |
531 if ( oper._format->_rep_vars.count() != 0 ) { | |
532 // Initialization code for ext_format | |
533 } | |
534 | |
535 // Build the format from the entries in strings and rep_vars | |
536 const char *string = NULL; | |
537 oper._format->_rep_vars.reset(); | |
538 oper._format->_strings.reset(); | |
539 while ( (string = oper._format->_strings.iter()) != NULL ) { | |
540 | |
541 // Check if this is a standard string or a replacement variable | |
542 if ( string != NameList::_signal ) { | |
543 // Normal string | |
544 // Pass through to st->print | |
6850 | 545 fprintf(fp," st->print(\"%s\");\n", string); |
0 | 546 } else { |
547 // Replacement variable | |
548 const char *rep_var = oper._format->_rep_vars.iter(); | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
549 // Check that it is a local name, and an operand |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
550 const Form* form = oper._localNames[rep_var]; |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
551 if (form == NULL) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
552 globalAD->syntax_err(oper._linenum, |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
553 "\'%s\' not found in format for %s\n", rep_var, oper._ident); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
554 assert(form, "replacement variable was not found in local names"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
555 } |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
556 OperandForm *op = form->is_operand(); |
0 | 557 // Get index if register or constant |
558 if ( op->_matrule && op->_matrule->is_base_register(globals) ) { | |
559 idx = oper.register_position( globals, rep_var); | |
560 } | |
561 else if (op->_matrule && op->_matrule->is_base_constant(globals)) { | |
562 idx = oper.constant_position( globals, rep_var); | |
563 } else { | |
564 idx = 0; | |
565 } | |
566 // output invocation of "$..."s format function | |
567 if ( op != NULL ) op->ext_format(fp, globals, idx); | |
568 | |
569 // Lookup the index position of the replacement variable | |
6850 | 570 idx = oper._components.operand_position_format(rep_var, &oper); |
0 | 571 if ( idx == -1 ) { |
572 fprintf(stderr, | |
573 "Using a name, %s, that isn't in match rule\n", rep_var); | |
574 assert( strcmp(op->_ident,"label")==0, "Unimplemented"); | |
575 } | |
576 } // Done with a replacement variable | |
577 } // Done with all format strings | |
578 | |
579 } else { | |
580 // Default formats for base operands (RegI, RegP, ConI, ConP, ...) | |
581 oper.ext_format(fp, globals, 0); | |
582 } | |
583 } else { // oper._format == NULL | |
584 // Provide a few special case formats where the AD writer cannot. | |
585 if ( strcmp(oper._ident,"Universe")==0 ) { | |
586 fprintf(fp, " st->print(\"$$univ\");\n"); | |
587 } | |
588 // labelOper::ext_format is defined in ad_<...>.cpp | |
589 } | |
590 // ALWAYS! Provide a special case output for condition codes. | |
591 if( oper.is_ideal_bool() ) { | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
592 defineCCodeDump(&oper, fp,0); |
0 | 593 } |
594 fprintf(fp, "}\n"); | |
595 fprintf(fp, "#endif\n"); | |
596 } | |
597 | |
598 | |
599 // Generate the format rule for an instruction | |
600 void gen_inst_format(FILE *fp, FormDict &globals, InstructForm &inst, bool for_c_file = false) { | |
601 if (!for_c_file) { | |
602 // compile the bodies separately, to cut down on recompilations | |
603 // #ifndef PRODUCT region generated by caller | |
604 fprintf(fp," virtual void format(PhaseRegAlloc *ra, outputStream *st) const;\n"); | |
605 return; | |
606 } | |
607 | |
608 // Define the format function | |
609 fprintf(fp, "#ifndef PRODUCT\n"); | |
610 fprintf(fp, "void %sNode::format(PhaseRegAlloc *ra, outputStream *st) const {\n", inst._ident); | |
611 | |
612 // Generate the user-defined portion of the format | |
613 if( inst._format ) { | |
614 // If there are replacement variables, | |
605 | 615 // Generate index values needed for determining the operand position |
0 | 616 if( inst._format->_rep_vars.count() ) |
617 inst.index_temps(fp, globals); | |
618 | |
619 // Build the format from the entries in strings and rep_vars | |
620 const char *string = NULL; | |
621 inst._format->_rep_vars.reset(); | |
622 inst._format->_strings.reset(); | |
623 while( (string = inst._format->_strings.iter()) != NULL ) { | |
6850 | 624 fprintf(fp," "); |
0 | 625 // Check if this is a standard string or a replacement variable |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
626 if( string == NameList::_signal ) { // Replacement variable |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
627 const char* rep_var = inst._format->_rep_vars.iter(); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
628 inst.rep_var_format( fp, rep_var); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
629 } else if( string == NameList::_signal3 ) { // Replacement variable in raw text |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
630 const char* rep_var = inst._format->_rep_vars.iter(); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
631 const Form *form = inst._localNames[rep_var]; |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
632 if (form == NULL) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
633 fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
634 assert(false, "ShouldNotReachHere()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
635 } |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
636 OpClassForm *opc = form->is_opclass(); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
637 assert( opc, "replacement variable was not found in local names"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
638 // Lookup the index position of the replacement variable |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
639 int idx = inst.operand_position_format(rep_var); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
640 if ( idx == -1 ) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
641 assert( strcmp(opc->_ident,"label")==0, "Unimplemented"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
642 assert( false, "ShouldNotReachHere()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
643 } |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
644 |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
645 if (inst.is_noninput_operand(idx)) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
646 assert( false, "ShouldNotReachHere()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
647 } else { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
648 // Output the format call for this operand |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
649 fprintf(fp,"opnd_array(%d)",idx); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
650 } |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
651 rep_var = inst._format->_rep_vars.iter(); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
652 inst._format->_strings.iter(); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
653 if ( strcmp(rep_var,"$constant") == 0 && opc->is_operand()) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
654 Form::DataType constant_type = form->is_operand()->is_base_constant(globals); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
655 if ( constant_type == Form::idealD ) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
656 fprintf(fp,"->constantD()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
657 } else if ( constant_type == Form::idealF ) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
658 fprintf(fp,"->constantF()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
659 } else if ( constant_type == Form::idealL ) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
660 fprintf(fp,"->constantL()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
661 } else { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
662 fprintf(fp,"->constant()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
663 } |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
664 } else if ( strcmp(rep_var,"$cmpcode") == 0) { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
665 fprintf(fp,"->ccode()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
666 } else { |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
667 assert( false, "ShouldNotReachHere()"); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
668 } |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
669 } else if( string == NameList::_signal2 ) // Raw program text |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
670 fputs(inst._format->_strings.iter(), fp); |
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
671 else |
0 | 672 fprintf(fp,"st->print(\"%s\");\n", string); |
673 } // Done with all format strings | |
674 } // Done generating the user-defined portion of the format | |
675 | |
676 // Add call debug info automatically | |
677 Form::CallType call_type = inst.is_ideal_call(); | |
678 if( call_type != Form::invalid_type ) { | |
679 switch( call_type ) { | |
680 case Form::JAVA_DYNAMIC: | |
6850 | 681 fprintf(fp," _method->print_short_name(st);\n"); |
0 | 682 break; |
683 case Form::JAVA_STATIC: | |
6850 | 684 fprintf(fp," if( _method ) _method->print_short_name(st);\n"); |
685 fprintf(fp," else st->print(\" wrapper for: %%s\", _name);\n"); | |
686 fprintf(fp," if( !_method ) dump_trap_args(st);\n"); | |
0 | 687 break; |
688 case Form::JAVA_COMPILED: | |
689 case Form::JAVA_INTERP: | |
690 break; | |
691 case Form::JAVA_RUNTIME: | |
692 case Form::JAVA_LEAF: | |
693 case Form::JAVA_NATIVE: | |
6850 | 694 fprintf(fp," st->print(\" %%s\", _name);"); |
0 | 695 break; |
696 default: | |
6850 | 697 assert(0,"ShouldNotReachHere"); |
0 | 698 } |
6850 | 699 fprintf(fp, " st->print_cr(\"\");\n" ); |
700 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); | |
701 fprintf(fp, " st->print(\" # \");\n" ); | |
702 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); | |
0 | 703 } |
704 else if(inst.is_ideal_safepoint()) { | |
6850 | 705 fprintf(fp, " st->print(\"\");\n" ); |
706 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); | |
707 fprintf(fp, " st->print(\" # \");\n" ); | |
708 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n"); | |
0 | 709 } |
710 else if( inst.is_ideal_if() ) { | |
6850 | 711 fprintf(fp, " st->print(\" P=%%f C=%%f\",_prob,_fcnt);\n" ); |
0 | 712 } |
713 else if( inst.is_ideal_mem() ) { | |
714 // Print out the field name if available to improve readability | |
6850 | 715 fprintf(fp, " if (ra->C->alias_type(adr_type())->field() != NULL) {\n"); |
716 fprintf(fp, " ciField* f = ra->C->alias_type(adr_type())->field();\n"); | |
717 fprintf(fp, " st->print(\" %s Field: \");\n", commentSeperator); | |
718 fprintf(fp, " if (f->is_volatile())\n"); | |
719 fprintf(fp, " st->print(\"volatile \");\n"); | |
720 fprintf(fp, " f->holder()->name()->print_symbol_on(st);\n"); | |
721 fprintf(fp, " st->print(\".\");\n"); | |
722 fprintf(fp, " f->name()->print_symbol_on(st);\n"); | |
723 fprintf(fp, " if (f->is_constant())\n"); | |
724 fprintf(fp, " st->print(\" (constant)\");\n"); | |
725 fprintf(fp, " } else {\n"); | |
0 | 726 // Make sure 'Volatile' gets printed out |
6266
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4120
diff
changeset
|
727 fprintf(fp, " if (ra->C->alias_type(adr_type())->is_volatile())\n"); |
1d7922586cf6
7023639: JSR 292 method handle invocation needs a fast path for compiled code
twisti
parents:
4120
diff
changeset
|
728 fprintf(fp, " st->print(\" volatile!\");\n"); |
6850 | 729 fprintf(fp, " }\n"); |
0 | 730 } |
731 | |
732 // Complete the definition of the format function | |
6850 | 733 fprintf(fp, "}\n#endif\n"); |
0 | 734 } |
735 | |
736 void ArchDesc::declare_pipe_classes(FILE *fp_hpp) { | |
737 if (!_pipeline) | |
738 return; | |
739 | |
740 fprintf(fp_hpp, "\n"); | |
741 fprintf(fp_hpp, "// Pipeline_Use_Cycle_Mask Class\n"); | |
742 fprintf(fp_hpp, "class Pipeline_Use_Cycle_Mask {\n"); | |
743 | |
744 if (_pipeline->_maxcycleused <= | |
745 #ifdef SPARC | |
746 64 | |
747 #else | |
748 32 | |
749 #endif | |
750 ) { | |
751 fprintf(fp_hpp, "protected:\n"); | |
752 fprintf(fp_hpp, " %s _mask;\n\n", _pipeline->_maxcycleused <= 32 ? "uint" : "uint64_t" ); | |
753 fprintf(fp_hpp, "public:\n"); | |
754 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : _mask(0) {}\n\n"); | |
755 if (_pipeline->_maxcycleused <= 32) | |
756 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask) : _mask(mask) {}\n\n"); | |
757 else { | |
758 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint mask1, uint mask2) : _mask((((uint64_t)mask1) << 32) | mask2) {}\n\n"); | |
759 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask(uint64_t mask) : _mask(mask) {}\n\n"); | |
760 } | |
761 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n"); | |
762 fprintf(fp_hpp, " _mask = in._mask;\n"); | |
763 fprintf(fp_hpp, " return *this;\n"); | |
764 fprintf(fp_hpp, " }\n\n"); | |
765 fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n"); | |
766 fprintf(fp_hpp, " return ((_mask & in2._mask) != 0);\n"); | |
767 fprintf(fp_hpp, " }\n\n"); | |
768 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n"); | |
769 fprintf(fp_hpp, " _mask <<= n;\n"); | |
770 fprintf(fp_hpp, " return *this;\n"); | |
771 fprintf(fp_hpp, " }\n\n"); | |
772 fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &in2) {\n"); | |
773 fprintf(fp_hpp, " _mask |= in2._mask;\n"); | |
774 fprintf(fp_hpp, " }\n\n"); | |
775 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n"); | |
776 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n"); | |
777 } | |
778 else { | |
779 fprintf(fp_hpp, "protected:\n"); | |
780 uint masklen = (_pipeline->_maxcycleused + 31) >> 5; | |
781 uint l; | |
782 fprintf(fp_hpp, " uint "); | |
783 for (l = 1; l <= masklen; l++) | |
784 fprintf(fp_hpp, "_mask%d%s", l, l < masklen ? ", " : ";\n\n"); | |
785 fprintf(fp_hpp, "public:\n"); | |
786 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask() : "); | |
787 for (l = 1; l <= masklen; l++) | |
788 fprintf(fp_hpp, "_mask%d(0)%s", l, l < masklen ? ", " : " {}\n\n"); | |
789 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask("); | |
790 for (l = 1; l <= masklen; l++) | |
791 fprintf(fp_hpp, "uint mask%d%s", l, l < masklen ? ", " : ") : "); | |
792 for (l = 1; l <= masklen; l++) | |
793 fprintf(fp_hpp, "_mask%d(mask%d)%s", l, l, l < masklen ? ", " : " {}\n\n"); | |
794 | |
795 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator=(const Pipeline_Use_Cycle_Mask &in) {\n"); | |
796 for (l = 1; l <= masklen; l++) | |
797 fprintf(fp_hpp, " _mask%d = in._mask%d;\n", l, l); | |
798 fprintf(fp_hpp, " return *this;\n"); | |
799 fprintf(fp_hpp, " }\n\n"); | |
800 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask intersect(const Pipeline_Use_Cycle_Mask &in2) {\n"); | |
801 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask out;\n"); | |
802 for (l = 1; l <= masklen; l++) | |
803 fprintf(fp_hpp, " out._mask%d = _mask%d & in2._mask%d;\n", l, l, l); | |
804 fprintf(fp_hpp, " return out;\n"); | |
805 fprintf(fp_hpp, " }\n\n"); | |
806 fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Cycle_Mask &in2) const {\n"); | |
807 fprintf(fp_hpp, " return ("); | |
808 for (l = 1; l <= masklen; l++) | |
809 fprintf(fp_hpp, "((_mask%d & in2._mask%d) != 0)%s", l, l, l < masklen ? " || " : ""); | |
810 fprintf(fp_hpp, ") ? true : false;\n"); | |
811 fprintf(fp_hpp, " }\n\n"); | |
812 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask& operator<<=(int n) {\n"); | |
813 fprintf(fp_hpp, " if (n >= 32)\n"); | |
814 fprintf(fp_hpp, " do {\n "); | |
815 for (l = masklen; l > 1; l--) | |
816 fprintf(fp_hpp, " _mask%d = _mask%d;", l, l-1); | |
817 fprintf(fp_hpp, " _mask%d = 0;\n", 1); | |
818 fprintf(fp_hpp, " } while ((n -= 32) >= 32);\n\n"); | |
819 fprintf(fp_hpp, " if (n > 0) {\n"); | |
820 fprintf(fp_hpp, " uint m = 32 - n;\n"); | |
821 fprintf(fp_hpp, " uint mask = (1 << n) - 1;\n"); | |
822 fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n;\n", 2, 1, 1); | |
823 for (l = 2; l < masklen; l++) { | |
824 fprintf(fp_hpp, " uint temp%d = mask & (_mask%d >> m); _mask%d <<= n; _mask%d |= temp%d;\n", l+1, l, l, l, l); | |
825 } | |
826 fprintf(fp_hpp, " _mask%d <<= n; _mask%d |= temp%d;\n", masklen, masklen, masklen); | |
827 fprintf(fp_hpp, " }\n"); | |
828 | |
829 fprintf(fp_hpp, " return *this;\n"); | |
830 fprintf(fp_hpp, " }\n\n"); | |
831 fprintf(fp_hpp, " void Or(const Pipeline_Use_Cycle_Mask &);\n\n"); | |
832 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator&(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n"); | |
833 fprintf(fp_hpp, " friend Pipeline_Use_Cycle_Mask operator|(const Pipeline_Use_Cycle_Mask &, const Pipeline_Use_Cycle_Mask &);\n\n"); | |
834 } | |
835 | |
836 fprintf(fp_hpp, " friend class Pipeline_Use;\n\n"); | |
837 fprintf(fp_hpp, " friend class Pipeline_Use_Element;\n\n"); | |
838 fprintf(fp_hpp, "};\n\n"); | |
839 | |
840 uint rescount = 0; | |
841 const char *resource; | |
842 | |
843 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { | |
844 int mask = _pipeline->_resdict[resource]->is_resource()->mask(); | |
845 if ((mask & (mask-1)) == 0) | |
846 rescount++; | |
847 } | |
848 | |
849 fprintf(fp_hpp, "// Pipeline_Use_Element Class\n"); | |
850 fprintf(fp_hpp, "class Pipeline_Use_Element {\n"); | |
851 fprintf(fp_hpp, "protected:\n"); | |
852 fprintf(fp_hpp, " // Mask of used functional units\n"); | |
853 fprintf(fp_hpp, " uint _used;\n\n"); | |
854 fprintf(fp_hpp, " // Lower and upper bound of functional unit number range\n"); | |
855 fprintf(fp_hpp, " uint _lb, _ub;\n\n"); | |
856 fprintf(fp_hpp, " // Indicates multiple functionals units available\n"); | |
857 fprintf(fp_hpp, " bool _multiple;\n\n"); | |
858 fprintf(fp_hpp, " // Mask of specific used cycles\n"); | |
859 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask _mask;\n\n"); | |
860 fprintf(fp_hpp, "public:\n"); | |
861 fprintf(fp_hpp, " Pipeline_Use_Element() {}\n\n"); | |
862 fprintf(fp_hpp, " Pipeline_Use_Element(uint used, uint lb, uint ub, bool multiple, Pipeline_Use_Cycle_Mask mask)\n"); | |
863 fprintf(fp_hpp, " : _used(used), _lb(lb), _ub(ub), _multiple(multiple), _mask(mask) {}\n\n"); | |
864 fprintf(fp_hpp, " uint used() const { return _used; }\n\n"); | |
865 fprintf(fp_hpp, " uint lowerBound() const { return _lb; }\n\n"); | |
866 fprintf(fp_hpp, " uint upperBound() const { return _ub; }\n\n"); | |
867 fprintf(fp_hpp, " bool multiple() const { return _multiple; }\n\n"); | |
868 fprintf(fp_hpp, " Pipeline_Use_Cycle_Mask mask() const { return _mask; }\n\n"); | |
869 fprintf(fp_hpp, " bool overlaps(const Pipeline_Use_Element &in2) const {\n"); | |
870 fprintf(fp_hpp, " return ((_used & in2._used) != 0 && _mask.overlaps(in2._mask));\n"); | |
871 fprintf(fp_hpp, " }\n\n"); | |
872 fprintf(fp_hpp, " void step(uint cycles) {\n"); | |
873 fprintf(fp_hpp, " _used = 0;\n"); | |
874 fprintf(fp_hpp, " _mask <<= cycles;\n"); | |
875 fprintf(fp_hpp, " }\n\n"); | |
876 fprintf(fp_hpp, " friend class Pipeline_Use;\n"); | |
877 fprintf(fp_hpp, "};\n\n"); | |
878 | |
879 fprintf(fp_hpp, "// Pipeline_Use Class\n"); | |
880 fprintf(fp_hpp, "class Pipeline_Use {\n"); | |
881 fprintf(fp_hpp, "protected:\n"); | |
882 fprintf(fp_hpp, " // These resources can be used\n"); | |
883 fprintf(fp_hpp, " uint _resources_used;\n\n"); | |
884 fprintf(fp_hpp, " // These resources are used; excludes multiple choice functional units\n"); | |
885 fprintf(fp_hpp, " uint _resources_used_exclusively;\n\n"); | |
886 fprintf(fp_hpp, " // Number of elements\n"); | |
887 fprintf(fp_hpp, " uint _count;\n\n"); | |
888 fprintf(fp_hpp, " // This is the array of Pipeline_Use_Elements\n"); | |
889 fprintf(fp_hpp, " Pipeline_Use_Element * _elements;\n\n"); | |
890 fprintf(fp_hpp, "public:\n"); | |
891 fprintf(fp_hpp, " Pipeline_Use(uint resources_used, uint resources_used_exclusively, uint count, Pipeline_Use_Element *elements)\n"); | |
892 fprintf(fp_hpp, " : _resources_used(resources_used)\n"); | |
893 fprintf(fp_hpp, " , _resources_used_exclusively(resources_used_exclusively)\n"); | |
894 fprintf(fp_hpp, " , _count(count)\n"); | |
895 fprintf(fp_hpp, " , _elements(elements)\n"); | |
896 fprintf(fp_hpp, " {}\n\n"); | |
897 fprintf(fp_hpp, " uint resourcesUsed() const { return _resources_used; }\n\n"); | |
898 fprintf(fp_hpp, " uint resourcesUsedExclusively() const { return _resources_used_exclusively; }\n\n"); | |
899 fprintf(fp_hpp, " uint count() const { return _count; }\n\n"); | |
900 fprintf(fp_hpp, " Pipeline_Use_Element * element(uint i) const { return &_elements[i]; }\n\n"); | |
901 fprintf(fp_hpp, " uint full_latency(uint delay, const Pipeline_Use &pred) const;\n\n"); | |
902 fprintf(fp_hpp, " void add_usage(const Pipeline_Use &pred);\n\n"); | |
903 fprintf(fp_hpp, " void reset() {\n"); | |
904 fprintf(fp_hpp, " _resources_used = _resources_used_exclusively = 0;\n"); | |
905 fprintf(fp_hpp, " };\n\n"); | |
906 fprintf(fp_hpp, " void step(uint cycles) {\n"); | |
907 fprintf(fp_hpp, " reset();\n"); | |
908 fprintf(fp_hpp, " for (uint i = 0; i < %d; i++)\n", | |
909 rescount); | |
910 fprintf(fp_hpp, " (&_elements[i])->step(cycles);\n"); | |
911 fprintf(fp_hpp, " };\n\n"); | |
912 fprintf(fp_hpp, " static const Pipeline_Use elaborated_use;\n"); | |
913 fprintf(fp_hpp, " static const Pipeline_Use_Element elaborated_elements[%d];\n\n", | |
914 rescount); | |
915 fprintf(fp_hpp, " friend class Pipeline;\n"); | |
916 fprintf(fp_hpp, "};\n\n"); | |
917 | |
918 fprintf(fp_hpp, "// Pipeline Class\n"); | |
919 fprintf(fp_hpp, "class Pipeline {\n"); | |
920 fprintf(fp_hpp, "public:\n"); | |
921 | |
922 fprintf(fp_hpp, " static bool enabled() { return %s; }\n\n", | |
923 _pipeline ? "true" : "false" ); | |
924 | |
925 assert( _pipeline->_maxInstrsPerBundle && | |
926 ( _pipeline->_instrUnitSize || _pipeline->_bundleUnitSize) && | |
927 _pipeline->_instrFetchUnitSize && | |
928 _pipeline->_instrFetchUnits, | |
929 "unspecified pipeline architecture units"); | |
930 | |
931 uint unitSize = _pipeline->_instrUnitSize ? _pipeline->_instrUnitSize : _pipeline->_bundleUnitSize; | |
932 | |
933 fprintf(fp_hpp, " enum {\n"); | |
934 fprintf(fp_hpp, " _variable_size_instructions = %d,\n", | |
935 _pipeline->_variableSizeInstrs ? 1 : 0); | |
936 fprintf(fp_hpp, " _fixed_size_instructions = %d,\n", | |
937 _pipeline->_variableSizeInstrs ? 0 : 1); | |
938 fprintf(fp_hpp, " _branch_has_delay_slot = %d,\n", | |
939 _pipeline->_branchHasDelaySlot ? 1 : 0); | |
940 fprintf(fp_hpp, " _max_instrs_per_bundle = %d,\n", | |
941 _pipeline->_maxInstrsPerBundle); | |
942 fprintf(fp_hpp, " _max_bundles_per_cycle = %d,\n", | |
943 _pipeline->_maxBundlesPerCycle); | |
944 fprintf(fp_hpp, " _max_instrs_per_cycle = %d\n", | |
945 _pipeline->_maxBundlesPerCycle * _pipeline->_maxInstrsPerBundle); | |
946 fprintf(fp_hpp, " };\n\n"); | |
947 | |
948 fprintf(fp_hpp, " static bool instr_has_unit_size() { return %s; }\n\n", | |
949 _pipeline->_instrUnitSize != 0 ? "true" : "false" ); | |
950 if( _pipeline->_bundleUnitSize != 0 ) | |
951 if( _pipeline->_instrUnitSize != 0 ) | |
952 fprintf(fp_hpp, "// Individual Instructions may be bundled together by the hardware\n\n"); | |
953 else | |
954 fprintf(fp_hpp, "// Instructions exist only in bundles\n\n"); | |
955 else | |
956 fprintf(fp_hpp, "// Bundling is not supported\n\n"); | |
957 if( _pipeline->_instrUnitSize != 0 ) | |
958 fprintf(fp_hpp, " // Size of an instruction\n"); | |
959 else | |
960 fprintf(fp_hpp, " // Size of an individual instruction does not exist - unsupported\n"); | |
961 fprintf(fp_hpp, " static uint instr_unit_size() {"); | |
962 if( _pipeline->_instrUnitSize == 0 ) | |
963 fprintf(fp_hpp, " assert( false, \"Instructions are only in bundles\" );"); | |
964 fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_instrUnitSize); | |
965 | |
966 if( _pipeline->_bundleUnitSize != 0 ) | |
967 fprintf(fp_hpp, " // Size of a bundle\n"); | |
968 else | |
969 fprintf(fp_hpp, " // Bundles do not exist - unsupported\n"); | |
970 fprintf(fp_hpp, " static uint bundle_unit_size() {"); | |
971 if( _pipeline->_bundleUnitSize == 0 ) | |
972 fprintf(fp_hpp, " assert( false, \"Bundles are not supported\" );"); | |
973 fprintf(fp_hpp, " return %d; };\n\n", _pipeline->_bundleUnitSize); | |
974 | |
975 fprintf(fp_hpp, " static bool requires_bundling() { return %s; }\n\n", | |
976 _pipeline->_bundleUnitSize != 0 && _pipeline->_instrUnitSize == 0 ? "true" : "false" ); | |
977 | |
978 fprintf(fp_hpp, "private:\n"); | |
979 fprintf(fp_hpp, " Pipeline(); // Not a legal constructor\n"); | |
980 fprintf(fp_hpp, "\n"); | |
981 fprintf(fp_hpp, " const unsigned char _read_stage_count;\n"); | |
982 fprintf(fp_hpp, " const unsigned char _write_stage;\n"); | |
983 fprintf(fp_hpp, " const unsigned char _fixed_latency;\n"); | |
984 fprintf(fp_hpp, " const unsigned char _instruction_count;\n"); | |
985 fprintf(fp_hpp, " const bool _has_fixed_latency;\n"); | |
986 fprintf(fp_hpp, " const bool _has_branch_delay;\n"); | |
987 fprintf(fp_hpp, " const bool _has_multiple_bundles;\n"); | |
988 fprintf(fp_hpp, " const bool _force_serialization;\n"); | |
989 fprintf(fp_hpp, " const bool _may_have_no_code;\n"); | |
990 fprintf(fp_hpp, " const enum machPipelineStages * const _read_stages;\n"); | |
991 fprintf(fp_hpp, " const enum machPipelineStages * const _resource_stage;\n"); | |
992 fprintf(fp_hpp, " const uint * const _resource_cycles;\n"); | |
993 fprintf(fp_hpp, " const Pipeline_Use _resource_use;\n"); | |
994 fprintf(fp_hpp, "\n"); | |
995 fprintf(fp_hpp, "public:\n"); | |
996 fprintf(fp_hpp, " Pipeline(uint write_stage,\n"); | |
997 fprintf(fp_hpp, " uint count,\n"); | |
998 fprintf(fp_hpp, " bool has_fixed_latency,\n"); | |
999 fprintf(fp_hpp, " uint fixed_latency,\n"); | |
1000 fprintf(fp_hpp, " uint instruction_count,\n"); | |
1001 fprintf(fp_hpp, " bool has_branch_delay,\n"); | |
1002 fprintf(fp_hpp, " bool has_multiple_bundles,\n"); | |
1003 fprintf(fp_hpp, " bool force_serialization,\n"); | |
1004 fprintf(fp_hpp, " bool may_have_no_code,\n"); | |
1005 fprintf(fp_hpp, " enum machPipelineStages * const dst,\n"); | |
1006 fprintf(fp_hpp, " enum machPipelineStages * const stage,\n"); | |
1007 fprintf(fp_hpp, " uint * const cycles,\n"); | |
1008 fprintf(fp_hpp, " Pipeline_Use resource_use)\n"); | |
1009 fprintf(fp_hpp, " : _write_stage(write_stage)\n"); | |
1010 fprintf(fp_hpp, " , _read_stage_count(count)\n"); | |
1011 fprintf(fp_hpp, " , _has_fixed_latency(has_fixed_latency)\n"); | |
1012 fprintf(fp_hpp, " , _fixed_latency(fixed_latency)\n"); | |
1013 fprintf(fp_hpp, " , _read_stages(dst)\n"); | |
1014 fprintf(fp_hpp, " , _resource_stage(stage)\n"); | |
1015 fprintf(fp_hpp, " , _resource_cycles(cycles)\n"); | |
1016 fprintf(fp_hpp, " , _resource_use(resource_use)\n"); | |
1017 fprintf(fp_hpp, " , _instruction_count(instruction_count)\n"); | |
1018 fprintf(fp_hpp, " , _has_branch_delay(has_branch_delay)\n"); | |
1019 fprintf(fp_hpp, " , _has_multiple_bundles(has_multiple_bundles)\n"); | |
1020 fprintf(fp_hpp, " , _force_serialization(force_serialization)\n"); | |
1021 fprintf(fp_hpp, " , _may_have_no_code(may_have_no_code)\n"); | |
1022 fprintf(fp_hpp, " {};\n"); | |
1023 fprintf(fp_hpp, "\n"); | |
1024 fprintf(fp_hpp, " uint writeStage() const {\n"); | |
1025 fprintf(fp_hpp, " return (_write_stage);\n"); | |
1026 fprintf(fp_hpp, " }\n"); | |
1027 fprintf(fp_hpp, "\n"); | |
1028 fprintf(fp_hpp, " enum machPipelineStages readStage(int ndx) const {\n"); | |
1029 fprintf(fp_hpp, " return (ndx < _read_stage_count ? _read_stages[ndx] : stage_undefined);"); | |
1030 fprintf(fp_hpp, " }\n\n"); | |
1031 fprintf(fp_hpp, " uint resourcesUsed() const {\n"); | |
1032 fprintf(fp_hpp, " return _resource_use.resourcesUsed();\n }\n\n"); | |
1033 fprintf(fp_hpp, " uint resourcesUsedExclusively() const {\n"); | |
1034 fprintf(fp_hpp, " return _resource_use.resourcesUsedExclusively();\n }\n\n"); | |
1035 fprintf(fp_hpp, " bool hasFixedLatency() const {\n"); | |
1036 fprintf(fp_hpp, " return (_has_fixed_latency);\n }\n\n"); | |
1037 fprintf(fp_hpp, " uint fixedLatency() const {\n"); | |
1038 fprintf(fp_hpp, " return (_fixed_latency);\n }\n\n"); | |
1039 fprintf(fp_hpp, " uint functional_unit_latency(uint start, const Pipeline *pred) const;\n\n"); | |
1040 fprintf(fp_hpp, " uint operand_latency(uint opnd, const Pipeline *pred) const;\n\n"); | |
1041 fprintf(fp_hpp, " const Pipeline_Use& resourceUse() const {\n"); | |
1042 fprintf(fp_hpp, " return (_resource_use); }\n\n"); | |
1043 fprintf(fp_hpp, " const Pipeline_Use_Element * resourceUseElement(uint i) const {\n"); | |
1044 fprintf(fp_hpp, " return (&_resource_use._elements[i]); }\n\n"); | |
1045 fprintf(fp_hpp, " uint resourceUseCount() const {\n"); | |
1046 fprintf(fp_hpp, " return (_resource_use._count); }\n\n"); | |
1047 fprintf(fp_hpp, " uint instructionCount() const {\n"); | |
1048 fprintf(fp_hpp, " return (_instruction_count); }\n\n"); | |
1049 fprintf(fp_hpp, " bool hasBranchDelay() const {\n"); | |
1050 fprintf(fp_hpp, " return (_has_branch_delay); }\n\n"); | |
1051 fprintf(fp_hpp, " bool hasMultipleBundles() const {\n"); | |
1052 fprintf(fp_hpp, " return (_has_multiple_bundles); }\n\n"); | |
1053 fprintf(fp_hpp, " bool forceSerialization() const {\n"); | |
1054 fprintf(fp_hpp, " return (_force_serialization); }\n\n"); | |
1055 fprintf(fp_hpp, " bool mayHaveNoCode() const {\n"); | |
1056 fprintf(fp_hpp, " return (_may_have_no_code); }\n\n"); | |
1057 fprintf(fp_hpp, "//const Pipeline_Use_Cycle_Mask& resourceUseMask(int resource) const {\n"); | |
1058 fprintf(fp_hpp, "// return (_resource_use_masks[resource]); }\n\n"); | |
1059 fprintf(fp_hpp, "\n#ifndef PRODUCT\n"); | |
1060 fprintf(fp_hpp, " static const char * stageName(uint i);\n"); | |
1061 fprintf(fp_hpp, "#endif\n"); | |
1062 fprintf(fp_hpp, "};\n\n"); | |
1063 | |
1064 fprintf(fp_hpp, "// Bundle class\n"); | |
1065 fprintf(fp_hpp, "class Bundle {\n"); | |
1066 | |
1067 uint mshift = 0; | |
1068 for (uint msize = _pipeline->_maxInstrsPerBundle * _pipeline->_maxBundlesPerCycle; msize != 0; msize >>= 1) | |
1069 mshift++; | |
1070 | |
1071 uint rshift = rescount; | |
1072 | |
1073 fprintf(fp_hpp, "protected:\n"); | |
1074 fprintf(fp_hpp, " enum {\n"); | |
1075 fprintf(fp_hpp, " _unused_delay = 0x%x,\n", 0); | |
1076 fprintf(fp_hpp, " _use_nop_delay = 0x%x,\n", 1); | |
1077 fprintf(fp_hpp, " _use_unconditional_delay = 0x%x,\n", 2); | |
1078 fprintf(fp_hpp, " _use_conditional_delay = 0x%x,\n", 3); | |
1079 fprintf(fp_hpp, " _used_in_conditional_delay = 0x%x,\n", 4); | |
1080 fprintf(fp_hpp, " _used_in_unconditional_delay = 0x%x,\n", 5); | |
1081 fprintf(fp_hpp, " _used_in_all_conditional_delays = 0x%x,\n", 6); | |
1082 fprintf(fp_hpp, "\n"); | |
1083 fprintf(fp_hpp, " _use_delay = 0x%x,\n", 3); | |
1084 fprintf(fp_hpp, " _used_in_delay = 0x%x\n", 4); | |
1085 fprintf(fp_hpp, " };\n\n"); | |
1086 fprintf(fp_hpp, " uint _flags : 3,\n"); | |
1087 fprintf(fp_hpp, " _starts_bundle : 1,\n"); | |
1088 fprintf(fp_hpp, " _instr_count : %d,\n", mshift); | |
1089 fprintf(fp_hpp, " _resources_used : %d;\n", rshift); | |
1090 fprintf(fp_hpp, "public:\n"); | |
1091 fprintf(fp_hpp, " Bundle() : _flags(_unused_delay), _starts_bundle(0), _instr_count(0), _resources_used(0) {}\n\n"); | |
1092 fprintf(fp_hpp, " void set_instr_count(uint i) { _instr_count = i; }\n"); | |
1093 fprintf(fp_hpp, " void set_resources_used(uint i) { _resources_used = i; }\n"); | |
1094 fprintf(fp_hpp, " void clear_usage() { _flags = _unused_delay; }\n"); | |
1095 fprintf(fp_hpp, " void set_starts_bundle() { _starts_bundle = true; }\n"); | |
1096 | |
1097 fprintf(fp_hpp, " uint flags() const { return (_flags); }\n"); | |
1098 fprintf(fp_hpp, " uint instr_count() const { return (_instr_count); }\n"); | |
1099 fprintf(fp_hpp, " uint resources_used() const { return (_resources_used); }\n"); | |
1100 fprintf(fp_hpp, " bool starts_bundle() const { return (_starts_bundle != 0); }\n"); | |
1101 | |
1102 fprintf(fp_hpp, " void set_use_nop_delay() { _flags = _use_nop_delay; }\n"); | |
1103 fprintf(fp_hpp, " void set_use_unconditional_delay() { _flags = _use_unconditional_delay; }\n"); | |
1104 fprintf(fp_hpp, " void set_use_conditional_delay() { _flags = _use_conditional_delay; }\n"); | |
1105 fprintf(fp_hpp, " void set_used_in_unconditional_delay() { _flags = _used_in_unconditional_delay; }\n"); | |
1106 fprintf(fp_hpp, " void set_used_in_conditional_delay() { _flags = _used_in_conditional_delay; }\n"); | |
1107 fprintf(fp_hpp, " void set_used_in_all_conditional_delays() { _flags = _used_in_all_conditional_delays; }\n"); | |
1108 | |
1109 fprintf(fp_hpp, " bool use_nop_delay() { return (_flags == _use_nop_delay); }\n"); | |
1110 fprintf(fp_hpp, " bool use_unconditional_delay() { return (_flags == _use_unconditional_delay); }\n"); | |
1111 fprintf(fp_hpp, " bool use_conditional_delay() { return (_flags == _use_conditional_delay); }\n"); | |
1112 fprintf(fp_hpp, " bool used_in_unconditional_delay() { return (_flags == _used_in_unconditional_delay); }\n"); | |
1113 fprintf(fp_hpp, " bool used_in_conditional_delay() { return (_flags == _used_in_conditional_delay); }\n"); | |
1114 fprintf(fp_hpp, " bool used_in_all_conditional_delays() { return (_flags == _used_in_all_conditional_delays); }\n"); | |
1115 fprintf(fp_hpp, " bool use_delay() { return ((_flags & _use_delay) != 0); }\n"); | |
1116 fprintf(fp_hpp, " bool used_in_delay() { return ((_flags & _used_in_delay) != 0); }\n\n"); | |
1117 | |
1118 fprintf(fp_hpp, " enum {\n"); | |
1119 fprintf(fp_hpp, " _nop_count = %d\n", | |
1120 _pipeline->_nopcnt); | |
1121 fprintf(fp_hpp, " };\n\n"); | |
1122 fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n", | |
1123 _pipeline->_nopcnt); | |
1124 fprintf(fp_hpp, "#ifndef PRODUCT\n"); | |
6850 | 1125 fprintf(fp_hpp, " void dump(outputStream *st = tty) const;\n"); |
0 | 1126 fprintf(fp_hpp, "#endif\n"); |
1127 fprintf(fp_hpp, "};\n\n"); | |
1128 | |
1129 // const char *classname; | |
1130 // for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) { | |
1131 // PipeClassForm *pipeclass = _pipeline->_classdict[classname]->is_pipeclass(); | |
1132 // fprintf(fp_hpp, "// Pipeline Class Instance for \"%s\"\n", classname); | |
1133 // } | |
1134 } | |
1135 | |
1136 //------------------------------declareClasses--------------------------------- | |
1137 // Construct the class hierarchy of MachNode classes from the instruction & | |
1138 // operand lists | |
1139 void ArchDesc::declareClasses(FILE *fp) { | |
1140 | |
1141 // Declare an array containing the machine register names, strings. | |
1142 declareRegNames(fp, _register); | |
1143 | |
1144 // Declare an array containing the machine register encoding values | |
1145 declareRegEncodes(fp, _register); | |
1146 | |
1147 // Generate declarations for the total number of operands | |
1148 fprintf(fp,"\n"); | |
1149 fprintf(fp,"// Total number of operands defined in architecture definition\n"); | |
1150 int num_operands = 0; | |
1151 OperandForm *op; | |
1152 for (_operands.reset(); (op = (OperandForm*)_operands.iter()) != NULL; ) { | |
1153 // Ensure this is a machine-world instruction | |
1154 if (op->ideal_only()) continue; | |
1155 | |
1156 ++num_operands; | |
1157 } | |
1158 int first_operand_class = num_operands; | |
1159 OpClassForm *opc; | |
1160 for (_opclass.reset(); (opc = (OpClassForm*)_opclass.iter()) != NULL; ) { | |
1161 // Ensure this is a machine-world instruction | |
1162 if (opc->ideal_only()) continue; | |
1163 | |
1164 ++num_operands; | |
1165 } | |
1166 fprintf(fp,"#define FIRST_OPERAND_CLASS %d\n", first_operand_class); | |
1167 fprintf(fp,"#define NUM_OPERANDS %d\n", num_operands); | |
1168 fprintf(fp,"\n"); | |
1169 // Generate declarations for the total number of instructions | |
1170 fprintf(fp,"// Total number of instructions defined in architecture definition\n"); | |
1171 fprintf(fp,"#define NUM_INSTRUCTIONS %d\n",instructFormCount()); | |
1172 | |
1173 | |
1174 // Generate Machine Classes for each operand defined in AD file | |
1175 fprintf(fp,"\n"); | |
1176 fprintf(fp,"//----------------------------Declare classes derived from MachOper----------\n"); | |
1177 // Iterate through all operands | |
1178 _operands.reset(); | |
1179 OperandForm *oper; | |
1180 for( ; (oper = (OperandForm*)_operands.iter()) != NULL;) { | |
1181 // Ensure this is a machine-world instruction | |
1182 if (oper->ideal_only() ) continue; | |
1183 // The declaration of labelOper is in machine-independent file: machnode | |
1184 if ( strcmp(oper->_ident,"label") == 0 ) continue; | |
1185 // The declaration of methodOper is in machine-independent file: machnode | |
1186 if ( strcmp(oper->_ident,"method") == 0 ) continue; | |
1187 | |
1188 // Build class definition for this operand | |
1189 fprintf(fp,"\n"); | |
1190 fprintf(fp,"class %sOper : public MachOper { \n",oper->_ident); | |
1191 fprintf(fp,"private:\n"); | |
1192 // Operand definitions that depend upon number of input edges | |
1193 { | |
1194 uint num_edges = oper->num_edges(_globalNames); | |
1195 if( num_edges != 1 ) { // Use MachOper::num_edges() {return 1;} | |
1196 fprintf(fp," virtual uint num_edges() const { return %d; }\n", | |
1197 num_edges ); | |
1198 } | |
1199 if( num_edges > 0 ) { | |
1200 in_RegMask(fp); | |
1201 } | |
1202 } | |
1203 | |
1204 // Support storing constants inside the MachOper | |
1205 declareConstStorage(fp,_globalNames,oper); | |
1206 | |
1207 // Support storage of the condition codes | |
1208 if( oper->is_ideal_bool() ) { | |
1209 fprintf(fp," virtual int ccode() const { \n"); | |
1210 fprintf(fp," switch (_c0) {\n"); | |
1211 fprintf(fp," case BoolTest::eq : return equal();\n"); | |
1212 fprintf(fp," case BoolTest::gt : return greater();\n"); | |
1213 fprintf(fp," case BoolTest::lt : return less();\n"); | |
1214 fprintf(fp," case BoolTest::ne : return not_equal();\n"); | |
1215 fprintf(fp," case BoolTest::le : return less_equal();\n"); | |
1216 fprintf(fp," case BoolTest::ge : return greater_equal();\n"); | |
12323 | 1217 fprintf(fp," case BoolTest::overflow : return overflow();\n"); |
1218 fprintf(fp," case BoolTest::no_overflow: return no_overflow();\n"); | |
0 | 1219 fprintf(fp," default : ShouldNotReachHere(); return 0;\n"); |
1220 fprintf(fp," }\n"); | |
1221 fprintf(fp," };\n"); | |
1222 } | |
1223 | |
1224 // Support storage of the condition codes | |
1225 if( oper->is_ideal_bool() ) { | |
1226 fprintf(fp," virtual void negate() { \n"); | |
1227 fprintf(fp," _c0 = (BoolTest::mask)((int)_c0^0x4); \n"); | |
1228 fprintf(fp," };\n"); | |
1229 } | |
1230 | |
1231 // Declare constructor. | |
1232 // Parameters start with condition code, then all other constants | |
1233 // | |
1234 // (1) MachXOper(int32 ccode, int32 c0, int32 c1, ..., int32 cn) | |
1235 // (2) : _ccode(ccode), _c0(c0), _c1(c1), ..., _cn(cn) { } | |
1236 // | |
1237 Form::DataType constant_type = oper->simple_type(_globalNames); | |
1238 defineConstructor(fp, oper->_ident, oper->num_consts(_globalNames), | |
1239 oper->_components, oper->is_ideal_bool(), | |
1240 constant_type, _globalNames); | |
1241 | |
1242 // Clone function | |
1243 fprintf(fp," virtual MachOper *clone(Compile* C) const;\n"); | |
1244 | |
1245 // Support setting a spill offset into a constant operand. | |
1246 // We only support setting an 'int' offset, while in the | |
1247 // LP64 build spill offsets are added with an AddP which | |
1248 // requires a long constant. Thus we don't support spilling | |
1249 // in frames larger than 4Gig. | |
1250 if( oper->has_conI(_globalNames) || | |
1251 oper->has_conL(_globalNames) ) | |
1252 fprintf(fp, " virtual void set_con( jint c0 ) { _c0 = c0; }\n"); | |
1253 | |
1254 // virtual functions for encoding and format | |
1255 // fprintf(fp," virtual void encode() const {\n %s }\n", | |
1256 // (oper->_encrule)?(oper->_encrule->_encrule):""); | |
1257 // Check the interface type, and generate the correct query functions | |
1258 // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER. | |
1259 | |
1260 fprintf(fp," virtual uint opcode() const { return %s; }\n", | |
1261 machOperEnum(oper->_ident)); | |
1262 | |
1263 // virtual function to look up ideal return type of machine instruction | |
1264 // | |
1265 // (1) virtual const Type *type() const { return .....; } | |
1266 // | |
1267 if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) && | |
1268 (oper->_matrule->_rChild == NULL)) { | |
1269 unsigned int position = 0; | |
1270 const char *opret, *opname, *optype; | |
1271 oper->_matrule->base_operand(position,_globalNames,opret,opname,optype); | |
6850 | 1272 fprintf(fp," virtual const Type *type() const {"); |
0 | 1273 const char *type = getIdealType(optype); |
1274 if( type != NULL ) { | |
1275 Form::DataType data_type = oper->is_base_constant(_globalNames); | |
1276 // Check if we are an ideal pointer type | |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1277 if( data_type == Form::idealP || data_type == Form::idealN || data_type == Form::idealNKlass ) { |
0 | 1278 // Return the ideal type we already have: <TypePtr *> |
1279 fprintf(fp," return _c0;"); | |
1280 } else { | |
1281 // Return the appropriate bottom type | |
1282 fprintf(fp," return %s;", getIdealType(optype)); | |
1283 } | |
1284 } else { | |
1285 fprintf(fp," ShouldNotCallThis(); return Type::BOTTOM;"); | |
1286 } | |
1287 fprintf(fp," }\n"); | |
1288 } else { | |
1289 // Check for user-defined stack slots, based upon sRegX | |
1290 Form::DataType data_type = oper->is_user_name_for_sReg(); | |
1291 if( data_type != Form::none ){ | |
1292 const char *type = NULL; | |
1293 switch( data_type ) { | |
1294 case Form::idealI: type = "TypeInt::INT"; break; | |
1295 case Form::idealP: type = "TypePtr::BOTTOM";break; | |
1296 case Form::idealF: type = "Type::FLOAT"; break; | |
1297 case Form::idealD: type = "Type::DOUBLE"; break; | |
1298 case Form::idealL: type = "TypeLong::LONG"; break; | |
1299 case Form::none: // fall through | |
1300 default: | |
1301 assert( false, "No support for this type of stackSlot"); | |
1302 } | |
1303 fprintf(fp," virtual const Type *type() const { return %s; } // stackSlotX\n", type); | |
1304 } | |
1305 } | |
1306 | |
1307 | |
1308 // | |
1309 // virtual functions for defining the encoding interface. | |
1310 // | |
1311 // Access the linearized ideal register mask, | |
1312 // map to physical register encoding | |
1313 if ( oper->_matrule && oper->_matrule->is_base_register(_globalNames) ) { | |
1314 // Just use the default virtual 'reg' call | |
1315 } else if ( oper->ideal_to_sReg_type(oper->_ident) != Form::none ) { | |
1316 // Special handling for operand 'sReg', a Stack Slot Register. | |
1317 // Map linearized ideal register mask to stack slot number | |
1318 fprintf(fp," virtual int reg(PhaseRegAlloc *ra_, const Node *node) const {\n"); | |
1319 fprintf(fp," return (int)OptoReg::reg2stack(ra_->get_reg_first(node));/* sReg */\n"); | |
1320 fprintf(fp," }\n"); | |
1321 fprintf(fp," virtual int reg(PhaseRegAlloc *ra_, const Node *node, int idx) const {\n"); | |
1322 fprintf(fp," return (int)OptoReg::reg2stack(ra_->get_reg_first(node->in(idx)));/* sReg */\n"); | |
1323 fprintf(fp," }\n"); | |
1324 } | |
1325 | |
1326 // Output the operand specific access functions used by an enc_class | |
1327 // These are only defined when we want to override the default virtual func | |
1328 if (oper->_interface != NULL) { | |
1329 fprintf(fp,"\n"); | |
1330 // Check if it is a Memory Interface | |
1331 if ( oper->_interface->is_MemInterface() != NULL ) { | |
1332 MemInterface *mem_interface = oper->_interface->is_MemInterface(); | |
1333 const char *base = mem_interface->_base; | |
1334 if( base != NULL ) { | |
1335 define_oper_interface(fp, *oper, _globalNames, "base", base); | |
1336 } | |
1337 char *index = mem_interface->_index; | |
1338 if( index != NULL ) { | |
1339 define_oper_interface(fp, *oper, _globalNames, "index", index); | |
1340 } | |
1341 const char *scale = mem_interface->_scale; | |
1342 if( scale != NULL ) { | |
1343 define_oper_interface(fp, *oper, _globalNames, "scale", scale); | |
1344 } | |
1345 const char *disp = mem_interface->_disp; | |
1346 if( disp != NULL ) { | |
1347 define_oper_interface(fp, *oper, _globalNames, "disp", disp); | |
1348 oper->disp_is_oop(fp, _globalNames); | |
1349 } | |
1350 if( oper->stack_slots_only(_globalNames) ) { | |
1351 // should not call this: | |
1352 fprintf(fp," virtual int constant_disp() const { return Type::OffsetBot; }"); | |
1353 } else if ( disp != NULL ) { | |
1354 define_oper_interface(fp, *oper, _globalNames, "constant_disp", disp); | |
1355 } | |
1356 } // end Memory Interface | |
1357 // Check if it is a Conditional Interface | |
1358 else if (oper->_interface->is_CondInterface() != NULL) { | |
1359 CondInterface *cInterface = oper->_interface->is_CondInterface(); | |
1360 const char *equal = cInterface->_equal; | |
1361 if( equal != NULL ) { | |
1362 define_oper_interface(fp, *oper, _globalNames, "equal", equal); | |
1363 } | |
1364 const char *not_equal = cInterface->_not_equal; | |
1365 if( not_equal != NULL ) { | |
1366 define_oper_interface(fp, *oper, _globalNames, "not_equal", not_equal); | |
1367 } | |
1368 const char *less = cInterface->_less; | |
1369 if( less != NULL ) { | |
1370 define_oper_interface(fp, *oper, _globalNames, "less", less); | |
1371 } | |
1372 const char *greater_equal = cInterface->_greater_equal; | |
1373 if( greater_equal != NULL ) { | |
1374 define_oper_interface(fp, *oper, _globalNames, "greater_equal", greater_equal); | |
1375 } | |
1376 const char *less_equal = cInterface->_less_equal; | |
1377 if( less_equal != NULL ) { | |
1378 define_oper_interface(fp, *oper, _globalNames, "less_equal", less_equal); | |
1379 } | |
1380 const char *greater = cInterface->_greater; | |
1381 if( greater != NULL ) { | |
1382 define_oper_interface(fp, *oper, _globalNames, "greater", greater); | |
1383 } | |
12323 | 1384 const char *overflow = cInterface->_overflow; |
1385 if( overflow != NULL ) { | |
1386 define_oper_interface(fp, *oper, _globalNames, "overflow", overflow); | |
1387 } | |
1388 const char *no_overflow = cInterface->_no_overflow; | |
1389 if( no_overflow != NULL ) { | |
1390 define_oper_interface(fp, *oper, _globalNames, "no_overflow", no_overflow); | |
1391 } | |
0 | 1392 } // end Conditional Interface |
1393 // Check if it is a Constant Interface | |
1394 else if (oper->_interface->is_ConstInterface() != NULL ) { | |
1395 assert( oper->num_consts(_globalNames) == 1, | |
1396 "Must have one constant when using CONST_INTER encoding"); | |
1397 if (!strcmp(oper->ideal_type(_globalNames), "ConI")) { | |
1398 // Access the locally stored constant | |
1399 fprintf(fp," virtual intptr_t constant() const {"); | |
1400 fprintf(fp, " return (intptr_t)_c0;"); | |
1401 fprintf(fp," }\n"); | |
1402 } | |
1403 else if (!strcmp(oper->ideal_type(_globalNames), "ConP")) { | |
1404 // Access the locally stored constant | |
1405 fprintf(fp," virtual intptr_t constant() const {"); | |
1406 fprintf(fp, " return _c0->get_con();"); | |
1407 fprintf(fp, " }\n"); | |
1408 // Generate query to determine if this pointer is an oop | |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1409 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1410 fprintf(fp, " return _c0->reloc();"); |
0 | 1411 fprintf(fp, " }\n"); |
1412 } | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1413 else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) { |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1414 // Access the locally stored constant |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1415 fprintf(fp," virtual intptr_t constant() const {"); |
827
bf3489cc0aa0
6856025: assert(_base >= OopPtr && _base <= KlassPtr,"Not a Java pointer")
never
parents:
605
diff
changeset
|
1416 fprintf(fp, " return _c0->get_ptrtype()->get_con();"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1417 fprintf(fp, " }\n"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1418 // Generate query to determine if this pointer is an oop |
6725
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1419 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {"); |
da91efe96a93
6964458: Reimplement class meta-data storage to use native memory
coleenp
parents:
6266
diff
changeset
|
1420 fprintf(fp, " return _c0->get_ptrtype()->reloc();"); |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1421 fprintf(fp, " }\n"); |
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1422 } |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1423 else if (!strcmp(oper->ideal_type(_globalNames), "ConNKlass")) { |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1424 // Access the locally stored constant |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1425 fprintf(fp," virtual intptr_t constant() const {"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1426 fprintf(fp, " return _c0->get_ptrtype()->get_con();"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1427 fprintf(fp, " }\n"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1428 // Generate query to determine if this pointer is an oop |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1429 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1430 fprintf(fp, " return _c0->get_ptrtype()->reloc();"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1431 fprintf(fp, " }\n"); |
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1432 } |
0 | 1433 else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) { |
1434 fprintf(fp," virtual intptr_t constant() const {"); | |
1435 // We don't support addressing modes with > 4Gig offsets. | |
1436 // Truncate to int. | |
1437 fprintf(fp, " return (intptr_t)_c0;"); | |
1438 fprintf(fp, " }\n"); | |
1439 fprintf(fp," virtual jlong constantL() const {"); | |
1440 fprintf(fp, " return _c0;"); | |
1441 fprintf(fp, " }\n"); | |
1442 } | |
1443 else if (!strcmp(oper->ideal_type(_globalNames), "ConF")) { | |
1444 fprintf(fp," virtual intptr_t constant() const {"); | |
1445 fprintf(fp, " ShouldNotReachHere(); return 0; "); | |
1446 fprintf(fp, " }\n"); | |
1447 fprintf(fp," virtual jfloat constantF() const {"); | |
1448 fprintf(fp, " return (jfloat)_c0;"); | |
1449 fprintf(fp, " }\n"); | |
1450 } | |
1451 else if (!strcmp(oper->ideal_type(_globalNames), "ConD")) { | |
1452 fprintf(fp," virtual intptr_t constant() const {"); | |
1453 fprintf(fp, " ShouldNotReachHere(); return 0; "); | |
1454 fprintf(fp, " }\n"); | |
1455 fprintf(fp," virtual jdouble constantD() const {"); | |
1456 fprintf(fp, " return _c0;"); | |
1457 fprintf(fp, " }\n"); | |
1458 } | |
1459 } | |
1460 else if (oper->_interface->is_RegInterface() != NULL) { | |
1461 // make sure that a fixed format string isn't used for an | |
1462 // operand which might be assiged to multiple registers. | |
1463 // Otherwise the opto assembly output could be misleading. | |
1464 if (oper->_format->_strings.count() != 0 && !oper->is_bound_register()) { | |
1465 syntax_err(oper->_linenum, | |
1466 "Only bound registers can have fixed formats: %s\n", | |
1467 oper->_ident); | |
1468 } | |
1469 } | |
1470 else { | |
1471 assert( false, "ShouldNotReachHere();"); | |
1472 } | |
1473 } | |
1474 | |
1475 fprintf(fp,"\n"); | |
1476 // // Currently all XXXOper::hash() methods are identical (990820) | |
1477 // declare_hash(fp); | |
1478 // // Currently all XXXOper::Cmp() methods are identical (990820) | |
1479 // declare_cmp(fp); | |
1480 | |
1481 // Do not place dump_spec() and Name() into PRODUCT code | |
1482 // int_format and ext_format are not needed in PRODUCT code either | |
1483 fprintf(fp, "#ifndef PRODUCT\n"); | |
1484 | |
1485 // Declare int_format() and ext_format() | |
1486 gen_oper_format(fp, _globalNames, *oper); | |
1487 | |
1488 // Machine independent print functionality for debugging | |
1489 // IF we have constants, create a dump_spec function for the derived class | |
1490 // | |
1491 // (1) virtual void dump_spec() const { | |
1492 // (2) st->print("#%d", _c#); // Constant != ConP | |
1493 // OR _c#->dump_on(st); // Type ConP | |
1494 // ... | |
1495 // (3) } | |
1496 uint num_consts = oper->num_consts(_globalNames); | |
1497 if( num_consts > 0 ) { | |
1498 // line (1) | |
1499 fprintf(fp, " virtual void dump_spec(outputStream *st) const {\n"); | |
1500 // generate format string for st->print | |
1501 // Iterate over the component list & spit out the right thing | |
1502 uint i = 0; | |
1503 const char *type = oper->ideal_type(_globalNames); | |
1504 Component *comp; | |
1505 oper->_components.reset(); | |
1506 if ((comp = oper->_components.iter()) == NULL) { | |
1507 assert(num_consts == 1, "Bad component list detected.\n"); | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
1508 i = dump_spec_constant( fp, type, i, oper ); |
0 | 1509 // Check that type actually matched |
1510 assert( i != 0, "Non-constant operand lacks component list."); | |
1511 } // end if NULL | |
1512 else { | |
1513 // line (2) | |
1514 // dump all components | |
1515 oper->_components.reset(); | |
1516 while((comp = oper->_components.iter()) != NULL) { | |
1517 type = comp->base_type(_globalNames); | |
415
4d9884b01ba6
6754519: don't emit flag fixup for NaN when condition being tested doesn't need it
never
parents:
293
diff
changeset
|
1518 i = dump_spec_constant( fp, type, i, NULL ); |
0 | 1519 } |
1520 } | |
1521 // finish line (3) | |
1522 fprintf(fp," }\n"); | |
1523 } | |
1524 | |
1525 fprintf(fp," virtual const char *Name() const { return \"%s\";}\n", | |
1526 oper->_ident); | |
1527 | |
1528 fprintf(fp,"#endif\n"); | |
1529 | |
1530 // Close definition of this XxxMachOper | |
1531 fprintf(fp,"};\n"); | |
1532 } | |
1533 | |
1534 | |
1535 // Generate Machine Classes for each instruction defined in AD file | |
1536 fprintf(fp,"\n"); | |
1537 fprintf(fp,"//----------------------------Declare classes for Pipelines-----------------\n"); | |
1538 declare_pipe_classes(fp); | |
1539 | |
1540 // Generate Machine Classes for each instruction defined in AD file | |
1541 fprintf(fp,"\n"); | |
1542 fprintf(fp,"//----------------------------Declare classes derived from MachNode----------\n"); | |
1543 _instructions.reset(); | |
1544 InstructForm *instr; | |
1545 for( ; (instr = (InstructForm*)_instructions.iter()) != NULL; ) { | |
1546 // Ensure this is a machine-world instruction | |
1547 if ( instr->ideal_only() ) continue; | |
1548 | |
1549 // Build class definition for this instruction | |
1550 fprintf(fp,"\n"); | |
1551 fprintf(fp,"class %sNode : public %s { \n", | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1203
diff
changeset
|
1552 instr->_ident, instr->mach_base_class(_globalNames) ); |
0 | 1553 fprintf(fp,"private:\n"); |
1554 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() ); | |
1555 if ( instr->is_ideal_jump() ) { | |
1556 fprintf(fp, " GrowableArray<Label*> _index2label;\n"); | |
1557 } | |
14419
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1558 |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1559 fprintf(fp, "public:\n"); |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1560 |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1561 Attribute *att = instr->_attribs; |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1562 // Fields of the node specified in the ad file. |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1563 while (att != NULL) { |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1564 if (strncmp(att->_ident, "ins_field_", 10) == 0) { |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1565 const char *field_name = att->_ident+10; |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1566 const char *field_type = att->_val; |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1567 fprintf(fp, " %s _%s;\n", field_type, field_name); |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1568 } |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1569 att = (Attribute *)att->_next; |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1570 } |
7373e44fa207
8024922: PPC64 (part 116): Extend adlc to generate fields into nodes.
goetz
parents:
9078
diff
changeset
|
1571 |
6850 | 1572 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n"); |
1573 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n"); | |
1574 fprintf(fp," return _opnd_array[operand_index];\n"); | |
1575 fprintf(fp," }\n"); | |
1576 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n"); | |
1577 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n"); | |
1578 fprintf(fp," _opnd_array[operand_index] = operand;\n"); | |
1579 fprintf(fp," }\n"); | |
0 | 1580 fprintf(fp,"private:\n"); |
1581 if ( instr->is_ideal_jump() ) { | |
1582 fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n"); | |
6850 | 1583 fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);\n"); |
1584 fprintf(fp," }\n"); | |
0 | 1585 } |
1586 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) { | |
1587 fprintf(fp," const RegMask *_cisc_RegMask;\n"); | |
1588 } | |
1589 | |
1590 out_RegMask(fp); // output register mask | |
1591 fprintf(fp," virtual uint rule() const { return %s_rule; }\n", | |
1592 instr->_ident); | |
1593 | |
1594 // If this instruction contains a labelOper | |
1595 // Declare Node::methods that set operand Label's contents | |
1596 int label_position = instr->label_position(); | |
1597 if( label_position != -1 ) { | |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3851
diff
changeset
|
1598 // Set/Save the label, stored in labelOper::_branch_label |
3839 | 1599 fprintf(fp," virtual void label_set( Label* label, uint block_num );\n"); |
3853
11211f7cb5a0
7079317: Incorrect branch's destination block in PrintoOptoAssembly output
kvn
parents:
3851
diff
changeset
|
1600 fprintf(fp," virtual void save_label( Label** label, uint* block_num );\n"); |
0 | 1601 } |
1602 | |
1603 // If this instruction contains a methodOper | |
1604 // Declare Node::methods that set operand method's contents | |
1605 int method_position = instr->method_position(); | |
1606 if( method_position != -1 ) { | |
1607 // Set the address method, stored in methodOper::_method | |
1608 fprintf(fp," virtual void method_set( intptr_t method );\n"); | |
1609 } | |
1610 | |
1611 // virtual functions for attributes | |
1612 // | |
1613 // Each instruction attribute results in a virtual call of same name. | |
1614 // The ins_cost is not handled here. | |
1615 Attribute *attr = instr->_attribs; | |
3851 | 1616 bool avoid_back_to_back = false; |
0 | 1617 while (attr != NULL) { |
14440
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1618 if (strcmp (attr->_ident, "ins_cost") != 0 && |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1619 strncmp(attr->_ident, "ins_field_", 10) != 0 && |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1620 // Must match function in node.hpp: return type bool, no prefix "ins_". |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1621 strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") != 0 && |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1622 strcmp (attr->_ident, "ins_short_branch") != 0) { |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1623 fprintf(fp, " virtual int %s() const { return %s; }\n", attr->_ident, attr->_val); |
0 | 1624 } |
3851 | 1625 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag |
14440
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1626 if (!strcmp(attr->_ident, "ins_avoid_back_to_back") != 0 && attr->int_val(*this) != 0) |
3851 | 1627 avoid_back_to_back = true; |
14440
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1628 if (strcmp (attr->_ident, "ins_is_TrapBasedCheckNode") == 0) |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1629 fprintf(fp, " virtual bool is_TrapBasedCheckNode() const { return %s; }\n", attr->_val); |
41b780b43b74
8029015: PPC64 (part 216): opto: trap based null and range checks
goetz
parents:
14437
diff
changeset
|
1630 |
0 | 1631 attr = (Attribute *)attr->_next; |
1632 } | |
1633 | |
1634 // virtual functions for encode and format | |
2008 | 1635 |
1636 // Virtual function for evaluating the constant. | |
1637 if (instr->is_mach_constant()) { | |
1638 fprintf(fp," virtual void eval_constant(Compile* C);\n"); | |
1639 } | |
1640 | |
0 | 1641 // Output the opcode function and the encode function here using the |
1642 // encoding class information in the _insencode slot. | |
1643 if ( instr->_insencode ) { | |
14428
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
1644 if (instr->postalloc_expands()) { |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
1645 fprintf(fp," virtual bool requires_postalloc_expand() const { return true; }\n"); |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
1646 fprintf(fp," virtual void postalloc_expand(GrowableArray <Node *> *nodes, PhaseRegAlloc *ra_);\n"); |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
1647 } else { |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
1648 fprintf(fp," virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const;\n"); |
044b28168e20
8003854: PPC64 (part 115): Introduce PostallocExpand that expands nodes after register allocation
goetz
parents:
14422
diff
changeset
|
1649 } |
0 | 1650 } |
1651 | |
1652 // virtual function for getting the size of an instruction | |
1653 if ( instr->_size ) { | |
2008 | 1654 fprintf(fp," virtual uint size(PhaseRegAlloc *ra_) const;\n"); |
0 | 1655 } |
1656 | |
1657 // Return the top-level ideal opcode. | |
1658 // Use MachNode::ideal_Opcode() for nodes based on MachNode class | |
1659 // if the ideal_Opcode == Op_Node. | |
1660 if ( strcmp("Node", instr->ideal_Opcode(_globalNames)) != 0 || | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1203
diff
changeset
|
1661 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { |
0 | 1662 fprintf(fp," virtual int ideal_Opcode() const { return Op_%s; }\n", |
1663 instr->ideal_Opcode(_globalNames) ); | |
1664 } | |
1665 | |
14434
318d0622a6d7
8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents:
14428
diff
changeset
|
1666 if (instr->needs_constant_base() && |
318d0622a6d7
8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents:
14428
diff
changeset
|
1667 !instr->is_mach_constant()) { // These inherit the funcion from MachConstantNode. |
14449
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1668 fprintf(fp," virtual uint mach_constant_base_node_input() const { "); |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1669 if (instr->is_ideal_call() != Form::invalid_type && |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1670 instr->is_ideal_call() != Form::JAVA_LEAF) { |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1671 // MachConstantBase goes behind arguments, but before jvms. |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1672 fprintf(fp,"assert(tf() && tf()->domain(), \"\"); return tf()->domain()->cnt();"); |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1673 } else { |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1674 fprintf(fp,"return req()-1;"); |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1675 } |
ad6695638a35
8030863: PPC64: (part 220): ConstantTableBase for calls between args and jvms
goetz
parents:
14440
diff
changeset
|
1676 fprintf(fp," }\n"); |
14434
318d0622a6d7
8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents:
14428
diff
changeset
|
1677 } |
318d0622a6d7
8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents:
14428
diff
changeset
|
1678 |
0 | 1679 // Allow machine-independent optimization, invert the sense of the IF test |
1680 if( instr->is_ideal_if() ) { | |
1681 fprintf(fp," virtual void negate() { \n"); | |
1682 // Identify which operand contains the negate(able) ideal condition code | |
1683 int idx = 0; | |
1684 instr->_components.reset(); | |
1685 for( Component *comp; (comp = instr->_components.iter()) != NULL; ) { | |
1686 // Check that component is an operand | |
1687 Form *form = (Form*)_globalNames[comp->_type]; | |
1688 OperandForm *opForm = form ? form->is_operand() : NULL; | |
1689 if( opForm == NULL ) continue; | |
1690 | |
1691 // Lookup the position of the operand in the instruction. | |
1692 if( opForm->is_ideal_bool() ) { | |
1693 idx = instr->operand_position(comp->_name, comp->_usedef); | |
1694 assert( idx != NameList::Not_in_list, "Did not find component in list that contained it."); | |
1695 break; | |
1696 } | |
1697 } | |
1698 fprintf(fp," opnd_array(%d)->negate();\n", idx); | |
1699 fprintf(fp," _prob = 1.0f - _prob;\n"); | |
1700 fprintf(fp," };\n"); | |
1701 } | |
1702 | |
1703 | |
1704 // Identify which input register matches the input register. | |
1705 uint matching_input = instr->two_address(_globalNames); | |
1706 | |
1707 // Generate the method if it returns != 0 otherwise use MachNode::two_adr() | |
1708 if( matching_input != 0 ) { | |
1709 fprintf(fp," virtual uint two_adr() const "); | |
1710 fprintf(fp,"{ return oper_input_base()"); | |
1711 for( uint i = 2; i <= matching_input; i++ ) | |
1712 fprintf(fp," + opnd_array(%d)->num_edges()",i-1); | |
1713 fprintf(fp,"; }\n"); | |
1714 } | |
1715 | |
1716 // Declare cisc_version, if applicable | |
1717 // MachNode *cisc_version( int offset /* ,... */ ); | |
1718 instr->declare_cisc_version(*this, fp); | |
1719 | |
1720 // If there is an explicit peephole rule, build it | |
1721 if ( instr->peepholes() != NULL ) { | |
1722 fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n"); | |
1723 } | |
1724 | |
1725 // Output the declaration for number of relocation entries | |
1726 if ( instr->reloc(_globalNames) != 0 ) { | |
6850 | 1727 fprintf(fp," virtual int reloc() const;\n"); |
0 | 1728 } |
1729 | |
1730 if (instr->alignment() != 1) { | |
6850 | 1731 fprintf(fp," virtual int alignment_required() const { return %d; }\n", instr->alignment()); |
1732 fprintf(fp," virtual int compute_padding(int current_offset) const;\n"); | |
0 | 1733 } |
1734 | |
1735 // Starting point for inputs matcher wants. | |
1736 // Use MachNode::oper_input_base() for nodes based on MachNode class | |
1737 // if the base == 1. | |
1738 if ( instr->oper_input_base(_globalNames) != 1 || | |
1541
b5fdf39b9749
6953576: bottom_type for matched AddPNodes doesn't always agree with ideal
never
parents:
1203
diff
changeset
|
1739 strcmp("MachNode", instr->mach_base_class(_globalNames)) != 0 ) { |
0 | 1740 fprintf(fp," virtual uint oper_input_base() const { return %d; }\n", |
1741 instr->oper_input_base(_globalNames)); | |
1742 } | |
1743 | |
1744 // Make the constructor and following methods 'public:' | |
1745 fprintf(fp,"public:\n"); | |
1746 | |
1747 // Constructor | |
1748 if ( instr->is_ideal_jump() ) { | |
1749 fprintf(fp," %sNode() : _index2label(MinJumpTableSize*2) { ", instr->_ident); | |
1750 } else { | |
1751 fprintf(fp," %sNode() { ", instr->_ident); | |
1752 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) { | |
1753 fprintf(fp,"_cisc_RegMask = NULL; "); | |
1754 } | |
1755 } | |
1756 | |
1757 fprintf(fp," _num_opnds = %d; _opnds = _opnd_array; ", instr->num_opnds()); | |
1758 | |
1759 bool node_flags_set = false; | |
1760 // flag: if this instruction matches an ideal 'Copy*' node | |
1761 if ( instr->is_ideal_copy() != 0 ) { | |
3842 | 1762 fprintf(fp,"init_flags(Flag_is_Copy"); |
1763 node_flags_set = true; | |
0 | 1764 } |
1765 | |
1766 // Is an instruction is a constant? If so, get its type | |
1767 Form::DataType data_type; | |
1768 const char *opType = NULL; | |
1769 const char *result = NULL; | |
1770 data_type = instr->is_chain_of_constant(_globalNames, opType, result); | |
1771 // Check if this instruction is a constant | |
1772 if ( data_type != Form::none ) { | |
1773 if ( node_flags_set ) { | |
1774 fprintf(fp," | Flag_is_Con"); | |
1775 } else { | |
1776 fprintf(fp,"init_flags(Flag_is_Con"); | |
1777 node_flags_set = true; | |
1778 } | |
1779 } | |
1780 | |
1781 // flag: if this instruction is cisc alternate | |
1782 if ( can_cisc_spill() && instr->is_cisc_alternate() ) { | |
1783 if ( node_flags_set ) { | |
1784 fprintf(fp," | Flag_is_cisc_alternate"); | |
1785 } else { | |
1786 fprintf(fp,"init_flags(Flag_is_cisc_alternate"); | |
1787 node_flags_set = true; | |
1788 } | |
1789 } | |
1790 | |
1791 // flag: if this instruction has short branch form | |
1792 if ( instr->has_short_branch_form() ) { | |
1793 if ( node_flags_set ) { | |
1794 fprintf(fp," | Flag_may_be_short_branch"); | |
1795 } else { | |
1796 fprintf(fp,"init_flags(Flag_may_be_short_branch"); | |
1797 node_flags_set = true; | |
1798 } | |
1799 } | |
1800 | |
3851 | 1801 // flag: if this instruction should not be generated back to back. |
1802 if ( avoid_back_to_back ) { | |
1803 if ( node_flags_set ) { | |
1804 fprintf(fp," | Flag_avoid_back_to_back"); | |
1805 } else { | |
1806 fprintf(fp,"init_flags(Flag_avoid_back_to_back"); | |
1807 node_flags_set = true; | |
1808 } | |
1809 } | |
1810 | |
0 | 1811 // Check if machine instructions that USE memory, but do not DEF memory, |
1812 // depend upon a node that defines memory in machine-independent graph. | |
1813 if ( instr->needs_anti_dependence_check(_globalNames) ) { | |
1814 if ( node_flags_set ) { | |
1815 fprintf(fp," | Flag_needs_anti_dependence_check"); | |
1816 } else { | |
1817 fprintf(fp,"init_flags(Flag_needs_anti_dependence_check"); | |
1818 node_flags_set = true; | |
1819 } | |
1820 } | |
1821 | |
4120
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1822 // flag: if this instruction is implemented with a call |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1823 if ( instr->_has_call ) { |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1824 if ( node_flags_set ) { |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1825 fprintf(fp," | Flag_has_call"); |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1826 } else { |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1827 fprintf(fp,"init_flags(Flag_has_call"); |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1828 node_flags_set = true; |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1829 } |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1830 } |
f03a3c8bd5e5
7077312: Provide a CALL effect for instruct declaration in the ad file
roland
parents:
3853
diff
changeset
|
1831 |
0 | 1832 if ( node_flags_set ) { |
1833 fprintf(fp,"); "); | |
1834 } | |
1835 | |
1836 fprintf(fp,"}\n"); | |
1837 | |
1838 // size_of, used by base class's clone to obtain the correct size. | |
1839 fprintf(fp," virtual uint size_of() const {"); | |
1840 fprintf(fp, " return sizeof(%sNode);", instr->_ident); | |
1841 fprintf(fp, " }\n"); | |
1842 | |
1843 // Virtual methods which are only generated to override base class | |
1844 if( instr->expands() || instr->needs_projections() || | |
1845 instr->has_temps() || | |
2008 | 1846 instr->is_mach_constant() || |
14434
318d0622a6d7
8028580: PPC64 (part 114/120): Support for Call nodes with constants.
goetz
parents:
14428
diff
changeset
|
1847 instr->needs_constant_base() || |
0 | 1848 instr->_matrule != NULL && |
1849 instr->num_opnds() != instr->num_unique_opnds() ) { | |
1203 | 1850 fprintf(fp," virtual MachNode *Expand(State *state, Node_List &proj_list, Node* mem);\n"); |
0 | 1851 } |
1852 | |
1853 if (instr->is_pinned(_globalNames)) { | |
1854 fprintf(fp," virtual bool pinned() const { return "); | |
1855 if (instr->is_parm(_globalNames)) { | |
1856 fprintf(fp,"_in[0]->pinned();"); | |
1857 } else { | |
1858 fprintf(fp,"true;"); | |
1859 } | |
1860 fprintf(fp," }\n"); | |
1861 } | |
1862 if (instr->is_projection(_globalNames)) { | |
1863 fprintf(fp," virtual const Node *is_block_proj() const { return this; }\n"); | |
1864 } | |
1865 if ( instr->num_post_match_opnds() != 0 | |
1866 || instr->is_chain_of_constant(_globalNames) ) { | |
1867 fprintf(fp," friend MachNode *State::MachNodeGenerator(int opcode, Compile* C);\n"); | |
1868 } | |
1869 if ( instr->rematerialize(_globalNames, get_registers()) ) { | |
1870 fprintf(fp," // Rematerialize %s\n", instr->_ident); | |
1871 } | |
1872 | |
1873 // Declare short branch methods, if applicable | |
1874 instr->declare_short_branch_methods(fp); | |
1875 | |
1876 // See if there is an "ins_pipe" declaration for this instruction | |
1877 if (instr->_ins_pipe) { | |
1878 fprintf(fp," static const Pipeline *pipeline_class();\n"); | |
1879 fprintf(fp," virtual const Pipeline *pipeline() const;\n"); | |
1880 } | |
1881 | |
1882 // Generate virtual function for MachNodeX::bottom_type when necessary | |
1883 // | |
1884 // Note on accuracy: Pointer-types of machine nodes need to be accurate, | |
1885 // or else alias analysis on the matched graph may produce bad code. | |
1886 // Moreover, the aliasing decisions made on machine-node graph must be | |
1887 // no less accurate than those made on the ideal graph, or else the graph | |
1888 // may fail to schedule. (Reason: Memory ops which are reordered in | |
1889 // the ideal graph might look interdependent in the machine graph, | |
1890 // thereby removing degrees of scheduling freedom that the optimizer | |
1891 // assumed would be available.) | |
1892 // | |
1893 // %%% We should handle many of these cases with an explicit ADL clause: | |
1894 // instruct foo() %{ ... bottom_type(TypeRawPtr::BOTTOM); ... %} | |
1895 if( data_type != Form::none ) { | |
1896 // A constant's bottom_type returns a Type containing its constant value | |
1897 | |
1898 // !!!!! | |
1899 // Convert all ints, floats, ... to machine-independent TypeXs | |
1900 // as is done for pointers | |
1901 // | |
1902 // Construct appropriate constant type containing the constant value. | |
6850 | 1903 fprintf(fp," virtual const class Type *bottom_type() const {\n"); |
0 | 1904 switch( data_type ) { |
1905 case Form::idealI: | |
1906 fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n"); | |
1907 break; | |
1908 case Form::idealP: | |
113
ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
coleenp
parents:
0
diff
changeset
|
1909 case Form::idealN: |
6848
8e47bac5643a
7054512: Compress class pointers after perm gen removal
roland
parents:
6725
diff
changeset
|
1910 case Form::idealNKlass: |
603
dbbe28fc66b5
6778669: Patch from Red Hat -- fixes compilation errors
twisti
parents:
417
diff
changeset
|
1911 fprintf(fp," return opnd_array(1)->type();\n"); |
0 | 1912 break; |
1913 case Form::idealD: | |
1914 fprintf(fp," return TypeD::make(opnd_array(1)->constantD());\n"); | |
1915 break; | |
1916 case Form::idealF: | |
1917 fprintf(fp," return TypeF::make(opnd_array(1)->constantF());\n"); | |
1918 break; | |
1919 case Form::idealL: | |
1920 fprintf(fp," return TypeLong::make(opnd_array(1)->constantL());\n"); | |
1921 break; | |
1922 default: | |
1923 assert( false, "Unimplemented()" ); | |
1924 break; | |
1925 } | |
1926 fprintf(fp," };\n"); | |
1927 } | |
1928 /* else if ( instr->_matrule && instr->_matrule->_rChild && | |
1929 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0 | |
1930 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) { | |
1931 // !!!!! !!!!! | |
1932 // Provide explicit bottom type for conversions to int | |
1933 // On Intel the result operand is a stackSlot, untyped. | |
6850 | 1934 fprintf(fp," virtual const class Type *bottom_type() const {"); |
0 | 1935 fprintf(fp, " return TypeInt::INT;"); |
1936 fprintf(fp, " };\n"); | |
1937 }*/ | |
1938 else if( instr->is_ideal_copy() && | |
1939 !strcmp(instr->_matrule->_lChild->_opType,"stackSlotP") ) { | |
1940 // !!!!! | |
1941 // Special hack for ideal Copy of pointer. Bottom type is oop or not depending on input. | |
1942 fprintf(fp," const Type *bottom_type() const { return in(1)->bottom_type(); } // Copy?\n"); | |
1943 } | |
1944 else if( instr->is_ideal_loadPC() ) { | |
1945 // LoadPCNode provides the return address of a call to native code. | |
1946 // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM | |
1947 // since it is a pointer to an internal VM location and must have a zero offset. | |
1948 // Allocation detects derived pointers, in part, by their non-zero offsets. | |
1949 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // LoadPC?\n"); | |
1950 } | |
1951 else if( instr->is_ideal_box() ) { | |
1952 // BoxNode provides the address of a stack slot. | |
1953 // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM | |
1954 // This prevent s insert_anti_dependencies from complaining. It will | |
6850 | 1955 // complain if it sees that the pointer base is TypePtr::BOTTOM since |
0 | 1956 // it doesn't understand what that might alias. |
1957 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n"); | |
1958 } | |
1959 else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveP") ) { | |
1960 int offset = 1; | |
1961 // Special special hack to see if the Cmp? has been incorporated in the conditional move | |
1962 MatchNode *rl = instr->_matrule->_rChild->_lChild; | |
1963 if( rl && !strcmp(rl->_opType, "Binary") ) { | |
1964 MatchNode *rlr = rl->_rChild; | |
1965 if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0) | |
1966 offset = 2; | |
1967 } | |
1968 // Special hack for ideal CMoveP; ideal type depends on inputs | |
1969 fprintf(fp," const Type *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveP\n", | |
1970 offset, offset+1, offset+1); | |
1971 } | |
293
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1972 else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveN") ) { |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1973 int offset = 1; |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1974 // Special special hack to see if the Cmp? has been incorporated in the conditional move |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1975 MatchNode *rl = instr->_matrule->_rChild->_lChild; |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1976 if( rl && !strcmp(rl->_opType, "Binary") ) { |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1977 MatchNode *rlr = rl->_rChild; |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1978 if (rlr && strncmp(rlr->_opType, "Cmp", 3) == 0) |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1979 offset = 2; |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1980 } |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1981 // Special hack for ideal CMoveN; ideal type depends on inputs |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1982 fprintf(fp," const Type *bottom_type() const { const Type *t = in(oper_input_base()+%d)->bottom_type(); return (req() <= oper_input_base()+%d) ? t : t->meet(in(oper_input_base()+%d)->bottom_type()); } // CMoveN\n", |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1983 offset, offset+1, offset+1); |
c3e045194476
6731641: assert(m->adr_type() == mach->adr_type(),"matcher should not change adr type")
kvn
parents:
196
diff
changeset
|
1984 } |
0 | 1985 else if (instr->is_tls_instruction()) { |
1986 // Special hack for tlsLoadP | |
1987 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // tlsLoadP\n"); | |
1988 } | |
1989 else if ( instr->is_ideal_if() ) { | |
1990 fprintf(fp," const Type *bottom_type() const { return TypeTuple::IFBOTH; } // matched IfNode\n"); | |
1991 } | |
1992 else if ( instr->is_ideal_membar() ) { | |
1993 fprintf(fp," const Type *bottom_type() const { return TypeTuple::MEMBAR; } // matched MemBar\n"); | |
1994 } | |
1995 | |
1996 // Check where 'ideal_type' must be customized | |
1997 /* | |
1998 if ( instr->_matrule && instr->_matrule->_rChild && | |
1999 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0 | |
2000 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) { | |
2001 fprintf(fp," virtual uint ideal_reg() const { return Compile::current()->matcher()->base2reg[Type::Int]; }\n"); | |
2002 }*/ | |
2003 | |
2004 // Analyze machine instructions that either USE or DEF memory. | |
2005 int memory_operand = instr->memory_operand(_globalNames); | |
2006 // Some guys kill all of memory | |
2007 if ( instr->is_wide_memory_kill(_globalNames) ) { | |
2008 memory_operand = InstructForm::MANY_MEMORY_OPERANDS; | |
2009 } | |
2010 if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) { | |
2011 if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) { | |
2012 fprintf(fp," virtual const TypePtr *adr_type() const;\n"); | |
2013 } | |
2014 fprintf(fp," virtual const MachOper *memory_operand() const;\n"); | |
2015 } | |
2016 | |
2017 fprintf(fp, "#ifndef PRODUCT\n"); | |
2018 | |
2019 // virtual function for generating the user's assembler output | |
2020 gen_inst_format(fp, _globalNames,*instr); | |
2021 | |
2022 // Machine independent print functionality for debugging | |
2023 fprintf(fp," virtual const char *Name() const { return \"%s\";}\n", | |
2024 instr->_ident); | |
2025 | |
2026 fprintf(fp, "#endif\n"); | |
2027 | |
2028 // Close definition of this XxxMachNode | |
2029 fprintf(fp,"};\n"); | |
2030 }; | |
2031 | |
2032 } | |
2033 | |
2034 void ArchDesc::defineStateClass(FILE *fp) { | |
2035 static const char *state__valid = "_valid[((uint)index) >> 5] & (0x1 << (((uint)index) & 0x0001F))"; | |
2036 static const char *state__set_valid= "_valid[((uint)index) >> 5] |= (0x1 << (((uint)index) & 0x0001F))"; | |
2037 | |
2038 fprintf(fp,"\n"); | |
2039 fprintf(fp,"// MACROS to inline and constant fold State::valid(index)...\n"); | |
2040 fprintf(fp,"// when given a constant 'index' in dfa_<arch>.cpp\n"); | |
2041 fprintf(fp,"// uint word = index >> 5; // Shift out bit position\n"); | |
2042 fprintf(fp,"// uint bitpos = index & 0x0001F; // Mask off word bits\n"); | |
2043 fprintf(fp,"#define STATE__VALID(index) "); | |
2044 fprintf(fp," (%s)\n", state__valid); | |
2045 fprintf(fp,"\n"); | |
2046 fprintf(fp,"#define STATE__NOT_YET_VALID(index) "); | |
2047 fprintf(fp," ( (%s) == 0 )\n", state__valid); | |
2048 fprintf(fp,"\n"); | |
2049 fprintf(fp,"#define STATE__VALID_CHILD(state,index) "); | |
2050 fprintf(fp," ( state && (state->%s) )\n", state__valid); | |
2051 fprintf(fp,"\n"); | |
2052 fprintf(fp,"#define STATE__SET_VALID(index) "); | |
2053 fprintf(fp," (%s)\n", state__set_valid); | |
2054 fprintf(fp,"\n"); | |
2055 fprintf(fp, | |
2056 "//---------------------------State-------------------------------------------\n"); | |
2057 fprintf(fp,"// State contains an integral cost vector, indexed by machine operand opcodes,\n"); | |
2058 fprintf(fp,"// a rule vector consisting of machine operand/instruction opcodes, and also\n"); | |
2059 fprintf(fp,"// indexed by machine operand opcodes, pointers to the children in the label\n"); | |
2060 fprintf(fp,"// tree generated by the Label routines in ideal nodes (currently limited to\n"); | |
2061 fprintf(fp,"// two for convenience, but this could change).\n"); | |
2062 fprintf(fp,"class State : public ResourceObj {\n"); | |
2063 fprintf(fp,"public:\n"); | |
2064 fprintf(fp," int _id; // State identifier\n"); | |
2065 fprintf(fp," Node *_leaf; // Ideal (non-machine-node) leaf of match tree\n"); | |
2066 fprintf(fp," State *_kids[2]; // Children of state node in label tree\n"); | |
2067 fprintf(fp," unsigned int _cost[_LAST_MACH_OPER]; // Cost vector, indexed by operand opcodes\n"); | |
2068 fprintf(fp," unsigned int _rule[_LAST_MACH_OPER]; // Rule vector, indexed by operand opcodes\n"); | |
2069 fprintf(fp," unsigned int _valid[(_LAST_MACH_OPER/32)+1]; // Bit Map of valid Cost/Rule entries\n"); | |
2070 fprintf(fp,"\n"); | |
2071 fprintf(fp," State(void); // Constructor\n"); | |
2072 fprintf(fp," DEBUG_ONLY( ~State(void); ) // Destructor\n"); | |
2073 fprintf(fp,"\n"); | |
2074 fprintf(fp," // Methods created by ADLC and invoked by Reduce\n"); | |
2075 fprintf(fp," MachOper *MachOperGenerator( int opcode, Compile* C );\n"); | |
2076 fprintf(fp," MachNode *MachNodeGenerator( int opcode, Compile* C );\n"); | |
2077 fprintf(fp,"\n"); | |
2078 fprintf(fp," // Assign a state to a node, definition of method produced by ADLC\n"); | |
2079 fprintf(fp," bool DFA( int opcode, const Node *ideal );\n"); | |
2080 fprintf(fp,"\n"); | |
2081 fprintf(fp," // Access function for _valid bit vector\n"); | |
2082 fprintf(fp," bool valid(uint index) {\n"); | |
2083 fprintf(fp," return( STATE__VALID(index) != 0 );\n"); | |
2084 fprintf(fp," }\n"); | |
2085 fprintf(fp,"\n"); | |
2086 fprintf(fp," // Set function for _valid bit vector\n"); | |
2087 fprintf(fp," void set_valid(uint index) {\n"); | |
2088 fprintf(fp," STATE__SET_VALID(index);\n"); | |
2089 fprintf(fp," }\n"); | |
2090 fprintf(fp,"\n"); | |
2091 fprintf(fp,"#ifndef PRODUCT\n"); | |
2092 fprintf(fp," void dump(); // Debugging prints\n"); | |
2093 fprintf(fp," void dump(int depth);\n"); | |
2094 fprintf(fp,"#endif\n"); | |
2095 if (_dfa_small) { | |
2096 // Generate the routine name we'll need | |
2097 for (int i = 1; i < _last_opcode; i++) { | |
2098 if (_mlistab[i] == NULL) continue; | |
2099 fprintf(fp, " void _sub_Op_%s(const Node *n);\n", NodeClassNames[i]); | |
2100 } | |
2101 } | |
2102 fprintf(fp,"};\n"); | |
2103 fprintf(fp,"\n"); | |
2104 fprintf(fp,"\n"); | |
2105 | |
2106 } | |
2107 | |
2108 | |
2109 //---------------------------buildMachOperEnum--------------------------------- | |
2110 // Build enumeration for densely packed operands. | |
2111 // This enumeration is used to index into the arrays in the State objects | |
2112 // that indicate cost and a successfull rule match. | |
2113 | |
2114 // Information needed to generate the ReduceOp mapping for the DFA | |
2115 class OutputMachOperands : public OutputMap { | |
2116 public: | |
2117 OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) | |
6850 | 2118 : OutputMap(hpp, cpp, globals, AD, "MachOperands") {}; |
0 | 2119 |
2120 void declaration() { } | |
2121 void definition() { fprintf(_cpp, "enum MachOperands {\n"); } | |
2122 void closing() { fprintf(_cpp, " _LAST_MACH_OPER\n"); | |
2123 OutputMap::closing(); | |
2124 } | |
9078
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2125 void map(OpClassForm &opc) { |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2126 const char* opc_ident_to_upper = _AD.machOperEnum(opc._ident); |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2127 fprintf(_cpp, " %s", opc_ident_to_upper); |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2128 delete[] opc_ident_to_upper; |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2129 } |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2130 void map(OperandForm &oper) { |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2131 const char* oper_ident_to_upper = _AD.machOperEnum(oper._ident); |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2132 fprintf(_cpp, " %s", oper_ident_to_upper); |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2133 delete[] oper_ident_to_upper; |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2134 } |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2135 void map(char *name) { |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2136 const char* name_to_upper = _AD.machOperEnum(name); |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2137 fprintf(_cpp, " %s", name_to_upper); |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2138 delete[] name_to_upper; |
705ef39fcaa9
8006016: Memory leak at hotspot/src/share/vm/adlc/output_c.cpp
neliasso
parents:
6850
diff
changeset
|
2139 } |
0 | 2140 |
2141 bool do_instructions() { return false; } | |
2142 void map(InstructForm &inst){ assert( false, "ShouldNotCallThis()"); } | |
2143 }; | |
2144 | |
2145 | |
2146 void ArchDesc::buildMachOperEnum(FILE *fp_hpp) { | |
2147 // Construct the table for MachOpcodes | |
2148 OutputMachOperands output_mach_operands(fp_hpp, fp_hpp, _globalNames, *this); | |
2149 build_map(output_mach_operands); | |
2150 } | |
2151 | |
2152 | |
2153 //---------------------------buildMachEnum---------------------------------- | |
2154 // Build enumeration for all MachOpers and all MachNodes | |
2155 | |
2156 // Information needed to generate the ReduceOp mapping for the DFA | |
2157 class OutputMachOpcodes : public OutputMap { | |
2158 int begin_inst_chain_rule; | |
2159 int end_inst_chain_rule; | |
2160 int begin_rematerialize; | |
2161 int end_rematerialize; | |
2162 int end_instructions; | |
2163 public: | |
2164 OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) | |
6850 | 2165 : OutputMap(hpp, cpp, globals, AD, "MachOpcodes"), |
0 | 2166 begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1) |
2167 {}; | |
2168 | |
2169 void declaration() { } | |
2170 void definition() { fprintf(_cpp, "enum MachOpcodes {\n"); } | |
2171 void closing() { | |
2172 if( begin_inst_chain_rule != -1 ) | |
2173 fprintf(_cpp, " _BEGIN_INST_CHAIN_RULE = %d,\n", begin_inst_chain_rule); | |
2174 if( end_inst_chain_rule != -1 ) | |
2175 fprintf(_cpp, " _END_INST_CHAIN_RULE = %d,\n", end_inst_chain_rule); | |
2176 if( begin_rematerialize != -1 ) | |
2177 fprintf(_cpp, " _BEGIN_REMATERIALIZE = %d,\n", begin_rematerialize); | |
2178 if( end_rematerialize != -1 ) | |
2179 fprintf(_cpp, " _END_REMATERIALIZE = %d,\n", end_rematerialize); | |
2180 // always execute since do_instructions() is true, and avoids trailing comma | |
2181 fprintf(_cpp, " _last_Mach_Node = %d \n", end_instructions); | |
2182 OutputMap::closing(); | |
2183 } | |
2184 void map(OpClassForm &opc) { fprintf(_cpp, " %s_rule", opc._ident ); } | |
2185 void map(OperandForm &oper) { fprintf(_cpp, " %s_rule", oper._ident ); } | |
2186 void map(char *name) { if (name) fprintf(_cpp, " %s_rule", name); | |
2187 else fprintf(_cpp, " 0"); } | |
2188 void map(InstructForm &inst) {fprintf(_cpp, " %s_rule", inst._ident ); } | |
2189 | |
2190 void record_position(OutputMap::position place, int idx ) { | |
2191 switch(place) { | |
2192 case OutputMap::BEGIN_INST_CHAIN_RULES : | |
2193 begin_inst_chain_rule = idx; | |
2194 break; | |
2195 case OutputMap::END_INST_CHAIN_RULES : | |
2196 end_inst_chain_rule = idx; | |
2197 break; | |
2198 case OutputMap::BEGIN_REMATERIALIZE : | |
2199 begin_rematerialize = idx; | |
2200 break; | |
2201 case OutputMap::END_REMATERIALIZE : | |
2202 end_rematerialize = idx; | |
2203 break; | |
2204 case OutputMap::END_INSTRUCTIONS : | |
2205 end_instructions = idx; | |
2206 break; | |
2207 default: | |
2208 break; | |
2209 } | |
2210 } | |
2211 }; | |
2212 | |
2213 | |
2214 void ArchDesc::buildMachOpcodesEnum(FILE *fp_hpp) { | |
2215 // Construct the table for MachOpcodes | |
2216 OutputMachOpcodes output_mach_opcodes(fp_hpp, fp_hpp, _globalNames, *this); | |
2217 build_map(output_mach_opcodes); | |
2218 } | |
2219 | |
2220 | |
2221 // Generate an enumeration of the pipeline states, and both | |
2222 // the functional units (resources) and the masks for | |
2223 // specifying resources | |
2224 void ArchDesc::build_pipeline_enums(FILE *fp_hpp) { | |
2225 int stagelen = (int)strlen("undefined"); | |
2226 int stagenum = 0; | |
2227 | |
2228 if (_pipeline) { // Find max enum string length | |
2229 const char *stage; | |
2230 for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; ) { | |
2231 int len = (int)strlen(stage); | |
2232 if (stagelen < len) stagelen = len; | |
2233 } | |
2234 } | |
2235 | |
2236 // Generate a list of stages | |
2237 fprintf(fp_hpp, "\n"); | |
2238 fprintf(fp_hpp, "// Pipeline Stages\n"); | |
2239 fprintf(fp_hpp, "enum machPipelineStages {\n"); | |
2240 fprintf(fp_hpp, " stage_%-*s = 0,\n", stagelen, "undefined"); | |
2241 | |
2242 if( _pipeline ) { | |
2243 const char *stage; | |
2244 for ( _pipeline->_stages.reset(); (stage = _pipeline->_stages.iter()) != NULL; ) | |
2245 fprintf(fp_hpp, " stage_%-*s = %d,\n", stagelen, stage, ++stagenum); | |
2246 } | |
2247 | |
2248 fprintf(fp_hpp, " stage_%-*s = %d\n", stagelen, "count", stagenum); | |
2249 fprintf(fp_hpp, "};\n"); | |
2250 | |
2251 fprintf(fp_hpp, "\n"); | |
2252 fprintf(fp_hpp, "// Pipeline Resources\n"); | |
2253 fprintf(fp_hpp, "enum machPipelineResources {\n"); | |
2254 int rescount = 0; | |
2255 | |
2256 if( _pipeline ) { | |
2257 const char *resource; | |
2258 int reslen = 0; | |
2259 | |
2260 // Generate a list of resources, and masks | |
2261 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { | |
2262 int len = (int)strlen(resource); | |
2263 if (reslen < len) | |
2264 reslen = len; | |
2265 } | |
2266 | |
2267 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { | |
2268 const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource(); | |
2269 int mask = resform->mask(); | |
2270 if ((mask & (mask-1)) == 0) | |
2271 fprintf(fp_hpp, " resource_%-*s = %d,\n", reslen, resource, rescount++); | |
2272 } | |
2273 fprintf(fp_hpp, "\n"); | |
2274 for ( _pipeline->_reslist.reset(); (resource = _pipeline->_reslist.iter()) != NULL; ) { | |
2275 const ResourceForm *resform = _pipeline->_resdict[resource]->is_resource(); | |
2276 fprintf(fp_hpp, " res_mask_%-*s = 0x%08x,\n", reslen, resource, resform->mask()); | |
2277 } | |
2278 fprintf(fp_hpp, "\n"); | |
2279 } | |
2280 fprintf(fp_hpp, " resource_count = %d\n", rescount); | |
2281 fprintf(fp_hpp, "};\n"); | |
2282 } |