Currently we don't have a way to iterate over the register operands of an instr_t directly.
To do so, we have to:
1) obtain the number of src (instr_num_srcs()) and dst (instr_num_dsts()) operands;
2) iterate over and obtain the operand (with instr_get_src() and instr_get_dst());
3) obtain the number of registers of every operand with opnd_num_regs_used();
4) iterate over and obtain the reg_id_t register with opnd_get_reg_used().
We find this operation common enough to warrant its own APIs in core/ir/instr_shared.c to avoid code duplication.
Since we still want to distinguish between source register operands and destination register operands of an instr_t, we'd want the following 4 APIs:
Note that registers in destination operands that are memory references are still being read, hence they should be counted among the source register operands of an instruction.
Currently we don't have a way to iterate over the register operands of an instr_t directly. To do so, we have to: 1) obtain the number of src (
instr_num_srcs()
) and dst (instr_num_dsts()
) operands; 2) iterate over and obtain the operand (withinstr_get_src()
andinstr_get_dst()
); 3) obtain the number of registers of every operand withopnd_num_regs_used()
; 4) iterate over and obtain thereg_id_t
register withopnd_get_reg_used()
.We find this operation common enough to warrant its own APIs in core/ir/instr_shared.c to avoid code duplication.
Since we still want to distinguish between source register operands and destination register operands of an instr_t, we'd want the following 4 APIs:
Note that registers in destination operands that are memory references are still being read, hence they should be counted among the source register operands of an instruction.