190 Component *comp;
191
192 if (oper->num_consts(globals) == 0) return;
193 // Iterate over the component list looking for constants
194 oper->_components.reset();
195 if ((comp = oper->_components.iter()) == NULL) {
196 assert(oper->num_consts(globals) == 1, "Bad component list detected.\n");
197 const char *type = oper->ideal_type(globals);
198 if (!strcmp(type, "ConI")) {
199 if (i > 0) fprintf(fp,", ");
200 fprintf(fp," int32 _c%d;\n", i);
201 }
202 else if (!strcmp(type, "ConP")) {
203 if (i > 0) fprintf(fp,", ");
204 fprintf(fp," const TypePtr *_c%d;\n", i);
205 }
206 else if (!strcmp(type, "ConN")) {
207 if (i > 0) fprintf(fp,", ");
208 fprintf(fp," const TypeNarrowOop *_c%d;\n", i);
209 }
210 else if (!strcmp(type, "ConL")) {
211 if (i > 0) fprintf(fp,", ");
212 fprintf(fp," jlong _c%d;\n", i);
213 }
214 else if (!strcmp(type, "ConF")) {
215 if (i > 0) fprintf(fp,", ");
216 fprintf(fp," jfloat _c%d;\n", i);
217 }
218 else if (!strcmp(type, "ConD")) {
219 if (i > 0) fprintf(fp,", ");
220 fprintf(fp," jdouble _c%d;\n", i);
221 }
222 else if (!strcmp(type, "Bool")) {
223 fprintf(fp,"private:\n");
224 fprintf(fp," BoolTest::mask _c%d;\n", i);
225 fprintf(fp,"public:\n");
226 }
227 else {
228 assert(0, "Non-constant operand lacks component list.");
229 }
230 } // end if NULL
231 else {
232 oper->_components.reset();
233 while ((comp = oper->_components.iter()) != NULL) {
234 if (!strcmp(comp->base_type(globals), "ConI")) {
235 fprintf(fp," jint _c%d;\n", i);
236 i++;
237 }
238 else if (!strcmp(comp->base_type(globals), "ConP")) {
239 fprintf(fp," const TypePtr *_c%d;\n", i);
240 i++;
241 }
242 else if (!strcmp(comp->base_type(globals), "ConN")) {
243 fprintf(fp," const TypePtr *_c%d;\n", i);
244 i++;
245 }
246 else if (!strcmp(comp->base_type(globals), "ConL")) {
247 fprintf(fp," jlong _c%d;\n", i);
248 i++;
249 }
250 else if (!strcmp(comp->base_type(globals), "ConF")) {
251 fprintf(fp," jfloat _c%d;\n", i);
252 i++;
253 }
254 else if (!strcmp(comp->base_type(globals), "ConD")) {
255 fprintf(fp," jdouble _c%d;\n", i);
256 i++;
257 }
258 }
259 }
260 }
261
262 // Declare constructor.
263 // Parameters start with condition code, then all other constants
264 //
265 // (0) public:
272 fprintf(fp,"public:\n");
273 // generate line (1)
274 fprintf(fp," %sOper(", name);
275 if( num_consts == 0 ) {
276 fprintf(fp,") {}\n");
277 return;
278 }
279
280 // generate parameters for constants
281 uint i = 0;
282 Component *comp;
283 lst.reset();
284 if ((comp = lst.iter()) == NULL) {
285 assert(num_consts == 1, "Bad component list detected.\n");
286 switch( constant_type ) {
287 case Form::idealI : {
288 fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i);
289 break;
290 }
291 case Form::idealN : { fprintf(fp,"const TypeNarrowOop *c%d", i); break; }
292 case Form::idealP : { fprintf(fp,"const TypePtr *c%d", i); break; }
293 case Form::idealL : { fprintf(fp,"jlong c%d", i); break; }
294 case Form::idealF : { fprintf(fp,"jfloat c%d", i); break; }
295 case Form::idealD : { fprintf(fp,"jdouble c%d", i); break; }
296 default:
297 assert(!is_ideal_bool, "Non-constant operand lacks component list.");
298 break;
299 }
300 } // end if NULL
301 else {
302 lst.reset();
303 while((comp = lst.iter()) != NULL) {
304 if (!strcmp(comp->base_type(globals), "ConI")) {
305 if (i > 0) fprintf(fp,", ");
306 fprintf(fp,"int32 c%d", i);
307 i++;
308 }
309 else if (!strcmp(comp->base_type(globals), "ConP")) {
310 if (i > 0) fprintf(fp,", ");
311 fprintf(fp,"const TypePtr *c%d", i);
312 i++;
313 }
314 else if (!strcmp(comp->base_type(globals), "ConN")) {
315 if (i > 0) fprintf(fp,", ");
316 fprintf(fp,"const TypePtr *c%d", i);
317 i++;
318 }
319 else if (!strcmp(comp->base_type(globals), "ConL")) {
320 if (i > 0) fprintf(fp,", ");
321 fprintf(fp,"jlong c%d", i);
322 i++;
323 }
324 else if (!strcmp(comp->base_type(globals), "ConF")) {
325 if (i > 0) fprintf(fp,", ");
326 fprintf(fp,"jfloat c%d", i);
327 i++;
328 }
329 else if (!strcmp(comp->base_type(globals), "ConD")) {
330 if (i > 0) fprintf(fp,", ");
331 fprintf(fp,"jdouble c%d", i);
332 i++;
333 }
334 else if (!strcmp(comp->base_type(globals), "Bool")) {
335 if (i > 0) fprintf(fp,", ");
336 fprintf(fp,"BoolTest::mask c%d", i);
337 i++;
338 }
363 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format);
364 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
365 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
366 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
367 }
368
369 // Output code that dumps constant values, increment "i" if type is constant
370 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
371 if (!strcmp(ideal_type, "ConI")) {
372 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i);
373 ++i;
374 }
375 else if (!strcmp(ideal_type, "ConP")) {
376 fprintf(fp," _c%d->dump_on(st);\n", i);
377 ++i;
378 }
379 else if (!strcmp(ideal_type, "ConN")) {
380 fprintf(fp," _c%d->dump_on(st);\n", i);
381 ++i;
382 }
383 else if (!strcmp(ideal_type, "ConL")) {
384 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i);
385 ++i;
386 }
387 else if (!strcmp(ideal_type, "ConF")) {
388 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
389 ++i;
390 }
391 else if (!strcmp(ideal_type, "ConD")) {
392 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
393 ++i;
394 }
395 else if (!strcmp(ideal_type, "Bool")) {
396 defineCCodeDump(oper, fp,i);
397 ++i;
398 }
399
400 return i;
401 }
402
1222 // Check the interface type, and generate the correct query functions
1223 // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER.
1224
1225 fprintf(fp," virtual uint opcode() const { return %s; }\n",
1226 machOperEnum(oper->_ident));
1227
1228 // virtual function to look up ideal return type of machine instruction
1229 //
1230 // (1) virtual const Type *type() const { return .....; }
1231 //
1232 if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
1233 (oper->_matrule->_rChild == NULL)) {
1234 unsigned int position = 0;
1235 const char *opret, *opname, *optype;
1236 oper->_matrule->base_operand(position,_globalNames,opret,opname,optype);
1237 fprintf(fp," virtual const Type *type() const {");
1238 const char *type = getIdealType(optype);
1239 if( type != NULL ) {
1240 Form::DataType data_type = oper->is_base_constant(_globalNames);
1241 // Check if we are an ideal pointer type
1242 if( data_type == Form::idealP || data_type == Form::idealN ) {
1243 // Return the ideal type we already have: <TypePtr *>
1244 fprintf(fp," return _c0;");
1245 } else {
1246 // Return the appropriate bottom type
1247 fprintf(fp," return %s;", getIdealType(optype));
1248 }
1249 } else {
1250 fprintf(fp," ShouldNotCallThis(); return Type::BOTTOM;");
1251 }
1252 fprintf(fp," }\n");
1253 } else {
1254 // Check for user-defined stack slots, based upon sRegX
1255 Form::DataType data_type = oper->is_user_name_for_sReg();
1256 if( data_type != Form::none ){
1257 const char *type = NULL;
1258 switch( data_type ) {
1259 case Form::idealI: type = "TypeInt::INT"; break;
1260 case Form::idealP: type = "TypePtr::BOTTOM";break;
1261 case Form::idealF: type = "Type::FLOAT"; break;
1262 case Form::idealD: type = "Type::DOUBLE"; break;
1360 else if (!strcmp(oper->ideal_type(_globalNames), "ConP")) {
1361 // Access the locally stored constant
1362 fprintf(fp," virtual intptr_t constant() const {");
1363 fprintf(fp, " return _c0->get_con();");
1364 fprintf(fp, " }\n");
1365 // Generate query to determine if this pointer is an oop
1366 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
1367 fprintf(fp, " return _c0->reloc();");
1368 fprintf(fp, " }\n");
1369 }
1370 else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) {
1371 // Access the locally stored constant
1372 fprintf(fp," virtual intptr_t constant() const {");
1373 fprintf(fp, " return _c0->get_ptrtype()->get_con();");
1374 fprintf(fp, " }\n");
1375 // Generate query to determine if this pointer is an oop
1376 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
1377 fprintf(fp, " return _c0->get_ptrtype()->reloc();");
1378 fprintf(fp, " }\n");
1379 }
1380 else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) {
1381 fprintf(fp," virtual intptr_t constant() const {");
1382 // We don't support addressing modes with > 4Gig offsets.
1383 // Truncate to int.
1384 fprintf(fp, " return (intptr_t)_c0;");
1385 fprintf(fp, " }\n");
1386 fprintf(fp," virtual jlong constantL() const {");
1387 fprintf(fp, " return _c0;");
1388 fprintf(fp, " }\n");
1389 }
1390 else if (!strcmp(oper->ideal_type(_globalNames), "ConF")) {
1391 fprintf(fp," virtual intptr_t constant() const {");
1392 fprintf(fp, " ShouldNotReachHere(); return 0; ");
1393 fprintf(fp, " }\n");
1394 fprintf(fp," virtual jfloat constantF() const {");
1395 fprintf(fp, " return (jfloat)_c0;");
1396 fprintf(fp, " }\n");
1397 }
1398 else if (!strcmp(oper->ideal_type(_globalNames), "ConD")) {
1399 fprintf(fp," virtual intptr_t constant() const {");
1793 // thereby removing degrees of scheduling freedom that the optimizer
1794 // assumed would be available.)
1795 //
1796 // %%% We should handle many of these cases with an explicit ADL clause:
1797 // instruct foo() %{ ... bottom_type(TypeRawPtr::BOTTOM); ... %}
1798 if( data_type != Form::none ) {
1799 // A constant's bottom_type returns a Type containing its constant value
1800
1801 // !!!!!
1802 // Convert all ints, floats, ... to machine-independent TypeXs
1803 // as is done for pointers
1804 //
1805 // Construct appropriate constant type containing the constant value.
1806 fprintf(fp," virtual const class Type *bottom_type() const{\n");
1807 switch( data_type ) {
1808 case Form::idealI:
1809 fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n");
1810 break;
1811 case Form::idealP:
1812 case Form::idealN:
1813 fprintf(fp," return opnd_array(1)->type();\n");
1814 break;
1815 case Form::idealD:
1816 fprintf(fp," return TypeD::make(opnd_array(1)->constantD());\n");
1817 break;
1818 case Form::idealF:
1819 fprintf(fp," return TypeF::make(opnd_array(1)->constantF());\n");
1820 break;
1821 case Form::idealL:
1822 fprintf(fp," return TypeLong::make(opnd_array(1)->constantL());\n");
1823 break;
1824 default:
1825 assert( false, "Unimplemented()" );
1826 break;
1827 }
1828 fprintf(fp," };\n");
1829 }
1830 /* else if ( instr->_matrule && instr->_matrule->_rChild &&
1831 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
1832 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
|
190 Component *comp;
191
192 if (oper->num_consts(globals) == 0) return;
193 // Iterate over the component list looking for constants
194 oper->_components.reset();
195 if ((comp = oper->_components.iter()) == NULL) {
196 assert(oper->num_consts(globals) == 1, "Bad component list detected.\n");
197 const char *type = oper->ideal_type(globals);
198 if (!strcmp(type, "ConI")) {
199 if (i > 0) fprintf(fp,", ");
200 fprintf(fp," int32 _c%d;\n", i);
201 }
202 else if (!strcmp(type, "ConP")) {
203 if (i > 0) fprintf(fp,", ");
204 fprintf(fp," const TypePtr *_c%d;\n", i);
205 }
206 else if (!strcmp(type, "ConN")) {
207 if (i > 0) fprintf(fp,", ");
208 fprintf(fp," const TypeNarrowOop *_c%d;\n", i);
209 }
210 else if (!strcmp(type, "ConNKlass")) {
211 if (i > 0) fprintf(fp,", ");
212 fprintf(fp," const TypeNarrowKlass *_c%d;\n", i);
213 }
214 else if (!strcmp(type, "ConL")) {
215 if (i > 0) fprintf(fp,", ");
216 fprintf(fp," jlong _c%d;\n", i);
217 }
218 else if (!strcmp(type, "ConF")) {
219 if (i > 0) fprintf(fp,", ");
220 fprintf(fp," jfloat _c%d;\n", i);
221 }
222 else if (!strcmp(type, "ConD")) {
223 if (i > 0) fprintf(fp,", ");
224 fprintf(fp," jdouble _c%d;\n", i);
225 }
226 else if (!strcmp(type, "Bool")) {
227 fprintf(fp,"private:\n");
228 fprintf(fp," BoolTest::mask _c%d;\n", i);
229 fprintf(fp,"public:\n");
230 }
231 else {
232 assert(0, "Non-constant operand lacks component list.");
233 }
234 } // end if NULL
235 else {
236 oper->_components.reset();
237 while ((comp = oper->_components.iter()) != NULL) {
238 if (!strcmp(comp->base_type(globals), "ConI")) {
239 fprintf(fp," jint _c%d;\n", i);
240 i++;
241 }
242 else if (!strcmp(comp->base_type(globals), "ConP")) {
243 fprintf(fp," const TypePtr *_c%d;\n", i);
244 i++;
245 }
246 else if (!strcmp(comp->base_type(globals), "ConN")) {
247 fprintf(fp," const TypePtr *_c%d;\n", i);
248 i++;
249 }
250 else if (!strcmp(comp->base_type(globals), "ConNKlass")) {
251 fprintf(fp," const TypePtr *_c%d;\n", i);
252 i++;
253 }
254 else if (!strcmp(comp->base_type(globals), "ConL")) {
255 fprintf(fp," jlong _c%d;\n", i);
256 i++;
257 }
258 else if (!strcmp(comp->base_type(globals), "ConF")) {
259 fprintf(fp," jfloat _c%d;\n", i);
260 i++;
261 }
262 else if (!strcmp(comp->base_type(globals), "ConD")) {
263 fprintf(fp," jdouble _c%d;\n", i);
264 i++;
265 }
266 }
267 }
268 }
269
270 // Declare constructor.
271 // Parameters start with condition code, then all other constants
272 //
273 // (0) public:
280 fprintf(fp,"public:\n");
281 // generate line (1)
282 fprintf(fp," %sOper(", name);
283 if( num_consts == 0 ) {
284 fprintf(fp,") {}\n");
285 return;
286 }
287
288 // generate parameters for constants
289 uint i = 0;
290 Component *comp;
291 lst.reset();
292 if ((comp = lst.iter()) == NULL) {
293 assert(num_consts == 1, "Bad component list detected.\n");
294 switch( constant_type ) {
295 case Form::idealI : {
296 fprintf(fp,is_ideal_bool ? "BoolTest::mask c%d" : "int32 c%d", i);
297 break;
298 }
299 case Form::idealN : { fprintf(fp,"const TypeNarrowOop *c%d", i); break; }
300 case Form::idealNKlass : { fprintf(fp,"const TypeNarrowKlass *c%d", i); break; }
301 case Form::idealP : { fprintf(fp,"const TypePtr *c%d", i); break; }
302 case Form::idealL : { fprintf(fp,"jlong c%d", i); break; }
303 case Form::idealF : { fprintf(fp,"jfloat c%d", i); break; }
304 case Form::idealD : { fprintf(fp,"jdouble c%d", i); break; }
305 default:
306 assert(!is_ideal_bool, "Non-constant operand lacks component list.");
307 break;
308 }
309 } // end if NULL
310 else {
311 lst.reset();
312 while((comp = lst.iter()) != NULL) {
313 if (!strcmp(comp->base_type(globals), "ConI")) {
314 if (i > 0) fprintf(fp,", ");
315 fprintf(fp,"int32 c%d", i);
316 i++;
317 }
318 else if (!strcmp(comp->base_type(globals), "ConP")) {
319 if (i > 0) fprintf(fp,", ");
320 fprintf(fp,"const TypePtr *c%d", i);
321 i++;
322 }
323 else if (!strcmp(comp->base_type(globals), "ConN")) {
324 if (i > 0) fprintf(fp,", ");
325 fprintf(fp,"const TypePtr *c%d", i);
326 i++;
327 }
328 else if (!strcmp(comp->base_type(globals), "ConNKlass")) {
329 if (i > 0) fprintf(fp,", ");
330 fprintf(fp,"const TypePtr *c%d", i);
331 i++;
332 }
333 else if (!strcmp(comp->base_type(globals), "ConL")) {
334 if (i > 0) fprintf(fp,", ");
335 fprintf(fp,"jlong c%d", i);
336 i++;
337 }
338 else if (!strcmp(comp->base_type(globals), "ConF")) {
339 if (i > 0) fprintf(fp,", ");
340 fprintf(fp,"jfloat c%d", i);
341 i++;
342 }
343 else if (!strcmp(comp->base_type(globals), "ConD")) {
344 if (i > 0) fprintf(fp,", ");
345 fprintf(fp,"jdouble c%d", i);
346 i++;
347 }
348 else if (!strcmp(comp->base_type(globals), "Bool")) {
349 if (i > 0) fprintf(fp,", ");
350 fprintf(fp,"BoolTest::mask c%d", i);
351 i++;
352 }
377 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format);
378 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"%s\");\n",i,cond->_greater_equal_format);
379 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"%s\");\n",i,cond->_less_format);
380 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
381 }
382
383 // Output code that dumps constant values, increment "i" if type is constant
384 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
385 if (!strcmp(ideal_type, "ConI")) {
386 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i);
387 ++i;
388 }
389 else if (!strcmp(ideal_type, "ConP")) {
390 fprintf(fp," _c%d->dump_on(st);\n", i);
391 ++i;
392 }
393 else if (!strcmp(ideal_type, "ConN")) {
394 fprintf(fp," _c%d->dump_on(st);\n", i);
395 ++i;
396 }
397 else if (!strcmp(ideal_type, "ConNKlass")) {
398 fprintf(fp," _c%d->dump_on(st);\n", i);
399 ++i;
400 }
401 else if (!strcmp(ideal_type, "ConL")) {
402 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i);
403 ++i;
404 }
405 else if (!strcmp(ideal_type, "ConF")) {
406 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
407 ++i;
408 }
409 else if (!strcmp(ideal_type, "ConD")) {
410 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
411 ++i;
412 }
413 else if (!strcmp(ideal_type, "Bool")) {
414 defineCCodeDump(oper, fp,i);
415 ++i;
416 }
417
418 return i;
419 }
420
1240 // Check the interface type, and generate the correct query functions
1241 // encoding queries based upon MEMORY_INTER, REG_INTER, CONST_INTER.
1242
1243 fprintf(fp," virtual uint opcode() const { return %s; }\n",
1244 machOperEnum(oper->_ident));
1245
1246 // virtual function to look up ideal return type of machine instruction
1247 //
1248 // (1) virtual const Type *type() const { return .....; }
1249 //
1250 if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
1251 (oper->_matrule->_rChild == NULL)) {
1252 unsigned int position = 0;
1253 const char *opret, *opname, *optype;
1254 oper->_matrule->base_operand(position,_globalNames,opret,opname,optype);
1255 fprintf(fp," virtual const Type *type() const {");
1256 const char *type = getIdealType(optype);
1257 if( type != NULL ) {
1258 Form::DataType data_type = oper->is_base_constant(_globalNames);
1259 // Check if we are an ideal pointer type
1260 if( data_type == Form::idealP || data_type == Form::idealN || data_type == Form::idealNKlass ) {
1261 // Return the ideal type we already have: <TypePtr *>
1262 fprintf(fp," return _c0;");
1263 } else {
1264 // Return the appropriate bottom type
1265 fprintf(fp," return %s;", getIdealType(optype));
1266 }
1267 } else {
1268 fprintf(fp," ShouldNotCallThis(); return Type::BOTTOM;");
1269 }
1270 fprintf(fp," }\n");
1271 } else {
1272 // Check for user-defined stack slots, based upon sRegX
1273 Form::DataType data_type = oper->is_user_name_for_sReg();
1274 if( data_type != Form::none ){
1275 const char *type = NULL;
1276 switch( data_type ) {
1277 case Form::idealI: type = "TypeInt::INT"; break;
1278 case Form::idealP: type = "TypePtr::BOTTOM";break;
1279 case Form::idealF: type = "Type::FLOAT"; break;
1280 case Form::idealD: type = "Type::DOUBLE"; break;
1378 else if (!strcmp(oper->ideal_type(_globalNames), "ConP")) {
1379 // Access the locally stored constant
1380 fprintf(fp," virtual intptr_t constant() const {");
1381 fprintf(fp, " return _c0->get_con();");
1382 fprintf(fp, " }\n");
1383 // Generate query to determine if this pointer is an oop
1384 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
1385 fprintf(fp, " return _c0->reloc();");
1386 fprintf(fp, " }\n");
1387 }
1388 else if (!strcmp(oper->ideal_type(_globalNames), "ConN")) {
1389 // Access the locally stored constant
1390 fprintf(fp," virtual intptr_t constant() const {");
1391 fprintf(fp, " return _c0->get_ptrtype()->get_con();");
1392 fprintf(fp, " }\n");
1393 // Generate query to determine if this pointer is an oop
1394 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
1395 fprintf(fp, " return _c0->get_ptrtype()->reloc();");
1396 fprintf(fp, " }\n");
1397 }
1398 else if (!strcmp(oper->ideal_type(_globalNames), "ConNKlass")) {
1399 // Access the locally stored constant
1400 fprintf(fp," virtual intptr_t constant() const {");
1401 fprintf(fp, " return _c0->get_ptrtype()->get_con();");
1402 fprintf(fp, " }\n");
1403 // Generate query to determine if this pointer is an oop
1404 fprintf(fp," virtual relocInfo::relocType constant_reloc() const {");
1405 fprintf(fp, " return _c0->get_ptrtype()->reloc();");
1406 fprintf(fp, " }\n");
1407 }
1408 else if (!strcmp(oper->ideal_type(_globalNames), "ConL")) {
1409 fprintf(fp," virtual intptr_t constant() const {");
1410 // We don't support addressing modes with > 4Gig offsets.
1411 // Truncate to int.
1412 fprintf(fp, " return (intptr_t)_c0;");
1413 fprintf(fp, " }\n");
1414 fprintf(fp," virtual jlong constantL() const {");
1415 fprintf(fp, " return _c0;");
1416 fprintf(fp, " }\n");
1417 }
1418 else if (!strcmp(oper->ideal_type(_globalNames), "ConF")) {
1419 fprintf(fp," virtual intptr_t constant() const {");
1420 fprintf(fp, " ShouldNotReachHere(); return 0; ");
1421 fprintf(fp, " }\n");
1422 fprintf(fp," virtual jfloat constantF() const {");
1423 fprintf(fp, " return (jfloat)_c0;");
1424 fprintf(fp, " }\n");
1425 }
1426 else if (!strcmp(oper->ideal_type(_globalNames), "ConD")) {
1427 fprintf(fp," virtual intptr_t constant() const {");
1821 // thereby removing degrees of scheduling freedom that the optimizer
1822 // assumed would be available.)
1823 //
1824 // %%% We should handle many of these cases with an explicit ADL clause:
1825 // instruct foo() %{ ... bottom_type(TypeRawPtr::BOTTOM); ... %}
1826 if( data_type != Form::none ) {
1827 // A constant's bottom_type returns a Type containing its constant value
1828
1829 // !!!!!
1830 // Convert all ints, floats, ... to machine-independent TypeXs
1831 // as is done for pointers
1832 //
1833 // Construct appropriate constant type containing the constant value.
1834 fprintf(fp," virtual const class Type *bottom_type() const{\n");
1835 switch( data_type ) {
1836 case Form::idealI:
1837 fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n");
1838 break;
1839 case Form::idealP:
1840 case Form::idealN:
1841 case Form::idealNKlass:
1842 fprintf(fp," return opnd_array(1)->type();\n");
1843 break;
1844 case Form::idealD:
1845 fprintf(fp," return TypeD::make(opnd_array(1)->constantD());\n");
1846 break;
1847 case Form::idealF:
1848 fprintf(fp," return TypeF::make(opnd_array(1)->constantF());\n");
1849 break;
1850 case Form::idealL:
1851 fprintf(fp," return TypeLong::make(opnd_array(1)->constantL());\n");
1852 break;
1853 default:
1854 assert( false, "Unimplemented()" );
1855 break;
1856 }
1857 fprintf(fp," };\n");
1858 }
1859 /* else if ( instr->_matrule && instr->_matrule->_rChild &&
1860 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
1861 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
|