Exemple #1
0
bool
SpillPlacement::placeSpills(const SmallVectorImpl<BlockConstraint> &LiveBlocks,
                            BitVector &RegBundles) {
  // Reuse RegBundles as our ActiveNodes vector.
  ActiveNodes = &RegBundles;
  ActiveNodes->clear();
  ActiveNodes->resize(bundles->getNumBundles());

  // Compute active nodes, links and biases.
  prepareNodes(LiveBlocks);

  // Update all active nodes, and find the ones that are actually linked to
  // something so their value may change when iterating.
  DEBUG(dbgs() << "Network has " << RegBundles.count() << " active nodes:\n");
  SmallVector<unsigned, 8> Linked;
  for (int n = RegBundles.find_first(); n>=0; n = RegBundles.find_next(n)) {
    nodes[n].update(nodes);
    // A node that must spill, or a node without any links is not going to
    // change its value ever again, so exclude it from iterations.
    if (!nodes[n].Links.empty() && !nodes[n].mustSpill())
      Linked.push_back(n);

    DEBUG({
      dbgs() << "  EB#" << n << format(" = %+2.0f", nodes[n].Value)
             << format(", Bias %+.2f", nodes[n].Bias)
             << format(", Freq %.1f/%.1f", nodes[n].Frequency[0],
                                           nodes[n].Frequency[1]);
      for (unsigned i = 0, e = nodes[n].Links.size(); i != e; ++i)
        dbgs() << format(", %.2f -> EB#%u", nodes[n].Links[i].first,
                                            nodes[n].Links[i].second);
      dbgs() << '\n';
    });
  }
Exemple #2
0
int main() {
  init_bit_vector(0);
  {for (unsigned i = 0; i < 1600; i++) {
    BitVector bv;
    bv.set_bit(i, true);
    BitVectorIter iter(&bv);
    if (!iter.is_valid()) {
      fprintf(stderr, "ERROR: %d\n", i);
      continue;
    }
    size_t val = iter.current();
    if (val != i) {
      fprintf(stderr, "ERROR: %d\n", i);
      continue;
    }
    if (bv.count() != 1) {
      fprintf(stderr, "ERROR: %d\n", i);
      continue;
    }
    iter.next();
    if (iter.is_valid()) {
      fprintf(stderr, "ERROR: %d\n", i);
      continue;
    }
  }}
  
  {for (unsigned i = 24; i < 160; i++) {
    BitVector bv;
    bv.set_bit(i, true);
    for (unsigned j = 32; j < 160; j++) {
      if (j > 0 && j != i+1) bv.set_bit(j-1, false);
      if (i == j) continue;
      bv.set_bit(j, true);
      BitVectorIter iter(&bv);
      if (!iter.is_valid()) {
	fprintf(stderr, "ERROR: %d %d\n", i, j);
	continue;
      }

      size_t val = iter.current();
      if (bv.count() != 2) {
	fprintf(stderr, "ERROR: %d %d\n", i, j);
	continue;
      }
      iter.next();
      size_t val2 = iter.current();
      if (!iter.is_valid()) {
	fprintf(stderr, "ERROR: %d %d\n", i, j);
	continue;
      }
      if (!((val == i && val2 == j) ||
	    (val == j && val2 == i))) {
	fprintf(stderr, "ERROR: %d %d\n", i, j);
	continue;
      }
      iter.next();
      if (iter.is_valid()) {
	fprintf(stderr, "ERROR: %d %d\n", i, j);
	continue;
      }
    }
  }}


  return(0);
}