bool RegisterAllocator::init() { if (!insData.init(mir, graph.numInstructions())) return false; if (!entryPositions.reserve(graph.numBlocks()) || !exitPositions.reserve(graph.numBlocks())) return false; for (size_t i = 0; i < graph.numBlocks(); i++) { LBlock* block = graph.getBlock(i); for (LInstructionIterator ins = block->begin(); ins != block->end(); ins++) insData[ins->id()] = *ins; for (size_t j = 0; j < block->numPhis(); j++) { LPhi* phi = block->getPhi(j); insData[phi->id()] = phi; } CodePosition entry = block->numPhis() != 0 ? CodePosition(block->getPhi(0)->id(), CodePosition::INPUT) : inputOf(block->firstInstructionWithId()); CodePosition exit = outputOf(block->lastInstructionWithId()); MOZ_ASSERT(block->mir()->id() == i); entryPositions.infallibleAppend(entry); exitPositions.infallibleAppend(exit); } return true; }
bool LiveRangeAllocator<VREG>::init() { if (!RegisterAllocator::init()) return false; liveIn = lir->mir()->allocate<BitSet*>(graph.numBlockIds()); if (!liveIn) return false; // Initialize fixed intervals. for (size_t i = 0; i < AnyRegister::Total; i++) { AnyRegister reg = AnyRegister::FromCode(i); LiveInterval *interval = new LiveInterval(0); interval->setAllocation(LAllocation(reg)); fixedIntervals[i] = interval; } fixedIntervalsUnion = new LiveInterval(0); if (!vregs.init(lir->mir(), graph.numVirtualRegisters())) return false; // Build virtual register objects for (size_t i = 0; i < graph.numBlocks(); i++) { if (mir->shouldCancel("LSRA create data structures (main loop)")) return false; LBlock *block = graph.getBlock(i); for (LInstructionIterator ins = block->begin(); ins != block->end(); ins++) { for (size_t j = 0; j < ins->numDefs(); j++) { LDefinition *def = ins->getDef(j); if (def->policy() != LDefinition::PASSTHROUGH) { uint32_t reg = def->virtualRegister(); if (!vregs[reg].init(reg, block, *ins, def, /* isTemp */ false)) return false; } } for (size_t j = 0; j < ins->numTemps(); j++) { LDefinition *def = ins->getTemp(j); if (def->isBogusTemp()) continue; if (!vregs[def].init(def->virtualRegister(), block, *ins, def, /* isTemp */ true)) return false; } } for (size_t j = 0; j < block->numPhis(); j++) { LPhi *phi = block->getPhi(j); LDefinition *def = phi->getDef(0); if (!vregs[def].init(phi->id(), block, phi, def, /* isTemp */ false)) return false; } } return true; }
bool RegisterAllocator::init() { if (!insData.init(mir, graph.numInstructions())) return false; for (size_t i = 0; i < graph.numBlocks(); i++) { LBlock* block = graph.getBlock(i); for (LInstructionIterator ins = block->begin(); ins != block->end(); ins++) insData[ins->id()] = *ins; for (size_t j = 0; j < block->numPhis(); j++) { LPhi* phi = block->getPhi(j); insData[phi->id()] = phi; } } return true; }