本文整理汇总了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);
}
}
示例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);
}
}
}
示例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);
}
}
示例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;
}
}