On 09/27/2012 10:15 AM, Aurelien Jarno wrote:
> + /* We have to load the value in a register for moving it to another
> + or for saving it. We assume it's better to keep it there than to
> + reload it later. */
> + if ((NEED_SYNC_ARG(0) && ts->val_type != TEMP_VAL_REG)
> + || ts->val_type == TEMP_VAL_MEM) {
> + ts->reg = tcg_reg_alloc(s, arg_ct->u.regs, allocated_regs);
> + if (ts->val_type == TEMP_VAL_MEM) {
> + tcg_out_ld(s, ts->type, ts->reg, ts->mem_reg, ts->mem_offset);
> + } else if (ts->val_type == TEMP_VAL_CONST) {
> + tcg_out_movi(s, ts->type, ts->reg, ts->val);
> + }
> + s->reg_to_temp[ts->reg] = args[1];
> + ts->val_type = TEMP_VAL_REG;
> + ts->mem_coherent = 1;
> + }
Ok, I believe I understand what's going on now. Nothing like trying to
rewrite the function yourself to figure out why you've done things this way.
The only thing I'd change for clarity is that first condition:
/* If the source value is not in a register, and we're going to be
forced to have it in a register in order to perform the copy,
then copy the SOURCE value into its own register first. That way
we don't have to reload SOURCE the next time it is used.
Note that in the CONST + SYNC case, we must for the moment have
the value in a register because we have no direct access to a
store constant primitive. */
if ((ts->val_type == TEMP_VAL_CONST && NEED_SYNC_ARG(0))
|| ts->val_type == TEMP_VAL_MEM) {
r~