本文整理汇总了C++中RegionNode类的典型用法代码示例。如果您正苦于以下问题:C++ RegionNode类的具体用法?C++ RegionNode怎么用?C++ RegionNode使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RegionNode类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: new
//------------------------------expand_unlock_node----------------------
void PhaseMacroExpand::expand_unlock_node(UnlockNode*lock) {
if( !InlineFastPathLocking ) return;
// If inlining the fast-path locking code, do it now. Inserts a
// diamond control-flow, with the call on the slow-path. Fencing is
// included in the both the FastLock test (on success) and the
// slow-path call. Memory Phi's are inserted at the diamond merge to
// prevent hoisting mem ops into the fast-path side (where they might
// bypass the FastUnlock because it does not carry memory edges).
Node*ctl=lock->in(TypeFunc::Control);
Node*obj=lock->in(TypeFunc::Parms+0);
Node *flock = new (C, 2) FastUnlockNode( ctl, obj );
RegionNode *region = new (C, 3) RegionNode(3);
transform_later(region);
Node*slow_path=opt_iff(region,flock);
// Make the merge point
PhiNode*memphi=new(C,3)PhiNode(region,Type::MEMORY,TypePtr::BOTTOM);
transform_later(memphi);
Node *mem = lock->in(TypeFunc::Memory);
memphi->init_req(2,mem); // Plug in the fast-path
Node*lock_ctl=lock->proj_out(TypeFunc::Control);
Node*lock_mem=lock->proj_out(TypeFunc::Memory);
_igvn.hash_delete(lock_ctl);
_igvn.hash_delete(lock_mem);
_igvn.subsume_node_keep_old(lock_ctl,region);
_igvn.subsume_node_keep_old(lock_mem,memphi);
// Plug in the slow-path
region->init_req(1,lock_ctl);
memphi->init_req(1,lock_mem);
lock->set_req(TypeFunc::Control,slow_path);
}
示例2: padExitBlocks
void JSEdgeRemovalPass::padExitBlocks(RegionInfo& ri, Region* target) {
for(Region::element_iterator i = target->element_begin(), e = target->element_end(); i != e; ++i) {
RegionNode* rn = (RegionNode*)(*i);
if(rn->isSubRegion()) {
Region* subRegion = rn->getNodeAs<Region>();
padExitBlocks(ri, subRegion);
}
}
BasicBlock* exit = target->getExit();
if(exit != NULL) {
//we need to split the block into two parts to give padding space
//Keep the phi nodes and landing pad instructions in the original
//block and push all instructions into the new block below. That
//way we have convergence yet space to move elements up onto a
//given path if it turns out that the given instruction can't
//32 is a good number
unsigned count = 0;
SmallVector<BasicBlock*,32> elements;
for(pred_iterator PI = pred_begin(exit), E = pred_end(exit); PI != E; ++PI) {
BasicBlock* bb = *PI;
if(target->contains(bb)) {
elements.push_back(bb);
}
count++;
}
if(elements.size() > 0 && count != elements.size()) {
BasicBlock* update = SplitBlockPredecessors(exit, elements, "Pad", this);
target->replaceExit(update);
}
//ri.splitBlock(update, exit);
}
}
示例3: wireFlow
/// Take one node from the order vector and wire it up
void StructurizeCFG::wireFlow(bool ExitUseAllowed,
BasicBlock *LoopEnd) {
RegionNode *Node = Order.pop_back_val();
Visited.insert(Node->getEntry());
if (isPredictableTrue(Node)) {
// Just a linear flow
if (PrevNode) {
changeExit(PrevNode, Node->getEntry(), true);
}
PrevNode = Node;
} else {
// Insert extra prefix node (or reuse last one)
BasicBlock *Flow = needPrefix(false);
// Insert extra postfix node (or use exit instead)
BasicBlock *Entry = Node->getEntry();
BasicBlock *Next = needPostfix(Flow, ExitUseAllowed);
// let it point to entry and next block
Conditions.push_back(BranchInst::Create(Entry, Next, BoolUndef, Flow));
addPhiValues(Flow, Entry);
DT->changeImmediateDominator(Entry, Flow);
PrevNode = Node;
while (!Order.empty() && !Visited.count(LoopEnd) &&
dominatesPredicates(Entry, Order.back())) {
handleLoops(false, LoopEnd);
}
changeExit(PrevNode, Next, false);
setPrevNode(Next);
}
}
示例4: getEdgeAttributes
std::string getEdgeAttributes(RegionNode *srcNode,
GraphTraits<RegionInfo *>::ChildIteratorType CI,
RegionInfo *G) {
RegionNode *destNode = *CI;
if (srcNode->isSubRegion() || destNode->isSubRegion())
return "";
// In case of a backedge, do not use it to define the layout of the nodes.
BasicBlock *srcBB = srcNode->getNodeAs<BasicBlock>();
BasicBlock *destBB = destNode->getNodeAs<BasicBlock>();
Region *R = G->getRegionFor(destBB);
while (R && R->getParent())
if (R->getParent()->getEntry() == destBB)
R = R->getParent();
else
break;
if (R && R->getEntry() == destBB && R->contains(srcBB))
return "constraint=false";
return "";
}
示例5: getDataSize
std::size_t global_reg_t::getDataSize() const {
RegionNode *n = key->getRegionNode( id );
std::size_t dataSize = 1;
for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
std::size_t accessedLength = n->getValue();
n = n->getParent();
n = n->getParent();
dataSize *= accessedLength;
}
return dataSize;
}
示例6: fillDimensionData
void global_reg_t::fillDimensionData( nanos_region_dimension_internal_t *region) const {
RegionNode *n = key->getRegionNode( id );
std::vector< std::size_t > const &sizes = key->getDimensionSizes();
for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
std::size_t accessedLength = n->getValue();
n = n->getParent();
std::size_t lowerBound = n->getValue();
n = n->getParent();
region[ dimIdx ].accessed_length = accessedLength;
region[ dimIdx ].lower_bound = lowerBound;
region[ dimIdx ].size = sizes[ dimIdx ];
}
}
示例7: getSlabRegionId
reg_t global_reg_t::getSlabRegionId( std::size_t slabSize ) const {
RegionNode *n = key->getRegionNode( id );
std::vector< std::size_t > const &sizes = key->getDimensionSizes();
std::size_t acc_size = 1;
nanos_region_dimension_internal_t fitDimensions[ key->getNumDimensions() ];
if ( slabSize < this->getBreadth() ) {
fatal("Can not allocate slab for this region. Not supported yet. slabSize "<< slabSize << " breadth " << this->getBreadth());
} else if ( this->getBreadth() < slabSize && id == 1 ) {
return id;
} else {
unsigned int lower_bounds[key->getNumDimensions()];
for ( int idx = key->getNumDimensions() - 1; idx >= 0; idx -= 1 ) {
//std::size_t accessedLength = n->getValue();
n = n->getParent();
std::size_t lowerBound = n->getValue();
n = n->getParent();
lower_bounds[idx] = lowerBound;
}
bool keep_expanding = true;
for ( unsigned int idx = 0; idx < key->getNumDimensions(); idx += 1 ) {
fitDimensions[ idx ].size = sizes[ idx ];
//std::cerr << "This dimension size " << sizes[ idx ] << std::endl;
if ( keep_expanding ) {
acc_size *= sizes[ idx ];
//std::cerr << "This dimension acc_size " << acc_size << " slab size " << slabSize << std::endl;
if ( slabSize == acc_size || ( slabSize > acc_size && ( ( slabSize % acc_size ) == 0 ) ) ) {
fitDimensions[ idx ].lower_bound = 0;
fitDimensions[ idx ].accessed_length = sizes[ idx ];
} else if ( slabSize < acc_size && ( acc_size % slabSize ) == 0 ) {
std::size_t slab_elems = slabSize / ( acc_size / sizes[ idx ] );
//std::cerr << "slab_elems is " << slab_elems << " lb: " << lower_bounds[idx] << std::endl;
fitDimensions[ idx ].accessed_length = slab_elems;
fitDimensions[ idx ].lower_bound = ( lower_bounds[idx] / slab_elems ) * slab_elems;
keep_expanding = false;
} else {
fatal("invalid slabSize: " << slabSize << " reg size is " << this->getBreadth() );
}
} else {
fitDimensions[ idx ].accessed_length = 1;
fitDimensions[ idx ].lower_bound = 1;
}
}
(void ) fitDimensions;
}
return key->obtainRegionId( fitDimensions );
}
示例8: expand
void expand(std::vector<RegionNode*> ®ions, ProbabilityDensityFunction<RegionNode> &pdf, std::vector<Edge*> &tree, KDTree &kdtree, const State &goal) {
RegionNode *randomNode = pdf.sample();
Edge *randomEdge = randomNode->getRandomEdge(zeroToOne);
for(unsigned int i = 0; i < howManySamplePoints; ++i) {
State sample = (zeroToOne(GlobalRandomGenerator) < goalBias) ? goal : agent.getRandomStateNearState(randomEdge->end, samplePointRadius);
#ifdef WITHGRAPHICS
samples.push_back(sample);
#endif
samplesGenerated++;
unsigned int cellId = discretization.getCellId(sample);
if(zeroToOne(GlobalRandomGenerator) < regions[cellId]->getWeight()) {
if(workspace.safeState(agent, sample)) {
samplesAdded++;
Edge newEdge = agent.steer(randomEdge->end, sample, std::numeric_limits<double>::infinity());
edgesGenerated++;
newEdge.updateParent(randomEdge);
if(newEdge.gCost() >= gBound) {
continue;
}
if(workspace.safeEdge(agent, newEdge, collisionCheckDT)) {
edgesAdded++;
Edge *newEdgePointer = pool.construct(newEdge);
#ifdef WITHGRAPHICS
treeEdges.push_back(newEdgePointer);
#endif
cellId = discretization.getCellId(newEdgePointer->end);
regions[cellId]->addEdge(newEdgePointer);
tree.push_back(newEdgePointer);
kdtree.insertPoint(newEdgePointer);
if(regions[cellId]->inPDF) {
pdf.update(regions[cellId]->pdfId, regions[cellId]->getWeight());
} else {
typename ProbabilityDensityFunction<RegionNode>::Element *pdfElem = pdf.add(regions[cellId], regions[cellId]->getWeight()); discretization.setInPDF(cellId);
regions[cellId]->setInPDF(true, pdfElem->getId());
}
}
}
}
}
}
示例9: buildExtractionBlockSet
/// \brief Helper to call buildExtractionBlockSet with a RegionNode.
static SetVector<BasicBlock *> buildExtractionBlockSet(const RegionNode &RN) {
if (!RN.isSubRegion())
// Just a single BasicBlock.
return buildExtractionBlockSet(RN.getNodeAs<BasicBlock>());
const Region &R = *RN.getNodeAs<Region>();
return buildExtractionBlockSet(R.block_begin(), R.block_end());
}
示例10: handleLoops
void StructurizeCFG::handleLoops(bool ExitUseAllowed,
BasicBlock *LoopEnd) {
RegionNode *Node = Order.front();
BasicBlock *LoopStart = Node->getEntry();
if (!Loops.count(LoopStart)) {
wireFlow(ExitUseAllowed, LoopEnd);
return;
}
if (!isPredictableTrue(Node))
LoopStart = needPrefix(true);
LoopEnd = Loops[Node->getEntry()];
wireFlow(false, LoopEnd);
while (!Visited.count(LoopEnd)) {
handleLoops(false, LoopEnd);
}
// If the start of the loop is the entry block, we can't branch to it so
// insert a new dummy entry block.
Function *LoopFunc = LoopStart->getParent();
if (LoopStart == &LoopFunc->getEntryBlock()) {
LoopStart->setName("entry.orig");
BasicBlock *NewEntry =
BasicBlock::Create(LoopStart->getContext(),
"entry",
LoopFunc,
LoopStart);
BranchInst::Create(LoopStart, NewEntry);
DT->setNewRoot(NewEntry);
}
// Create an extra loop end node
LoopEnd = needPrefix(false);
BasicBlock *Next = needPostfix(LoopEnd, ExitUseAllowed);
LoopConds.push_back(BranchInst::Create(Next, LoopStart,
BoolUndef, LoopEnd));
addPhiValues(LoopEnd, LoopStart);
setPrevNode(Next);
}
示例11: getFirstAddress
uint64_t global_reg_t::getFirstAddress( uint64_t baseAddress ) const {
RegionNode *n = key->getRegionNode( id );
uint64_t offset = 0;
std::vector< std::size_t > const &sizes = key->getDimensionSizes();
uint64_t acumSizes = 1;
for ( unsigned int dimIdx = 0; dimIdx < key->getNumDimensions() - 1; dimIdx += 1 ) {
acumSizes *= sizes[ dimIdx ];
}
for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
//std::size_t accessedLength = n->getValue();
n = n->getParent();
std::size_t lowerBound = n->getValue();
n = n->getParent();
offset += acumSizes * lowerBound;
if ( dimIdx >= 1 ) acumSizes = acumSizes / sizes[ dimIdx - 1 ];
}
return baseAddress + offset;
}
示例12: getBreadth
std::size_t global_reg_t::getBreadth() const {
RegionNode *n = key->getRegionNode( id );
std::size_t offset = 0;
std::size_t lastOffset = 0;
std::vector< std::size_t > const &sizes = key->getDimensionSizes();
uint64_t acumSizes = 1;
for ( unsigned int dimIdx = 0; dimIdx < key->getNumDimensions() - 1; dimIdx += 1 ) {
acumSizes *= sizes[ dimIdx ];
}
for ( int dimIdx = key->getNumDimensions() - 1; dimIdx >= 0; dimIdx -= 1 ) {
std::size_t accessedLength = n->getValue();
n = n->getParent();
std::size_t lowerBound = n->getValue();
n = n->getParent();
offset += acumSizes * lowerBound;
lastOffset += acumSizes * ( lowerBound + accessedLength - 1 );
if ( dimIdx >= 1 ) acumSizes = acumSizes / sizes[ dimIdx - 1 ];
}
return ( lastOffset - offset ) + 1;
}
示例13: assert
//------------------------------insert_goto_at---------------------------------
// Inserts a goto & corresponding basic block between
// block[block_no] and its succ_no'th successor block
void PhaseCFG::insert_goto_at(uint block_no, uint succ_no) {
// get block with block_no
assert(block_no < _num_blocks, "illegal block number");
Block* in = _blocks[block_no];
// get successor block succ_no
assert(succ_no < in->_num_succs, "illegal successor number");
Block* out = in->_succs[succ_no];
// get ProjNode corresponding to the succ_no'th successor of the in block
ProjNode* proj = in->_nodes[in->_nodes.size() - in->_num_succs + succ_no]->as_Proj();
// create region for basic block
RegionNode* region = new (C, 2) RegionNode(2);
region->init_req(1, proj);
// setup corresponding basic block
Block* block = new (_bbs._arena) Block(_bbs._arena, region);
_bbs.map(region->_idx, block);
C->regalloc()->set_bad(region->_idx);
// add a goto node
Node* gto = _goto->clone(); // get a new goto node
gto->set_req(0, region);
// add it to the basic block
block->_nodes.push(gto);
_bbs.map(gto->_idx, block);
C->regalloc()->set_bad(gto->_idx);
// hook up successor block
block->_succs.map(block->_num_succs++, out);
// remap successor's predecessors if necessary
for (uint i = 1; i < out->num_preds(); i++) {
if (out->pred(i) == proj) out->head()->set_req(i, gto);
}
// remap predecessor's successor to new block
in->_succs.map(succ_no, block);
// add new basic block to basic block list
_blocks.insert(block_no + 1, block);
_num_blocks++;
// Fixup block freq
block->_freq = out->_freq;
}
示例14: getFitRegionId
reg_t global_reg_t::getFitRegionId() const {
RegionNode *n = key->getRegionNode( id );
bool keep_fitting = true;
nanos_region_dimension_internal_t fitDimensions[ key->getNumDimensions() ];
std::vector< std::size_t > const &sizes = key->getDimensionSizes();
for ( int idx = key->getNumDimensions() - 1; idx >= 0; idx -= 1 ) {
std::size_t accessedLength = n->getValue();
n = n->getParent();
std::size_t lowerBound = n->getValue();
n = n->getParent();
fitDimensions[ idx ].size = sizes[ idx ];
if ( keep_fitting ) {
fitDimensions[ idx ].accessed_length = accessedLength;
fitDimensions[ idx ].lower_bound = lowerBound;
if ( accessedLength != 1 )
keep_fitting = false;
} else {
fitDimensions[ idx ].lower_bound = 0;
fitDimensions[ idx ].accessed_length = sizes[ idx ];
}
}
return key->obtainRegionId( fitDimensions );
}
示例15: Unimplemented
//--- expand_allocation ------------------------------------------------------
void PhaseMacroExpand::expand_allocate(AllocateNode*A) {
// See if we are forced to go slow-path.
if( A->_entry_point == (address)SharedRuntime::_new )
return; // Always go slow-path - required for finalizers, etc
Node*A_ctl=A->proj_out(TypeFunc::Control);
Node*A_mem=A->proj_out(TypeFunc::Memory);
Node*A_oop=A->proj_out(TypeFunc::Parms+0);
// Inject a fast-path / slow-path diamond. Fast-path is still milli-code,
// which returns an oop or null - and does not block, nor GC, nor kill
// registers. If we have an allocation failure the fast-path leaves the
// regs in-place for a slow-path call which DOES block, GC, etc.
Node*ctl=A->in(TypeFunc::Control);
Node*kid=A->in(AllocateNode::KID);
Node*siz=A->in(AllocateNode::AllocSize);
Node*xtr=A->in(AllocateNode::ExtraSlow);
Node *len = A->is_AllocateArray() ? A->in(AllocateNode::ALength) : C->top();
if ( !A_oop && ( !A->is_AllocateArray() || ( _igvn.type(A->in(AllocateNode::ALength))->higher_equal(TypeInt::POS) ) ) ) {
tty->print_cr("Dead allocation should be removed earlier");
Unimplemented();
}
// Convert the array element count to a Long value,
// and fold in the EKID value for oop-arrays.
const TypeOopPtr *toop = A->_tf->range()->field_at(TypeFunc::Parms+0)->is_ptr()->cast_to_ptr_type(TypePtr::BotPTR)->is_oopptr();
if( len != C->top() ) {
assert0( A->is_AllocateArray() );
Node*lenl=transform_later(new(C,2)ConvI2LNode(len));
Node*ekid=A->in(AllocateNode::EKID);
if( ekid->bottom_type() != TypeInt::ZERO ) {
// Have an EKID? Smash the array length and EKID together.
Node *ekidl = transform_later(new (C,2) CastP2XNode(0,ekid));
Node *ekidshf= transform_later(new (C,3) LShiftLNode(ekidl,_igvn.intcon(32)));
Node *combo = transform_later(new (C,3) OrLNode(lenl,ekidshf));
len=combo;
} else {
len=lenl;
}
// Crunch arguments for matching. The old ExtraSlow argument is used to
// make more gating control flow in this function, but is not an argument
// to the runtime call. Neither is the EKID argument: the slow-path will
// compute it's own EKID.
A->set_req(AllocateNode::ExtraSlow,len);
A->set_req(AllocateNode::ALength,C->top());
A->set_req(AllocateNode::EKID,C->top());
} else {
A->set_req(AllocateNode::ExtraSlow,_igvn.zerocon(T_INT));
assert0( !A->is_AllocateArray() );
}
// Extra slow-path test required?
RegionNode *region2 = NULL;
if( xtr->bottom_type() != TypeInt::ZERO ) { // Commonly, no extra test required
// Extra slow-path tests can be required for fast-pathing reflection
// allocation (and cloning). If the new object requires e.g. finalization
// or further class linking/loading.
Node *cmp = transform_later(new(C,3)CmpINode(xtr,_igvn.zerocon(T_INT)));
Node*bol=transform_later(new(C,2)BoolNode(cmp,BoolTest::eq));
Node *iff = new (C, 2) IfNode( ctl, bol, PROB_LIKELY_MAG(5), COUNT_UNKNOWN );
region2=new(C,3)RegionNode(3);
transform_later(region2);
ctl = opt_iff(region2,iff);
}
FastAllocNode *fal = new (C, 4) FastAllocNode(kid,siz,toop,len);
fal->set_req(0,ctl);
transform_later(fal);
Node *mem = new (C,1) SCMemProjNode(fal);
transform_later(mem);
Node *cmp = transform_later(new(C,3)CmpPNode(fal,_igvn.zerocon(T_OBJECT)));
Node*bol=transform_later(new(C,2)BoolNode(cmp,BoolTest::eq));
Node*iff=new(C,2)IfNode(ctl,bol,PROB_UNLIKELY_MAG(5),COUNT_UNKNOWN);
RegionNode *region = new (C, 3) RegionNode(3);
transform_later(region);
Node *slow_path = opt_iff(region,iff);
// Make the merge point
PhiNode*phimem=new(C,3)PhiNode(region,Type::MEMORY,TypePtr::BOTTOM);
transform_later(phimem);
phimem->init_req(2,mem); // Plug in the fast-path
PhiNode*phioop=NULL;
if (A_oop) {
phioop = new (C, 3) PhiNode(region,toop);
transform_later(phioop);
phioop->init_req(2,fal); // Plug in the fast-path
}
_igvn.hash_delete(A_ctl);
_igvn.hash_delete(A_mem);
if (A_oop) _igvn.hash_delete (A_oop);
_igvn.subsume_node_keep_old(A_ctl,region);
_igvn.subsume_node_keep_old(A_mem,phimem);
if (A_oop) _igvn.subsume_node_keep_old(A_oop,phioop);
// Plug in the slow-path
//.........这里部分代码省略.........