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