< prev index next >

src/hotspot/share/opto/matcher.cpp

Print this page

 147   worklist.push(xroot);
 148   while (worklist.size() > 0) {
 149     Node* n = worklist.pop();
 150     if (visited.test_set(n->_idx)) {
 151       continue;
 152     }
 153     assert(C->node_arena()->contains(n), "dead node");
 154     for (uint j = 0; j < n->req(); j++) {
 155       Node* in = n->in(j);
 156       if (in != nullptr) {
 157         worklist.push(in);
 158       }
 159     }
 160     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 161       worklist.push(n->fast_out(j));
 162     }
 163   }
 164 }
 165 #endif
 166 













































 167 
 168 //---------------------------match---------------------------------------------
 169 void Matcher::match( ) {
 170   if( MaxLabelRootDepth < 100 ) { // Too small?
 171     assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
 172     MaxLabelRootDepth = 100;
 173   }
 174   // One-time initialization of some register masks.
 175   init_spill_mask( C->root()->in(1) );
 176   if (C->failing()) {
 177     return;
 178   }
 179   assert(_return_addr_mask.is_Empty(),
 180          "return address mask must be empty initially");
 181   _return_addr_mask.Insert(return_addr());
 182 #ifdef _LP64
 183   // Pointers take 2 slots in 64-bit land
 184   _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
 185 #endif
 186 
 187   // Map a Java-signature return type into return register-value
 188   // machine registers for 0, 1 and 2 returned values.
 189   const TypeTuple *range = C->tf()->range();
 190   if( range->cnt() > TypeFunc::Parms ) { // If not a void function
 191     // Get ideal-register return type
 192     uint ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
 193     // Get machine return register
 194     uint sop = C->start()->Opcode();
 195     OptoRegPair regs = return_value(ireg);
 196 
 197     // And mask for same
 198     _return_value_mask = RegMask(regs.first());
 199     if( OptoReg::is_valid(regs.second()) )
 200       _return_value_mask.Insert(regs.second());
 201   }
 202 
 203   // ---------------
 204   // Frame Layout
 205 
 206   // Need the method signature to determine the incoming argument types,
 207   // because the types determine which registers the incoming arguments are
 208   // in, and this affects the matched code.
 209   const TypeTuple *domain = C->tf()->domain();
 210   uint             argcnt = domain->cnt() - TypeFunc::Parms;
 211   BasicType *sig_bt        = NEW_RESOURCE_ARRAY( BasicType, argcnt );
 212   VMRegPair *vm_parm_regs  = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
 213   _parm_regs               = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
 214   _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
 215   uint i;
 216   for( i = 0; i<argcnt; i++ ) {
 217     sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
 218     new (_calling_convention_mask + i) RegMask(C->comp_arena());
 219   }
 220 
 221   // Pass array of ideal registers and length to USER code (from the AD file)
 222   // that will convert this to an array of register numbers.
 223   const StartNode *start = C->start();
 224   start->calling_convention( sig_bt, vm_parm_regs, argcnt );
 225 #ifdef ASSERT
 226   // Sanity check users' calling convention.  Real handy while trying to
 227   // get the initial port correct.
 228   { for (uint i = 0; i<argcnt; i++) {
 229       if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {

 461   // Initialize empty placeholder masks into the newly allocated arena
 462   for (int i = 0; i < NOF_STACK_MASKS; i++) {
 463     new (rms + i) RegMask(C->comp_arena());
 464   }
 465 
 466   int index = 0;
 467   for (int i = Op_RegN; i <= Op_RegVectMask; ++i) {
 468     idealreg2spillmask[i] = &rms[index++];
 469     idealreg2debugmask[i] = &rms[index++];
 470   }
 471   assert(index == NOF_STACK_MASKS, "wrong size");
 472 
 473   // At first, start with the empty mask
 474   C->FIRST_STACK_mask().Clear();
 475 
 476   // Add in the incoming argument area
 477   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 478   for (OptoReg::Name i = init_in; i < _in_arg_limit; i = OptoReg::add(i, 1)) {
 479     C->FIRST_STACK_mask().Insert(i);
 480   }

 481   // Add in all bits past the outgoing argument area
 482   C->FIRST_STACK_mask().Set_All_From(_out_arg_limit);
 483 
 484   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 485   RegMask aligned_stack_mask(C->FIRST_STACK_mask(), C->comp_arena());
 486   // Keep spill masks aligned.
 487   aligned_stack_mask.clear_to_pairs();
 488   assert(aligned_stack_mask.is_infinite_stack(), "should be infinite stack");
 489   RegMask scalable_stack_mask(aligned_stack_mask, C->comp_arena());
 490 
 491   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 492 #ifdef _LP64
 493   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];
 494    idealreg2spillmask[Op_RegN]->OR(C->FIRST_STACK_mask());
 495    idealreg2spillmask[Op_RegP]->OR(aligned_stack_mask);
 496 #else
 497    idealreg2spillmask[Op_RegP]->OR(C->FIRST_STACK_mask());
 498 #endif
 499   *idealreg2spillmask[Op_RegI] = *idealreg2regmask[Op_RegI];
 500    idealreg2spillmask[Op_RegI]->OR(C->FIRST_STACK_mask());

 681     _register_save_policy[reg] == 'E' ||
 682     _register_save_policy[reg] == 'A'; // Save-on-entry register?
 683 }
 684 
 685 //---------------------------Fixup_Save_On_Entry-------------------------------
 686 void Matcher::Fixup_Save_On_Entry( ) {
 687   init_first_stack_mask();
 688 
 689   Node *root = C->root();       // Short name for root
 690   // Count number of save-on-entry registers.
 691   uint soe_cnt = number_of_saved_registers();
 692   uint i;
 693 
 694   // Find the procedure Start Node
 695   StartNode *start = C->start();
 696   assert( start, "Expect a start node" );
 697 
 698   // Input RegMask array shared by all Returns.
 699   // The type for doubles and longs has a count of 2, but
 700   // there is only 1 returned value
 701   uint ret_edge_cnt = TypeFunc::Parms + ((C->tf()->range()->cnt() == TypeFunc::Parms) ? 0 : 1);
 702   RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 703   // Returns have 0 or 1 returned values depending on call signature.
 704   // Return register is specified by return_value in the AD file.
 705   if (ret_edge_cnt > TypeFunc::Parms)
 706     ret_rms[TypeFunc::Parms+0] = _return_value_mask;
 707 
 708   // Input RegMask array shared by all ForwardExceptions
 709   uint forw_exc_edge_cnt = TypeFunc::Parms;
 710   RegMask* forw_exc_rms  = init_input_masks( forw_exc_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 711 
 712   // Input RegMask array shared by all Rethrows.
 713   uint reth_edge_cnt = TypeFunc::Parms+1;
 714   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 715   // Rethrow takes exception oop only, but in the argument 0 slot.
 716   OptoReg::Name reg = find_receiver();
 717   if (reg >= 0) {
 718     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 719 #ifdef _LP64
 720     // Need two slots for ptrs in 64-bit land
 721     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 722 #endif
 723   }
 724 
 725   // Input RegMask array shared by all TailCalls
 726   uint tail_call_edge_cnt = TypeFunc::Parms+2;

 758 
 759   // Input RegMask array shared by all Halts
 760   uint halt_edge_cnt = TypeFunc::Parms;
 761   RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 762 
 763   // Capture the return input masks into each exit flavor
 764   for( i=1; i < root->req(); i++ ) {
 765     MachReturnNode *exit = root->in(i)->as_MachReturn();
 766     switch( exit->ideal_Opcode() ) {
 767       case Op_Return   : exit->_in_rms = ret_rms;  break;
 768       case Op_Rethrow  : exit->_in_rms = reth_rms; break;
 769       case Op_TailCall : exit->_in_rms = tail_call_rms; break;
 770       case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
 771       case Op_ForwardException: exit->_in_rms = forw_exc_rms; break;
 772       case Op_Halt     : exit->_in_rms = halt_rms; break;
 773       default          : ShouldNotReachHere();
 774     }
 775   }
 776 
 777   // Next unused projection number from Start.
 778   int proj_cnt = C->tf()->domain()->cnt();
 779 
 780   // Do all the save-on-entry registers.  Make projections from Start for
 781   // them, and give them a use at the exit points.  To the allocator, they
 782   // look like incoming register arguments.
 783   for( i = 0; i < _last_Mach_Reg; i++ ) {
 784     if( is_save_on_entry(i) ) {
 785 
 786       // Add the save-on-entry to the mask array
 787       ret_rms      [      ret_edge_cnt] = mreg2regmask[i];
 788       reth_rms     [     reth_edge_cnt] = mreg2regmask[i];
 789       tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
 790       tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
 791       forw_exc_rms [ forw_exc_edge_cnt] = mreg2regmask[i];
 792       // Halts need the SOE registers, but only in the stack as debug info.
 793       // A just-prior uncommon-trap or deoptimization will use the SOE regs.
 794       halt_rms     [     halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
 795 
 796       Node *mproj;
 797 
 798       // Is this a RegF low half of a RegD?  Double up 2 adjacent RegF's

1027       Node *oldn = n;
1028       // Old-space or new-space check
1029       if (!C->node_arena()->contains(n)) {
1030         // Old space!
1031         Node* m;
1032         if (has_new_node(n)) {  // Not yet Label/Reduced
1033           m = new_node(n);
1034         } else {
1035           if (!is_dontcare(n)) { // Matcher can match this guy
1036             // Calls match special.  They match alone with no children.
1037             // Their children, the incoming arguments, match normally.
1038             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1039             if (C->failing())  return nullptr;
1040             if (m == nullptr) { Matcher::soft_match_failure(); return nullptr; }
1041             if (n->is_MemBar()) {
1042               m->as_MachMemBar()->set_adr_type(n->adr_type());
1043             }
1044           } else {                  // Nothing the matcher cares about
1045             if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Multi()) {       // Projections?
1046               // Convert to machine-dependent projection
1047               m = n->in(0)->as_Multi()->match( n->as_Proj(), this );




1048               NOT_PRODUCT(record_new2old(m, n);)
1049               if (m->in(0) != nullptr) // m might be top
1050                 collect_null_checks(m, n);
1051             } else {                // Else just a regular 'ol guy
1052               m = n->clone();       // So just clone into new-space
1053               NOT_PRODUCT(record_new2old(m, n);)
1054               // Def-Use edges will be added incrementally as Uses
1055               // of this node are matched.
1056               assert(m->outcnt() == 0, "no Uses of this clone yet");
1057             }
1058           }
1059 
1060           set_new_node(n, m);       // Map old to new
1061           if (_old_node_note_array != nullptr) {
1062             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1063                                                   n->_idx);
1064             C->set_node_notes_at(m->_idx, nn);
1065           }
1066           DEBUG_ONLY(match_alias_type(C, n, m));
1067         }

1162     return warped;
1163   }
1164   return OptoReg::as_OptoReg(reg);
1165 }
1166 
1167 
1168 //------------------------------match_sfpt-------------------------------------
1169 // Helper function to match call instructions.  Calls match special.
1170 // They match alone with no children.  Their children, the incoming
1171 // arguments, match normally.
1172 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1173   MachSafePointNode *msfpt = nullptr;
1174   MachCallNode      *mcall = nullptr;
1175   uint               cnt;
1176   // Split out case for SafePoint vs Call
1177   CallNode *call;
1178   const TypeTuple *domain;
1179   ciMethod*        method = nullptr;
1180   if( sfpt->is_Call() ) {
1181     call = sfpt->as_Call();
1182     domain = call->tf()->domain();
1183     cnt = domain->cnt();
1184 
1185     // Match just the call, nothing else
1186     MachNode *m = match_tree(call);
1187     if (C->failing())  return nullptr;
1188     if( m == nullptr ) { Matcher::soft_match_failure(); return nullptr; }
1189 
1190     // Copy data from the Ideal SafePoint to the machine version
1191     mcall = m->as_MachCall();
1192 
1193     mcall->set_tf(                  call->tf());
1194     mcall->set_entry_point(         call->entry_point());
1195     mcall->set_cnt(                 call->cnt());
1196     mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1197 
1198     if( mcall->is_MachCallJava() ) {
1199       MachCallJavaNode *mcall_java  = mcall->as_MachCallJava();
1200       const CallJavaNode *call_java =  call->as_CallJava();
1201       assert(call_java->validate_symbolic_info(), "inconsistent info");
1202       method = call_java->method();

1238   for (uint i = 0; i < cnt; i++) {
1239     ::new (msfpt->_in_rms + i) RegMask(C->comp_arena());
1240   }
1241 
1242   // Do all the pre-defined non-Empty register masks
1243   msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1244   msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1245 
1246   // Place first outgoing argument can possibly be put.
1247   OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1248   assert( is_even(begin_out_arg_area), "" );
1249   // Compute max outgoing register number per call site.
1250   OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1251   // Calls to C may hammer extra stack slots above and beyond any arguments.
1252   // These are usually backing store for register arguments for varargs.
1253   if( call != nullptr && call->is_CallRuntime() )
1254     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1255 
1256 
1257   // Do the normal argument list (parameters) register masks
1258   int argcnt = cnt - TypeFunc::Parms;



1259   if( argcnt > 0 ) {          // Skip it all if we have no args
1260     BasicType *sig_bt  = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1261     VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1262     int i;
1263     for( i = 0; i < argcnt; i++ ) {
1264       sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
1265     }
1266     // V-call to pick proper calling convention
1267     call->calling_convention( sig_bt, parm_regs, argcnt );
1268 
1269 #ifdef ASSERT
1270     // Sanity check users' calling convention.  Really handy during
1271     // the initial porting effort.  Fairly expensive otherwise.
1272     { for (int i = 0; i<argcnt; i++) {
1273       if( !parm_regs[i].first()->is_valid() &&
1274           !parm_regs[i].second()->is_valid() ) continue;
1275       VMReg reg1 = parm_regs[i].first();
1276       VMReg reg2 = parm_regs[i].second();
1277       for (int j = 0; j < i; j++) {
1278         if( !parm_regs[j].first()->is_valid() &&
1279             !parm_regs[j].second()->is_valid() ) continue;
1280         VMReg reg3 = parm_regs[j].first();
1281         VMReg reg4 = parm_regs[j].second();
1282         if( !reg1->is_valid() ) {
1283           assert( !reg2->is_valid(), "valid halvsies" );
1284         } else if( !reg3->is_valid() ) {
1285           assert( !reg4->is_valid(), "valid halvsies" );
1286         } else {
1287           assert( reg1 != reg2, "calling conv. must produce distinct regs");
1288           assert( reg1 != reg3, "calling conv. must produce distinct regs");
1289           assert( reg1 != reg4, "calling conv. must produce distinct regs");
1290           assert( reg2 != reg3, "calling conv. must produce distinct regs");
1291           assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1292           assert( reg3 != reg4, "calling conv. must produce distinct regs");
1293         }
1294       }
1295     }
1296     }
1297 #endif
1298 
1299     // Visit each argument.  Compute its outgoing register mask.
1300     // Return results now can have 2 bits returned.
1301     // Compute max over all outgoing arguments both per call-site
1302     // and over the entire method.
1303     for( i = 0; i < argcnt; i++ ) {
1304       // Address of incoming argument mask to fill in
1305       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1306       VMReg first = parm_regs[i].first();
1307       VMReg second = parm_regs[i].second();
1308       if(!first->is_valid() &&
1309          !second->is_valid()) {
1310         continue;               // Avoid Halves
1311       }
1312       // Handle case where arguments are in vector registers.
1313       if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1314         OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1315         OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1316         assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1317         for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1318           rm->Insert(r);
1319         }
1320       }
1321       // Grab first register, adjust stack slots and insert in mask.
1322       OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1323       if (OptoReg::is_valid(reg1))
1324         rm->Insert( reg1 );

1325       // Grab second register (if any), adjust stack slots and insert in mask.
1326       OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1327       if (OptoReg::is_valid(reg2))
1328         rm->Insert( reg2 );

1329     } // End of for all arguments
1330   }
1331 
1332   // Compute the max stack slot killed by any call.  These will not be
1333   // available for debug info, and will be used to adjust FIRST_STACK_mask
1334   // after all call sites have been visited.
1335   if( _out_arg_limit < out_arg_limit_per_call)
1336     _out_arg_limit = out_arg_limit_per_call;
1337 
1338   if (mcall) {
1339     // Kill the outgoing argument area, including any non-argument holes and
1340     // any legacy C-killed slots.  Use Fat-Projections to do the killing.
1341     // Since the max-per-method covers the max-per-call-site and debug info
1342     // is excluded on the max-per-method basis, debug info cannot land in
1343     // this killed area.
1344     uint r_cnt = mcall->tf()->range()->cnt();
1345     MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1346     for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++) {
1347       proj->_rout.Insert(OptoReg::Name(i));
1348     }
1349     if (!proj->_rout.is_Empty()) {
1350       push_projection(proj);
1351     }
1352   }
1353   // Transfer the safepoint information from the call to the mcall
1354   // Move the JVMState list
1355   msfpt->set_jvms(sfpt->jvms());
1356   for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1357     jvms->set_map(sfpt);
1358   }
1359 
1360   // Debug inputs begin just after the last incoming parameter
1361   assert((mcall == nullptr) || (mcall->jvms() == nullptr) ||
1362          (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain()->cnt()), "");
1363 
1364   // Add additional edges.
1365   if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1366     // For these calls we can not add MachConstantBase in expand(), as the
1367     // ins are not complete then.
1368     msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1369     if (msfpt->jvms() &&
1370         msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1371       // We added an edge before jvms, so we must adapt the position of the ins.
1372       msfpt->jvms()->adapt_position(+1);
1373     }
1374   }
1375 
1376   // Registers killed by the call are set in the local scheduling pass
1377   // of Global Code Motion.
1378   return msfpt;
1379 }
1380 
1381 //---------------------------match_tree----------------------------------------
1382 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce.  Used as part

2031         set_shared(n);       // Flag as shared and
2032         if (n->is_DecodeNarrowPtr()) {
2033           // Oop field/array element loads must be shared but since
2034           // they are shared through a DecodeN they may appear to have
2035           // a single use so force sharing here.
2036           set_shared(n->in(1));
2037         }
2038         mstack.pop();        // remove node from stack
2039         continue;
2040       }
2041       nstate = Visit; // Not already visited; so visit now
2042     }
2043     if (nstate == Visit) {
2044       mstack.set_state(Post_Visit);
2045       set_visited(n);   // Flag as visited now
2046       bool mem_op = false;
2047       int mem_addr_idx = MemNode::Address;
2048       if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2049         continue;
2050       }
2051       for (int i = n->req() - 1; i >= 0; --i) { // For my children
2052         Node* m = n->in(i); // Get ith input
2053         if (m == nullptr) {
2054           continue;  // Ignore nulls
2055         }
2056         if (clone_node(n, m, mstack)) {
2057           continue;
2058         }
2059 
2060         // Clone addressing expressions as they are "free" in memory access instructions
2061         if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2062             // When there are other uses besides address expressions
2063             // put it on stack and mark as shared.
2064             !is_visited(m)) {
2065           // Some inputs for address expression are not put on stack
2066           // to avoid marking them as shared and forcing them into register
2067           // if they are used only in address expressions.
2068           // But they should be marked as shared if there are other uses
2069           // besides address expressions.
2070 
2071           if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {

2342     case Op_FmaHF:
2343     case Op_FmaVD:
2344     case Op_FmaVF:
2345     case Op_FmaVHF: {
2346       // Restructure into a binary tree for Matching.
2347       Node* pair = new BinaryNode(n->in(1), n->in(2));
2348       n->set_req(2, pair);
2349       n->set_req(1, n->in(3));
2350       n->del_req(3);
2351       break;
2352     }
2353     case Op_MulAddS2I: {
2354       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2355       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2356       n->set_req(1, pair1);
2357       n->set_req(2, pair2);
2358       n->del_req(4);
2359       n->del_req(3);
2360       break;
2361     }







2362     case Op_VectorCmpMasked:
2363     case Op_CopySignD:
2364     case Op_SignumVF:
2365     case Op_SignumVD:
2366     case Op_SignumF:
2367     case Op_SignumD: {
2368       Node* pair = new BinaryNode(n->in(2), n->in(3));
2369       n->set_req(2, pair);
2370       n->del_req(3);
2371       break;
2372     }
2373     case Op_VectorBlend:
2374     case Op_VectorInsert: {
2375       Node* pair = new BinaryNode(n->in(1), n->in(2));
2376       n->set_req(1, pair);
2377       n->set_req(2, n->in(3));
2378       n->del_req(3);
2379       break;
2380     }
2381     case Op_LoadVectorGatherMasked: // fall-through

2391       n->del_req(MemNode::ValueIn+2);
2392       pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2393       n->set_req(MemNode::ValueIn, pair);
2394       n->del_req(MemNode::ValueIn+1);
2395       break;
2396     }
2397     case Op_VectorMaskCmp: {
2398       n->set_req(1, new BinaryNode(n->in(1), n->in(2)));
2399       n->set_req(2, n->in(3));
2400       n->del_req(3);
2401       break;
2402     }
2403     case Op_PartialSubtypeCheck: {
2404       if (UseSecondarySupersTable && n->in(2)->is_Con()) {
2405         // PartialSubtypeCheck uses both constant and register operands for superclass input.
2406         n->set_req(2, new BinaryNode(n->in(2), n->in(2)));
2407         break;
2408       }
2409       break;
2410     }








2411     default:
2412       break;
2413   }
2414 }
2415 
2416 #ifndef PRODUCT
2417 void Matcher::record_new2old(Node* newn, Node* old) {
2418   _new2old_map.map(newn->_idx, old);
2419   if (!_reused.test_set(old->_igv_idx)) {
2420     // Reuse the Ideal-level IGV identifier so that the node can be tracked
2421     // across matching. If there are multiple machine nodes expanded from the
2422     // same Ideal node, only one will reuse its IGV identifier.
2423     newn->_igv_idx = old->_igv_idx;
2424   }
2425 }
2426 
2427 // machine-independent root to machine-dependent root
2428 void Matcher::dump_old2new_map() {
2429   _old2new_map.dump();
2430 }

 147   worklist.push(xroot);
 148   while (worklist.size() > 0) {
 149     Node* n = worklist.pop();
 150     if (visited.test_set(n->_idx)) {
 151       continue;
 152     }
 153     assert(C->node_arena()->contains(n), "dead node");
 154     for (uint j = 0; j < n->req(); j++) {
 155       Node* in = n->in(j);
 156       if (in != nullptr) {
 157         worklist.push(in);
 158       }
 159     }
 160     for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
 161       worklist.push(n->fast_out(j));
 162     }
 163   }
 164 }
 165 #endif
 166 
 167 // Array of RegMask, one per returned values (inline type instances can
 168 // be returned as multiple return values, one per field)
 169 RegMask* Matcher::return_values_mask(const TypeFunc* tf) {
 170   const TypeTuple* range = tf->range_cc();
 171   uint cnt = range->cnt() - TypeFunc::Parms;
 172   if (cnt == 0) {
 173     return nullptr;
 174   }
 175   RegMask* mask = NEW_RESOURCE_ARRAY(RegMask, cnt);
 176   BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, cnt);
 177   VMRegPair* vm_parm_regs = NEW_RESOURCE_ARRAY(VMRegPair, cnt);
 178   for (uint i = 0; i < cnt; i++) {
 179     sig_bt[i] = range->field_at(i+TypeFunc::Parms)->basic_type();
 180     new (mask + i) RegMask();
 181   }
 182 
 183   int regs = SharedRuntime::java_return_convention(sig_bt, vm_parm_regs, cnt);
 184   if (regs <= 0) {
 185     // We ran out of registers to store the null marker for a nullable inline type return.
 186     // Since it is only set in the 'call_epilog', we can simply put it on the stack.
 187     assert(tf->returns_inline_type_as_fields(), "should have been tested during graph construction");
 188     // TODO 8284443 Can we teach the register allocator to reserve a stack slot instead?
 189     // mask[--cnt] = STACK_ONLY_mask does not work (test with -XX:+StressGCM)
 190     int slot = C->fixed_slots() - 2;
 191     if (C->needs_stack_repair()) {
 192       slot -= 2; // Account for stack increment value
 193     }
 194     mask[--cnt].Clear();
 195     mask[cnt].Insert(OptoReg::stack2reg(slot));
 196   }
 197   for (uint i = 0; i < cnt; i++) {
 198     mask[i].Clear();
 199 
 200     OptoReg::Name reg1 = OptoReg::as_OptoReg(vm_parm_regs[i].first());
 201     if (OptoReg::is_valid(reg1)) {
 202       mask[i].Insert(reg1);
 203     }
 204     OptoReg::Name reg2 = OptoReg::as_OptoReg(vm_parm_regs[i].second());
 205     if (OptoReg::is_valid(reg2)) {
 206       mask[i].Insert(reg2);
 207     }
 208   }
 209 
 210   return mask;
 211 }
 212 
 213 //---------------------------match---------------------------------------------
 214 void Matcher::match( ) {
 215   if( MaxLabelRootDepth < 100 ) { // Too small?
 216     assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
 217     MaxLabelRootDepth = 100;
 218   }
 219   // One-time initialization of some register masks.
 220   init_spill_mask( C->root()->in(1) );
 221   if (C->failing()) {
 222     return;
 223   }
 224   assert(_return_addr_mask.is_Empty(),
 225          "return address mask must be empty initially");
 226   _return_addr_mask.Insert(return_addr());
 227 #ifdef _LP64
 228   // Pointers take 2 slots in 64-bit land
 229   _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
 230 #endif
 231 
 232   // Map Java-signature return types into return register-value
 233   // machine registers.
 234   _return_values_mask = return_values_mask(C->tf());












 235 
 236   // ---------------
 237   // Frame Layout
 238 
 239   // Need the method signature to determine the incoming argument types,
 240   // because the types determine which registers the incoming arguments are
 241   // in, and this affects the matched code.
 242   const TypeTuple *domain = C->tf()->domain_cc();
 243   uint             argcnt = domain->cnt() - TypeFunc::Parms;
 244   BasicType *sig_bt        = NEW_RESOURCE_ARRAY( BasicType, argcnt );
 245   VMRegPair *vm_parm_regs  = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
 246   _parm_regs               = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
 247   _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
 248   uint i;
 249   for( i = 0; i<argcnt; i++ ) {
 250     sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
 251     new (_calling_convention_mask + i) RegMask(C->comp_arena());
 252   }
 253 
 254   // Pass array of ideal registers and length to USER code (from the AD file)
 255   // that will convert this to an array of register numbers.
 256   const StartNode *start = C->start();
 257   start->calling_convention( sig_bt, vm_parm_regs, argcnt );
 258 #ifdef ASSERT
 259   // Sanity check users' calling convention.  Real handy while trying to
 260   // get the initial port correct.
 261   { for (uint i = 0; i<argcnt; i++) {
 262       if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {

 494   // Initialize empty placeholder masks into the newly allocated arena
 495   for (int i = 0; i < NOF_STACK_MASKS; i++) {
 496     new (rms + i) RegMask(C->comp_arena());
 497   }
 498 
 499   int index = 0;
 500   for (int i = Op_RegN; i <= Op_RegVectMask; ++i) {
 501     idealreg2spillmask[i] = &rms[index++];
 502     idealreg2debugmask[i] = &rms[index++];
 503   }
 504   assert(index == NOF_STACK_MASKS, "wrong size");
 505 
 506   // At first, start with the empty mask
 507   C->FIRST_STACK_mask().Clear();
 508 
 509   // Add in the incoming argument area
 510   OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
 511   for (OptoReg::Name i = init_in; i < _in_arg_limit; i = OptoReg::add(i, 1)) {
 512     C->FIRST_STACK_mask().Insert(i);
 513   }
 514 
 515   // Add in all bits past the outgoing argument area
 516   C->FIRST_STACK_mask().Set_All_From(_out_arg_limit);
 517 
 518   // Make spill masks.  Registers for their class, plus FIRST_STACK_mask.
 519   RegMask aligned_stack_mask(C->FIRST_STACK_mask(), C->comp_arena());
 520   // Keep spill masks aligned.
 521   aligned_stack_mask.clear_to_pairs();
 522   assert(aligned_stack_mask.is_infinite_stack(), "should be infinite stack");
 523   RegMask scalable_stack_mask(aligned_stack_mask, C->comp_arena());
 524 
 525   *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
 526 #ifdef _LP64
 527   *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];
 528    idealreg2spillmask[Op_RegN]->OR(C->FIRST_STACK_mask());
 529    idealreg2spillmask[Op_RegP]->OR(aligned_stack_mask);
 530 #else
 531    idealreg2spillmask[Op_RegP]->OR(C->FIRST_STACK_mask());
 532 #endif
 533   *idealreg2spillmask[Op_RegI] = *idealreg2regmask[Op_RegI];
 534    idealreg2spillmask[Op_RegI]->OR(C->FIRST_STACK_mask());

 715     _register_save_policy[reg] == 'E' ||
 716     _register_save_policy[reg] == 'A'; // Save-on-entry register?
 717 }
 718 
 719 //---------------------------Fixup_Save_On_Entry-------------------------------
 720 void Matcher::Fixup_Save_On_Entry( ) {
 721   init_first_stack_mask();
 722 
 723   Node *root = C->root();       // Short name for root
 724   // Count number of save-on-entry registers.
 725   uint soe_cnt = number_of_saved_registers();
 726   uint i;
 727 
 728   // Find the procedure Start Node
 729   StartNode *start = C->start();
 730   assert( start, "Expect a start node" );
 731 
 732   // Input RegMask array shared by all Returns.
 733   // The type for doubles and longs has a count of 2, but
 734   // there is only 1 returned value
 735   uint ret_edge_cnt = C->tf()->range_cc()->cnt();
 736   RegMask *ret_rms  = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 737   for (i = TypeFunc::Parms; i < ret_edge_cnt; i++) {
 738     ret_rms[i] = _return_values_mask[i-TypeFunc::Parms];
 739   }

 740 
 741   // Input RegMask array shared by all ForwardExceptions
 742   uint forw_exc_edge_cnt = TypeFunc::Parms;
 743   RegMask* forw_exc_rms  = init_input_masks( forw_exc_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 744 
 745   // Input RegMask array shared by all Rethrows.
 746   uint reth_edge_cnt = TypeFunc::Parms+1;
 747   RegMask *reth_rms  = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 748   // Rethrow takes exception oop only, but in the argument 0 slot.
 749   OptoReg::Name reg = find_receiver();
 750   if (reg >= 0) {
 751     reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
 752 #ifdef _LP64
 753     // Need two slots for ptrs in 64-bit land
 754     reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
 755 #endif
 756   }
 757 
 758   // Input RegMask array shared by all TailCalls
 759   uint tail_call_edge_cnt = TypeFunc::Parms+2;

 791 
 792   // Input RegMask array shared by all Halts
 793   uint halt_edge_cnt = TypeFunc::Parms;
 794   RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
 795 
 796   // Capture the return input masks into each exit flavor
 797   for( i=1; i < root->req(); i++ ) {
 798     MachReturnNode *exit = root->in(i)->as_MachReturn();
 799     switch( exit->ideal_Opcode() ) {
 800       case Op_Return   : exit->_in_rms = ret_rms;  break;
 801       case Op_Rethrow  : exit->_in_rms = reth_rms; break;
 802       case Op_TailCall : exit->_in_rms = tail_call_rms; break;
 803       case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
 804       case Op_ForwardException: exit->_in_rms = forw_exc_rms; break;
 805       case Op_Halt     : exit->_in_rms = halt_rms; break;
 806       default          : ShouldNotReachHere();
 807     }
 808   }
 809 
 810   // Next unused projection number from Start.
 811   int proj_cnt = C->tf()->domain_cc()->cnt();
 812 
 813   // Do all the save-on-entry registers.  Make projections from Start for
 814   // them, and give them a use at the exit points.  To the allocator, they
 815   // look like incoming register arguments.
 816   for( i = 0; i < _last_Mach_Reg; i++ ) {
 817     if( is_save_on_entry(i) ) {
 818 
 819       // Add the save-on-entry to the mask array
 820       ret_rms      [      ret_edge_cnt] = mreg2regmask[i];
 821       reth_rms     [     reth_edge_cnt] = mreg2regmask[i];
 822       tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
 823       tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
 824       forw_exc_rms [ forw_exc_edge_cnt] = mreg2regmask[i];
 825       // Halts need the SOE registers, but only in the stack as debug info.
 826       // A just-prior uncommon-trap or deoptimization will use the SOE regs.
 827       halt_rms     [     halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
 828 
 829       Node *mproj;
 830 
 831       // Is this a RegF low half of a RegD?  Double up 2 adjacent RegF's

1060       Node *oldn = n;
1061       // Old-space or new-space check
1062       if (!C->node_arena()->contains(n)) {
1063         // Old space!
1064         Node* m;
1065         if (has_new_node(n)) {  // Not yet Label/Reduced
1066           m = new_node(n);
1067         } else {
1068           if (!is_dontcare(n)) { // Matcher can match this guy
1069             // Calls match special.  They match alone with no children.
1070             // Their children, the incoming arguments, match normally.
1071             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1072             if (C->failing())  return nullptr;
1073             if (m == nullptr) { Matcher::soft_match_failure(); return nullptr; }
1074             if (n->is_MemBar()) {
1075               m->as_MachMemBar()->set_adr_type(n->adr_type());
1076             }
1077           } else {                  // Nothing the matcher cares about
1078             if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Multi()) {       // Projections?
1079               // Convert to machine-dependent projection
1080               RegMask* mask = nullptr;
1081               if (n->in(0)->is_Call() && n->in(0)->as_Call()->tf()->returns_inline_type_as_fields()) {
1082                 mask = return_values_mask(n->in(0)->as_Call()->tf());
1083               }
1084               m = n->in(0)->as_Multi()->match(n->as_Proj(), this, mask);
1085               NOT_PRODUCT(record_new2old(m, n);)
1086               if (m->in(0) != nullptr) // m might be top
1087                 collect_null_checks(m, n);
1088             } else {                // Else just a regular 'ol guy
1089               m = n->clone();       // So just clone into new-space
1090               NOT_PRODUCT(record_new2old(m, n);)
1091               // Def-Use edges will be added incrementally as Uses
1092               // of this node are matched.
1093               assert(m->outcnt() == 0, "no Uses of this clone yet");
1094             }
1095           }
1096 
1097           set_new_node(n, m);       // Map old to new
1098           if (_old_node_note_array != nullptr) {
1099             Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1100                                                   n->_idx);
1101             C->set_node_notes_at(m->_idx, nn);
1102           }
1103           DEBUG_ONLY(match_alias_type(C, n, m));
1104         }

1199     return warped;
1200   }
1201   return OptoReg::as_OptoReg(reg);
1202 }
1203 
1204 
1205 //------------------------------match_sfpt-------------------------------------
1206 // Helper function to match call instructions.  Calls match special.
1207 // They match alone with no children.  Their children, the incoming
1208 // arguments, match normally.
1209 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1210   MachSafePointNode *msfpt = nullptr;
1211   MachCallNode      *mcall = nullptr;
1212   uint               cnt;
1213   // Split out case for SafePoint vs Call
1214   CallNode *call;
1215   const TypeTuple *domain;
1216   ciMethod*        method = nullptr;
1217   if( sfpt->is_Call() ) {
1218     call = sfpt->as_Call();
1219     domain = call->tf()->domain_cc();
1220     cnt = domain->cnt();
1221 
1222     // Match just the call, nothing else
1223     MachNode *m = match_tree(call);
1224     if (C->failing())  return nullptr;
1225     if( m == nullptr ) { Matcher::soft_match_failure(); return nullptr; }
1226 
1227     // Copy data from the Ideal SafePoint to the machine version
1228     mcall = m->as_MachCall();
1229 
1230     mcall->set_tf(                  call->tf());
1231     mcall->set_entry_point(         call->entry_point());
1232     mcall->set_cnt(                 call->cnt());
1233     mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1234 
1235     if( mcall->is_MachCallJava() ) {
1236       MachCallJavaNode *mcall_java  = mcall->as_MachCallJava();
1237       const CallJavaNode *call_java =  call->as_CallJava();
1238       assert(call_java->validate_symbolic_info(), "inconsistent info");
1239       method = call_java->method();

1275   for (uint i = 0; i < cnt; i++) {
1276     ::new (msfpt->_in_rms + i) RegMask(C->comp_arena());
1277   }
1278 
1279   // Do all the pre-defined non-Empty register masks
1280   msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1281   msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1282 
1283   // Place first outgoing argument can possibly be put.
1284   OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1285   assert( is_even(begin_out_arg_area), "" );
1286   // Compute max outgoing register number per call site.
1287   OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1288   // Calls to C may hammer extra stack slots above and beyond any arguments.
1289   // These are usually backing store for register arguments for varargs.
1290   if( call != nullptr && call->is_CallRuntime() )
1291     out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1292 
1293 
1294   // Do the normal argument list (parameters) register masks
1295   // Null entry point is a special cast where the target of the call
1296   // is in a register.
1297   int adj = (call != nullptr && call->entry_point() == nullptr) ? 1 : 0;
1298   int argcnt = cnt - TypeFunc::Parms - adj;
1299   if( argcnt > 0 ) {          // Skip it all if we have no args
1300     BasicType *sig_bt  = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1301     VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1302     int i;
1303     for( i = 0; i < argcnt; i++ ) {
1304       sig_bt[i] = domain->field_at(i+TypeFunc::Parms+adj)->basic_type();
1305     }
1306     // V-call to pick proper calling convention
1307     call->calling_convention( sig_bt, parm_regs, argcnt );
1308 
1309 #ifdef ASSERT
1310     // Sanity check users' calling convention.  Really handy during
1311     // the initial porting effort.  Fairly expensive otherwise.
1312     { for (int i = 0; i<argcnt; i++) {
1313       if( !parm_regs[i].first()->is_valid() &&
1314           !parm_regs[i].second()->is_valid() ) continue;
1315       VMReg reg1 = parm_regs[i].first();
1316       VMReg reg2 = parm_regs[i].second();
1317       for (int j = 0; j < i; j++) {
1318         if( !parm_regs[j].first()->is_valid() &&
1319             !parm_regs[j].second()->is_valid() ) continue;
1320         VMReg reg3 = parm_regs[j].first();
1321         VMReg reg4 = parm_regs[j].second();
1322         if( !reg1->is_valid() ) {
1323           assert( !reg2->is_valid(), "valid halvsies" );
1324         } else if( !reg3->is_valid() ) {
1325           assert( !reg4->is_valid(), "valid halvsies" );
1326         } else {
1327           assert( reg1 != reg2, "calling conv. must produce distinct regs");
1328           assert( reg1 != reg3, "calling conv. must produce distinct regs");
1329           assert( reg1 != reg4, "calling conv. must produce distinct regs");
1330           assert( reg2 != reg3, "calling conv. must produce distinct regs");
1331           assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1332           assert( reg3 != reg4, "calling conv. must produce distinct regs");
1333         }
1334       }
1335     }
1336     }
1337 #endif
1338 
1339     // Visit each argument.  Compute its outgoing register mask.
1340     // Return results now can have 2 bits returned.
1341     // Compute max over all outgoing arguments both per call-site
1342     // and over the entire method.
1343     for( i = 0; i < argcnt; i++ ) {
1344       // Address of incoming argument mask to fill in
1345       RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms+adj];
1346       VMReg first = parm_regs[i].first();
1347       VMReg second = parm_regs[i].second();
1348       if(!first->is_valid() &&
1349          !second->is_valid()) {
1350         continue;               // Avoid Halves
1351       }
1352       // Handle case where arguments are in vector registers.
1353       if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1354         OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1355         OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1356         assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1357         for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1358           rm->Insert(r);
1359         }
1360       }
1361       // Grab first register, adjust stack slots and insert in mask.
1362       OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1363       if (OptoReg::is_valid(reg1)) {
1364         rm->Insert( reg1 );
1365       }
1366       // Grab second register (if any), adjust stack slots and insert in mask.
1367       OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1368       if (OptoReg::is_valid(reg2)) {
1369         rm->Insert( reg2 );
1370       }
1371     } // End of for all arguments
1372   }
1373 
1374   // Compute the max stack slot killed by any call.  These will not be
1375   // available for debug info, and will be used to adjust FIRST_STACK_mask
1376   // after all call sites have been visited.
1377   if( _out_arg_limit < out_arg_limit_per_call)
1378     _out_arg_limit = out_arg_limit_per_call;
1379 
1380   if (mcall) {
1381     // Kill the outgoing argument area, including any non-argument holes and
1382     // any legacy C-killed slots.  Use Fat-Projections to do the killing.
1383     // Since the max-per-method covers the max-per-call-site and debug info
1384     // is excluded on the max-per-method basis, debug info cannot land in
1385     // this killed area.
1386     uint r_cnt = mcall->tf()->range_sig()->cnt();
1387     MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1388     for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++) {
1389       proj->_rout.Insert(OptoReg::Name(i));
1390     }
1391     if (!proj->_rout.is_Empty()) {
1392       push_projection(proj);
1393     }
1394   }
1395   // Transfer the safepoint information from the call to the mcall
1396   // Move the JVMState list
1397   msfpt->set_jvms(sfpt->jvms());
1398   for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1399     jvms->set_map(sfpt);
1400   }
1401 
1402   // Debug inputs begin just after the last incoming parameter
1403   assert((mcall == nullptr) || (mcall->jvms() == nullptr) ||
1404          (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain_cc()->cnt()), "");
1405 
1406   // Add additional edges.
1407   if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1408     // For these calls we can not add MachConstantBase in expand(), as the
1409     // ins are not complete then.
1410     msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1411     if (msfpt->jvms() &&
1412         msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1413       // We added an edge before jvms, so we must adapt the position of the ins.
1414       msfpt->jvms()->adapt_position(+1);
1415     }
1416   }
1417 
1418   // Registers killed by the call are set in the local scheduling pass
1419   // of Global Code Motion.
1420   return msfpt;
1421 }
1422 
1423 //---------------------------match_tree----------------------------------------
1424 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce.  Used as part

2073         set_shared(n);       // Flag as shared and
2074         if (n->is_DecodeNarrowPtr()) {
2075           // Oop field/array element loads must be shared but since
2076           // they are shared through a DecodeN they may appear to have
2077           // a single use so force sharing here.
2078           set_shared(n->in(1));
2079         }
2080         mstack.pop();        // remove node from stack
2081         continue;
2082       }
2083       nstate = Visit; // Not already visited; so visit now
2084     }
2085     if (nstate == Visit) {
2086       mstack.set_state(Post_Visit);
2087       set_visited(n);   // Flag as visited now
2088       bool mem_op = false;
2089       int mem_addr_idx = MemNode::Address;
2090       if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2091         continue;
2092       }
2093       for (int i = n->len() - 1; i >= 0; --i) { // For my children
2094         Node* m = n->in(i); // Get ith input
2095         if (m == nullptr) {
2096           continue;  // Ignore nulls
2097         }
2098         if (clone_node(n, m, mstack)) {
2099           continue;
2100         }
2101 
2102         // Clone addressing expressions as they are "free" in memory access instructions
2103         if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2104             // When there are other uses besides address expressions
2105             // put it on stack and mark as shared.
2106             !is_visited(m)) {
2107           // Some inputs for address expression are not put on stack
2108           // to avoid marking them as shared and forcing them into register
2109           // if they are used only in address expressions.
2110           // But they should be marked as shared if there are other uses
2111           // besides address expressions.
2112 
2113           if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {

2384     case Op_FmaHF:
2385     case Op_FmaVD:
2386     case Op_FmaVF:
2387     case Op_FmaVHF: {
2388       // Restructure into a binary tree for Matching.
2389       Node* pair = new BinaryNode(n->in(1), n->in(2));
2390       n->set_req(2, pair);
2391       n->set_req(1, n->in(3));
2392       n->del_req(3);
2393       break;
2394     }
2395     case Op_MulAddS2I: {
2396       Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2397       Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2398       n->set_req(1, pair1);
2399       n->set_req(2, pair2);
2400       n->del_req(4);
2401       n->del_req(3);
2402       break;
2403     }
2404     case Op_ClearArray: {
2405       Node* pair = new BinaryNode(n->in(2), n->in(3));
2406       n->set_req(2, pair);
2407       n->set_req(3, n->in(4));
2408       n->del_req(4);
2409       break;
2410     }
2411     case Op_VectorCmpMasked:
2412     case Op_CopySignD:
2413     case Op_SignumVF:
2414     case Op_SignumVD:
2415     case Op_SignumF:
2416     case Op_SignumD: {
2417       Node* pair = new BinaryNode(n->in(2), n->in(3));
2418       n->set_req(2, pair);
2419       n->del_req(3);
2420       break;
2421     }
2422     case Op_VectorBlend:
2423     case Op_VectorInsert: {
2424       Node* pair = new BinaryNode(n->in(1), n->in(2));
2425       n->set_req(1, pair);
2426       n->set_req(2, n->in(3));
2427       n->del_req(3);
2428       break;
2429     }
2430     case Op_LoadVectorGatherMasked: // fall-through

2440       n->del_req(MemNode::ValueIn+2);
2441       pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2442       n->set_req(MemNode::ValueIn, pair);
2443       n->del_req(MemNode::ValueIn+1);
2444       break;
2445     }
2446     case Op_VectorMaskCmp: {
2447       n->set_req(1, new BinaryNode(n->in(1), n->in(2)));
2448       n->set_req(2, n->in(3));
2449       n->del_req(3);
2450       break;
2451     }
2452     case Op_PartialSubtypeCheck: {
2453       if (UseSecondarySupersTable && n->in(2)->is_Con()) {
2454         // PartialSubtypeCheck uses both constant and register operands for superclass input.
2455         n->set_req(2, new BinaryNode(n->in(2), n->in(2)));
2456         break;
2457       }
2458       break;
2459     }
2460     case Op_StoreLSpecial: {
2461       if (n->req() > (MemNode::ValueIn + 1) && n->in(MemNode::ValueIn + 1) != nullptr) {
2462         Node* pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn + 1));
2463         n->set_req(MemNode::ValueIn, pair);
2464         n->del_req(MemNode::ValueIn + 1);
2465       }
2466       break;
2467     }
2468     default:
2469       break;
2470   }
2471 }
2472 
2473 #ifndef PRODUCT
2474 void Matcher::record_new2old(Node* newn, Node* old) {
2475   _new2old_map.map(newn->_idx, old);
2476   if (!_reused.test_set(old->_igv_idx)) {
2477     // Reuse the Ideal-level IGV identifier so that the node can be tracked
2478     // across matching. If there are multiple machine nodes expanded from the
2479     // same Ideal node, only one will reuse its IGV identifier.
2480     newn->_igv_idx = old->_igv_idx;
2481   }
2482 }
2483 
2484 // machine-independent root to machine-dependent root
2485 void Matcher::dump_old2new_map() {
2486   _old2new_map.dump();
2487 }
< prev index next >