util: LLVM code cleanups
Among others, rename instr_info to instr to avoid shadowing the class member with the same name. Change-Id: I53d2ee08f11a944528931bf8cb4003ec64391016
This commit is contained in:
@ -114,16 +114,16 @@ void LLVMDisassembler::disassemble()
|
|||||||
if (disas->getInstruction(Inst, Size, Bytes.slice(Index), Index,
|
if (disas->getInstruction(Inst, Size, Bytes.slice(Index), Index,
|
||||||
nulls(), nulls()) == MCDisassembler::Success) {
|
nulls(), nulls()) == MCDisassembler::Success) {
|
||||||
const MCInstrDesc &desc = this->instr_info->get(Inst.getOpcode());
|
const MCInstrDesc &desc = this->instr_info->get(Inst.getOpcode());
|
||||||
// Inst.dump();
|
|
||||||
Instr instr_info;
|
Instr instr;
|
||||||
instr_info.opcode = Inst.getOpcode();
|
instr.opcode = Inst.getOpcode();
|
||||||
instr_info.length = Size;
|
instr.length = Size;
|
||||||
instr_info.address = SectionAddr + Index;
|
instr.address = SectionAddr + Index;
|
||||||
instr_info.conditional_branch = desc.isConditionalBranch();
|
instr.conditional_branch = desc.isConditionalBranch();
|
||||||
|
|
||||||
assert( Size > 0 && "zero size instruction disassembled" );
|
assert( Size > 0 && "zero size instruction disassembled" );
|
||||||
|
|
||||||
unsigned int pos = 0;
|
unsigned int pos = 0;
|
||||||
for (MCInst::iterator it = Inst.begin(); it != Inst.end(); ++it) {
|
for (MCInst::iterator it = Inst.begin(); it != Inst.end(); ++it) {
|
||||||
|
|
||||||
if (it->isValid() && it->isReg()
|
if (it->isValid() && it->isReg()
|
||||||
@ -131,9 +131,9 @@ void LLVMDisassembler::disassemble()
|
|||||||
// Distinguish between input and
|
// Distinguish between input and
|
||||||
// output register operands
|
// output register operands
|
||||||
if (pos < desc.getNumDefs())
|
if (pos < desc.getNumDefs())
|
||||||
instr_info.reg_defs.push_back(it->getReg());
|
instr.reg_defs.push_back(it->getReg());
|
||||||
else
|
else
|
||||||
instr_info.reg_uses.push_back(it->getReg());
|
instr.reg_uses.push_back(it->getReg());
|
||||||
}
|
}
|
||||||
pos ++;
|
pos ++;
|
||||||
}
|
}
|
||||||
@ -141,17 +141,17 @@ void LLVMDisassembler::disassemble()
|
|||||||
for (unsigned int i = 0; i < desc.getNumImplicitUses(); i++) {
|
for (unsigned int i = 0; i < desc.getNumImplicitUses(); i++) {
|
||||||
if (ptr[i] == 0) // NOREG
|
if (ptr[i] == 0) // NOREG
|
||||||
continue;
|
continue;
|
||||||
instr_info.reg_uses.push_back(ptr[i]);
|
instr.reg_uses.push_back(ptr[i]);
|
||||||
}
|
}
|
||||||
ptr = desc.getImplicitDefs();
|
ptr = desc.getImplicitDefs();
|
||||||
for (unsigned int i = 0; i < desc.getNumImplicitDefs(); i++) {
|
for (unsigned i = 0; i < desc.getNumImplicitDefs(); i++) {
|
||||||
if (ptr[i] == 0) // NOREG
|
if (ptr[i] == 0) // NOREG
|
||||||
continue;
|
continue;
|
||||||
instr_info.reg_defs.push_back(ptr[i]);
|
instr.reg_defs.push_back(ptr[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insert the instruction info into the instr map
|
// Insert the instruction info into the instr map
|
||||||
(*instrs)[instr_info.address] = instr_info;
|
(*instrs)[instr.address] = instr;
|
||||||
} else {
|
} else {
|
||||||
if (Size == 0)
|
if (Size == 0)
|
||||||
Size = 1; // skip illegible bytes
|
Size = 1; // skip illegible bytes
|
||||||
|
|||||||
Reference in New Issue
Block a user