if(regs->ternary || !regs->descs[0].value)
{
/* this is either a ternary op or a binary/unary note */
- if(regs->on_stack)
+ if(IS_STACK_REG(reg))
{
/* all input values are popped */
clobber = 1;
* Set assigned and clobber flags for a register.
*/
static void
-set_register_flags(_jit_regs_t *regs, int reg, int clobber_reg, int clobber_input)
+set_register_flags(
+ jit_gencode_t gen,
+ _jit_regs_t *regs,
+ int reg,
+ int clobber_reg,
+ int clobber_input)
{
if(reg >= 0)
{
+ jit_reg_set_used(gen->touched, reg);
jit_reg_set_used(regs->assigned, reg);
if(clobber_reg)
{
desc->used = 0;
desc->clobber = 0;
desc->early_clobber = 0;
- desc->on_stack = 0;
desc->duplicate = 0;
desc->load = 0;
desc->copy = 0;
}
desc->live = live;
desc->used = used;
- if(regs->on_stack)
- {
- desc->on_stack = 1;
- }
}
/*
regs->descs[index].other_reg = other_reg;
clobber = clobbers_register(gen, regs, index, reg, other_reg);
- set_register_flags(regs, reg,
+ set_register_flags(gen, regs, reg,
(clobber & CLOBBER_REG),
(clobber & CLOBBER_INPUT_VALUE));
if(other_reg >= 0)
{
- set_register_flags(regs, other_reg,
+ set_register_flags(gen, regs, other_reg,
(clobber & CLOBBER_OTHER_REG),
(clobber & CLOBBER_INPUT_VALUE));
}
}
}
- if(desc->on_stack)
+ if(IS_STACK_REG(desc->reg))
{
stack_start = get_stack_start(desc->reg);
if(regs->stack_start < 0)
cost = COST_TOO_MUCH;
}
}
+ else if(other_reg >= 0 && jit_reg_is_used(gen->permanent, other_reg))
+ {
+ cost = COST_TOO_MUCH;
+ }
else if(thrashes_register(gen, regs, desc, reg, other_reg))
{
cost = COST_TOO_MUCH;
{
desc2->reg = desc1->reg;
desc2->other_reg = desc1->other_reg;
- desc2->on_stack = desc1->on_stack;
desc2->duplicate = 1;
}
}
_jit_regdesc_t *desc;
desc = ®s->descs[index];
- if(!desc->value || !desc->on_stack)
+ if(!desc->value || !IS_STACK_REG(desc->reg))
{
return;
}
/* Update information about the contents of the registers. */
for(index = 0;
- index < gen->contents[reg].num_values && index < gen->contents[top].num_values;
+ index < gen->contents[reg].num_values || index < gen->contents[top].num_values;
index++)
{
value1 = (index < gen->contents[reg].num_values
}
}
+static void
+adjust_top_value(jit_gencode_t gen, _jit_regs_t *regs, int index, int top, int reg)
+{
+ if(regs->descs[index].stack_reg == top)
+ {
+ regs->descs[index].stack_reg = reg;
+ }
+}
+
+static void
+adjust_top_values(jit_gencode_t gen, _jit_regs_t *regs, int top, int reg)
+{
+ if(regs->ternary)
+ {
+ adjust_top_value(gen, regs, 0, top, reg);
+ }
+ adjust_top_value(gen, regs, 1, top, reg);
+ adjust_top_value(gen, regs, 2, top, reg);
+}
+
static void
spill_value(jit_gencode_t gen, _jit_regs_t *regs, jit_value_t value, int reg, int other_reg)
{
if(top != reg)
{
exch_stack_top(gen, reg, 0);
+ adjust_top_values(gen, regs, top, reg);
}
if(!(value->is_constant || value->in_frame))
bind_value(gen, desc->value, desc->reg, desc->other_reg, 1);
}
}
-
- jit_reg_set_used(gen->touched, desc->reg);
- if(desc->other_reg >= 0)
- {
- jit_reg_set_used(gen->touched, desc->reg);
- }
}
static void
{
return;
}
+ if(!IS_STACK_REG(desc->value->reg))
+ {
+ return;
+ }
if(desc->copy)
{
}
}
}
-
- jit_reg_set_used(gen->touched, desc->reg);
- if(desc->other_reg >= 0)
- {
- jit_reg_set_used(gen->touched, desc->other_reg);
- }
}
void
#endif
/* Set clobber flags. */
- if(regs->clobber_all)
+ for(index = 0; index < JIT_NUM_REGS; index++)
{
- for(index = 0; index < JIT_NUM_REGS; index++)
+ if((_jit_reg_info[index].flags & JIT_REG_FIXED)
+ || jit_reg_is_used(gen->permanent, index))
+ {
+ continue;
+ }
+ if(regs->clobber_all)
{
- if((_jit_reg_info[index].flags & JIT_REG_FIXED)
- || jit_reg_is_used(gen->permanent, index))
- {
- continue;
- }
jit_reg_set_used(regs->clobber, index);
}
+ if(jit_reg_is_used(regs->clobber, index))
+ {
+ jit_reg_set_used(gen->touched, index);
+ }
}
/* Spill all clobbered registers. */
{
return 0;
}
- set_register_flags(regs, regs->scratch[index].reg, 1, 0);
+ set_register_flags(gen, regs, regs->scratch[index].reg, 1, 0);
}
}
for(index = 0; index < regs->num_scratch; index++)
{
return 0;
}
- set_register_flags(regs, regs->scratch[index].reg, 1, 0);
+ set_register_flags(gen, regs, regs->scratch[index].reg, 1, 0);
}
}
{
return 0;
}
- set_register_flags(regs, regs->scratch[index].reg, 1, 0);
+ set_register_flags(gen, regs, regs->scratch[index].reg, 1, 0);
}
}
select_stack_order(gen, regs);
}
- /* Load values. */
- if(regs->on_stack)
+ /* Shuffle the values that are already on the register stack. */
+ if(regs->loaded_stack_count > 0)
{
- /* shuffle the values that are already on the stack */
if(regs->ternary)
{
if(regs->descs[0].value && regs->descs[0].value->in_register)
move_input_value(gen, regs, 1);
move_input_value(gen, regs, 2);
}
+ }
- /* load and shuffle the remaining values */
- if(regs->x87_arith && regs->reverse_args)
- {
- load_input_value(gen, regs, 2);
- move_input_value(gen, regs, 2);
- load_input_value(gen, regs, 1);
- move_input_value(gen, regs, 1);
- }
- else
- {
- if(regs->ternary)
- {
- load_input_value(gen, regs, 0);
- move_input_value(gen, regs, 0);
- }
- load_input_value(gen, regs, 1);
- move_input_value(gen, regs, 1);
- load_input_value(gen, regs, 2);
- move_input_value(gen, regs, 2);
- }
+ /* Load and shuffle the remaining values. */
+ if(regs->x87_arith && regs->reverse_args)
+ {
+ load_input_value(gen, regs, 2);
+ move_input_value(gen, regs, 2);
+ load_input_value(gen, regs, 1);
+ move_input_value(gen, regs, 1);
}
else
{
if(regs->ternary)
{
load_input_value(gen, regs, 0);
+ move_input_value(gen, regs, 0);
}
load_input_value(gen, regs, 1);
+ move_input_value(gen, regs, 1);
load_input_value(gen, regs, 2);
+ move_input_value(gen, regs, 2);
}
#ifdef JIT_REG_DEBUG