本文整理汇总了C++中BlockList类的典型用法代码示例。如果您正苦于以下问题:C++ BlockList类的具体用法?C++ BlockList怎么用?C++ BlockList使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了BlockList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MergeReturnedValues
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void IndirectCallPromotion::MergeReturnedValues(BlockList& callBlocks,
Block* continuationBlock,
CallInstr* instr) {
// If the call returns 'void' or the result is not used
// there are no values to merge.
if(instr->IsVoid() || (instr->HasDestinationOp() == false)) {
return;
}
auto unit = callBlocks[0]->ParentFunction()->ParentUnit();
auto& references = unit->References();
// Create the 'phi' that merges the returned values.
auto phiResultOp = Temporary::GetTemporary(instr->ResultOp()->GetType());
auto phiInstr = PhiInstr::GetPhi(phiResultOp, callBlocks.Count());
continuationBlock->InsertInstructionFirst(phiInstr);
// Now add the incoming operands.
for(int i = 0; i < callBlocks.Count(); i++) {
auto beforeGoto = callBlocks[i]->LastInstruction()->PreviousInstruction();
auto callInstr = beforeGoto->As<CallInstr>();
DebugValidator::IsNotNull(callInstr);
DebugValidator::IsNotNull(callInstr->ResultOp());
auto blockRef = references.GetBlockRef(callBlocks[i]);
phiInstr->AddOperand(callInstr->ResultOp(), blockRef);
}
// The original returned value is replaced by the 'phi' result.
instr->ResultOp()->ReplaceWith(phiResultOp);
}
示例2: isRPOSorted
bool isRPOSorted(const BlockList& blocks) {
int id = 0;
for (auto it = blocks.rbegin(); it != blocks.rend(); ++it) {
if ((*it)->postId() != id++) return false;
}
return true;
}
示例3: numberInstructions
void LinearScan::allocRegsToTrace() {
ExitTraceMap etm;
numberInstructions(m_blocks);
if (HPHP::Trace::moduleEnabled(HPHP::Trace::hhir, 5)) {
std::stringstream s;
s << "RPO: ";
for (auto& b : m_blocks) {
s << folly::format("{}{} ",
b->isMain() ? "M" : "E",
b->id());
}
s << "\n";
HPHP::Trace::traceRelease("%s\n", s.str().c_str());
}
BlockList::iterator it = m_blocks.begin();
while (it != m_blocks.end()) {
allocRegsOneTrace(it, etm);
}
for (it = m_blocks.begin(); it != m_blocks.end();) {
if ((*it)->isMain()) {
++it;
continue;
}
allocRegsOneTrace(it, etm);
}
}
示例4: new
/* Acquire one blob from the pool.
*/
void* blob_pool::acquire() {
BlockList* blist;
if(! helper::get_blist(&blist, &_pool))
new (blist) BlockList(&_pool, BLOB_POOL_TEMPLATE_ARGS);
void* ptr = blist->acquire(BLOB_POOL_TEMPLATE_ARGS);
assert(_pool.validate_pointer(ptr));
return ptr;
}
示例5:
typename MemoryManager<AllocatorType>::BlockList::iterator MemoryManager<AllocatorType>::findBlock(BlockList& blockList, Byte* address, size_t index)
{
typename BlockList::iterator it{blockList.begin()};
const size_t blockSize{1UL << index};
// Loop while the address is not in the block pointed by it
while((address < *it or address >= *it + blockSize) and it != blockList.end())
++it;
return it;
}
示例6: initStates
//
// Compute the generate and kill sets for each basic block in the given
// function. The generate and kill functions are overriden by the subclass.
//
void DataFlowPass::initStates(const BlockList& blocks, BlockStates& states) {
for (BlockList::const_iterator FI = blocks.begin(), FE = blocks.end();
FI != FE; ++FI) {
const BasicBlock& block = *FI;
BlockState state;
initState(block, state);
states.insert(BlockStatePair(&block, state));
}
}
示例7: moveToNextPage
void Line::moveToNextPage(BlockList& floats, double minX, double maxX,
const WTextRenderer& renderer)
{
for (unsigned i = 0; i < blocks_.size(); ++i) {
Block *b = blocks_[i];
if (b->isFloat())
Utils::erase(floats, b);
}
PageState ps;
ps.floats = floats;
ps.page = page_;
Block::clearFloats(ps);
page_ = ps.page;
floats = ps.floats;
double oldY = y_;
y_ = 0;
x_ = minX;
++page_;
BlockList blocks = blocks_;
blocks_.clear();
Range rangeX(x_, maxX);
Block::adjustAvailableWidth(y_, page_, floats, rangeX);
x_ = rangeX.start;
maxX = rangeX.end;
for (unsigned i = 0; i < blocks.size(); ++i) {
Block *b = blocks[i];
if (b->isFloat()) {
b->layoutFloat(y_, page_, floats, x_, height_, minX, maxX,
false, renderer);
reflow(b);
} else {
for (unsigned j = 0; j < b->inlineLayout.size(); ++j) {
InlineBox& ib = b->inlineLayout[j];
if (ib.y == oldY && ib.page == page_ - 1) {
if (ib.x != LEFT_MARGIN_X) {
ib.x = x_;
x_ += ib.width;
}
ib.page = page_;
ib.y = y_;
}
}
}
blocks_.push_back(b);
}
}
示例8: write_bc_file
void write_bc_file(const BlockList &blockList, const std::string &file_name) {
FILE *fp = fopen(file_name.c_str(), "wb");
if (!fp) {
abort_("[write_bc_file] File %s cound not be opened for writing", file_name.c_str());
}
cout << "Writing " << file_name << " ..." << endl;
for (BlockList::const_iterator it=blockList.begin(); it!=blockList.end(); ++it) {
fwrite(&it->front(), 1, it->size(), fp);
}
fclose(fp);
}
示例9: display
//
// Called after the pass is complete.
// Show the results of the pass for each program point b/t blocks.
//
void DataFlowPass::display(const BlockList& blocks, BlockStates& states) {
for (BlockList::const_iterator I = blocks.begin(), IE = blocks.end();
I != IE; ++I) {
const BasicBlock* block = &(*I);
BlockState& state = states[block];
if (I == blocks.begin()) {
DataFlowUtil::print(state.in);
cout << endl;
}
block->dump();
DataFlowUtil::print(state.out);
cout << endl;
}
cout << endl;
}
示例10: collectInfo
void LinearScan::collectInfo(BlockList::iterator it, IRTrace* trace) {
m_natives.clear();
m_uses.reset(); // TODO(#2536764): serious time sink
while (it != m_blocks.end()) {
Block* block = *it++;
bool offTrace = block->trace() != trace;
if (offTrace) {
if (!trace->isMain()) return;
int lastId = block->trace()->data();
for (IRInstruction& inst : *block) {
for (auto* src : inst.srcs()) {
if (lastId > m_uses[src].lastUse) {
m_uses[src].lastUse = lastId;
}
}
}
} else {
for (IRInstruction& inst : *block) {
for (auto* src : inst.srcs()) {
m_uses[src].lastUse = m_linear[inst];
}
if (inst.isNative()) m_natives.push_back(&inst);
}
IRInstruction* jmp = block->back();
if (jmp->op() == Jmp_ && jmp->numSrcs() != 0) {
for (SSATmp* src : jmp->srcs()) {
m_jmps[src].push_back(jmp);
}
}
}
}
}
示例11: runOnBlocks
//
// Generic helper functions for arbitrary sets of blocks
//
BlockStates DataFlowPass::runOnBlocks(const BlockList& blocks) {
BlockStates states;
// First pass: precompute generate and kill sets.
initStates(blocks, states);
// iterate for a forwards pass
if (_direction == FORWARDS) {
const BasicBlock* start = &(blocks.front());
traverseForwards(start, states);
}
// iterate for a backwards pass
else if (_direction == BACKWARDS) {
const BasicBlock* start = &(blocks.back());
traverseBackwards(start, states);
}
// return copy of states
return states;
}
示例12: findDominators
/*
* Find the immediate dominator of each block using Cooper, Harvey, and
* Kennedy's "A Simple, Fast Dominance Algorithm", returned as a vector
* of postorder ids, indexed by postorder id.
*/
IdomVector findDominators(const BlockList& blocks) {
assert(isRPOSorted(blocks));
// Calculate immediate dominators with the iterative two-finger algorithm.
// When it terminates, idom[post-id] will contain the post-id of the
// immediate dominator of each block. idom[start] will be -1. This is
// the general algorithm but it will only loop twice for loop-free graphs.
auto const num_blocks = blocks.size();
IdomVector idom(num_blocks, -1);
auto start = blocks.begin();
int start_id = (*start)->postId();
idom[start_id] = start_id;
start++;
for (bool changed = true; changed; ) {
changed = false;
// for each block after start, in reverse postorder
for (auto it = start; it != blocks.end(); it++) {
Block* block = *it;
int b = block->postId();
// new_idom = any already-processed predecessor
auto edge_it = block->preds().begin();
int new_idom = edge_it->from()->postId();
while (idom[new_idom] == -1) new_idom = (++edge_it)->from()->postId();
// for all other already-processed predecessors p of b
for (auto& edge : block->preds()) {
auto p = edge.from()->postId();
if (p != new_idom && idom[p] != -1) {
// find earliest common predecessor of p and new_idom
// (higher postIds are earlier in flow and in dom-tree).
int b1 = p, b2 = new_idom;
do {
while (b1 < b2) b1 = idom[b1];
while (b2 < b1) b2 = idom[b2];
} while (b1 != b2);
new_idom = b1;
}
}
if (idom[b] != new_idom) {
idom[b] = new_idom;
changed = true;
}
}
}
idom[start_id] = -1; // start has no idom.
return idom;
}
示例13: findDomChildren
DomChildren findDomChildren(const BlockList& blocks) {
IdomVector idom = findDominators(blocks);
DomChildren children(blocks.size(), BlockList());
for (Block* block : blocks) {
int idom_id = idom[block->postId()];
if (idom_id != -1) children[idom_id].push_back(block);
}
return children;
}
示例14: leave_scope
/*removes the temp blocks in the current scope, then delete the scope's TempBlockStack */
void BlockManager::leave_scope() {
BlockList* temps = temp_block_list_stack_.back();
BlockList::iterator it;
for (it = temps->begin(); it != temps->end(); ++it) {
BlockId &block_id = *it;
int array_id = block_id.array_id();
// Cached delete for distributed/served arrays.
// Regular delete for temp blocks.
if (sip_tables_.is_distributed(array_id) || sip_tables_.is_served(array_id))
cached_delete_block(*it);
else
delete_block(*it);
// delete_block(*it);
}
temp_block_list_stack_.pop_back();
delete temps;
}
示例15: reflowTypes
void reflowTypes(Block* const changed, const BlockList& blocks) {
assert(isRPOSorted(blocks));
auto it = rpoIteratorTo(blocks, changed);
assert(it != blocks.end());
for (; it != blocks.end(); ++it) {
FTRACE(5, "reflowTypes: visiting block {}\n", (*it)->id());
for (auto& inst : **it) visitInstruction(&inst);
}
}