当前位置: 首页>>代码示例>>C++>>正文


C++ CFG::entry方法代码示例

本文整理汇总了C++中CFG::entry方法的典型用法代码示例。如果您正苦于以下问题:C++ CFG::entry方法的具体用法?C++ CFG::entry怎么用?C++ CFG::entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CFG的用法示例。


在下文中一共展示了CFG::entry方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: reduce

void LoopReductor::reduce(VirtualCFG *vcfg, CFG *cfg) {

	HashTable<BasicBlock*,BasicBlock*> map;
	map.put(cfg->entry(), vcfg->entry());
	map.put(cfg->exit(),vcfg->exit());

	idx = 1;
	/* duplicate the basic blocks */
	for (CFG::BBIterator bb(cfg); bb; bb++) {
		if (!bb->isEnd()) {
			BasicBlock *vbb = new VirtualBasicBlock(*bb);
			INDEX(vbb) = idx;
			idx++;
			map.put(bb, vbb);
			vcfg->addBB(vbb);
		}
	}
	INDEX(vcfg->exit()) = idx;
	idx++;

	/* connect edges */
	for (CFG::BBIterator bb(cfg); bb; bb++) {
		for (BasicBlock::OutIterator edge(bb); edge; edge++) {
			if (edge->kind() == Edge::CALL) {
				BasicBlock *vsource = map.get(edge->source(), NULL);
				CFG *vcalled = vcfgvec.get(INDEX(edge->calledCFG()));
				ASSERT(vsource && vcalled);
				Edge *vedge = new Edge(vsource, vcalled->entry(), Edge::CALL);
				CALLED_CFG(vedge) = vcalled;

			} else {
				BasicBlock *vsource = map.get(edge->source(), NULL);
				BasicBlock *vtarget = map.get(edge->target(), NULL);
				ASSERT(vsource && vtarget);
				new Edge(vsource, vtarget, edge->kind());
			}
		}
	}


	Vector<BasicBlock*> *ancestors = new Vector<BasicBlock*>();

	for (CFG::BBIterator bb(vcfg); bb; bb++) {
		IN_LOOPS(bb) = new dfa::BitSet(vcfg->countBB());
	}

	/* Do the Depth-First Search, compute the ancestors sets, and mark loop headers */
	depthFirstSearch(vcfg->entry(), ancestors);

	/* Collect all loop headers in a bitset */
/*
	for (CFG::BBIterator bb(vcfg); bb; bb++)
		if (LOOP_HEADER(bb)) {
			realhdr.add(bb->number());
		}
		*/
	/*
	HashTable<int, BasicBlock*> hdrmap;
	Vector<BasicBlock*> dups;
	*/


	bool done = false;
	while (!done) {
		done = true;
		for (CFG::BBIterator bb(vcfg); bb; bb++) {
			Vector<Edge*> toDel;
			BasicBlock *duplicate = NULL;
			for (BasicBlock::InIterator edge(bb); edge; edge++) {

				/* compute loops entered by the edge */
				dfa::BitSet enteredLoops(**IN_LOOPS(bb));
				enteredLoops.remove(**IN_LOOPS(edge->source()));

				/* The edge is a regular entry if it enters one loop, and edge->target() == loop header */
				if (!((enteredLoops.count() == 0) || ((enteredLoops.count() == 1) && (enteredLoops.contains(bb->number()))))) {
					if (!duplicate) {
						duplicate = new VirtualBasicBlock(bb);
						ASSERT(DUPLICATE_OF(bb) == NULL);
						DUPLICATE_OF(bb) = duplicate;
						INDEX(duplicate) = idx;
						idx++;
						vcfg->addBB(duplicate);
						IN_LOOPS(duplicate) = new dfa::BitSet(**IN_LOOPS(edge->source()));
						for (BasicBlock::OutIterator outedge(bb); outedge; outedge++) {
							if (DUPLICATE_OF(outedge->target())) {
								new Edge(duplicate, DUPLICATE_OF(outedge->target()), outedge->kind());
							} else {
								new Edge(duplicate, outedge->target(), outedge->kind());
							}
						}

					}
					done = false;

					new Edge(edge->source(), duplicate, edge->kind());

					toDel.add(edge);
				}
			}
//.........这里部分代码省略.........
开发者ID:alexjordan,项目名称:otawa,代码行数:101,代码来源:cfg_LoopReductor.cpp


注:本文中的CFG::entry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。