169 worklist.push(xroot);
170 while (worklist.size() > 0) {
171 Node* n = worklist.pop();
172 if (visited.test_set(n->_idx)) {
173 continue;
174 }
175 assert(C->node_arena()->contains(n), "dead node");
176 for (uint j = 0; j < n->req(); j++) {
177 Node* in = n->in(j);
178 if (in != nullptr) {
179 worklist.push(in);
180 }
181 }
182 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
183 worklist.push(n->fast_out(j));
184 }
185 }
186 }
187 #endif
188
189
190 //---------------------------match---------------------------------------------
191 void Matcher::match( ) {
192 if( MaxLabelRootDepth < 100 ) { // Too small?
193 assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
194 MaxLabelRootDepth = 100;
195 }
196 // One-time initialization of some register masks.
197 init_spill_mask( C->root()->in(1) );
198 if (C->failing()) {
199 return;
200 }
201 _return_addr_mask = return_addr();
202 #ifdef _LP64
203 // Pointers take 2 slots in 64-bit land
204 _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
205 #endif
206
207 // Map a Java-signature return type into return register-value
208 // machine registers for 0, 1 and 2 returned values.
209 const TypeTuple *range = C->tf()->range();
210 if( range->cnt() > TypeFunc::Parms ) { // If not a void function
211 // Get ideal-register return type
212 uint ireg = range->field_at(TypeFunc::Parms)->ideal_reg();
213 // Get machine return register
214 uint sop = C->start()->Opcode();
215 OptoRegPair regs = return_value(ireg);
216
217 // And mask for same
218 _return_value_mask = RegMask(regs.first());
219 if( OptoReg::is_valid(regs.second()) )
220 _return_value_mask.Insert(regs.second());
221 }
222
223 // ---------------
224 // Frame Layout
225
226 // Need the method signature to determine the incoming argument types,
227 // because the types determine which registers the incoming arguments are
228 // in, and this affects the matched code.
229 const TypeTuple *domain = C->tf()->domain();
230 uint argcnt = domain->cnt() - TypeFunc::Parms;
231 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
232 VMRegPair *vm_parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
233 _parm_regs = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
234 _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
235 uint i;
236 for( i = 0; i<argcnt; i++ ) {
237 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
238 }
239
240 // Pass array of ideal registers and length to USER code (from the AD file)
241 // that will convert this to an array of register numbers.
242 const StartNode *start = C->start();
243 start->calling_convention( sig_bt, vm_parm_regs, argcnt );
244 #ifdef ASSERT
245 // Sanity check users' calling convention. Real handy while trying to
246 // get the initial port correct.
247 { for (uint i = 0; i<argcnt; i++) {
248 if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
249 assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );
532 idealreg2mhdebugmask[Op_VecS] = &rms[31];
533 idealreg2mhdebugmask[Op_VecD] = &rms[32];
534 idealreg2mhdebugmask[Op_VecX] = &rms[33];
535 idealreg2mhdebugmask[Op_VecY] = &rms[34];
536 idealreg2mhdebugmask[Op_VecZ] = &rms[35];
537
538 idealreg2spillmask [Op_RegVectMask] = &rms[36];
539 idealreg2debugmask [Op_RegVectMask] = &rms[37];
540 idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
541
542 OptoReg::Name i;
543
544 // At first, start with the empty mask
545 C->FIRST_STACK_mask().Clear();
546
547 // Add in the incoming argument area
548 OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
549 for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
550 C->FIRST_STACK_mask().Insert(i);
551 }
552 // Add in all bits past the outgoing argument area
553 guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
554 "must be able to represent all call arguments in reg mask");
555 OptoReg::Name init = _out_arg_limit;
556 for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
557 C->FIRST_STACK_mask().Insert(i);
558 }
559 // Finally, set the "infinite stack" bit.
560 C->FIRST_STACK_mask().set_AllStack();
561
562 // Make spill masks. Registers for their class, plus FIRST_STACK_mask.
563 RegMask aligned_stack_mask = C->FIRST_STACK_mask();
564 // Keep spill masks aligned.
565 aligned_stack_mask.clear_to_pairs();
566 assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
567 RegMask scalable_stack_mask = aligned_stack_mask;
568
569 *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
570 #ifdef _LP64
571 *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];
790 _register_save_policy[reg] == 'E' ||
791 _register_save_policy[reg] == 'A'; // Save-on-entry register?
792 }
793
794 //---------------------------Fixup_Save_On_Entry-------------------------------
795 void Matcher::Fixup_Save_On_Entry( ) {
796 init_first_stack_mask();
797
798 Node *root = C->root(); // Short name for root
799 // Count number of save-on-entry registers.
800 uint soe_cnt = number_of_saved_registers();
801 uint i;
802
803 // Find the procedure Start Node
804 StartNode *start = C->start();
805 assert( start, "Expect a start node" );
806
807 // Input RegMask array shared by all Returns.
808 // The type for doubles and longs has a count of 2, but
809 // there is only 1 returned value
810 uint ret_edge_cnt = TypeFunc::Parms + ((C->tf()->range()->cnt() == TypeFunc::Parms) ? 0 : 1);
811 RegMask *ret_rms = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
812 // Returns have 0 or 1 returned values depending on call signature.
813 // Return register is specified by return_value in the AD file.
814 if (ret_edge_cnt > TypeFunc::Parms)
815 ret_rms[TypeFunc::Parms+0] = _return_value_mask;
816
817 // Input RegMask array shared by all ForwardExceptions
818 uint forw_exc_edge_cnt = TypeFunc::Parms;
819 RegMask* forw_exc_rms = init_input_masks( forw_exc_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
820
821 // Input RegMask array shared by all Rethrows.
822 uint reth_edge_cnt = TypeFunc::Parms+1;
823 RegMask *reth_rms = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
824 // Rethrow takes exception oop only, but in the argument 0 slot.
825 OptoReg::Name reg = find_receiver();
826 if (reg >= 0) {
827 reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
828 #ifdef _LP64
829 // Need two slots for ptrs in 64-bit land
830 reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
831 #endif
832 }
833
834 // Input RegMask array shared by all TailCalls
835 uint tail_call_edge_cnt = TypeFunc::Parms+2;
867
868 // Input RegMask array shared by all Halts
869 uint halt_edge_cnt = TypeFunc::Parms;
870 RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
871
872 // Capture the return input masks into each exit flavor
873 for( i=1; i < root->req(); i++ ) {
874 MachReturnNode *exit = root->in(i)->as_MachReturn();
875 switch( exit->ideal_Opcode() ) {
876 case Op_Return : exit->_in_rms = ret_rms; break;
877 case Op_Rethrow : exit->_in_rms = reth_rms; break;
878 case Op_TailCall : exit->_in_rms = tail_call_rms; break;
879 case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
880 case Op_ForwardException: exit->_in_rms = forw_exc_rms; break;
881 case Op_Halt : exit->_in_rms = halt_rms; break;
882 default : ShouldNotReachHere();
883 }
884 }
885
886 // Next unused projection number from Start.
887 int proj_cnt = C->tf()->domain()->cnt();
888
889 // Do all the save-on-entry registers. Make projections from Start for
890 // them, and give them a use at the exit points. To the allocator, they
891 // look like incoming register arguments.
892 for( i = 0; i < _last_Mach_Reg; i++ ) {
893 if( is_save_on_entry(i) ) {
894
895 // Add the save-on-entry to the mask array
896 ret_rms [ ret_edge_cnt] = mreg2regmask[i];
897 reth_rms [ reth_edge_cnt] = mreg2regmask[i];
898 tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
899 tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
900 forw_exc_rms [ forw_exc_edge_cnt] = mreg2regmask[i];
901 // Halts need the SOE registers, but only in the stack as debug info.
902 // A just-prior uncommon-trap or deoptimization will use the SOE regs.
903 halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
904
905 Node *mproj;
906
907 // Is this a RegF low half of a RegD? Double up 2 adjacent RegF's
1148 Node *oldn = n;
1149 // Old-space or new-space check
1150 if (!C->node_arena()->contains(n)) {
1151 // Old space!
1152 Node* m;
1153 if (has_new_node(n)) { // Not yet Label/Reduced
1154 m = new_node(n);
1155 } else {
1156 if (!is_dontcare(n)) { // Matcher can match this guy
1157 // Calls match special. They match alone with no children.
1158 // Their children, the incoming arguments, match normally.
1159 m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1160 if (C->failing()) return nullptr;
1161 if (m == nullptr) { Matcher::soft_match_failure(); return nullptr; }
1162 if (n->is_MemBar()) {
1163 m->as_MachMemBar()->set_adr_type(n->adr_type());
1164 }
1165 } else { // Nothing the matcher cares about
1166 if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Multi()) { // Projections?
1167 // Convert to machine-dependent projection
1168 m = n->in(0)->as_Multi()->match( n->as_Proj(), this );
1169 NOT_PRODUCT(record_new2old(m, n);)
1170 if (m->in(0) != nullptr) // m might be top
1171 collect_null_checks(m, n);
1172 } else { // Else just a regular 'ol guy
1173 m = n->clone(); // So just clone into new-space
1174 NOT_PRODUCT(record_new2old(m, n);)
1175 // Def-Use edges will be added incrementally as Uses
1176 // of this node are matched.
1177 assert(m->outcnt() == 0, "no Uses of this clone yet");
1178 }
1179 }
1180
1181 set_new_node(n, m); // Map old to new
1182 if (_old_node_note_array != nullptr) {
1183 Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1184 n->_idx);
1185 C->set_node_notes_at(m->_idx, nn);
1186 }
1187 debug_only(match_alias_type(C, n, m));
1188 }
1288 }
1289 return OptoReg::as_OptoReg(reg);
1290 }
1291
1292
1293 //------------------------------match_sfpt-------------------------------------
1294 // Helper function to match call instructions. Calls match special.
1295 // They match alone with no children. Their children, the incoming
1296 // arguments, match normally.
1297 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1298 MachSafePointNode *msfpt = nullptr;
1299 MachCallNode *mcall = nullptr;
1300 uint cnt;
1301 // Split out case for SafePoint vs Call
1302 CallNode *call;
1303 const TypeTuple *domain;
1304 ciMethod* method = nullptr;
1305 bool is_method_handle_invoke = false; // for special kill effects
1306 if( sfpt->is_Call() ) {
1307 call = sfpt->as_Call();
1308 domain = call->tf()->domain();
1309 cnt = domain->cnt();
1310
1311 // Match just the call, nothing else
1312 MachNode *m = match_tree(call);
1313 if (C->failing()) return nullptr;
1314 if( m == nullptr ) { Matcher::soft_match_failure(); return nullptr; }
1315
1316 // Copy data from the Ideal SafePoint to the machine version
1317 mcall = m->as_MachCall();
1318
1319 mcall->set_tf( call->tf());
1320 mcall->set_entry_point( call->entry_point());
1321 mcall->set_cnt( call->cnt());
1322 mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1323
1324 if( mcall->is_MachCallJava() ) {
1325 MachCallJavaNode *mcall_java = mcall->as_MachCallJava();
1326 const CallJavaNode *call_java = call->as_CallJava();
1327 assert(call_java->validate_symbolic_info(), "inconsistent info");
1328 method = call_java->method();
1367 msfpt->_in_rms = NEW_RESOURCE_ARRAY( RegMask, cnt );
1368 // Empty them all.
1369 for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1370
1371 // Do all the pre-defined non-Empty register masks
1372 msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1373 msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1374
1375 // Place first outgoing argument can possibly be put.
1376 OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1377 assert( is_even(begin_out_arg_area), "" );
1378 // Compute max outgoing register number per call site.
1379 OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1380 // Calls to C may hammer extra stack slots above and beyond any arguments.
1381 // These are usually backing store for register arguments for varargs.
1382 if( call != nullptr && call->is_CallRuntime() )
1383 out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1384
1385
1386 // Do the normal argument list (parameters) register masks
1387 int argcnt = cnt - TypeFunc::Parms;
1388 if( argcnt > 0 ) { // Skip it all if we have no args
1389 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1390 VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1391 int i;
1392 for( i = 0; i < argcnt; i++ ) {
1393 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
1394 }
1395 // V-call to pick proper calling convention
1396 call->calling_convention( sig_bt, parm_regs, argcnt );
1397
1398 #ifdef ASSERT
1399 // Sanity check users' calling convention. Really handy during
1400 // the initial porting effort. Fairly expensive otherwise.
1401 { for (int i = 0; i<argcnt; i++) {
1402 if( !parm_regs[i].first()->is_valid() &&
1403 !parm_regs[i].second()->is_valid() ) continue;
1404 VMReg reg1 = parm_regs[i].first();
1405 VMReg reg2 = parm_regs[i].second();
1406 for (int j = 0; j < i; j++) {
1407 if( !parm_regs[j].first()->is_valid() &&
1408 !parm_regs[j].second()->is_valid() ) continue;
1409 VMReg reg3 = parm_regs[j].first();
1410 VMReg reg4 = parm_regs[j].second();
1411 if( !reg1->is_valid() ) {
1412 assert( !reg2->is_valid(), "valid halvsies" );
1413 } else if( !reg3->is_valid() ) {
1414 assert( !reg4->is_valid(), "valid halvsies" );
1415 } else {
1416 assert( reg1 != reg2, "calling conv. must produce distinct regs");
1417 assert( reg1 != reg3, "calling conv. must produce distinct regs");
1418 assert( reg1 != reg4, "calling conv. must produce distinct regs");
1419 assert( reg2 != reg3, "calling conv. must produce distinct regs");
1420 assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1421 assert( reg3 != reg4, "calling conv. must produce distinct regs");
1422 }
1423 }
1424 }
1425 }
1426 #endif
1427
1428 // Visit each argument. Compute its outgoing register mask.
1429 // Return results now can have 2 bits returned.
1430 // Compute max over all outgoing arguments both per call-site
1431 // and over the entire method.
1432 for( i = 0; i < argcnt; i++ ) {
1433 // Address of incoming argument mask to fill in
1434 RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms];
1435 VMReg first = parm_regs[i].first();
1436 VMReg second = parm_regs[i].second();
1437 if(!first->is_valid() &&
1438 !second->is_valid()) {
1439 continue; // Avoid Halves
1440 }
1441 // Handle case where arguments are in vector registers.
1442 if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1443 OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1444 OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1445 assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1446 for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1447 rm->Insert(r);
1448 }
1449 }
1450 // Grab first register, adjust stack slots and insert in mask.
1451 OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1452 if (C->failing()) {
1453 return nullptr;
1454 }
1455 if (OptoReg::is_valid(reg1))
1456 rm->Insert( reg1 );
1457 // Grab second register (if any), adjust stack slots and insert in mask.
1458 OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1459 if (C->failing()) {
1460 return nullptr;
1461 }
1462 if (OptoReg::is_valid(reg2))
1463 rm->Insert( reg2 );
1464 } // End of for all arguments
1465 }
1466
1467 // Compute the max stack slot killed by any call. These will not be
1468 // available for debug info, and will be used to adjust FIRST_STACK_mask
1469 // after all call sites have been visited.
1470 if( _out_arg_limit < out_arg_limit_per_call)
1471 _out_arg_limit = out_arg_limit_per_call;
1472
1473 if (mcall) {
1474 // Kill the outgoing argument area, including any non-argument holes and
1475 // any legacy C-killed slots. Use Fat-Projections to do the killing.
1476 // Since the max-per-method covers the max-per-call-site and debug info
1477 // is excluded on the max-per-method basis, debug info cannot land in
1478 // this killed area.
1479 uint r_cnt = mcall->tf()->range()->cnt();
1480 MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1481 if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1482 // Bailout. We do not have space to represent all arguments.
1483 C->record_method_not_compilable("unsupported outgoing calling sequence");
1484 } else {
1485 for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1486 proj->_rout.Insert(OptoReg::Name(i));
1487 }
1488 if (proj->_rout.is_NotEmpty()) {
1489 push_projection(proj);
1490 }
1491 }
1492 // Transfer the safepoint information from the call to the mcall
1493 // Move the JVMState list
1494 msfpt->set_jvms(sfpt->jvms());
1495 for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1496 jvms->set_map(sfpt);
1497 }
1498
1499 // Debug inputs begin just after the last incoming parameter
1500 assert((mcall == nullptr) || (mcall->jvms() == nullptr) ||
1501 (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain()->cnt()), "");
1502
1503 // Add additional edges.
1504 if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1505 // For these calls we can not add MachConstantBase in expand(), as the
1506 // ins are not complete then.
1507 msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1508 if (msfpt->jvms() &&
1509 msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1510 // We added an edge before jvms, so we must adapt the position of the ins.
1511 msfpt->jvms()->adapt_position(+1);
1512 }
1513 }
1514
1515 // Registers killed by the call are set in the local scheduling pass
1516 // of Global Code Motion.
1517 return msfpt;
1518 }
1519
1520 //---------------------------match_tree----------------------------------------
1521 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce. Used as part
2170 set_shared(n); // Flag as shared and
2171 if (n->is_DecodeNarrowPtr()) {
2172 // Oop field/array element loads must be shared but since
2173 // they are shared through a DecodeN they may appear to have
2174 // a single use so force sharing here.
2175 set_shared(n->in(1));
2176 }
2177 mstack.pop(); // remove node from stack
2178 continue;
2179 }
2180 nstate = Visit; // Not already visited; so visit now
2181 }
2182 if (nstate == Visit) {
2183 mstack.set_state(Post_Visit);
2184 set_visited(n); // Flag as visited now
2185 bool mem_op = false;
2186 int mem_addr_idx = MemNode::Address;
2187 if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2188 continue;
2189 }
2190 for (int i = n->req() - 1; i >= 0; --i) { // For my children
2191 Node* m = n->in(i); // Get ith input
2192 if (m == nullptr) {
2193 continue; // Ignore nulls
2194 }
2195 if (clone_node(n, m, mstack)) {
2196 continue;
2197 }
2198
2199 // Clone addressing expressions as they are "free" in memory access instructions
2200 if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2201 // When there are other uses besides address expressions
2202 // put it on stack and mark as shared.
2203 !is_visited(m)) {
2204 // Some inputs for address expression are not put on stack
2205 // to avoid marking them as shared and forcing them into register
2206 // if they are used only in address expressions.
2207 // But they should be marked as shared if there are other uses
2208 // besides address expressions.
2209
2210 if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {
2479 case Op_FmaF:
2480 case Op_FmaHF:
2481 case Op_FmaVD:
2482 case Op_FmaVF: {
2483 // Restructure into a binary tree for Matching.
2484 Node* pair = new BinaryNode(n->in(1), n->in(2));
2485 n->set_req(2, pair);
2486 n->set_req(1, n->in(3));
2487 n->del_req(3);
2488 break;
2489 }
2490 case Op_MulAddS2I: {
2491 Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2492 Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2493 n->set_req(1, pair1);
2494 n->set_req(2, pair2);
2495 n->del_req(4);
2496 n->del_req(3);
2497 break;
2498 }
2499 case Op_VectorCmpMasked:
2500 case Op_CopySignD:
2501 case Op_SignumVF:
2502 case Op_SignumVD:
2503 case Op_SignumF:
2504 case Op_SignumD: {
2505 Node* pair = new BinaryNode(n->in(2), n->in(3));
2506 n->set_req(2, pair);
2507 n->del_req(3);
2508 break;
2509 }
2510 case Op_VectorBlend:
2511 case Op_VectorInsert: {
2512 Node* pair = new BinaryNode(n->in(1), n->in(2));
2513 n->set_req(1, pair);
2514 n->set_req(2, n->in(3));
2515 n->del_req(3);
2516 break;
2517 }
2518 case Op_LoadVectorGather:
2543 n->del_req(MemNode::ValueIn+2);
2544 pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2545 n->set_req(MemNode::ValueIn, pair);
2546 n->del_req(MemNode::ValueIn+1);
2547 break;
2548 }
2549 case Op_VectorMaskCmp: {
2550 n->set_req(1, new BinaryNode(n->in(1), n->in(2)));
2551 n->set_req(2, n->in(3));
2552 n->del_req(3);
2553 break;
2554 }
2555 case Op_PartialSubtypeCheck: {
2556 if (UseSecondarySupersTable && n->in(2)->is_Con()) {
2557 // PartialSubtypeCheck uses both constant and register operands for superclass input.
2558 n->set_req(2, new BinaryNode(n->in(2), n->in(2)));
2559 break;
2560 }
2561 break;
2562 }
2563 default:
2564 break;
2565 }
2566 }
2567
2568 #ifndef PRODUCT
2569 void Matcher::record_new2old(Node* newn, Node* old) {
2570 _new2old_map.map(newn->_idx, old);
2571 if (!_reused.test_set(old->_igv_idx)) {
2572 // Reuse the Ideal-level IGV identifier so that the node can be tracked
2573 // across matching. If there are multiple machine nodes expanded from the
2574 // same Ideal node, only one will reuse its IGV identifier.
2575 newn->_igv_idx = old->_igv_idx;
2576 }
2577 }
2578
2579 // machine-independent root to machine-dependent root
2580 void Matcher::dump_old2new_map() {
2581 _old2new_map.dump();
2582 }
|
169 worklist.push(xroot);
170 while (worklist.size() > 0) {
171 Node* n = worklist.pop();
172 if (visited.test_set(n->_idx)) {
173 continue;
174 }
175 assert(C->node_arena()->contains(n), "dead node");
176 for (uint j = 0; j < n->req(); j++) {
177 Node* in = n->in(j);
178 if (in != nullptr) {
179 worklist.push(in);
180 }
181 }
182 for (DUIterator_Fast jmax, j = n->fast_outs(jmax); j < jmax; j++) {
183 worklist.push(n->fast_out(j));
184 }
185 }
186 }
187 #endif
188
189 // Array of RegMask, one per returned values (inline type instances can
190 // be returned as multiple return values, one per field)
191 RegMask* Matcher::return_values_mask(const TypeFunc* tf) {
192 const TypeTuple* range = tf->range_cc();
193 uint cnt = range->cnt() - TypeFunc::Parms;
194 if (cnt == 0) {
195 return nullptr;
196 }
197 RegMask* mask = NEW_RESOURCE_ARRAY(RegMask, cnt);
198 BasicType* sig_bt = NEW_RESOURCE_ARRAY(BasicType, cnt);
199 VMRegPair* vm_parm_regs = NEW_RESOURCE_ARRAY(VMRegPair, cnt);
200 for (uint i = 0; i < cnt; i++) {
201 sig_bt[i] = range->field_at(i+TypeFunc::Parms)->basic_type();
202 }
203
204 int regs = SharedRuntime::java_return_convention(sig_bt, vm_parm_regs, cnt);
205 if (regs <= 0) {
206 // We ran out of registers to store the IsInit information for a nullable inline type return.
207 // Since it is only set in the 'call_epilog', we can simply put it on the stack.
208 assert(tf->returns_inline_type_as_fields(), "should have been tested during graph construction");
209 // TODO 8284443 Can we teach the register allocator to reserve a stack slot instead?
210 // mask[--cnt] = STACK_ONLY_mask does not work (test with -XX:+StressGCM)
211 int slot = C->fixed_slots() - 2;
212 if (C->needs_stack_repair()) {
213 slot -= 2; // Account for stack increment value
214 }
215 mask[--cnt].Clear();
216 mask[cnt].Insert(OptoReg::stack2reg(slot));
217 }
218 for (uint i = 0; i < cnt; i++) {
219 mask[i].Clear();
220
221 OptoReg::Name reg1 = OptoReg::as_OptoReg(vm_parm_regs[i].first());
222 if (OptoReg::is_valid(reg1)) {
223 mask[i].Insert(reg1);
224 }
225 OptoReg::Name reg2 = OptoReg::as_OptoReg(vm_parm_regs[i].second());
226 if (OptoReg::is_valid(reg2)) {
227 mask[i].Insert(reg2);
228 }
229 }
230
231 return mask;
232 }
233
234 //---------------------------match---------------------------------------------
235 void Matcher::match( ) {
236 if( MaxLabelRootDepth < 100 ) { // Too small?
237 assert(false, "invalid MaxLabelRootDepth, increase it to 100 minimum");
238 MaxLabelRootDepth = 100;
239 }
240 // One-time initialization of some register masks.
241 init_spill_mask( C->root()->in(1) );
242 if (C->failing()) {
243 return;
244 }
245 _return_addr_mask = return_addr();
246 #ifdef _LP64
247 // Pointers take 2 slots in 64-bit land
248 _return_addr_mask.Insert(OptoReg::add(return_addr(),1));
249 #endif
250
251 // Map Java-signature return types into return register-value
252 // machine registers.
253 _return_values_mask = return_values_mask(C->tf());
254
255 // ---------------
256 // Frame Layout
257
258 // Need the method signature to determine the incoming argument types,
259 // because the types determine which registers the incoming arguments are
260 // in, and this affects the matched code.
261 const TypeTuple *domain = C->tf()->domain_cc();
262 uint argcnt = domain->cnt() - TypeFunc::Parms;
263 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
264 VMRegPair *vm_parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
265 _parm_regs = NEW_RESOURCE_ARRAY( OptoRegPair, argcnt );
266 _calling_convention_mask = NEW_RESOURCE_ARRAY( RegMask, argcnt );
267 uint i;
268 for( i = 0; i<argcnt; i++ ) {
269 sig_bt[i] = domain->field_at(i+TypeFunc::Parms)->basic_type();
270 }
271
272 // Pass array of ideal registers and length to USER code (from the AD file)
273 // that will convert this to an array of register numbers.
274 const StartNode *start = C->start();
275 start->calling_convention( sig_bt, vm_parm_regs, argcnt );
276 #ifdef ASSERT
277 // Sanity check users' calling convention. Real handy while trying to
278 // get the initial port correct.
279 { for (uint i = 0; i<argcnt; i++) {
280 if( !vm_parm_regs[i].first()->is_valid() && !vm_parm_regs[i].second()->is_valid() ) {
281 assert(domain->field_at(i+TypeFunc::Parms)==Type::HALF, "only allowed on halve" );
564 idealreg2mhdebugmask[Op_VecS] = &rms[31];
565 idealreg2mhdebugmask[Op_VecD] = &rms[32];
566 idealreg2mhdebugmask[Op_VecX] = &rms[33];
567 idealreg2mhdebugmask[Op_VecY] = &rms[34];
568 idealreg2mhdebugmask[Op_VecZ] = &rms[35];
569
570 idealreg2spillmask [Op_RegVectMask] = &rms[36];
571 idealreg2debugmask [Op_RegVectMask] = &rms[37];
572 idealreg2mhdebugmask[Op_RegVectMask] = &rms[38];
573
574 OptoReg::Name i;
575
576 // At first, start with the empty mask
577 C->FIRST_STACK_mask().Clear();
578
579 // Add in the incoming argument area
580 OptoReg::Name init_in = OptoReg::add(_old_SP, C->out_preserve_stack_slots());
581 for (i = init_in; i < _in_arg_limit; i = OptoReg::add(i,1)) {
582 C->FIRST_STACK_mask().Insert(i);
583 }
584
585 // Add in all bits past the outgoing argument area
586 guarantee(RegMask::can_represent_arg(OptoReg::add(_out_arg_limit,-1)),
587 "must be able to represent all call arguments in reg mask");
588 OptoReg::Name init = _out_arg_limit;
589 for (i = init; RegMask::can_represent(i); i = OptoReg::add(i,1)) {
590 C->FIRST_STACK_mask().Insert(i);
591 }
592 // Finally, set the "infinite stack" bit.
593 C->FIRST_STACK_mask().set_AllStack();
594
595 // Make spill masks. Registers for their class, plus FIRST_STACK_mask.
596 RegMask aligned_stack_mask = C->FIRST_STACK_mask();
597 // Keep spill masks aligned.
598 aligned_stack_mask.clear_to_pairs();
599 assert(aligned_stack_mask.is_AllStack(), "should be infinite stack");
600 RegMask scalable_stack_mask = aligned_stack_mask;
601
602 *idealreg2spillmask[Op_RegP] = *idealreg2regmask[Op_RegP];
603 #ifdef _LP64
604 *idealreg2spillmask[Op_RegN] = *idealreg2regmask[Op_RegN];
823 _register_save_policy[reg] == 'E' ||
824 _register_save_policy[reg] == 'A'; // Save-on-entry register?
825 }
826
827 //---------------------------Fixup_Save_On_Entry-------------------------------
828 void Matcher::Fixup_Save_On_Entry( ) {
829 init_first_stack_mask();
830
831 Node *root = C->root(); // Short name for root
832 // Count number of save-on-entry registers.
833 uint soe_cnt = number_of_saved_registers();
834 uint i;
835
836 // Find the procedure Start Node
837 StartNode *start = C->start();
838 assert( start, "Expect a start node" );
839
840 // Input RegMask array shared by all Returns.
841 // The type for doubles and longs has a count of 2, but
842 // there is only 1 returned value
843 uint ret_edge_cnt = C->tf()->range_cc()->cnt();
844 RegMask *ret_rms = init_input_masks( ret_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
845 for (i = TypeFunc::Parms; i < ret_edge_cnt; i++) {
846 ret_rms[i] = _return_values_mask[i-TypeFunc::Parms];
847 }
848
849 // Input RegMask array shared by all ForwardExceptions
850 uint forw_exc_edge_cnt = TypeFunc::Parms;
851 RegMask* forw_exc_rms = init_input_masks( forw_exc_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
852
853 // Input RegMask array shared by all Rethrows.
854 uint reth_edge_cnt = TypeFunc::Parms+1;
855 RegMask *reth_rms = init_input_masks( reth_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
856 // Rethrow takes exception oop only, but in the argument 0 slot.
857 OptoReg::Name reg = find_receiver();
858 if (reg >= 0) {
859 reth_rms[TypeFunc::Parms] = mreg2regmask[reg];
860 #ifdef _LP64
861 // Need two slots for ptrs in 64-bit land
862 reth_rms[TypeFunc::Parms].Insert(OptoReg::add(OptoReg::Name(reg), 1));
863 #endif
864 }
865
866 // Input RegMask array shared by all TailCalls
867 uint tail_call_edge_cnt = TypeFunc::Parms+2;
899
900 // Input RegMask array shared by all Halts
901 uint halt_edge_cnt = TypeFunc::Parms;
902 RegMask *halt_rms = init_input_masks( halt_edge_cnt + soe_cnt, _return_addr_mask, c_frame_ptr_mask );
903
904 // Capture the return input masks into each exit flavor
905 for( i=1; i < root->req(); i++ ) {
906 MachReturnNode *exit = root->in(i)->as_MachReturn();
907 switch( exit->ideal_Opcode() ) {
908 case Op_Return : exit->_in_rms = ret_rms; break;
909 case Op_Rethrow : exit->_in_rms = reth_rms; break;
910 case Op_TailCall : exit->_in_rms = tail_call_rms; break;
911 case Op_TailJump : exit->_in_rms = tail_jump_rms; break;
912 case Op_ForwardException: exit->_in_rms = forw_exc_rms; break;
913 case Op_Halt : exit->_in_rms = halt_rms; break;
914 default : ShouldNotReachHere();
915 }
916 }
917
918 // Next unused projection number from Start.
919 int proj_cnt = C->tf()->domain_cc()->cnt();
920
921 // Do all the save-on-entry registers. Make projections from Start for
922 // them, and give them a use at the exit points. To the allocator, they
923 // look like incoming register arguments.
924 for( i = 0; i < _last_Mach_Reg; i++ ) {
925 if( is_save_on_entry(i) ) {
926
927 // Add the save-on-entry to the mask array
928 ret_rms [ ret_edge_cnt] = mreg2regmask[i];
929 reth_rms [ reth_edge_cnt] = mreg2regmask[i];
930 tail_call_rms[tail_call_edge_cnt] = mreg2regmask[i];
931 tail_jump_rms[tail_jump_edge_cnt] = mreg2regmask[i];
932 forw_exc_rms [ forw_exc_edge_cnt] = mreg2regmask[i];
933 // Halts need the SOE registers, but only in the stack as debug info.
934 // A just-prior uncommon-trap or deoptimization will use the SOE regs.
935 halt_rms [ halt_edge_cnt] = *idealreg2spillmask[_register_save_type[i]];
936
937 Node *mproj;
938
939 // Is this a RegF low half of a RegD? Double up 2 adjacent RegF's
1180 Node *oldn = n;
1181 // Old-space or new-space check
1182 if (!C->node_arena()->contains(n)) {
1183 // Old space!
1184 Node* m;
1185 if (has_new_node(n)) { // Not yet Label/Reduced
1186 m = new_node(n);
1187 } else {
1188 if (!is_dontcare(n)) { // Matcher can match this guy
1189 // Calls match special. They match alone with no children.
1190 // Their children, the incoming arguments, match normally.
1191 m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
1192 if (C->failing()) return nullptr;
1193 if (m == nullptr) { Matcher::soft_match_failure(); return nullptr; }
1194 if (n->is_MemBar()) {
1195 m->as_MachMemBar()->set_adr_type(n->adr_type());
1196 }
1197 } else { // Nothing the matcher cares about
1198 if (n->is_Proj() && n->in(0) != nullptr && n->in(0)->is_Multi()) { // Projections?
1199 // Convert to machine-dependent projection
1200 RegMask* mask = nullptr;
1201 if (n->in(0)->is_Call() && n->in(0)->as_Call()->tf()->returns_inline_type_as_fields()) {
1202 mask = return_values_mask(n->in(0)->as_Call()->tf());
1203 }
1204 m = n->in(0)->as_Multi()->match(n->as_Proj(), this, mask);
1205 NOT_PRODUCT(record_new2old(m, n);)
1206 if (m->in(0) != nullptr) // m might be top
1207 collect_null_checks(m, n);
1208 } else { // Else just a regular 'ol guy
1209 m = n->clone(); // So just clone into new-space
1210 NOT_PRODUCT(record_new2old(m, n);)
1211 // Def-Use edges will be added incrementally as Uses
1212 // of this node are matched.
1213 assert(m->outcnt() == 0, "no Uses of this clone yet");
1214 }
1215 }
1216
1217 set_new_node(n, m); // Map old to new
1218 if (_old_node_note_array != nullptr) {
1219 Node_Notes* nn = C->locate_node_notes(_old_node_note_array,
1220 n->_idx);
1221 C->set_node_notes_at(m->_idx, nn);
1222 }
1223 debug_only(match_alias_type(C, n, m));
1224 }
1324 }
1325 return OptoReg::as_OptoReg(reg);
1326 }
1327
1328
1329 //------------------------------match_sfpt-------------------------------------
1330 // Helper function to match call instructions. Calls match special.
1331 // They match alone with no children. Their children, the incoming
1332 // arguments, match normally.
1333 MachNode *Matcher::match_sfpt( SafePointNode *sfpt ) {
1334 MachSafePointNode *msfpt = nullptr;
1335 MachCallNode *mcall = nullptr;
1336 uint cnt;
1337 // Split out case for SafePoint vs Call
1338 CallNode *call;
1339 const TypeTuple *domain;
1340 ciMethod* method = nullptr;
1341 bool is_method_handle_invoke = false; // for special kill effects
1342 if( sfpt->is_Call() ) {
1343 call = sfpt->as_Call();
1344 domain = call->tf()->domain_cc();
1345 cnt = domain->cnt();
1346
1347 // Match just the call, nothing else
1348 MachNode *m = match_tree(call);
1349 if (C->failing()) return nullptr;
1350 if( m == nullptr ) { Matcher::soft_match_failure(); return nullptr; }
1351
1352 // Copy data from the Ideal SafePoint to the machine version
1353 mcall = m->as_MachCall();
1354
1355 mcall->set_tf( call->tf());
1356 mcall->set_entry_point( call->entry_point());
1357 mcall->set_cnt( call->cnt());
1358 mcall->set_guaranteed_safepoint(call->guaranteed_safepoint());
1359
1360 if( mcall->is_MachCallJava() ) {
1361 MachCallJavaNode *mcall_java = mcall->as_MachCallJava();
1362 const CallJavaNode *call_java = call->as_CallJava();
1363 assert(call_java->validate_symbolic_info(), "inconsistent info");
1364 method = call_java->method();
1403 msfpt->_in_rms = NEW_RESOURCE_ARRAY( RegMask, cnt );
1404 // Empty them all.
1405 for (uint i = 0; i < cnt; i++) ::new (&(msfpt->_in_rms[i])) RegMask();
1406
1407 // Do all the pre-defined non-Empty register masks
1408 msfpt->_in_rms[TypeFunc::ReturnAdr] = _return_addr_mask;
1409 msfpt->_in_rms[TypeFunc::FramePtr ] = c_frame_ptr_mask;
1410
1411 // Place first outgoing argument can possibly be put.
1412 OptoReg::Name begin_out_arg_area = OptoReg::add(_new_SP, C->out_preserve_stack_slots());
1413 assert( is_even(begin_out_arg_area), "" );
1414 // Compute max outgoing register number per call site.
1415 OptoReg::Name out_arg_limit_per_call = begin_out_arg_area;
1416 // Calls to C may hammer extra stack slots above and beyond any arguments.
1417 // These are usually backing store for register arguments for varargs.
1418 if( call != nullptr && call->is_CallRuntime() )
1419 out_arg_limit_per_call = OptoReg::add(out_arg_limit_per_call,C->varargs_C_out_slots_killed());
1420
1421
1422 // Do the normal argument list (parameters) register masks
1423 // Null entry point is a special cast where the target of the call
1424 // is in a register.
1425 int adj = (call != nullptr && call->entry_point() == nullptr) ? 1 : 0;
1426 int argcnt = cnt - TypeFunc::Parms - adj;
1427 if( argcnt > 0 ) { // Skip it all if we have no args
1428 BasicType *sig_bt = NEW_RESOURCE_ARRAY( BasicType, argcnt );
1429 VMRegPair *parm_regs = NEW_RESOURCE_ARRAY( VMRegPair, argcnt );
1430 int i;
1431 for( i = 0; i < argcnt; i++ ) {
1432 sig_bt[i] = domain->field_at(i+TypeFunc::Parms+adj)->basic_type();
1433 }
1434 // V-call to pick proper calling convention
1435 call->calling_convention( sig_bt, parm_regs, argcnt );
1436
1437 #ifdef ASSERT
1438 // Sanity check users' calling convention. Really handy during
1439 // the initial porting effort. Fairly expensive otherwise.
1440 { for (int i = 0; i<argcnt; i++) {
1441 if( !parm_regs[i].first()->is_valid() &&
1442 !parm_regs[i].second()->is_valid() ) continue;
1443 VMReg reg1 = parm_regs[i].first();
1444 VMReg reg2 = parm_regs[i].second();
1445 for (int j = 0; j < i; j++) {
1446 if( !parm_regs[j].first()->is_valid() &&
1447 !parm_regs[j].second()->is_valid() ) continue;
1448 VMReg reg3 = parm_regs[j].first();
1449 VMReg reg4 = parm_regs[j].second();
1450 if( !reg1->is_valid() ) {
1451 assert( !reg2->is_valid(), "valid halvsies" );
1452 } else if( !reg3->is_valid() ) {
1453 assert( !reg4->is_valid(), "valid halvsies" );
1454 } else {
1455 assert( reg1 != reg2, "calling conv. must produce distinct regs");
1456 assert( reg1 != reg3, "calling conv. must produce distinct regs");
1457 assert( reg1 != reg4, "calling conv. must produce distinct regs");
1458 assert( reg2 != reg3, "calling conv. must produce distinct regs");
1459 assert( reg2 != reg4 || !reg2->is_valid(), "calling conv. must produce distinct regs");
1460 assert( reg3 != reg4, "calling conv. must produce distinct regs");
1461 }
1462 }
1463 }
1464 }
1465 #endif
1466
1467 // Visit each argument. Compute its outgoing register mask.
1468 // Return results now can have 2 bits returned.
1469 // Compute max over all outgoing arguments both per call-site
1470 // and over the entire method.
1471 for( i = 0; i < argcnt; i++ ) {
1472 // Address of incoming argument mask to fill in
1473 RegMask *rm = &mcall->_in_rms[i+TypeFunc::Parms+adj];
1474 VMReg first = parm_regs[i].first();
1475 VMReg second = parm_regs[i].second();
1476 if(!first->is_valid() &&
1477 !second->is_valid()) {
1478 continue; // Avoid Halves
1479 }
1480 // Handle case where arguments are in vector registers.
1481 if(call->in(TypeFunc::Parms + i)->bottom_type()->isa_vect()) {
1482 OptoReg::Name reg_fst = OptoReg::as_OptoReg(first);
1483 OptoReg::Name reg_snd = OptoReg::as_OptoReg(second);
1484 assert (reg_fst <= reg_snd, "fst=%d snd=%d", reg_fst, reg_snd);
1485 for (OptoReg::Name r = reg_fst; r <= reg_snd; r++) {
1486 rm->Insert(r);
1487 }
1488 }
1489 // Grab first register, adjust stack slots and insert in mask.
1490 OptoReg::Name reg1 = warp_outgoing_stk_arg(first, begin_out_arg_area, out_arg_limit_per_call );
1491 if (C->failing()) {
1492 return nullptr;
1493 }
1494 if (OptoReg::is_valid(reg1)) {
1495 rm->Insert( reg1 );
1496 }
1497 // Grab second register (if any), adjust stack slots and insert in mask.
1498 OptoReg::Name reg2 = warp_outgoing_stk_arg(second, begin_out_arg_area, out_arg_limit_per_call );
1499 if (C->failing()) {
1500 return nullptr;
1501 }
1502 if (OptoReg::is_valid(reg2)) {
1503 rm->Insert( reg2 );
1504 }
1505 } // End of for all arguments
1506 }
1507
1508 // Compute the max stack slot killed by any call. These will not be
1509 // available for debug info, and will be used to adjust FIRST_STACK_mask
1510 // after all call sites have been visited.
1511 if( _out_arg_limit < out_arg_limit_per_call)
1512 _out_arg_limit = out_arg_limit_per_call;
1513
1514 if (mcall) {
1515 // Kill the outgoing argument area, including any non-argument holes and
1516 // any legacy C-killed slots. Use Fat-Projections to do the killing.
1517 // Since the max-per-method covers the max-per-call-site and debug info
1518 // is excluded on the max-per-method basis, debug info cannot land in
1519 // this killed area.
1520 uint r_cnt = mcall->tf()->range_sig()->cnt();
1521 MachProjNode *proj = new MachProjNode( mcall, r_cnt+10000, RegMask::Empty, MachProjNode::fat_proj );
1522 if (!RegMask::can_represent_arg(OptoReg::Name(out_arg_limit_per_call-1))) {
1523 // Bailout. We do not have space to represent all arguments.
1524 C->record_method_not_compilable("unsupported outgoing calling sequence");
1525 } else {
1526 for (int i = begin_out_arg_area; i < out_arg_limit_per_call; i++)
1527 proj->_rout.Insert(OptoReg::Name(i));
1528 }
1529 if (proj->_rout.is_NotEmpty()) {
1530 push_projection(proj);
1531 }
1532 }
1533 // Transfer the safepoint information from the call to the mcall
1534 // Move the JVMState list
1535 msfpt->set_jvms(sfpt->jvms());
1536 for (JVMState* jvms = msfpt->jvms(); jvms; jvms = jvms->caller()) {
1537 jvms->set_map(sfpt);
1538 }
1539
1540 // Debug inputs begin just after the last incoming parameter
1541 assert((mcall == nullptr) || (mcall->jvms() == nullptr) ||
1542 (mcall->jvms()->debug_start() + mcall->_jvmadj == mcall->tf()->domain_cc()->cnt()), "");
1543
1544 // Add additional edges.
1545 if (msfpt->mach_constant_base_node_input() != (uint)-1 && !msfpt->is_MachCallLeaf()) {
1546 // For these calls we can not add MachConstantBase in expand(), as the
1547 // ins are not complete then.
1548 msfpt->ins_req(msfpt->mach_constant_base_node_input(), C->mach_constant_base_node());
1549 if (msfpt->jvms() &&
1550 msfpt->mach_constant_base_node_input() <= msfpt->jvms()->debug_start() + msfpt->_jvmadj) {
1551 // We added an edge before jvms, so we must adapt the position of the ins.
1552 msfpt->jvms()->adapt_position(+1);
1553 }
1554 }
1555
1556 // Registers killed by the call are set in the local scheduling pass
1557 // of Global Code Motion.
1558 return msfpt;
1559 }
1560
1561 //---------------------------match_tree----------------------------------------
1562 // Match a Ideal Node DAG - turn it into a tree; Label & Reduce. Used as part
2211 set_shared(n); // Flag as shared and
2212 if (n->is_DecodeNarrowPtr()) {
2213 // Oop field/array element loads must be shared but since
2214 // they are shared through a DecodeN they may appear to have
2215 // a single use so force sharing here.
2216 set_shared(n->in(1));
2217 }
2218 mstack.pop(); // remove node from stack
2219 continue;
2220 }
2221 nstate = Visit; // Not already visited; so visit now
2222 }
2223 if (nstate == Visit) {
2224 mstack.set_state(Post_Visit);
2225 set_visited(n); // Flag as visited now
2226 bool mem_op = false;
2227 int mem_addr_idx = MemNode::Address;
2228 if (find_shared_visit(mstack, n, nop, mem_op, mem_addr_idx)) {
2229 continue;
2230 }
2231 for (int i = n->len() - 1; i >= 0; --i) { // For my children
2232 Node* m = n->in(i); // Get ith input
2233 if (m == nullptr) {
2234 continue; // Ignore nulls
2235 }
2236 if (clone_node(n, m, mstack)) {
2237 continue;
2238 }
2239
2240 // Clone addressing expressions as they are "free" in memory access instructions
2241 if (mem_op && i == mem_addr_idx && m->is_AddP() &&
2242 // When there are other uses besides address expressions
2243 // put it on stack and mark as shared.
2244 !is_visited(m)) {
2245 // Some inputs for address expression are not put on stack
2246 // to avoid marking them as shared and forcing them into register
2247 // if they are used only in address expressions.
2248 // But they should be marked as shared if there are other uses
2249 // besides address expressions.
2250
2251 if (pd_clone_address_expressions(m->as_AddP(), mstack, address_visited)) {
2520 case Op_FmaF:
2521 case Op_FmaHF:
2522 case Op_FmaVD:
2523 case Op_FmaVF: {
2524 // Restructure into a binary tree for Matching.
2525 Node* pair = new BinaryNode(n->in(1), n->in(2));
2526 n->set_req(2, pair);
2527 n->set_req(1, n->in(3));
2528 n->del_req(3);
2529 break;
2530 }
2531 case Op_MulAddS2I: {
2532 Node* pair1 = new BinaryNode(n->in(1), n->in(2));
2533 Node* pair2 = new BinaryNode(n->in(3), n->in(4));
2534 n->set_req(1, pair1);
2535 n->set_req(2, pair2);
2536 n->del_req(4);
2537 n->del_req(3);
2538 break;
2539 }
2540 case Op_ClearArray: {
2541 Node* pair = new BinaryNode(n->in(2), n->in(3));
2542 n->set_req(2, pair);
2543 n->set_req(3, n->in(4));
2544 n->del_req(4);
2545 break;
2546 }
2547 case Op_VectorCmpMasked:
2548 case Op_CopySignD:
2549 case Op_SignumVF:
2550 case Op_SignumVD:
2551 case Op_SignumF:
2552 case Op_SignumD: {
2553 Node* pair = new BinaryNode(n->in(2), n->in(3));
2554 n->set_req(2, pair);
2555 n->del_req(3);
2556 break;
2557 }
2558 case Op_VectorBlend:
2559 case Op_VectorInsert: {
2560 Node* pair = new BinaryNode(n->in(1), n->in(2));
2561 n->set_req(1, pair);
2562 n->set_req(2, n->in(3));
2563 n->del_req(3);
2564 break;
2565 }
2566 case Op_LoadVectorGather:
2591 n->del_req(MemNode::ValueIn+2);
2592 pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn+1));
2593 n->set_req(MemNode::ValueIn, pair);
2594 n->del_req(MemNode::ValueIn+1);
2595 break;
2596 }
2597 case Op_VectorMaskCmp: {
2598 n->set_req(1, new BinaryNode(n->in(1), n->in(2)));
2599 n->set_req(2, n->in(3));
2600 n->del_req(3);
2601 break;
2602 }
2603 case Op_PartialSubtypeCheck: {
2604 if (UseSecondarySupersTable && n->in(2)->is_Con()) {
2605 // PartialSubtypeCheck uses both constant and register operands for superclass input.
2606 n->set_req(2, new BinaryNode(n->in(2), n->in(2)));
2607 break;
2608 }
2609 break;
2610 }
2611 case Op_StoreLSpecial: {
2612 if (n->req() > (MemNode::ValueIn + 1) && n->in(MemNode::ValueIn + 1) != nullptr) {
2613 Node* pair = new BinaryNode(n->in(MemNode::ValueIn), n->in(MemNode::ValueIn + 1));
2614 n->set_req(MemNode::ValueIn, pair);
2615 n->del_req(MemNode::ValueIn + 1);
2616 }
2617 break;
2618 }
2619 default:
2620 break;
2621 }
2622 }
2623
2624 #ifndef PRODUCT
2625 void Matcher::record_new2old(Node* newn, Node* old) {
2626 _new2old_map.map(newn->_idx, old);
2627 if (!_reused.test_set(old->_igv_idx)) {
2628 // Reuse the Ideal-level IGV identifier so that the node can be tracked
2629 // across matching. If there are multiple machine nodes expanded from the
2630 // same Ideal node, only one will reuse its IGV identifier.
2631 newn->_igv_idx = old->_igv_idx;
2632 }
2633 }
2634
2635 // machine-independent root to machine-dependent root
2636 void Matcher::dump_old2new_map() {
2637 _old2new_map.dump();
2638 }
|