499 |
499 |
500 // Build the interference graph using virtual registers only. |
500 // Build the interference graph using virtual registers only. |
501 // Used for aggressive coalescing. |
501 // Used for aggressive coalescing. |
502 void build_ifg_virtual( ); |
502 void build_ifg_virtual( ); |
503 |
503 |
|
504 // used when computing the register pressure for each block in the CFG. This |
|
505 // is done during IFG creation. |
504 class Pressure { |
506 class Pressure { |
505 public: |
|
506 // keeps track of the register pressure at the current |
507 // keeps track of the register pressure at the current |
507 // instruction (used when stepping backwards in the block) |
508 // instruction (used when stepping backwards in the block) |
508 uint _current_pressure; |
509 uint _current_pressure; |
509 |
510 |
510 // keeps track of the instruction index of the first low to high register pressure |
511 // keeps track of the instruction index of the first low to high register pressure |
516 // stores the highest pressure we find |
517 // stores the highest pressure we find |
517 uint _final_pressure; |
518 uint _final_pressure; |
518 |
519 |
519 // number of live ranges that constitute high register pressure |
520 // number of live ranges that constitute high register pressure |
520 const uint _high_pressure_limit; |
521 const uint _high_pressure_limit; |
|
522 public: |
521 |
523 |
522 // lower the register pressure and look for a low to high pressure |
524 // lower the register pressure and look for a low to high pressure |
523 // transition |
525 // transition |
524 void lower(LRG& lrg, uint& location) { |
526 void lower(LRG& lrg, uint& location) { |
525 _current_pressure -= lrg.reg_pressure(); |
527 _current_pressure -= lrg.reg_pressure(); |
526 if (_current_pressure == _high_pressure_limit) { |
528 if (_current_pressure == _high_pressure_limit) { |
527 _high_pressure_index = location; |
529 _high_pressure_index = location; |
528 if (_current_pressure > _final_pressure) { |
|
529 _final_pressure = _current_pressure + 1; |
|
530 } |
|
531 } |
530 } |
532 } |
531 } |
533 |
532 |
534 // raise the pressure and store the pressure if it's the biggest |
533 // raise the pressure and store the pressure if it's the biggest |
535 // pressure so far |
534 // pressure so far |
536 void raise(LRG &lrg) { |
535 void raise(LRG &lrg) { |
537 _current_pressure += lrg.reg_pressure(); |
536 _current_pressure += lrg.reg_pressure(); |
538 if (_current_pressure > _final_pressure) { |
537 if (_current_pressure > _final_pressure) { |
539 _final_pressure = _current_pressure; |
538 _final_pressure = _current_pressure; |
|
539 } |
|
540 } |
|
541 |
|
542 uint high_pressure_index() const { |
|
543 return _high_pressure_index; |
|
544 } |
|
545 |
|
546 uint final_pressure() const { |
|
547 return _final_pressure; |
|
548 } |
|
549 |
|
550 uint current_pressure() const { |
|
551 return _current_pressure; |
|
552 } |
|
553 |
|
554 uint high_pressure_limit() const { |
|
555 return _high_pressure_limit; |
|
556 } |
|
557 |
|
558 void lower_high_pressure_index() { |
|
559 _high_pressure_index--; |
|
560 } |
|
561 |
|
562 void set_high_pressure_index_to_block_start() { |
|
563 _high_pressure_index = 0; |
|
564 } |
|
565 |
|
566 void check_pressure_at_fatproj(uint fatproj_location, RegMask& fatproj_mask) { |
|
567 // this pressure is only valid at this instruction, i.e. we don't need to lower |
|
568 // the register pressure since the fat proj was never live before (going backwards) |
|
569 uint new_pressure = current_pressure() + fatproj_mask.Size(); |
|
570 if (new_pressure > final_pressure()) { |
|
571 _final_pressure = new_pressure; |
|
572 } |
|
573 |
|
574 // if we were at a low pressure and now and the fat proj is at high pressure, record the fat proj location |
|
575 // as coming from a low to high (to low again) |
|
576 if (current_pressure() <= high_pressure_limit() && new_pressure > high_pressure_limit()) { |
|
577 _high_pressure_index = fatproj_location; |
540 } |
578 } |
541 } |
579 } |
542 |
580 |
543 Pressure(uint high_pressure_index, uint high_pressure_limit) |
581 Pressure(uint high_pressure_index, uint high_pressure_limit) |
544 : _current_pressure(0) |
582 : _current_pressure(0) |