本文整理汇总了C++中ControlFlowGraph类的典型用法代码示例。如果您正苦于以下问题:C++ ControlFlowGraph类的具体用法?C++ ControlFlowGraph怎么用?C++ ControlFlowGraph使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ControlFlowGraph类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateParams
void LiveDict::updateParams() {
ControlFlowGraph *g = m_am.graph();
ControlBlock *b = g->getDfBlock(1);
size_t width = g->bitWidth();
BitOps::Bits *avlin = b->getRow(DataFlow::PAvailIn);
BitOps::Bits *dieout = m_am.graph()->getTempBits(0);
BitOps::set(width, dieout, 0);
for (int i = size(); i--; ) {
if (ExpressionPtr e = get(i)) {
always_assert(e->is(Expression::KindOfSimpleVariable));
Symbol *sym = static_pointer_cast<SimpleVariable>(e)->getSymbol();
if (sym) {
if (sym->isParameter() || sym->isClosureVar() || e->isThis()) {
BitOps::set_bit(e->getCanonID(), avlin, true);
}
if (sym->isNeeded() || sym->isReferenced()) {
BitOps::set_bit(e->getCanonID(), dieout, true);
}
}
}
}
for (int i = g->getNumBlocks(); i; i--) {
b = g->getDfBlock(i);
if (!b->out_size()) {
BitOps::bit_or(width, b->getRow(DataFlow::PDieOut),
b->getRow(DataFlow::PDieOut), dieout);
}
}
}
示例2: genCFG
void MethodCodeSelector::genCFG(U_32 numNodes, CFGCodeSelector& codeSelector,
bool useEdgeProfile)
{
ControlFlowGraph* fg = irManager.getFlowGraph();
fg->setEdgeProfile(useEdgeProfile);
CfgCodeSelector cfgCodeSelector(sa, compilationInterface, *this,
codeSelectorMemManager,numNodes, irManager);
{
AutoTimer tm(selectionTimer);
if( NULL == irManager.getEntryPointInst() ) {
irManager.newEntryPointPseudoInst( irManager.getDefaultManagedCallingConvention() );
}
codeSelector.genCode(cfgCodeSelector);
}
{
AutoTimer tm(fixNodeInfoTimer);
irManager.expandSystemExceptions(0);
cfgCodeSelector.fixNodeInfo();
}
{
AutoTimer tm(blockMergingTimer);
fg->purgeEmptyNodes(false, true);
fg->mergeAdjacentNodes(true, false);
fg->purgeUnreachableNodes();
}
}
示例3: propagateSubCFG
void SubCfgBuilderUtils::propagateSubCFG(Inst* inst, bool purgeEmptyNodes)
{
ControlFlowGraph* mainCFG = m_irManager->getFlowGraph();
mainCFG->spliceFlowGraphInline(inst, *m_subCFG);
inst->unlink();
if (purgeEmptyNodes) {
mainCFG->purgeEmptyNodes(true, false);
}
m_subCFG = NULL;
}
示例4: ComputeAvailable
void DataFlow::ComputeAvailable(const ControlFlowGraph &g) {
int num = g.getNumBlocks();
bool changed;
BitOps::Bits *tmp1 = g.getTempBits(0);
bool hasAltered = g.rowExists(Altered);
size_t width = g.bitWidth();
bool firstTime = true;
do {
changed = false;
for (int i = 1; i <= num; i++) {
ControlBlock *b = g.getDfBlock(i);
std::pair<in_edge_iterator, in_edge_iterator> vi =
in_edges(b, g);
BitOps::Bits *ain = b->getRow(AvailIn);
if (vi.first != vi.second) {
ControlBlock *p = source(*vi.first, g);
if (++vi.first != vi.second) {
if (!changed) BitOps::bit_copy(width, tmp1, ain);
BitOps::bit_and(width, ain,
p->getRow(AvailOut),
source(*vi.first, g)->getRow(AvailOut));
while (++vi.first != vi.second) {
p = source(*vi.first, g);
BitOps::bit_and(width, ain, ain, p->getRow(AvailOut));
}
if (!changed) changed = !BitOps::bit_equal(width, tmp1, ain);
} else {
if (!changed) {
changed = !BitOps::bit_equal(width, ain, p->getRow(AvailOut));
}
BitOps::bit_copy(width, ain, p->getRow(AvailOut));
}
} else if (firstTime) {
// available defaults to all 1s
// if there are no preds, set to all 0s
BitOps::set(width, ain, 0);
}
BitOps::Bits *aout = b->getRow(AvailOut);
if (!changed) BitOps::bit_copy(width, tmp1, aout);
BitOps::Bits *avl = b->getRow(Available);
if (hasAltered) {
BitOps::Bits *alt = b->getRow(Altered);
BitOps::bit_andc_or(width, aout, ain, alt, avl);
} else {
BitOps::bit_or(width, aout, ain, avl);
}
if (!changed) changed = !BitOps::bit_equal(width, tmp1, aout);
}
firstTime = false;
} while (changed);
}
示例5: ComputeAnticipated
void DataFlow::ComputeAnticipated(const ControlFlowGraph &g) {
int num = g.getNumBlocks();
bool changed;
BitOps::Bits *tmp1 = g.getTempBits(0);
bool hasAltered = g.rowExists(Altered);
size_t width = g.bitWidth();
bool firstTime = true;
do {
changed = false;
for (int i = num; i ; i--) {
ControlBlock *b = g.getDfBlock(i);
std::pair<out_edge_iterator, out_edge_iterator> vi =
out_edges(b, g);
BitOps::Bits *aout = b->getRow(AntOut);
if (vi.first != vi.second) {
ControlBlock *s = target(*vi.first, g);
if (++vi.first != vi.second) {
if (!changed) BitOps::bit_copy(width, tmp1, aout);
BitOps::bit_and(width, aout,
s->getRow(AntIn),
target(*vi.first, g)->getRow(AntIn));
while (++vi.first != vi.second) {
s = target(*vi.first, g);
BitOps::bit_and(width, aout, aout, s->getRow(AntIn));
}
if (!changed) changed = !BitOps::bit_equal(width, tmp1, aout);
} else {
if (!changed) {
changed = !BitOps::bit_equal(width, aout, s->getRow(AntIn));
}
BitOps::bit_copy(width, aout, s->getRow(AntIn));
}
} else if (firstTime) {
// anticipated defaults to all 1s
// if there are no succs, set to all 0s
BitOps::set(width, aout, 0);
}
BitOps::Bits *ain = b->getRow(AntIn);
if (!changed) BitOps::bit_copy(width, tmp1, ain);
BitOps::Bits *ant = b->getRow(Anticipated);
if (hasAltered) {
BitOps::Bits *alt = b->getRow(Altered);
BitOps::bit_andc_or(width, ain, aout, alt, ant);
} else {
BitOps::bit_or(width, ain, aout, ant);
}
if (!changed) changed = !BitOps::bit_equal(width, tmp1, ain);
}
} while (changed);
}
示例6: assert
U_32 CfgCodeSelector::genExitNode(U_32 numInEdges, double cnt)
{
assert(nextNodeId < numNodes);
U_32 nodeId = nextNodeId++;
ControlFlowGraph* fg = irManager.getFlowGraph();
Node* exitNode = fg->createExitNode();
exitNode->setExecCount(cnt);
fg->setExitNode(exitNode);
nodes[nodeId] = exitNode;
return nodeId;
}
示例7: beginBlock
void Dictionary::beginBlock(ControlBlock *b) {
ControlFlowGraph *g = m_am.graph();
always_assert(g);
m_width = g->bitWidth();
m_altered = b->getRow(DataFlow::Altered);
m_available = g->rowExists(DataFlow::Available) ?
b->getRow(DataFlow::Available) : 0;
m_anticipated = g->rowExists(DataFlow::Anticipated) ?
b->getRow(DataFlow::Anticipated) : 0;
}
示例8: ComputeUsed
void DataFlow::ComputeUsed(const ControlFlowGraph &g) {
int num = g.getNumBlocks();
size_t width = g.bitWidth();
for (int i = num; i ; i--) {
ControlBlock *b = g.getDfBlock(i);
BitOps::Bits *ant = b->getRow(Anticipated);
BitOps::Bits *alt = b->getRow(Altered);
BitOps::Bits *avl = b->getRow(Available);
BitOps::bit_or_or(width, b->getRow(Used), ant, alt, avl);
}
}
示例9: ComputeForwards
void DataFlow::ComputeForwards(T func, const ControlFlowGraph &g,
int lAttr, int altAttr,
int inAttr, int outAttr) {
int num = g.getNumBlocks();
bool changed;
BitOps::Bits *tmp1 = g.getTempBits(0);
bool hasAltered = g.rowExists(altAttr);
size_t width = g.bitWidth();
do {
changed = false;
for (int i = 1; i <= num; i++) {
ControlBlock *b = g.getDfBlock(i);
std::pair<in_edge_iterator, in_edge_iterator> vi =
boost::in_edges(b, g);
BitOps::Bits *ain = b->getRow(inAttr);
if (vi.first != vi.second) {
ControlBlock *p = boost::source(*vi.first, g);
if (++vi.first != vi.second) {
if (!changed) BitOps::bit_copy(width, tmp1, ain);
func(width, ain,
p->getRow(outAttr),
boost::source(*vi.first, g)->getRow(outAttr));
while (++vi.first != vi.second) {
p = boost::source(*vi.first, g);
func(width, ain, ain, p->getRow(outAttr));
}
if (!changed) changed = !BitOps::bit_equal(width, tmp1, ain);
} else {
if (!changed) {
changed = !BitOps::bit_equal(width, ain, p->getRow(outAttr));
}
BitOps::bit_copy(width, ain, p->getRow(outAttr));
}
}
BitOps::Bits *aout = b->getRow(outAttr);
if (!changed) BitOps::bit_copy(width, tmp1, aout);
BitOps::Bits *avl = b->getRow(lAttr);
if (hasAltered) {
BitOps::Bits *alt = b->getRow(altAttr);
BitOps::bit_andc_or(width, aout, ain, alt, avl);
} else {
BitOps::bit_or(width, aout, ain, avl);
}
if (!changed) changed = !BitOps::bit_equal(width, tmp1, aout);
}
} while (changed);
}
示例10: operator
bool operator()(const ControlFlowGraph &cfg, const ControlFlowGraph::ConstEdgeIterator &callEdge, size_t depth) {
if (depth > partitioner.stackDeltaInterproceduralLimit())
return false;
ASSERT_require(callEdge != cfg.edges().end());
ASSERT_require(callEdge->target()->value().type() == V_BASIC_BLOCK);
Function::Ptr function = callEdge->target()->value().function();
return function && !function->stackDelta().getOptional().orDefault();
}
示例11: updateParams
void RefDict::updateParams() {
ControlFlowGraph *g = m_am.graph();
ControlBlock *b = g->getDfBlock(1);
BitOps::Bits *refbv = b->getRow(DataFlow::PRefIn);
BitOps::Bits *objbv = b->getRow(DataFlow::PObjIn);
for (int i = size(); i--; ) {
if (ExpressionPtr e = get(i)) {
always_assert(e->is(Expression::KindOfSimpleVariable));
always_assert(((unsigned int)i) == e->getCanonID());
Symbol *sym = static_pointer_cast<SimpleVariable>(e)->getSymbol();
if (sym && (sym->isParameter() || sym->isClosureVar())) {
TypePtr paramType;
bool isRef;
if (sym->isParameter()) {
ExpressionListPtr methodParams = m_method_stmt->getParams();
ExpressionPtr paramExprPtr =
(*methodParams)[sym->getParameterIndex()];
paramType = paramExprPtr->getType();
isRef = m_method_stmt->isRef(sym->getParameterIndex());
} else {
assert(sym->isClosureVar());
// can only assume it is a Variant for now
paramType = Type::Variant;
isRef = sym->isRefClosureVar();
}
if (first_pass) {
if (isRef || sym->isCallTimeRef()) {
BitOps::set_bit(i, refbv, true);
}
} else {
if (paramType) {
if (!paramType->isNoObjectInvolved()) {
BitOps::set_bit(i, objbv, true);
}
} else {
// no type information, so we must assume it holds an object
BitOps::set_bit(i, objbv, true);
}
}
}
}
}
}
示例12: beforePropagate
void ExprDict::beforePropagate(ControlBlock *b) {
ControlFlowGraph *g = m_am.graph();
always_assert(g);
m_width = size();
m_available = g->rowExists(DataFlow::AvailIn) ?
b->getRow(DataFlow::AvailIn) : 0;
m_anticipated = g->rowExists(DataFlow::AntIn) ?
b->getRow(DataFlow::AntIn) : 0;
vector<ExpressionRawPtr>(size()).swap(m_avlExpr);
vector<TypePtr>(size()).swap(m_avlTypes);
always_assert(m_available && m_anticipated);
if (b->getDfn()) {
for (size_t i = 1; i < m_width; i++) {
if (!BitOps::get_bit(i, m_available)) continue;
if (!isCanonicalStructure(i)) continue;
if (ExpressionPtr e = get(i)) {
// setup for copy-prop
if (e->is(Expression::KindOfAssignmentExpression)) {
AssignmentExpressionPtr ae(
static_pointer_cast<AssignmentExpression>(e));
ExpressionPtr var(ae->getVariable());
assert(isCanonicalStructure(var->getCanonID()));
if (BitOps::get_bit(var->getCanonID(), m_anticipated)) {
ExpressionPtr val(ae->getValue());
if (val->isScalar()) {
m_avlExpr[var->getCanonID()] = val;
}
}
}
// setup for type assertion prop
TypePtrIdxPairVec types;
getTypes(e->getCanonID(), types);
TypePtr t = reduceToSingleAssertion(types);
if (t) {
m_avlTypes[e->getCanonID()] = t;
}
}
}
}
}
示例13: addUses
void
DefUseBuilder::initialize(ControlFlowGraph& fg) {
const Nodes& nodes = fg.getNodes();
Nodes::const_iterator i;
for(i = nodes.begin(); i != nodes.end(); ++i) {
Node* node = *i;
Inst* label = (Inst*)node->getFirstInst();
for(Inst* inst = label->getNextInst(); inst != NULL; inst = inst->getNextInst())
addUses(inst);
}
}
示例14: readCFG
void readCFG(ControlFlowGraph& cfg)
{
try {
cfg.fromFile(conf.input_filename);
} catch (FileNotFoundException fne) {
std::cout << "\033[31m" << fne.message << " not found.\033[0m" << std::endl;
return;
} catch (boost::archive::archive_exception ae) {
std::cout << "\033[31marchive exception:\033[0m " << ae.what() << std::endl;
return;
}
}
示例15: _buildFrontier
void DominanceFrontier::_buildFrontier() {
DominatorTree::Direction domDir = _dt->getDirection();
ControlFlowGraph * cfg = _dt->getCFG();
ControlFlowGraph::ID_dir cfgDir = _dt->getCFGDirection();
for (int i = 0; i < _size; i++) {
ControlNode * currNode = cfg->getNode(i, cfgDir);
int nextSize;
if (domDir == DominatorTree::PRE) {
nextSize = currNode->numPredecessors();
} else {
nextSize = currNode->numSuccessors();
}
//If this is not a join point, we continue
if (nextSize < 2) continue;
//From here on, this is a join point
set<SimpleDirectedGraphNode *> nextNodes;
if (domDir == DominatorTree::PRE) {
nextNodes = currNode->getPredecessors();
} else {
nextNodes = currNode->getSuccessors();
}
set<SimpleDirectedGraphNode *>::iterator next;
for (next = nextNodes.begin(); next != nextNodes.end(); next++) {
ControlNode * runner = dynamic_cast<ControlNode *>(*next);
ROSE_ASSERT(runner != NULL);
int runnerID = runner->getID(cfgDir);
int currID = currNode->getID(cfgDir);
while (runnerID != _dt->getDom(currID)) {
_domFrontier[runnerID].insert(currID);
runnerID = _dt->getDom(runnerID);
}
}
}
}