comparison src/share/vm/adlc/output_h.cpp @ 6850:d336b3173277

8000592: Improve adlc usability Summary: several changes to adlc to improve its usability Reviewed-by: kvn Contributed-by: goetz.lindenmaier@sap.com
author kvn
date Tue, 09 Oct 2012 16:09:31 -0700
parents 8e47bac5643a
children 705ef39fcaa9
comparison
equal deleted inserted replaced
6849:f6badecb7ea7 6850:d336b3173277
23 */ 23 */
24 24
25 // output_h.cpp - Class HPP file output routines for architecture definition 25 // output_h.cpp - Class HPP file output routines for architecture definition
26 #include "adlc.hpp" 26 #include "adlc.hpp"
27 27
28 // The comment delimiter used in format statements after assembler instructions.
29 #define commentSeperator "!"
28 30
29 // Generate the #define that describes the number of registers. 31 // Generate the #define that describes the number of registers.
30 static void defineRegCount(FILE *fp, RegisterForm *registers) { 32 static void defineRegCount(FILE *fp, RegisterForm *registers) {
31 if (registers) { 33 if (registers) {
32 int regCount = AdlcVMDeps::Physical + registers->_rdefs.count(); 34 int regCount = AdlcVMDeps::Physical + registers->_rdefs.count();
77 79
78 // Output the register number for each register in the allocation classes 80 // Output the register number for each register in the allocation classes
79 _register->reset_RegDefs(); 81 _register->reset_RegDefs();
80 int i = 0; 82 int i = 0;
81 while( (reg_def = _register->iter_RegDefs()) != NULL ) { 83 while( (reg_def = _register->iter_RegDefs()) != NULL ) {
82 fprintf(fp_hpp," %s_num,\t\t// %d\n", reg_def->_regname, i++); 84 fprintf(fp_hpp," %s_num,", reg_def->_regname);
85 for (int j = 0; j < 20-(int)strlen(reg_def->_regname); j++) fprintf(fp_hpp, " ");
86 fprintf(fp_hpp," // enum %3d, regnum %3d, reg encode %3s\n",
87 i++,
88 reg_def->register_num(),
89 reg_def->register_encode());
83 } 90 }
84 // Finish defining enumeration 91 // Finish defining enumeration
85 fprintf(fp_hpp, " _last_Mach_Reg\t// %d\n", i); 92 fprintf(fp_hpp, " _last_Mach_Reg // %d\n", i);
86 fprintf(fp_hpp, "};\n"); 93 fprintf(fp_hpp, "};\n");
87 } 94 }
88 95
89 fprintf(fp_hpp, "\n// Size of register-mask in ints\n"); 96 fprintf(fp_hpp, "\n// Size of register-mask in ints\n");
90 fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size()); 97 fprintf(fp_hpp, "#define RM_SIZE %d\n",RegisterForm::RegMask_Size());
119 fprintf(fp_hpp, "\n"); 126 fprintf(fp_hpp, "\n");
120 fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n"); 127 fprintf(fp_hpp, "// Enumerate machine registers starting after reserved regs.\n");
121 fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n"); 128 fprintf(fp_hpp, "// in the order of occurrence in the alloc_class(es).\n");
122 fprintf(fp_hpp, "enum MachRegisterEncodes {\n"); 129 fprintf(fp_hpp, "enum MachRegisterEncodes {\n");
123 130
131 // Find max enum string length.
132 size_t maxlen = 0;
133 _register->reset_RegDefs();
134 reg_def = _register->iter_RegDefs();
135 while (reg_def != NULL) {
136 size_t len = strlen(reg_def->_regname);
137 if (len > maxlen) maxlen = len;
138 reg_def = _register->iter_RegDefs();
139 }
140
124 // Output the register encoding for each register in the allocation classes 141 // Output the register encoding for each register in the allocation classes
125 _register->reset_RegDefs(); 142 _register->reset_RegDefs();
126 reg_def_next = _register->iter_RegDefs(); 143 reg_def_next = _register->iter_RegDefs();
127 while( (reg_def = reg_def_next) != NULL ) { 144 while( (reg_def = reg_def_next) != NULL ) {
128 reg_def_next = _register->iter_RegDefs(); 145 reg_def_next = _register->iter_RegDefs();
129 fprintf(fp_hpp," %s_enc = %s%s\n", 146 fprintf(fp_hpp," %s_enc", reg_def->_regname);
130 reg_def->_regname, reg_def->register_encode(), reg_def_next == NULL? "" : "," ); 147 for (size_t i = strlen(reg_def->_regname); i < maxlen; i++) fprintf(fp_hpp, " ");
148 fprintf(fp_hpp," = %3s%s\n", reg_def->register_encode(), reg_def_next == NULL? "" : "," );
131 } 149 }
132 // Finish defining enumeration 150 // Finish defining enumeration
133 fprintf(fp_hpp, "};\n"); 151 fprintf(fp_hpp, "};\n");
134 152
135 } // Done with register form 153 } // Done with register form
173 // --------------------------------------------------------------------------- 191 // ---------------------------------------------------------------------------
174 192
175 //------------------------------Utilities to build Operand Classes------------ 193 //------------------------------Utilities to build Operand Classes------------
176 static void in_RegMask(FILE *fp) { 194 static void in_RegMask(FILE *fp) {
177 fprintf(fp," virtual const RegMask *in_RegMask(int index) const;\n"); 195 fprintf(fp," virtual const RegMask *in_RegMask(int index) const;\n");
178 }
179
180 static void declare_hash(FILE *fp) {
181 fprintf(fp," virtual uint hash() const;\n");
182 }
183
184 static void declare_cmp(FILE *fp) {
185 fprintf(fp," virtual uint cmp( const MachOper &oper ) const;\n");
186 } 196 }
187 197
188 static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) { 198 static void declareConstStorage(FILE *fp, FormDict &globals, OperandForm *oper) {
189 int i = 0; 199 int i = 0;
190 Component *comp; 200 Component *comp;
370 380
371 // Generate the format rule for condition codes 381 // Generate the format rule for condition codes
372 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) { 382 static void defineCCodeDump(OperandForm* oper, FILE *fp, int i) {
373 assert(oper != NULL, "what"); 383 assert(oper != NULL, "what");
374 CondInterface* cond = oper->_interface->is_CondInterface(); 384 CondInterface* cond = oper->_interface->is_CondInterface();
375 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format); 385 fprintf(fp, " if( _c%d == BoolTest::eq ) st->print(\"%s\");\n",i,cond->_equal_format);
376 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format); 386 fprintf(fp, " else if( _c%d == BoolTest::ne ) st->print(\"%s\");\n",i,cond->_not_equal_format);
377 fprintf(fp, " else if( _c%d == BoolTest::le ) st->print(\"%s\");\n",i,cond->_less_equal_format); 387 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); 388 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); 389 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); 390 fprintf(fp, " else if( _c%d == BoolTest::gt ) st->print(\"%s\");\n",i,cond->_greater_format);
381 } 391 }
382 392
383 // Output code that dumps constant values, increment "i" if type is constant 393 // 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) { 394 static uint dump_spec_constant(FILE *fp, const char *ideal_type, uint i, OperandForm* oper) {
385 if (!strcmp(ideal_type, "ConI")) { 395 if (!strcmp(ideal_type, "ConI")) {
386 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i); 396 fprintf(fp," st->print(\"#%%d\", _c%d);\n", i);
397 fprintf(fp," st->print(\"/0x%%08x\", _c%d);\n", i);
387 ++i; 398 ++i;
388 } 399 }
389 else if (!strcmp(ideal_type, "ConP")) { 400 else if (!strcmp(ideal_type, "ConP")) {
390 fprintf(fp," _c%d->dump_on(st);\n", i); 401 fprintf(fp," _c%d->dump_on(st);\n", i);
391 ++i; 402 ++i;
398 fprintf(fp," _c%d->dump_on(st);\n", i); 409 fprintf(fp," _c%d->dump_on(st);\n", i);
399 ++i; 410 ++i;
400 } 411 }
401 else if (!strcmp(ideal_type, "ConL")) { 412 else if (!strcmp(ideal_type, "ConL")) {
402 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i); 413 fprintf(fp," st->print(\"#\" INT64_FORMAT, _c%d);\n", i);
414 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%d);\n", i);
403 ++i; 415 ++i;
404 } 416 }
405 else if (!strcmp(ideal_type, "ConF")) { 417 else if (!strcmp(ideal_type, "ConF")) {
406 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); 418 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
419 fprintf(fp," jint _c%di = JavaValue(_c%d).get_jint();\n", i, i);
420 fprintf(fp," st->print(\"/0x%%x/\", _c%di);\n", i);
407 ++i; 421 ++i;
408 } 422 }
409 else if (!strcmp(ideal_type, "ConD")) { 423 else if (!strcmp(ideal_type, "ConD")) {
410 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i); 424 fprintf(fp," st->print(\"#%%f\", _c%d);\n", i);
425 fprintf(fp," jlong _c%dl = JavaValue(_c%d).get_jlong();\n", i, i);
426 fprintf(fp," st->print(\"/\" PTR64_FORMAT, _c%dl);\n", i);
411 ++i; 427 ++i;
412 } 428 }
413 else if (!strcmp(ideal_type, "Bool")) { 429 else if (!strcmp(ideal_type, "Bool")) {
414 defineCCodeDump(oper, fp,i); 430 defineCCodeDump(oper, fp,i);
415 ++i; 431 ++i;
427 fprintf(fp," virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n"); 443 fprintf(fp," virtual void ext_format(PhaseRegAlloc *ra, const MachNode *node, int idx, outputStream *st) const;\n");
428 return; 444 return;
429 } 445 }
430 446
431 // Local pointer indicates remaining part of format rule 447 // Local pointer indicates remaining part of format rule
432 uint idx = 0; // position of operand in match rule 448 int idx = 0; // position of operand in match rule
433 449
434 // Generate internal format function, used when stored locally 450 // Generate internal format function, used when stored locally
435 fprintf(fp, "\n#ifndef PRODUCT\n"); 451 fprintf(fp, "\n#ifndef PRODUCT\n");
436 fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident); 452 fprintf(fp,"void %sOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {\n", oper._ident);
437 // Generate the user-defined portion of the format 453 // Generate the user-defined portion of the format
442 // Build the format from the entries in strings and rep_vars 458 // Build the format from the entries in strings and rep_vars
443 const char *string = NULL; 459 const char *string = NULL;
444 oper._format->_rep_vars.reset(); 460 oper._format->_rep_vars.reset();
445 oper._format->_strings.reset(); 461 oper._format->_strings.reset();
446 while ( (string = oper._format->_strings.iter()) != NULL ) { 462 while ( (string = oper._format->_strings.iter()) != NULL ) {
447 fprintf(fp," ");
448 463
449 // Check if this is a standard string or a replacement variable 464 // Check if this is a standard string or a replacement variable
450 if ( string != NameList::_signal ) { 465 if ( string != NameList::_signal ) {
451 // Normal string 466 // Normal string
452 // Pass through to st->print 467 // Pass through to st->print
453 fprintf(fp,"st->print(\"%s\");\n", string); 468 fprintf(fp," st->print(\"%s\");\n", string);
454 } else { 469 } else {
455 // Replacement variable 470 // Replacement variable
456 const char *rep_var = oper._format->_rep_vars.iter(); 471 const char *rep_var = oper._format->_rep_vars.iter();
457 // Check that it is a local name, and an operand 472 // Check that it is a local name, and an operand
458 const Form* form = oper._localNames[rep_var]; 473 const Form* form = oper._localNames[rep_var];
471 } else { 486 } else {
472 idx = 0; 487 idx = 0;
473 } 488 }
474 489
475 // output invocation of "$..."s format function 490 // output invocation of "$..."s format function
476 if ( op != NULL ) op->int_format(fp, globals, idx); 491 if ( op != NULL ) op->int_format(fp, globals, idx);
477 492
478 if ( idx == -1 ) { 493 if ( idx == -1 ) {
479 fprintf(stderr, 494 fprintf(stderr,
480 "Using a name, %s, that isn't in match rule\n", rep_var); 495 "Using a name, %s, that isn't in match rule\n", rep_var);
481 assert( strcmp(op->_ident,"label")==0, "Unimplemented"); 496 assert( strcmp(op->_ident,"label")==0, "Unimplemented");
514 // Build the format from the entries in strings and rep_vars 529 // Build the format from the entries in strings and rep_vars
515 const char *string = NULL; 530 const char *string = NULL;
516 oper._format->_rep_vars.reset(); 531 oper._format->_rep_vars.reset();
517 oper._format->_strings.reset(); 532 oper._format->_strings.reset();
518 while ( (string = oper._format->_strings.iter()) != NULL ) { 533 while ( (string = oper._format->_strings.iter()) != NULL ) {
519 fprintf(fp," ");
520 534
521 // Check if this is a standard string or a replacement variable 535 // Check if this is a standard string or a replacement variable
522 if ( string != NameList::_signal ) { 536 if ( string != NameList::_signal ) {
523 // Normal string 537 // Normal string
524 // Pass through to st->print 538 // Pass through to st->print
525 fprintf(fp,"st->print(\"%s\");\n", string); 539 fprintf(fp," st->print(\"%s\");\n", string);
526 } else { 540 } else {
527 // Replacement variable 541 // Replacement variable
528 const char *rep_var = oper._format->_rep_vars.iter(); 542 const char *rep_var = oper._format->_rep_vars.iter();
529 // Check that it is a local name, and an operand 543 // Check that it is a local name, and an operand
530 const Form* form = oper._localNames[rep_var]; 544 const Form* form = oper._localNames[rep_var];
545 } 559 }
546 // output invocation of "$..."s format function 560 // output invocation of "$..."s format function
547 if ( op != NULL ) op->ext_format(fp, globals, idx); 561 if ( op != NULL ) op->ext_format(fp, globals, idx);
548 562
549 // Lookup the index position of the replacement variable 563 // Lookup the index position of the replacement variable
550 idx = oper._components.operand_position_format(rep_var); 564 idx = oper._components.operand_position_format(rep_var, &oper);
551 if ( idx == -1 ) { 565 if ( idx == -1 ) {
552 fprintf(stderr, 566 fprintf(stderr,
553 "Using a name, %s, that isn't in match rule\n", rep_var); 567 "Using a name, %s, that isn't in match rule\n", rep_var);
554 assert( strcmp(op->_ident,"label")==0, "Unimplemented"); 568 assert( strcmp(op->_ident,"label")==0, "Unimplemented");
555 } 569 }
599 // Build the format from the entries in strings and rep_vars 613 // Build the format from the entries in strings and rep_vars
600 const char *string = NULL; 614 const char *string = NULL;
601 inst._format->_rep_vars.reset(); 615 inst._format->_rep_vars.reset();
602 inst._format->_strings.reset(); 616 inst._format->_strings.reset();
603 while( (string = inst._format->_strings.iter()) != NULL ) { 617 while( (string = inst._format->_strings.iter()) != NULL ) {
604 fprintf(fp," "); 618 fprintf(fp," ");
605 // Check if this is a standard string or a replacement variable 619 // Check if this is a standard string or a replacement variable
606 if( string == NameList::_signal ) { // Replacement variable 620 if( string == NameList::_signal ) { // Replacement variable
607 const char* rep_var = inst._format->_rep_vars.iter(); 621 const char* rep_var = inst._format->_rep_vars.iter();
608 inst.rep_var_format( fp, rep_var); 622 inst.rep_var_format( fp, rep_var);
609 } else if( string == NameList::_signal3 ) { // Replacement variable in raw text 623 } else if( string == NameList::_signal3 ) { // Replacement variable in raw text
656 // Add call debug info automatically 670 // Add call debug info automatically
657 Form::CallType call_type = inst.is_ideal_call(); 671 Form::CallType call_type = inst.is_ideal_call();
658 if( call_type != Form::invalid_type ) { 672 if( call_type != Form::invalid_type ) {
659 switch( call_type ) { 673 switch( call_type ) {
660 case Form::JAVA_DYNAMIC: 674 case Form::JAVA_DYNAMIC:
661 fprintf(fp," _method->print_short_name();\n"); 675 fprintf(fp," _method->print_short_name(st);\n");
662 break; 676 break;
663 case Form::JAVA_STATIC: 677 case Form::JAVA_STATIC:
664 fprintf(fp," if( _method ) _method->print_short_name(st); else st->print(\" wrapper for: %%s\", _name);\n"); 678 fprintf(fp," if( _method ) _method->print_short_name(st);\n");
665 fprintf(fp," if( !_method ) dump_trap_args(st);\n"); 679 fprintf(fp," else st->print(\" wrapper for: %%s\", _name);\n");
680 fprintf(fp," if( !_method ) dump_trap_args(st);\n");
666 break; 681 break;
667 case Form::JAVA_COMPILED: 682 case Form::JAVA_COMPILED:
668 case Form::JAVA_INTERP: 683 case Form::JAVA_INTERP:
669 break; 684 break;
670 case Form::JAVA_RUNTIME: 685 case Form::JAVA_RUNTIME:
671 case Form::JAVA_LEAF: 686 case Form::JAVA_LEAF:
672 case Form::JAVA_NATIVE: 687 case Form::JAVA_NATIVE:
673 fprintf(fp," st->print(\" %%s\", _name);"); 688 fprintf(fp," st->print(\" %%s\", _name);");
674 break; 689 break;
675 default: 690 default:
676 assert(0,"ShouldNotReacHere"); 691 assert(0,"ShouldNotReachHere");
677 } 692 }
678 fprintf(fp, " st->print_cr(\"\");\n" ); 693 fprintf(fp, " st->print_cr(\"\");\n" );
679 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); 694 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" );
680 fprintf(fp, " st->print(\" # \");\n" ); 695 fprintf(fp, " st->print(\" # \");\n" );
681 fprintf(fp, " if( _jvms ) _oop_map->print_on(st);\n"); 696 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
682 } 697 }
683 else if(inst.is_ideal_safepoint()) { 698 else if(inst.is_ideal_safepoint()) {
684 fprintf(fp, " st->print(\"\");\n" ); 699 fprintf(fp, " st->print(\"\");\n" );
685 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" ); 700 fprintf(fp, " if (_jvms) _jvms->format(ra, this, st); else st->print_cr(\" No JVM State Info\");\n" );
686 fprintf(fp, " st->print(\" # \");\n" ); 701 fprintf(fp, " st->print(\" # \");\n" );
687 fprintf(fp, " if( _jvms ) _oop_map->print_on(st);\n"); 702 fprintf(fp, " if( _jvms && _oop_map ) _oop_map->print_on(st);\n");
688 } 703 }
689 else if( inst.is_ideal_if() ) { 704 else if( inst.is_ideal_if() ) {
690 fprintf(fp, " st->print(\" P=%%f C=%%f\",_prob,_fcnt);\n" ); 705 fprintf(fp, " st->print(\" P=%%f C=%%f\",_prob,_fcnt);\n" );
691 } 706 }
692 else if( inst.is_ideal_mem() ) { 707 else if( inst.is_ideal_mem() ) {
693 // Print out the field name if available to improve readability 708 // Print out the field name if available to improve readability
694 fprintf(fp, " if (ra->C->alias_type(adr_type())->field() != NULL) {\n"); 709 fprintf(fp, " if (ra->C->alias_type(adr_type())->field() != NULL) {\n");
695 fprintf(fp, " ciField* f = ra->C->alias_type(adr_type())->field();\n"); 710 fprintf(fp, " ciField* f = ra->C->alias_type(adr_type())->field();\n");
696 fprintf(fp, " st->print(\" ! Field: \");\n"); 711 fprintf(fp, " st->print(\" %s Field: \");\n", commentSeperator);
697 fprintf(fp, " if (f->is_volatile())\n"); 712 fprintf(fp, " if (f->is_volatile())\n");
698 fprintf(fp, " st->print(\"volatile \");\n"); 713 fprintf(fp, " st->print(\"volatile \");\n");
699 fprintf(fp, " f->holder()->name()->print_symbol_on(st);\n"); 714 fprintf(fp, " f->holder()->name()->print_symbol_on(st);\n");
700 fprintf(fp, " st->print(\".\");\n"); 715 fprintf(fp, " st->print(\".\");\n");
701 fprintf(fp, " f->name()->print_symbol_on(st);\n"); 716 fprintf(fp, " f->name()->print_symbol_on(st);\n");
702 fprintf(fp, " if (f->is_constant())\n"); 717 fprintf(fp, " if (f->is_constant())\n");
703 fprintf(fp, " st->print(\" (constant)\");\n"); 718 fprintf(fp, " st->print(\" (constant)\");\n");
704 fprintf(fp, " } else\n"); 719 fprintf(fp, " } else {\n");
705 // Make sure 'Volatile' gets printed out 720 // Make sure 'Volatile' gets printed out
706 fprintf(fp, " if (ra->C->alias_type(adr_type())->is_volatile())\n"); 721 fprintf(fp, " if (ra->C->alias_type(adr_type())->is_volatile())\n");
707 fprintf(fp, " st->print(\" volatile!\");\n"); 722 fprintf(fp, " st->print(\" volatile!\");\n");
723 fprintf(fp, " }\n");
708 } 724 }
709 725
710 // Complete the definition of the format function 726 // Complete the definition of the format function
711 fprintf(fp, " }\n#endif\n"); 727 fprintf(fp, "}\n#endif\n");
712 }
713
714 static bool is_non_constant(char* x) {
715 // Tells whether the string (part of an operator interface) is non-constant.
716 // Simply detect whether there is an occurrence of a formal parameter,
717 // which will always begin with '$'.
718 return strchr(x, '$') == 0;
719 } 728 }
720 729
721 void ArchDesc::declare_pipe_classes(FILE *fp_hpp) { 730 void ArchDesc::declare_pipe_classes(FILE *fp_hpp) {
722 if (!_pipeline) 731 if (!_pipeline)
723 return; 732 return;
1105 _pipeline->_nopcnt); 1114 _pipeline->_nopcnt);
1106 fprintf(fp_hpp, " };\n\n"); 1115 fprintf(fp_hpp, " };\n\n");
1107 fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n", 1116 fprintf(fp_hpp, " static void initialize_nops(MachNode *nop_list[%d], Compile* C);\n\n",
1108 _pipeline->_nopcnt); 1117 _pipeline->_nopcnt);
1109 fprintf(fp_hpp, "#ifndef PRODUCT\n"); 1118 fprintf(fp_hpp, "#ifndef PRODUCT\n");
1110 fprintf(fp_hpp, " void dump() const;\n"); 1119 fprintf(fp_hpp, " void dump(outputStream *st = tty) const;\n");
1111 fprintf(fp_hpp, "#endif\n"); 1120 fprintf(fp_hpp, "#endif\n");
1112 fprintf(fp_hpp, "};\n\n"); 1121 fprintf(fp_hpp, "};\n\n");
1113 1122
1114 // const char *classname; 1123 // const char *classname;
1115 // for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) { 1124 // for (_pipeline->_classlist.reset(); (classname = _pipeline->_classlist.iter()) != NULL; ) {
1250 if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) && 1259 if ((oper->_matrule) && (oper->_matrule->_lChild == NULL) &&
1251 (oper->_matrule->_rChild == NULL)) { 1260 (oper->_matrule->_rChild == NULL)) {
1252 unsigned int position = 0; 1261 unsigned int position = 0;
1253 const char *opret, *opname, *optype; 1262 const char *opret, *opname, *optype;
1254 oper->_matrule->base_operand(position,_globalNames,opret,opname,optype); 1263 oper->_matrule->base_operand(position,_globalNames,opret,opname,optype);
1255 fprintf(fp," virtual const Type *type() const {"); 1264 fprintf(fp," virtual const Type *type() const {");
1256 const char *type = getIdealType(optype); 1265 const char *type = getIdealType(optype);
1257 if( type != NULL ) { 1266 if( type != NULL ) {
1258 Form::DataType data_type = oper->is_base_constant(_globalNames); 1267 Form::DataType data_type = oper->is_base_constant(_globalNames);
1259 // Check if we are an ideal pointer type 1268 // Check if we are an ideal pointer type
1260 if( data_type == Form::idealP || data_type == Form::idealN || data_type == Form::idealNKlass ) { 1269 if( data_type == Form::idealP || data_type == Form::idealN || data_type == Form::idealNKlass ) {
1529 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() ); 1538 fprintf(fp," MachOper *_opnd_array[%d];\n", instr->num_opnds() );
1530 if ( instr->is_ideal_jump() ) { 1539 if ( instr->is_ideal_jump() ) {
1531 fprintf(fp, " GrowableArray<Label*> _index2label;\n"); 1540 fprintf(fp, " GrowableArray<Label*> _index2label;\n");
1532 } 1541 }
1533 fprintf(fp,"public:\n"); 1542 fprintf(fp,"public:\n");
1534 fprintf(fp," MachOper *opnd_array(uint operand_index) const { assert(operand_index < _num_opnds, \"invalid _opnd_array index\"); return _opnd_array[operand_index]; }\n"); 1543 fprintf(fp," MachOper *opnd_array(uint operand_index) const {\n");
1535 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) { assert(operand_index < _num_opnds, \"invalid _opnd_array index\"); _opnd_array[operand_index] = operand; }\n"); 1544 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
1545 fprintf(fp," return _opnd_array[operand_index];\n");
1546 fprintf(fp," }\n");
1547 fprintf(fp," void set_opnd_array(uint operand_index, MachOper *operand) {\n");
1548 fprintf(fp," assert(operand_index < _num_opnds, \"invalid _opnd_array index\");\n");
1549 fprintf(fp," _opnd_array[operand_index] = operand;\n");
1550 fprintf(fp," }\n");
1536 fprintf(fp,"private:\n"); 1551 fprintf(fp,"private:\n");
1537 if ( instr->is_ideal_jump() ) { 1552 if ( instr->is_ideal_jump() ) {
1538 fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n"); 1553 fprintf(fp," virtual void add_case_label(int index_num, Label* blockLabel) {\n");
1539 fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);}\n"); 1554 fprintf(fp," _index2label.at_put_grow(index_num, blockLabel);\n");
1555 fprintf(fp," }\n");
1540 } 1556 }
1541 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) { 1557 if( can_cisc_spill() && (instr->cisc_spill_alternate() != NULL) ) {
1542 fprintf(fp," const RegMask *_cisc_RegMask;\n"); 1558 fprintf(fp," const RegMask *_cisc_RegMask;\n");
1543 } 1559 }
1544 1560
1570 Attribute *attr = instr->_attribs; 1586 Attribute *attr = instr->_attribs;
1571 bool avoid_back_to_back = false; 1587 bool avoid_back_to_back = false;
1572 while (attr != NULL) { 1588 while (attr != NULL) {
1573 if (strcmp(attr->_ident,"ins_cost") && 1589 if (strcmp(attr->_ident,"ins_cost") &&
1574 strcmp(attr->_ident,"ins_short_branch")) { 1590 strcmp(attr->_ident,"ins_short_branch")) {
1575 fprintf(fp," int %s() const { return %s; }\n", 1591 fprintf(fp," int %s() const { return %s; }\n",
1576 attr->_ident, attr->_val); 1592 attr->_ident, attr->_val);
1577 } 1593 }
1578 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag 1594 // Check value for ins_avoid_back_to_back, and if it is true (1), set the flag
1579 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0) 1595 if (!strcmp(attr->_ident,"ins_avoid_back_to_back") && attr->int_val(*this) != 0)
1580 avoid_back_to_back = true; 1596 avoid_back_to_back = true;
1654 fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n"); 1670 fprintf(fp," virtual MachNode *peephole(Block *block, int block_index, PhaseRegAlloc *ra_, int &deleted, Compile *C);\n");
1655 } 1671 }
1656 1672
1657 // Output the declaration for number of relocation entries 1673 // Output the declaration for number of relocation entries
1658 if ( instr->reloc(_globalNames) != 0 ) { 1674 if ( instr->reloc(_globalNames) != 0 ) {
1659 fprintf(fp," virtual int reloc() const;\n"); 1675 fprintf(fp," virtual int reloc() const;\n");
1660 } 1676 }
1661 1677
1662 if (instr->alignment() != 1) { 1678 if (instr->alignment() != 1) {
1663 fprintf(fp," virtual int alignment_required() const { return %d; }\n", instr->alignment()); 1679 fprintf(fp," virtual int alignment_required() const { return %d; }\n", instr->alignment());
1664 fprintf(fp," virtual int compute_padding(int current_offset) const;\n"); 1680 fprintf(fp," virtual int compute_padding(int current_offset) const;\n");
1665 } 1681 }
1666 1682
1667 // Starting point for inputs matcher wants. 1683 // Starting point for inputs matcher wants.
1668 // Use MachNode::oper_input_base() for nodes based on MachNode class 1684 // Use MachNode::oper_input_base() for nodes based on MachNode class
1669 // if the base == 1. 1685 // if the base == 1.
1829 // !!!!! 1845 // !!!!!
1830 // Convert all ints, floats, ... to machine-independent TypeXs 1846 // Convert all ints, floats, ... to machine-independent TypeXs
1831 // as is done for pointers 1847 // as is done for pointers
1832 // 1848 //
1833 // Construct appropriate constant type containing the constant value. 1849 // Construct appropriate constant type containing the constant value.
1834 fprintf(fp," virtual const class Type *bottom_type() const{\n"); 1850 fprintf(fp," virtual const class Type *bottom_type() const {\n");
1835 switch( data_type ) { 1851 switch( data_type ) {
1836 case Form::idealI: 1852 case Form::idealI:
1837 fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n"); 1853 fprintf(fp," return TypeInt::make(opnd_array(1)->constant());\n");
1838 break; 1854 break;
1839 case Form::idealP: 1855 case Form::idealP:
1860 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0 1876 ( strcmp("ConvF2I",instr->_matrule->_rChild->_opType)==0
1861 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) { 1877 || strcmp("ConvD2I",instr->_matrule->_rChild->_opType)==0 ) ) {
1862 // !!!!! !!!!! 1878 // !!!!! !!!!!
1863 // Provide explicit bottom type for conversions to int 1879 // Provide explicit bottom type for conversions to int
1864 // On Intel the result operand is a stackSlot, untyped. 1880 // On Intel the result operand is a stackSlot, untyped.
1865 fprintf(fp," virtual const class Type *bottom_type() const{"); 1881 fprintf(fp," virtual const class Type *bottom_type() const {");
1866 fprintf(fp, " return TypeInt::INT;"); 1882 fprintf(fp, " return TypeInt::INT;");
1867 fprintf(fp, " };\n"); 1883 fprintf(fp, " };\n");
1868 }*/ 1884 }*/
1869 else if( instr->is_ideal_copy() && 1885 else if( instr->is_ideal_copy() &&
1870 !strcmp(instr->_matrule->_lChild->_opType,"stackSlotP") ) { 1886 !strcmp(instr->_matrule->_lChild->_opType,"stackSlotP") ) {
1881 } 1897 }
1882 else if( instr->is_ideal_box() ) { 1898 else if( instr->is_ideal_box() ) {
1883 // BoxNode provides the address of a stack slot. 1899 // BoxNode provides the address of a stack slot.
1884 // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM 1900 // Define its bottom type to be TypeRawPtr::BOTTOM instead of TypePtr::BOTTOM
1885 // This prevent s insert_anti_dependencies from complaining. It will 1901 // This prevent s insert_anti_dependencies from complaining. It will
1886 // complain if it see that the pointer base is TypePtr::BOTTOM since 1902 // complain if it sees that the pointer base is TypePtr::BOTTOM since
1887 // it doesn't understand what that might alias. 1903 // it doesn't understand what that might alias.
1888 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n"); 1904 fprintf(fp," const Type *bottom_type() const { return TypeRawPtr::BOTTOM; } // Box?\n");
1889 } 1905 }
1890 else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveP") ) { 1906 else if( instr->_matrule && instr->_matrule->_rChild && !strcmp(instr->_matrule->_rChild->_opType,"CMoveP") ) {
1891 int offset = 1; 1907 int offset = 1;
2044 2060
2045 // Information needed to generate the ReduceOp mapping for the DFA 2061 // Information needed to generate the ReduceOp mapping for the DFA
2046 class OutputMachOperands : public OutputMap { 2062 class OutputMachOperands : public OutputMap {
2047 public: 2063 public:
2048 OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 2064 OutputMachOperands(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
2049 : OutputMap(hpp, cpp, globals, AD) {}; 2065 : OutputMap(hpp, cpp, globals, AD, "MachOperands") {};
2050 2066
2051 void declaration() { } 2067 void declaration() { }
2052 void definition() { fprintf(_cpp, "enum MachOperands {\n"); } 2068 void definition() { fprintf(_cpp, "enum MachOperands {\n"); }
2053 void closing() { fprintf(_cpp, " _LAST_MACH_OPER\n"); 2069 void closing() { fprintf(_cpp, " _LAST_MACH_OPER\n");
2054 OutputMap::closing(); 2070 OutputMap::closing();
2079 int begin_rematerialize; 2095 int begin_rematerialize;
2080 int end_rematerialize; 2096 int end_rematerialize;
2081 int end_instructions; 2097 int end_instructions;
2082 public: 2098 public:
2083 OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD) 2099 OutputMachOpcodes(FILE *hpp, FILE *cpp, FormDict &globals, ArchDesc &AD)
2084 : OutputMap(hpp, cpp, globals, AD), 2100 : OutputMap(hpp, cpp, globals, AD, "MachOpcodes"),
2085 begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1) 2101 begin_inst_chain_rule(-1), end_inst_chain_rule(-1), end_instructions(-1)
2086 {}; 2102 {};
2087 2103
2088 void declaration() { } 2104 void declaration() { }
2089 void definition() { fprintf(_cpp, "enum MachOpcodes {\n"); } 2105 void definition() { fprintf(_cpp, "enum MachOpcodes {\n"); }