1348 if( i < m->req() ) 1349 m->ins_req( i, n->in(i) ); 1350 else 1351 m->add_req( n->in(i) ); 1352 } 1353 } 1354 1355 debug_only( _mem_node = save_mem_node; ) 1356 return m; 1357 } 1358 1359 1360 //------------------------------match_into_reg--------------------------------- 1361 // Choose to either match this Node in a register or part of the current 1362 // match tree. Return true for requiring a register and false for matching 1363 // as part of the current match tree. 1364 static bool match_into_reg( const Node *n, Node *m, Node *control, int i, bool shared ) { 1365 1366 const Type *t = m->bottom_type(); 1367 1368 if( t->singleton() ) { 1369 // Never force constants into registers. Allow them to match as 1370 // constants or registers. Copies of the same value will share 1371 // the same register. See find_shared_node. 1372 return false; 1373 } else { // Not a constant 1374 // Stop recursion if they have different Controls. 1375 // Slot 0 of constants is not really a Control. 1376 if( control && m->in(0) && control != m->in(0) ) { 1377 1378 // Actually, we can live with the most conservative control we 1379 // find, if it post-dominates the others. This allows us to 1380 // pick up load/op/store trees where the load can float a little 1381 // above the store. 1382 Node *x = control; 1383 const uint max_scan = 6; // Arbitrary scan cutoff 1384 uint j; 1385 for( j=0; j<max_scan; j++ ) { 1386 if( x->is_Region() ) // Bail out at merge points 1387 return true; 1388 x = x->in(0); 1389 if( x == m->in(0) ) // Does 'control' post-dominate 1390 break; // m->in(0)? If so, we can use it 1391 } 1392 if( j == max_scan ) // No post-domination before scan end? 1393 return true; // Then break the match tree up 1394 } 1395 if (m->is_DecodeN() && Matcher::narrow_oop_use_complex_address()) { 1396 // These are commonly used in address expressions and can 1397 // efficiently fold into them on X64 in some cases. 1398 return false; 1399 } 1400 } 1401 1402 // Not forceable cloning. If shared, put it into a register. 1403 return shared; 1404 } 1405 1406 1407 //------------------------------Instruction Selection-------------------------- 1408 // Label method walks a "tree" of nodes, using the ADLC generated DFA to match 1409 // ideal nodes to machine instructions. Trees are delimited by shared Nodes, 1410 // things the Matcher does not match (e.g., Memory), and things with different 1411 // Controls (hence forced into different blocks). We pass in the Control 1412 // selected for this entire State tree. | 1348 if( i < m->req() ) 1349 m->ins_req( i, n->in(i) ); 1350 else 1351 m->add_req( n->in(i) ); 1352 } 1353 } 1354 1355 debug_only( _mem_node = save_mem_node; ) 1356 return m; 1357 } 1358 1359 1360 //------------------------------match_into_reg--------------------------------- 1361 // Choose to either match this Node in a register or part of the current 1362 // match tree. Return true for requiring a register and false for matching 1363 // as part of the current match tree. 1364 static bool match_into_reg( const Node *n, Node *m, Node *control, int i, bool shared ) { 1365 1366 const Type *t = m->bottom_type(); 1367 1368 if (t->singleton()) { 1369 // Never force constants into registers. Allow them to match as 1370 // constants or registers. Copies of the same value will share 1371 // the same register. See find_shared_node. 1372 return false; 1373 } else { // Not a constant 1374 // Stop recursion if they have different Controls. 1375 Node* m_control = m->in(0); 1376 // Control of load's memory can post-dominates load's control. 1377 // So use it since load can't float above its memory. 1378 Node* mem_control = (m->is_Load()) ? m->in(MemNode::Memory)->in(0) : NULL; 1379 if (control && m_control && control != m_control && control != mem_control) { 1380 1381 // Actually, we can live with the most conservative control we 1382 // find, if it post-dominates the others. This allows us to 1383 // pick up load/op/store trees where the load can float a little 1384 // above the store. 1385 Node *x = control; 1386 const uint max_scan = 6; // Arbitrary scan cutoff 1387 uint j; 1388 for (j=0; j<max_scan; j++) { 1389 if (x->is_Region()) // Bail out at merge points 1390 return true; 1391 x = x->in(0); 1392 if (x == m_control) // Does 'control' post-dominate 1393 break; // m->in(0)? If so, we can use it 1394 if (x == mem_control) // Does 'control' post-dominate 1395 break; // mem_control? If so, we can use it 1396 } 1397 if (j == max_scan) // No post-domination before scan end? 1398 return true; // Then break the match tree up 1399 } 1400 if (m->is_DecodeN() && Matcher::narrow_oop_use_complex_address()) { 1401 // These are commonly used in address expressions and can 1402 // efficiently fold into them on X64 in some cases. 1403 return false; 1404 } 1405 } 1406 1407 // Not forceable cloning. If shared, put it into a register. 1408 return shared; 1409 } 1410 1411 1412 //------------------------------Instruction Selection-------------------------- 1413 // Label method walks a "tree" of nodes, using the ADLC generated DFA to match 1414 // ideal nodes to machine instructions. Trees are delimited by shared Nodes, 1415 // things the Matcher does not match (e.g., Memory), and things with different 1416 // Controls (hence forced into different blocks). We pass in the Control 1417 // selected for this entire State tree. |