src/share/vm/adlc/formssel.cpp

Print this page




 733     if( is_ideal_load()  != Form::none ) {
 734       fprintf(stderr, "Warning: cannot find memory opnd in instr.\n");
 735       ((InstructForm*)this)->dump();
 736       // pretend it has multiple uses and no defs
 737       return MANY_MEMORY_OPERANDS;
 738     }
 739   }
 740 
 741   return NO_MEMORY_OPERAND;
 742 }
 743 
 744 
 745 // This instruction captures the machine-independent bottom_type
 746 // Expected use is for pointer vs oop determination for LoadP
 747 bool InstructForm::captures_bottom_type(FormDict &globals) const {
 748   if( _matrule && _matrule->_rChild &&
 749        (!strcmp(_matrule->_rChild->_opType,"CastPP")     ||  // new result type
 750         !strcmp(_matrule->_rChild->_opType,"CastX2P")    ||  // new result type
 751         !strcmp(_matrule->_rChild->_opType,"DecodeN")    ||
 752         !strcmp(_matrule->_rChild->_opType,"EncodeP")    ||


 753         !strcmp(_matrule->_rChild->_opType,"LoadN")      ||
 754         !strcmp(_matrule->_rChild->_opType,"GetAndSetN") ||
 755         !strcmp(_matrule->_rChild->_opType,"LoadNKlass") ||
 756         !strcmp(_matrule->_rChild->_opType,"CreateEx")   ||  // type of exception
 757         !strcmp(_matrule->_rChild->_opType,"CheckCastPP")) ) return true;
 758   else if ( is_ideal_load() == Form::idealP )                return true;
 759   else if ( is_ideal_store() != Form::none  )                return true;
 760 
 761   if (needs_base_oop_edge(globals)) return true;
 762 
 763   if (is_vector()) return true;
 764   if (is_mach_constant()) return true;
 765 
 766   return  false;
 767 }
 768 
 769 
 770 // Access instr_cost attribute or return NULL.
 771 const char* InstructForm::cost() {
 772   for (Attribute* cur = _attribs; cur != NULL; cur = (Attribute*)cur->_next) {


2435   } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) {
2436     format_constant( fp, index, dtype );
2437   } else if (ideal_to_sReg_type(_ident) != Form::none) {
2438     // Special format for Stack Slot Register
2439     fprintf(fp,    "{ char reg_str[128];\n");
2440     fprintf(fp,"      ra->dump_register(node->in(idx");
2441     if ( index != 0 ) fprintf(fp,                  "+%d",index);
2442     fprintf(fp,                                       "),reg_str);\n");
2443     fprintf(fp,"      tty->print(\"%cs\",reg_str);\n",'%');
2444     fprintf(fp,"    }\n");
2445   } else {
2446     fprintf(fp,"tty->print(\"No format defined for %s\n\");\n", _ident);
2447     assert( false,"Internal error:\n  output_external_operand() attempting to output other than a Register or Constant");
2448   }
2449 }
2450 
2451 void OperandForm::format_constant(FILE *fp, uint const_index, uint const_type) {
2452   switch(const_type) {
2453   case Form::idealI:  fprintf(fp,"st->print(\"#%%d\", _c%d);\n", const_index); break;
2454   case Form::idealP:  fprintf(fp,"_c%d->dump_on(st);\n",         const_index); break;

2455   case Form::idealN:  fprintf(fp,"_c%d->dump_on(st);\n",         const_index); break;
2456   case Form::idealL:  fprintf(fp,"st->print(\"#%%lld\", _c%d);\n", const_index); break;
2457   case Form::idealF:  fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break;
2458   case Form::idealD:  fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break;
2459   default:
2460     assert( false, "ShouldNotReachHere()");
2461   }
2462 }
2463 
2464 // Return the operand form corresponding to the given index, else NULL.
2465 OperandForm *OperandForm::constant_operand(FormDict &globals,
2466                                            uint      index) {
2467   // !!!!!
2468   // Check behavior on complex operands
2469   uint n_consts = num_consts(globals);
2470   if( n_consts > 0 ) {
2471     uint i = 0;
2472     const char *type;
2473     Component  *comp;
2474     _components.reset();


3373 
3374 
3375 void MatchNode::dump() {
3376   output(stderr);
3377 }
3378 
3379 void MatchNode::output(FILE *fp) {
3380   if (_lChild==0 && _rChild==0) {
3381     fprintf(fp," %s",_name);    // operand
3382   }
3383   else {
3384     fprintf(fp," (%s ",_name);  // " (opcodeName "
3385     if(_lChild) _lChild->output(fp); //               left operand
3386     if(_rChild) _rChild->output(fp); //                    right operand
3387     fprintf(fp,")");                 //                                 ")"
3388   }
3389 }
3390 
3391 int MatchNode::needs_ideal_memory_edge(FormDict &globals) const {
3392   static const char *needs_ideal_memory_list[] = {
3393     "StoreI","StoreL","StoreP","StoreN","StoreD","StoreF" ,
3394     "StoreB","StoreC","Store" ,"StoreFP",
3395     "LoadI", "LoadUI2L", "LoadL", "LoadP" ,"LoadN", "LoadD" ,"LoadF"  ,
3396     "LoadB" , "LoadUB", "LoadUS" ,"LoadS" ,"Load" ,
3397     "StoreVector", "LoadVector",
3398     "LoadRange", "LoadKlass", "LoadNKlass", "LoadL_unaligned", "LoadD_unaligned",
3399     "LoadPLocked",
3400     "StorePConditional", "StoreIConditional", "StoreLConditional",
3401     "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN",
3402     "StoreCM",
3403     "ClearArray",
3404     "GetAndAddI", "GetAndSetI", "GetAndSetP",
3405     "GetAndAddL", "GetAndSetL", "GetAndSetN",
3406   };
3407   int cnt = sizeof(needs_ideal_memory_list)/sizeof(char*);
3408   if( strcmp(_opType,"PrefetchRead")==0 ||
3409       strcmp(_opType,"PrefetchWrite")==0 ||
3410       strcmp(_opType,"PrefetchAllocation")==0 )
3411     return 1;
3412   if( _lChild ) {
3413     const char *opType = _lChild->_opType;


3930         strcmp(opType,"ModF")==0 ||
3931         strcmp(opType,"ModI")==0 ||
3932         strcmp(opType,"PowD")==0 ||
3933         strcmp(opType,"SinD")==0 ||
3934         strcmp(opType,"SqrtD")==0 ||
3935         strcmp(opType,"TanD")==0 ||
3936         strcmp(opType,"ConvD2F")==0 ||
3937         strcmp(opType,"ConvD2I")==0 ||
3938         strcmp(opType,"ConvD2L")==0 ||
3939         strcmp(opType,"ConvF2D")==0 ||
3940         strcmp(opType,"ConvF2I")==0 ||
3941         strcmp(opType,"ConvF2L")==0 ||
3942         strcmp(opType,"ConvI2D")==0 ||
3943         strcmp(opType,"ConvI2F")==0 ||
3944         strcmp(opType,"ConvI2L")==0 ||
3945         strcmp(opType,"ConvL2D")==0 ||
3946         strcmp(opType,"ConvL2F")==0 ||
3947         strcmp(opType,"ConvL2I")==0 ||
3948         strcmp(opType,"DecodeN")==0 ||
3949         strcmp(opType,"EncodeP")==0 ||


3950         strcmp(opType,"RoundDouble")==0 ||
3951         strcmp(opType,"RoundFloat")==0 ||
3952         strcmp(opType,"ReverseBytesI")==0 ||
3953         strcmp(opType,"ReverseBytesL")==0 ||
3954         strcmp(opType,"ReverseBytesUS")==0 ||
3955         strcmp(opType,"ReverseBytesS")==0 ||
3956         strcmp(opType,"ReplicateB")==0 ||
3957         strcmp(opType,"ReplicateS")==0 ||
3958         strcmp(opType,"ReplicateI")==0 ||
3959         strcmp(opType,"ReplicateL")==0 ||
3960         strcmp(opType,"ReplicateF")==0 ||
3961         strcmp(opType,"ReplicateD")==0 ||
3962         0 /* 0 to line up columns nicely */ )
3963       return 1;
3964   }
3965   return 0;
3966 }
3967 
3968 bool MatchRule::is_ideal_if() const {
3969   if( !_opType ) return false;




 733     if( is_ideal_load()  != Form::none ) {
 734       fprintf(stderr, "Warning: cannot find memory opnd in instr.\n");
 735       ((InstructForm*)this)->dump();
 736       // pretend it has multiple uses and no defs
 737       return MANY_MEMORY_OPERANDS;
 738     }
 739   }
 740 
 741   return NO_MEMORY_OPERAND;
 742 }
 743 
 744 
 745 // This instruction captures the machine-independent bottom_type
 746 // Expected use is for pointer vs oop determination for LoadP
 747 bool InstructForm::captures_bottom_type(FormDict &globals) const {
 748   if( _matrule && _matrule->_rChild &&
 749        (!strcmp(_matrule->_rChild->_opType,"CastPP")       ||  // new result type
 750         !strcmp(_matrule->_rChild->_opType,"CastX2P")      ||  // new result type
 751         !strcmp(_matrule->_rChild->_opType,"DecodeN")      ||
 752         !strcmp(_matrule->_rChild->_opType,"EncodeP")      ||
 753         !strcmp(_matrule->_rChild->_opType,"DecodeNKlass") ||
 754         !strcmp(_matrule->_rChild->_opType,"EncodePKlass") ||
 755         !strcmp(_matrule->_rChild->_opType,"LoadN")        ||
 756         !strcmp(_matrule->_rChild->_opType,"GetAndSetN")   ||
 757         !strcmp(_matrule->_rChild->_opType,"LoadNKlass")   ||
 758         !strcmp(_matrule->_rChild->_opType,"CreateEx")     ||  // type of exception
 759         !strcmp(_matrule->_rChild->_opType,"CheckCastPP")) ) return true;
 760   else if ( is_ideal_load() == Form::idealP )                return true;
 761   else if ( is_ideal_store() != Form::none  )                return true;
 762 
 763   if (needs_base_oop_edge(globals)) return true;
 764 
 765   if (is_vector()) return true;
 766   if (is_mach_constant()) return true;
 767 
 768   return  false;
 769 }
 770 
 771 
 772 // Access instr_cost attribute or return NULL.
 773 const char* InstructForm::cost() {
 774   for (Attribute* cur = _attribs; cur != NULL; cur = (Attribute*)cur->_next) {


2437   } else if (_matrule && (dtype = _matrule->is_base_constant(globals)) != Form::none) {
2438     format_constant( fp, index, dtype );
2439   } else if (ideal_to_sReg_type(_ident) != Form::none) {
2440     // Special format for Stack Slot Register
2441     fprintf(fp,    "{ char reg_str[128];\n");
2442     fprintf(fp,"      ra->dump_register(node->in(idx");
2443     if ( index != 0 ) fprintf(fp,                  "+%d",index);
2444     fprintf(fp,                                       "),reg_str);\n");
2445     fprintf(fp,"      tty->print(\"%cs\",reg_str);\n",'%');
2446     fprintf(fp,"    }\n");
2447   } else {
2448     fprintf(fp,"tty->print(\"No format defined for %s\n\");\n", _ident);
2449     assert( false,"Internal error:\n  output_external_operand() attempting to output other than a Register or Constant");
2450   }
2451 }
2452 
2453 void OperandForm::format_constant(FILE *fp, uint const_index, uint const_type) {
2454   switch(const_type) {
2455   case Form::idealI:  fprintf(fp,"st->print(\"#%%d\", _c%d);\n", const_index); break;
2456   case Form::idealP:  fprintf(fp,"_c%d->dump_on(st);\n",         const_index); break;
2457   case Form::idealNKlass:
2458   case Form::idealN:  fprintf(fp,"_c%d->dump_on(st);\n",         const_index); break;
2459   case Form::idealL:  fprintf(fp,"st->print(\"#%%lld\", _c%d);\n", const_index); break;
2460   case Form::idealF:  fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break;
2461   case Form::idealD:  fprintf(fp,"st->print(\"#%%f\", _c%d);\n", const_index); break;
2462   default:
2463     assert( false, "ShouldNotReachHere()");
2464   }
2465 }
2466 
2467 // Return the operand form corresponding to the given index, else NULL.
2468 OperandForm *OperandForm::constant_operand(FormDict &globals,
2469                                            uint      index) {
2470   // !!!!!
2471   // Check behavior on complex operands
2472   uint n_consts = num_consts(globals);
2473   if( n_consts > 0 ) {
2474     uint i = 0;
2475     const char *type;
2476     Component  *comp;
2477     _components.reset();


3376 
3377 
3378 void MatchNode::dump() {
3379   output(stderr);
3380 }
3381 
3382 void MatchNode::output(FILE *fp) {
3383   if (_lChild==0 && _rChild==0) {
3384     fprintf(fp," %s",_name);    // operand
3385   }
3386   else {
3387     fprintf(fp," (%s ",_name);  // " (opcodeName "
3388     if(_lChild) _lChild->output(fp); //               left operand
3389     if(_rChild) _rChild->output(fp); //                    right operand
3390     fprintf(fp,")");                 //                                 ")"
3391   }
3392 }
3393 
3394 int MatchNode::needs_ideal_memory_edge(FormDict &globals) const {
3395   static const char *needs_ideal_memory_list[] = {
3396     "StoreI","StoreL","StoreP","StoreN","StoreNKlass","StoreD","StoreF" ,
3397     "StoreB","StoreC","Store" ,"StoreFP",
3398     "LoadI", "LoadUI2L", "LoadL", "LoadP" ,"LoadN", "LoadD" ,"LoadF"  ,
3399     "LoadB" , "LoadUB", "LoadUS" ,"LoadS" ,"Load" ,
3400     "StoreVector", "LoadVector",
3401     "LoadRange", "LoadKlass", "LoadNKlass", "LoadL_unaligned", "LoadD_unaligned",
3402     "LoadPLocked",
3403     "StorePConditional", "StoreIConditional", "StoreLConditional",
3404     "CompareAndSwapI", "CompareAndSwapL", "CompareAndSwapP", "CompareAndSwapN",
3405     "StoreCM",
3406     "ClearArray",
3407     "GetAndAddI", "GetAndSetI", "GetAndSetP",
3408     "GetAndAddL", "GetAndSetL", "GetAndSetN",
3409   };
3410   int cnt = sizeof(needs_ideal_memory_list)/sizeof(char*);
3411   if( strcmp(_opType,"PrefetchRead")==0 ||
3412       strcmp(_opType,"PrefetchWrite")==0 ||
3413       strcmp(_opType,"PrefetchAllocation")==0 )
3414     return 1;
3415   if( _lChild ) {
3416     const char *opType = _lChild->_opType;


3933         strcmp(opType,"ModF")==0 ||
3934         strcmp(opType,"ModI")==0 ||
3935         strcmp(opType,"PowD")==0 ||
3936         strcmp(opType,"SinD")==0 ||
3937         strcmp(opType,"SqrtD")==0 ||
3938         strcmp(opType,"TanD")==0 ||
3939         strcmp(opType,"ConvD2F")==0 ||
3940         strcmp(opType,"ConvD2I")==0 ||
3941         strcmp(opType,"ConvD2L")==0 ||
3942         strcmp(opType,"ConvF2D")==0 ||
3943         strcmp(opType,"ConvF2I")==0 ||
3944         strcmp(opType,"ConvF2L")==0 ||
3945         strcmp(opType,"ConvI2D")==0 ||
3946         strcmp(opType,"ConvI2F")==0 ||
3947         strcmp(opType,"ConvI2L")==0 ||
3948         strcmp(opType,"ConvL2D")==0 ||
3949         strcmp(opType,"ConvL2F")==0 ||
3950         strcmp(opType,"ConvL2I")==0 ||
3951         strcmp(opType,"DecodeN")==0 ||
3952         strcmp(opType,"EncodeP")==0 ||
3953         strcmp(opType,"EncodePKlass")==0 ||
3954         strcmp(opType,"DecodeNKlass")==0 ||
3955         strcmp(opType,"RoundDouble")==0 ||
3956         strcmp(opType,"RoundFloat")==0 ||
3957         strcmp(opType,"ReverseBytesI")==0 ||
3958         strcmp(opType,"ReverseBytesL")==0 ||
3959         strcmp(opType,"ReverseBytesUS")==0 ||
3960         strcmp(opType,"ReverseBytesS")==0 ||
3961         strcmp(opType,"ReplicateB")==0 ||
3962         strcmp(opType,"ReplicateS")==0 ||
3963         strcmp(opType,"ReplicateI")==0 ||
3964         strcmp(opType,"ReplicateL")==0 ||
3965         strcmp(opType,"ReplicateF")==0 ||
3966         strcmp(opType,"ReplicateD")==0 ||
3967         0 /* 0 to line up columns nicely */ )
3968       return 1;
3969   }
3970   return 0;
3971 }
3972 
3973 bool MatchRule::is_ideal_if() const {
3974   if( !_opType ) return false;