From e8efa63b23b4fcf86193a1698f22c0782bede52c Mon Sep 17 00:00:00 2001 From: Vladimir Kargov Date: Sat, 4 Feb 2017 00:36:28 -0800 Subject: [PATCH] [runtime] Add the MONO_INS_FOR_EACH_REG macro. --- mono/mini/mini.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/mono/mini/mini.h b/mono/mini/mini.h index b3eb72a0d3f..71adeb1d494 100644 --- a/mono/mini/mini.h +++ b/mono/mini/mini.h @@ -593,6 +593,20 @@ extern const gint8 ins_sreg_counts []; #define mono_bb_first_ins(bb) (bb)->code +/* + * Iterate through all used registers in the instruction. + * Relies on the existing order of the MONO_INST enum: MONO_INST_{DREG,SREG1,SREG2,SREG3,LEN} + * INS is the instruction, IDX is the register index, REG is the pointer to a register. + */ +#define MONO_INS_FOR_EACH_REG(ins, idx, reg) for ((idx) = INS_INFO ((ins)->opcode)[MONO_INST_DEST] != ' ' ? MONO_INST_DEST : \ + (mono_inst_get_num_src_registers (ins) ? MONO_INST_SRC1 : MONO_INST_LEN); \ + (reg) = (idx) == MONO_INST_DEST ? &(ins)->dreg : \ + ((idx) == MONO_INST_SRC1 ? &(ins)->sreg1 : \ + ((idx) == MONO_INST_SRC2 ? &(ins)->sreg2 : \ + ((idx) == MONO_INST_SRC3 ? &(ins)->sreg3 : NULL))), \ + idx < MONO_INST_LEN; \ + (idx) = (idx) > mono_inst_get_num_src_registers (ins) + (INS_INFO ((ins)->opcode)[MONO_INST_DEST] != ' ') ? MONO_INST_LEN : (idx) + 1) + struct MonoSpillInfo { int offset; }; -- 2.25.1