Lower llvm.isunordered(a, b) into a != a | b != b.
[oota-llvm.git] / lib / CodeGen / RegAllocIterativeScan.cpp
index 4cdcc1d4dd221da849f71dd4e0947cbb5510cc29..0ebef5ef643a968dbfb97407c759c59806b73190 100644 (file)
@@ -51,6 +51,7 @@ namespace {
     const TargetMachine* tm_;
     const MRegisterInfo* mri_;
     LiveIntervals* li_;
+    bool *PhysRegsUsed;
     typedef std::vector<LiveInterval*> IntervalPtrs;
     IntervalPtrs unhandled_, fixed_, active_, inactive_, handled_, spilled_;
 
@@ -145,6 +146,11 @@ bool RA::runOnMachineFunction(MachineFunction &fn) {
   tm_ = &fn.getTarget();
   mri_ = tm_->getRegisterInfo();
   li_ = &getAnalysis<LiveIntervals>();
+
+  PhysRegsUsed = new bool[mri_->getNumRegs()];
+  std::fill(PhysRegsUsed, PhysRegsUsed+mri_->getNumRegs(), false);
+  fn.setUsedPhysRegs(PhysRegsUsed);
+
   if (!prt_.get()) prt_.reset(new PhysRegTracker(*mri_));
   vrm_.reset(new VirtRegMap(*mf_));
   if (!spiller_.get()) spiller_.reset(createSpiller());
@@ -256,8 +262,10 @@ void RA::initIntervalSets() {
 
   for (LiveIntervals::iterator i = li_->begin(), e = li_->end(); i != e; ++i){
     unhandled_.push_back(&i->second);
-    if (MRegisterInfo::isPhysicalRegister(i->second.reg))
+    if (MRegisterInfo::isPhysicalRegister(i->second.reg)) {
+      PhysRegsUsed[i->second.reg] = true;
       fixed_.push_back(&i->second);
+    }
   }
 }
 
@@ -270,7 +278,7 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur)
     unsigned reg = i->reg;
 
     // remove expired intervals
-    if (i->expiredAt(cur->start())) {
+    if (i->expiredAt(cur->beginNumber())) {
       DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
       if (MRegisterInfo::isVirtualRegister(reg))
         reg = vrm_->getPhys(reg);
@@ -279,7 +287,7 @@ void RA::processActiveIntervals(IntervalPtrs::value_type cur)
       std::iter_swap(ii, --ie);
     }
     // move inactive intervals to inactive list
-    else if (!i->liveAt(cur->start())) {
+    else if (!i->liveAt(cur->beginNumber())) {
       DEBUG(std::cerr << "\t\tinterval " << *i << " inactive\n");
       if (MRegisterInfo::isVirtualRegister(reg))
         reg = vrm_->getPhys(reg);
@@ -305,13 +313,13 @@ void RA::processInactiveIntervals(IntervalPtrs::value_type cur)
     unsigned reg = i->reg;
 
     // remove expired intervals
-    if (i->expiredAt(cur->start())) {
+    if (i->expiredAt(cur->beginNumber())) {
       DEBUG(std::cerr << "\t\tinterval " << *i << " expired\n");
       // swap with last element and move end iterator back one position
       std::iter_swap(ii, --ie);
     }
     // move re-activated intervals in active list
-    else if (i->liveAt(cur->start())) {
+    else if (i->liveAt(cur->beginNumber())) {
       DEBUG(std::cerr << "\t\tinterval " << *i << " active\n");
       if (MRegisterInfo::isVirtualRegister(reg))
         reg = vrm_->getPhys(reg);
@@ -394,11 +402,11 @@ void RA::assignRegOrSpillAtInterval(IntervalPtrs::value_type cur)
 
   DEBUG(std::cerr << "\tassigning stack slot at interval "<< *cur << ":\n");
 
-  float minWeight = HUGE_VAL;
+  float minWeight = (float)HUGE_VAL;
   unsigned minReg = 0;
   const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg);
-  for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_);
-       i != rc->allocation_order_end(*mf_); ++i) {
+  for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_),
+       e = rc->allocation_order_end(*mf_); i != e; ++i) {
     unsigned reg = *i;
     if (minWeight > spillWeights_[reg]) {
       minWeight = spillWeights_[reg];
@@ -424,7 +432,7 @@ void RA::assignRegOrSpillAtInterval(IntervalPtrs::value_type cur)
   toSpill[minReg] = true;
   for (const unsigned* as = mri_->getAliasSet(minReg); *as; ++as)
     toSpill[*as] = true;
-  unsigned earliestStart = cur->start();
+  unsigned earliestStart = cur->beginNumber();
 
   std::set<unsigned> spilled;
 
@@ -477,8 +485,8 @@ unsigned RA::getFreePhysReg(LiveInterval* cur)
   const TargetRegisterClass* rc = mf_->getSSARegMap()->getRegClass(cur->reg);
 
   unsigned freeReg = 0;
-  for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_);
-       i != rc->allocation_order_end(*mf_); ++i) {
+  for (TargetRegisterClass::iterator i = rc->allocation_order_begin(*mf_),
+       e = rc->allocation_order_end(*mf_); i != e; ++i) {
     unsigned reg = *i;
     if (prt_->isRegAvail(reg) &&
         (!freeReg || inactiveCounts[freeReg] < inactiveCounts[reg]))