comparison src/share/vm/adlc/output_h.cpp @ 415:4d9884b01ba6

6754519: don't emit flag fixup for NaN when condition being tested doesn't need it Reviewed-by: kvn, rasbold
author never
date Tue, 28 Oct 2008 09:31:30 -0700
parents c3e045194476
children f4fe12e429a4
comparison
equal deleted inserted replaced
407:ebfd4ae89bf6 415:4d9884b01ba6
353 // --------------------------------------------------------------------------- 353 // ---------------------------------------------------------------------------
354 // Utilities to generate format rules for machine operands and instructions 354 // Utilities to generate format rules for machine operands and instructions
355 // --------------------------------------------------------------------------- 355 // ---------------------------------------------------------------------------
356 356
357 // Generate the format rule for condition codes 357 // Generate the format rule for condition codes
358 static void defineCCodeDump(FILE *fp, int i) { 358 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) {
359 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"eq\");\n",i); 359 assert(oper != NULL, "what");
360 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"ne\");\n",i); 360 CondInterface* cond = oper->_interface->is_CondInterface();
361 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"le\");\n",i); 361 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format);
362 fprintf(fp, " else if( _c%d == BoolTest::ge ) st->print(\"ge\");\n",i); 362 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format);
363 fprintf(fp, " else if( _c%d == BoolTest::lt ) st->print(\"lt\");\n",i); 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::gt ) st->print(\"gt\");\n",i); 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);
365 } 367 }
366 368
367 // Output code that dumps constant values, increment "i" if type is constant 369 // Output code that dumps constant values, increment "i" if type is constant
368 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i) { 370 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
369 if (!strcmp(ideal_type, "ConI")) { 371 if (!strcmp(ideal_type, "ConI")) {
370 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i); 372 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i);
371 ++i; 373 ++i;
372 } 374 }
373 else if (!strcmp(ideal_type, "ConP")) { 375 else if (!strcmp(ideal_type, "ConP")) {
389 else if (!strcmp(ideal_type, "ConD")) { 391 else if (!strcmp(ideal_type, "ConD")) {
390 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); 392 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
391 ++i; 393 ++i;
392 } 394 }
393 else if (!strcmp(ideal_type, "Bool")) { 395 else if (!strcmp(ideal_type, "Bool")) {
394 defineCCodeDump(fp,i); 396 defineCCodeDump(oper, fp,i);
395 ++i; 397 ++i;
396 } 398 }
397 399
398 return i; 400 return i;
399 } 401 }
474 } 476 }
475 // labelOper::int_format is defined in ad_<...>.cpp 477 // labelOper::int_format is defined in ad_<...>.cpp
476 } 478 }
477 // ALWAYS! Provide a special case output for condition codes. 479 // ALWAYS! Provide a special case output for condition codes.
478 if( oper.is_ideal_bool() ) { 480 if( oper.is_ideal_bool() ) {
479 defineCCodeDump(fp,0); 481 defineCCodeDump(&oper, fp,0);
480 } 482 }
481 fprintf(fp,"}\n"); 483 fprintf(fp,"}\n");
482 484
483 // Generate external format function, when data is stored externally 485 // Generate external format function, when data is stored externally
484 fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident); 486 fprintf(fp,"void %sOper::ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const {\n", oper._ident);
547 } 549 }
548 // labelOper::ext_format is defined in ad_<...>.cpp 550 // labelOper::ext_format is defined in ad_<...>.cpp
549 } 551 }
550 // ALWAYS! Provide a special case output for condition codes. 552 // ALWAYS! Provide a special case output for condition codes.
551 if( oper.is_ideal_bool() ) { 553 if( oper.is_ideal_bool() ) {
552 defineCCodeDump(fp,0); 554 defineCCodeDump(&oper, fp,0);
553 } 555 }
554 fprintf(fp, "}\n"); 556 fprintf(fp, "}\n");
555 fprintf(fp, "#endif\n"); 557 fprintf(fp, "#endif\n");
556 } 558 }
557 559
581 inst._format->_rep_vars.reset(); 583 inst._format->_rep_vars.reset();
582 inst._format->_strings.reset(); 584 inst._format->_strings.reset();
583 while( (string = inst._format->_strings.iter()) != NULL ) { 585 while( (string = inst._format->_strings.iter()) != NULL ) {
584 fprintf(fp," "); 586 fprintf(fp," ");
585 // Check if this is a standard string or a replacement variable 587 // Check if this is a standard string or a replacement variable
586 if( string != NameList::_signal ) // Normal string. Pass through. 588 if( string == NameList::_signal ) { // Replacement variable
589 const char* rep_var = inst._format->_rep_vars.iter();
590 inst.rep_var_format( fp, rep_var);
591 } else if( string == NameList::_signal3 ) { // Replacement variable in raw text
592 const char* rep_var = inst._format->_rep_vars.iter();
593 const Form *form = inst._localNames[rep_var];
594 if (form == NULL) {
595 fprintf(stderr, "unknown replacement variable in format statement: '%s'\n", rep_var);
596 assert(false, "ShouldNotReachHere()");
597 }
598 OpClassForm *opc = form->is_opclass();
599 assert( opc, "replacement variable was not found in local names");
600 // Lookup the index position of the replacement variable
601 int idx = inst.operand_position_format(rep_var);
602 if ( idx == -1 ) {
603 assert( strcmp(opc->_ident,"label")==0, "Unimplemented");
604 assert( false, "ShouldNotReachHere()");
605 }
606
607 if (inst.is_noninput_operand(idx)) {
608 assert( false, "ShouldNotReachHere()");
609 } else {
610 // Output the format call for this operand
611 fprintf(fp,"opnd_array(%d)",idx);
612 }
613 rep_var = inst._format->_rep_vars.iter();
614 inst._format->_strings.iter();
615 if ( strcmp(rep_var,"$constant") == 0 && opc->is_operand()) {
616 Form::DataType constant_type = form->is_operand()->is_base_constant(globals);
617 if ( constant_type == Form::idealD ) {
618 fprintf(fp,"->constantD()");
619 } else if ( constant_type == Form::idealF ) {
620 fprintf(fp,"->constantF()");
621 } else if ( constant_type == Form::idealL ) {
622 fprintf(fp,"->constantL()");
623 } else {
624 fprintf(fp,"->constant()");
625 }
626 } else if ( strcmp(rep_var,"$cmpcode") == 0) {
627 fprintf(fp,"->ccode()");
628 } else {
629 assert( false, "ShouldNotReachHere()");
630 }
631 } else if( string == NameList::_signal2 ) // Raw program text
632 fputs(inst._format->_strings.iter(), fp);
633 else
587 fprintf(fp,"st->print(\"%s\");\n", string); 634 fprintf(fp,"st->print(\"%s\");\n", string);
588 else // Replacement variable
589 inst.rep_var_format( fp, inst._format->_rep_vars.iter() );
590 } // Done with all format strings 635 } // Done with all format strings
591 } // Done generating the user-defined portion of the format 636 } // Done generating the user-defined portion of the format
592 637
593 // Add call debug info automatically 638 // Add call debug info automatically
594 Form::CallType call_type = inst.is_ideal_call(); 639 Form::CallType call_type = inst.is_ideal_call();
1402 const char *type = oper->ideal_type(_globalNames); 1447 const char *type = oper->ideal_type(_globalNames);
1403 Component *comp; 1448 Component *comp;
1404 oper->_components.reset(); 1449 oper->_components.reset();
1405 if ((comp = oper->_components.iter()) == NULL) { 1450 if ((comp = oper->_components.iter()) == NULL) {
1406 assert(num_consts == 1, "Bad component list detected.\n"); 1451 assert(num_consts == 1, "Bad component list detected.\n");
1407 i = dump_spec_constant( fp, type, i ); 1452 i = dump_spec_constant( fp, type, i, oper );
1408 // Check that type actually matched 1453 // Check that type actually matched
1409 assert( i != 0, "Non-constant operand lacks component list."); 1454 assert( i != 0, "Non-constant operand lacks component list.");
1410 } // end if NULL 1455 } // end if NULL
1411 else { 1456 else {
1412 // line (2) 1457 // line (2)
1413 // dump all components 1458 // dump all components
1414 oper->_components.reset(); 1459 oper->_components.reset();
1415 while((comp = oper->_components.iter()) != NULL) { 1460 while((comp = oper->_components.iter()) != NULL) {
1416 type = comp->base_type(_globalNames); 1461 type = comp->base_type(_globalNames);
1417 i = dump_spec_constant( fp, type, i ); 1462 i = dump_spec_constant( fp, type, i, NULL );
1418 } 1463 }
1419 } 1464 }
1420 // finish line (3) 1465 // finish line (3)
1421 fprintf(fp," }\n"); 1466 fprintf(fp," }\n");
1422 } 1467 }