1167 |
1167 |
1168 // Put the simplified guy on the simplified list. |
1168 // Put the simplified guy on the simplified list. |
1169 lrgs(lo)._next = _simplified; |
1169 lrgs(lo)._next = _simplified; |
1170 _simplified = lo; |
1170 _simplified = lo; |
1171 // If this guy is "at risk" then mark his current neighbors |
1171 // If this guy is "at risk" then mark his current neighbors |
1172 if( lrgs(lo)._at_risk ) { |
1172 if (lrgs(lo)._at_risk && !_ifg->neighbors(lo)->is_empty()) { |
1173 IndexSetIterator elements(_ifg->neighbors(lo)); |
1173 IndexSetIterator elements(_ifg->neighbors(lo)); |
1174 uint datum; |
1174 uint datum; |
1175 while ((datum = elements.next()) != 0) { |
1175 while ((datum = elements.next()) != 0) { |
1176 lrgs(datum)._risk_bias = lo; |
1176 lrgs(datum)._risk_bias = lo; |
1177 } |
1177 } |
1178 } |
1178 } |
1179 |
1179 |
1180 // Yank this guy from the IFG. |
1180 // Yank this guy from the IFG. |
1181 IndexSet *adj = _ifg->remove_node( lo ); |
1181 IndexSet *adj = _ifg->remove_node(lo); |
|
1182 if (adj->is_empty()) { |
|
1183 continue; |
|
1184 } |
1182 |
1185 |
1183 // If any neighbors' degrees fall below their number of |
1186 // If any neighbors' degrees fall below their number of |
1184 // allowed registers, then put that neighbor on the low degree |
1187 // allowed registers, then put that neighbor on the low degree |
1185 // list. Note that 'degree' can only fall and 'numregs' is |
1188 // list. Note that 'degree' can only fall and 'numregs' is |
1186 // unchanged by this action. Thus the two are equal at most once, |
1189 // unchanged by this action. Thus the two are equal at most once, |
1200 if (n->just_lo_degree() && !n->_must_spill) { |
1203 if (n->just_lo_degree() && !n->_must_spill) { |
1201 assert(!_ifg->_yanked->test(neighbor), "Cannot move to lo degree twice"); |
1204 assert(!_ifg->_yanked->test(neighbor), "Cannot move to lo degree twice"); |
1202 // Pull from hi-degree list |
1205 // Pull from hi-degree list |
1203 uint prev = n->_prev; |
1206 uint prev = n->_prev; |
1204 uint next = n->_next; |
1207 uint next = n->_next; |
1205 if (prev) lrgs(prev)._next = next; |
1208 if (prev) { |
1206 else _hi_degree = next; |
1209 lrgs(prev)._next = next; |
|
1210 } else { |
|
1211 _hi_degree = next; |
|
1212 } |
1207 lrgs(next)._prev = prev; |
1213 lrgs(next)._prev = prev; |
1208 n->_next = _lo_degree; |
1214 n->_next = _lo_degree; |
1209 _lo_degree = neighbor; |
1215 _lo_degree = neighbor; |
1210 } |
1216 } |
1211 } |
1217 } |
1312 // Choose a color using the biasing heuristic |
1318 // Choose a color using the biasing heuristic |
1313 OptoReg::Name PhaseChaitin::bias_color( LRG &lrg, int chunk ) { |
1319 OptoReg::Name PhaseChaitin::bias_color( LRG &lrg, int chunk ) { |
1314 |
1320 |
1315 // Check for "at_risk" LRG's |
1321 // Check for "at_risk" LRG's |
1316 uint risk_lrg = _lrg_map.find(lrg._risk_bias); |
1322 uint risk_lrg = _lrg_map.find(lrg._risk_bias); |
1317 if( risk_lrg != 0 ) { |
1323 if (risk_lrg != 0 && !_ifg->neighbors(risk_lrg)->is_empty()) { |
1318 // Walk the colored neighbors of the "at_risk" candidate |
1324 // Walk the colored neighbors of the "at_risk" candidate |
1319 // Choose a color which is both legal and already taken by a neighbor |
1325 // Choose a color which is both legal and already taken by a neighbor |
1320 // of the "at_risk" candidate in order to improve the chances of the |
1326 // of the "at_risk" candidate in order to improve the chances of the |
1321 // "at_risk" candidate of coloring |
1327 // "at_risk" candidate of coloring |
1322 IndexSetIterator elements(_ifg->neighbors(risk_lrg)); |
1328 IndexSetIterator elements(_ifg->neighbors(risk_lrg)); |
1328 return reg; |
1334 return reg; |
1329 } |
1335 } |
1330 } |
1336 } |
1331 |
1337 |
1332 uint copy_lrg = _lrg_map.find(lrg._copy_bias); |
1338 uint copy_lrg = _lrg_map.find(lrg._copy_bias); |
1333 if( copy_lrg != 0 ) { |
1339 if (copy_lrg != 0) { |
1334 // If he has a color, |
1340 // If he has a color, |
1335 if(!_ifg->_yanked->test(copy_lrg)) { |
1341 if(!_ifg->_yanked->test(copy_lrg)) { |
1336 OptoReg::Name reg = lrgs(copy_lrg).reg(); |
1342 OptoReg::Name reg = lrgs(copy_lrg).reg(); |
1337 // And it is legal for you, |
1343 // And it is legal for you, |
1338 if (is_legal_reg(lrg, reg, chunk)) |
1344 if (is_legal_reg(lrg, reg, chunk)) |
1430 int chunk = 0; // Current chunk is first chunk |
1436 int chunk = 0; // Current chunk is first chunk |
1431 retry_next_chunk: |
1437 retry_next_chunk: |
1432 |
1438 |
1433 // Remove neighbor colors |
1439 // Remove neighbor colors |
1434 IndexSet *s = _ifg->neighbors(lidx); |
1440 IndexSet *s = _ifg->neighbors(lidx); |
1435 |
|
1436 debug_only(RegMask orig_mask = lrg->mask();) |
1441 debug_only(RegMask orig_mask = lrg->mask();) |
1437 IndexSetIterator elements(s); |
1442 |
1438 uint neighbor; |
1443 if (!s->is_empty()) { |
1439 while ((neighbor = elements.next()) != 0) { |
1444 IndexSetIterator elements(s); |
1440 // Note that neighbor might be a spill_reg. In this case, exclusion |
1445 uint neighbor; |
1441 // of its color will be a no-op, since the spill_reg chunk is in outer |
1446 while ((neighbor = elements.next()) != 0) { |
1442 // space. Also, if neighbor is in a different chunk, this exclusion |
1447 // Note that neighbor might be a spill_reg. In this case, exclusion |
1443 // will be a no-op. (Later on, if lrg runs out of possible colors in |
1448 // of its color will be a no-op, since the spill_reg chunk is in outer |
1444 // its chunk, a new chunk of color may be tried, in which case |
1449 // space. Also, if neighbor is in a different chunk, this exclusion |
1445 // examination of neighbors is started again, at retry_next_chunk.) |
1450 // will be a no-op. (Later on, if lrg runs out of possible colors in |
1446 LRG &nlrg = lrgs(neighbor); |
1451 // its chunk, a new chunk of color may be tried, in which case |
1447 OptoReg::Name nreg = nlrg.reg(); |
1452 // examination of neighbors is started again, at retry_next_chunk.) |
1448 // Only subtract masks in the same chunk |
1453 LRG &nlrg = lrgs(neighbor); |
1449 if( nreg >= chunk && nreg < chunk + RegMask::CHUNK_SIZE ) { |
1454 OptoReg::Name nreg = nlrg.reg(); |
|
1455 // Only subtract masks in the same chunk |
|
1456 if (nreg >= chunk && nreg < chunk + RegMask::CHUNK_SIZE) { |
1450 #ifndef PRODUCT |
1457 #ifndef PRODUCT |
1451 uint size = lrg->mask().Size(); |
1458 uint size = lrg->mask().Size(); |
1452 RegMask rm = lrg->mask(); |
1459 RegMask rm = lrg->mask(); |
1453 #endif |
1460 #endif |
1454 lrg->SUBTRACT(nlrg.mask()); |
1461 lrg->SUBTRACT(nlrg.mask()); |
1455 #ifndef PRODUCT |
1462 #ifndef PRODUCT |
1456 if (trace_spilling() && lrg->mask().Size() != size) { |
1463 if (trace_spilling() && lrg->mask().Size() != size) { |
1457 ttyLocker ttyl; |
1464 ttyLocker ttyl; |
1458 tty->print("L%d ", lidx); |
1465 tty->print("L%d ", lidx); |
1459 rm.dump(); |
1466 rm.dump(); |
1460 tty->print(" intersected L%d ", neighbor); |
1467 tty->print(" intersected L%d ", neighbor); |
1461 nlrg.mask().dump(); |
1468 nlrg.mask().dump(); |
1462 tty->print(" removed "); |
1469 tty->print(" removed "); |
1463 rm.SUBTRACT(lrg->mask()); |
1470 rm.SUBTRACT(lrg->mask()); |
1464 rm.dump(); |
1471 rm.dump(); |
1465 tty->print(" leaving "); |
1472 tty->print(" leaving "); |
1466 lrg->mask().dump(); |
1473 lrg->mask().dump(); |
1467 tty->cr(); |
1474 tty->cr(); |
1468 } |
1475 } |
1469 #endif |
1476 #endif |
|
1477 } |
1470 } |
1478 } |
1471 } |
1479 } |
1472 //assert(is_allstack == lrg->mask().is_AllStack(), "nbrs must not change AllStackedness"); |
1480 //assert(is_allstack == lrg->mask().is_AllStack(), "nbrs must not change AllStackedness"); |
1473 // Aligned pairs need aligned masks |
1481 // Aligned pairs need aligned masks |
1474 assert(!lrg->_is_vector || !lrg->_fat_proj, "sanity"); |
1482 assert(!lrg->_is_vector || !lrg->_fat_proj, "sanity"); |