本文整理汇总了C++中AsmCode::deleteRange方法的典型用法代码示例。如果您正苦于以下问题:C++ AsmCode::deleteRange方法的具体用法?C++ AsmCode::deleteRange怎么用?C++ AsmCode::deleteRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AsmCode
的用法示例。
在下文中一共展示了AsmCode::deleteRange方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool Jmp2NextLineOptimization::optimize(AsmCode& code, int index){
if (prepare(code[index], code[index + 1]) && *cmd1->argument() == cmd2->label){
code.deleteRange(index, index);
return true;
}
return false;
}
示例2: 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);
}
}
示例3: optimize
bool AddSubESPZeroOptimization::optimize(AsmCode &code, int index){
if (prepare(code[index]) && *cmd1->firstArg() == ESP && *cmd1->secondArg() == 0){
code.deleteRange(index, index);
return true;
}
return false;
}
示例4: makeArg
bool Neg2MovOppositeOptimization::optimize(AsmCode& code, int index){
if (prepare(code[index], code[index + 1])
&& *cmd1 == cmdMOV && *cmd1->firstArg() == EAX
&& *cmd2 == cmdNEG && *cmd2->argument() == EAX
&& dynamic_cast<AsmImmediateArg*>(cmd1->secondArg())){
int val = dynamic_cast<AsmImmediateArg*>(cmd1->secondArg())->value;
AsmCmd2* optCmd = new AsmCmd2(cmdMOV, makeArg(EAX), makeArg(-val));
code.deleteRange(index, index + 1);
code.insert(optCmd, index);
return true;
}
return false;
}
示例5: 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);
}
}