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


C++ AsmCode::size方法代码示例

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


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

示例1: deleteUselessMovs

void Optimizer::deleteUselessMovs(AsmCode& code){
	for (int i = 0; i < code.size(); i++){
		if (*code[i] != cmdMOV || !code[i]->usedRegister(EAX))
			continue;
		AsmCmd2* cmd = dynamic_cast<AsmCmd2*>(code[i]);
		if (cmd->secondArg()->usedRegister(EAX))
			continue;
		if (*cmd->firstArg() != EAX)
			continue;
		int idx = i + 1;
		bool deletingNedeed = true;
		while (idx < code.size() && deletingNedeed){
			if (code[idx]->usedRegister(EAX))
				if (*code[idx] != cmdMOV)
					deletingNedeed = false;
				else {
					AsmCmd2* tmp = dynamic_cast<AsmCmd2*>(code[idx]);
					if (tmp->secondArg()->usedRegister(EAX)	|| dynamic_cast<AsmIndirectArg*>(tmp->firstArg()))
						deletingNedeed = false;
					else
						break;
				}
			idx++;
		}
		if (deletingNedeed)
			code.deleteRange(i, i);
	}
}
开发者ID:Alex-ttt,项目名称:C-Compoiler,代码行数:28,代码来源:l_optimizer.cpp

示例2: pushDownPopUp

void Optimizer::pushDownPopUp(AsmCode& code){
	for (int i = 0; i < code.size(); i++){
		AsmCmd1* cmd = dynamic_cast<AsmCmd1*>(code[i]);
		int j = i;
		if (cmd && *cmd == cmdPUSH){			
			while (j + 1 < code.size() && !code[j + 1]->changeStack() && !code[j + 1]->operateWith(cmd->argument()))
				j++;
			code.move(i, j);
		} else if (cmd && *cmd == cmdPOP) {
			while (j - 1 > -1 && !code[j - 1]->changeStack() && !code[j - 1]->operateWith(cmd->argument()))
				j--;
			code.move(i, j);
		}
	}
}
开发者ID:Alex-ttt,项目名称:C-Compoiler,代码行数:15,代码来源:l_optimizer.cpp

示例3: deleteUselessLabels

void Optimizer::deleteUselessLabels(AsmCode& code){
	for (int i = 0; i < code.size(); i++){
		AsmInstrLabel* label = dynamic_cast<AsmInstrLabel*>(code[i]);
		if (!label || *label == string("start"))
			continue;
		bool unused = true;
		for (int j = 0; j < code.size() && unused; j++){
			if (j == i)
				continue;
			if (code[j]->isJump()){
				AsmArgLabel* dstn = dynamic_cast<AsmArgLabel*>(dynamic_cast<AsmCmd1*>(code[j])->argument());
				unused = *label->label != dstn;
			}
		}
		if (unused)
			code.deleteRange(i, i);
	}
}
开发者ID:Alex-ttt,项目名称:C-Compoiler,代码行数:18,代码来源:l_optimizer.cpp

示例4: optimize

void Optimizer::optimize(AsmCode& code){
	while(true)	{
		pushDownPopUp(code);
		bool goToNextIteration = false;
		for (int i = 0; i < code.size(); i++)
			for (int j = 0; j < oneOpOpts.size(); j++)
				if (oneOpOpts[j]->optimize(code, i))
					goToNextIteration = true;				
		if(goToNextIteration)
			continue;
		for(int i = 0; i < code.size() - 1; i++)
			for (int j = 0; j < twoOpOpts.size(); j++)
				if (twoOpOpts[j]->optimize(code, i))
					goToNextIteration = true;
		if(goToNextIteration)
			continue;
		for(int i = 0; i < code.size() - 2; i++)
			for(int j = 0; j < threeOpOpts.size(); j++)
				if (threeOpOpts[j]->optimize(code, i))
					goToNextIteration = true;
		for(int i = 0; i < code.size() - 3; i++)
			for (int j = 0; j < fourOpOpts.size(); j++)
				if (fourOpOpts[j]->optimize(code, i))
					goToNextIteration = true;
		if(!goToNextIteration)
			break;
	}
	deleteUselessMovs(code);
	deleteUselessLabels(code);
	while(true){
		bool goToNextIteration = false;
		for (int i = 0; i < code.size() - 1; i++)
			for (int j = 0; j < postTwoOpOpts.size(); j++)
				if (postTwoOpOpts[j]->optimize(code, i))
					goToNextIteration = true;
		if (goToNextIteration)
			continue;
		else
			break;
	}
}
开发者ID:Alex-ttt,项目名称:C-Compoiler,代码行数:41,代码来源:l_optimizer.cpp


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