tcg_abort();
}
-/* at the end of a basic block, we assume all temporaries are dead and
- all globals are stored at their canonical location */
-/* XXX: optimize by handling constants in another array ? */
-void tcg_reg_alloc_bb_end(TCGContext *s)
+/* save globals to their cannonical location and assume they can be
+ modified be the following code. */
+static void save_globals(TCGContext *s)
{
TCGTemp *ts;
int i;
if (!ts->fixed_reg) {
if (ts->val_type == TEMP_VAL_REG) {
tcg_reg_free(s, ts->reg);
+ } else if (ts->val_type == TEMP_VAL_DEAD) {
+ ts->val_type = TEMP_VAL_MEM;
}
}
}
+}
+
+/* at the end of a basic block, we assume all temporaries are dead and
+ all globals are stored at their canonical location */
+/* XXX: optimize by handling constants in another array ? */
+void tcg_reg_alloc_bb_end(TCGContext *s)
+{
+ TCGTemp *ts;
+ int i;
+
+ save_globals(s);
for(i = s->nb_globals; i < s->nb_temps; i++) {
ts = &s->temps[i];
/* store globals and free associated registers (we assume the insn
can modify any global. */
- for(i = 0; i < s->nb_globals; i++) {
- ts = &s->temps[i];
- if (!ts->fixed_reg) {
- if (ts->val_type == TEMP_VAL_REG) {
- tcg_reg_free(s, ts->reg);
- }
- }
- }
+ save_globals(s);
}
/* satisfy the output constraints */
/* store globals and free associated registers (we assume the call
can modify any global. */
- for(i = 0; i < s->nb_globals; i++) {
- ts = &s->temps[i];
- if (!ts->fixed_reg) {
- if (ts->val_type == TEMP_VAL_REG) {
- tcg_reg_free(s, ts->reg);
- }
- }
- }
+ save_globals(s);
tcg_out_op(s, opc, &func_arg, &const_func_arg);