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