add_double (lnum_orig, hnum_orig, *lrem, *hrem, lrem, hrem);
}
\f
+/* Effectively truncate a real value to represent
+ the nearest possible value in a narrower mode.
+ The result is actually represented in the same data type as the argument,
+ but its value is usually different. */
+
+REAL_VALUE_TYPE
+real_value_truncate (mode, arg)
+ enum machine_mode mode;
+ REAL_VALUE_TYPE arg;
+{
+#ifdef __STDC__
+ /* Make sure the value is actually stored in memory before we turn off
+ the handler. */
+ volatile
+#endif
+ REAL_VALUE_TYPE value;
+ jmp_buf handler;
+
+ if (setjmp (handler))
+ {
+ error ("floating overflow");
+ return dconst0;
+ }
+ set_float_handler (handler);
+ value = REAL_VALUE_TRUNCATE (mode, arg);
+ set_float_handler (0);
+ return value;
+}
+
#if TARGET_FLOAT_FORMAT == IEEE_FLOAT_FORMAT
/* Check for infinity in an IEEE double precision number. */
}
#endif /* no REAL_ARITHMETIC */
t = build_real (TREE_TYPE (arg1),
- REAL_VALUE_TRUNCATE (TYPE_MODE (TREE_TYPE (arg1)), value));
+ real_value_truncate (TYPE_MODE (TREE_TYPE (arg1)), value));
set_float_handler (0);
return t;
}
}
set_float_handler (float_error);
- t = build_real (type, REAL_VALUE_TRUNCATE (TYPE_MODE (type),
+ t = build_real (type, real_value_truncate (TYPE_MODE (type),
TREE_REAL_CST (arg1)));
set_float_handler (0);
return t;
static int modes_equiv_for_class_p ();
static void alter_reg ();
static void delete_dead_insn ();
+static void spill_failure ();
static int new_spill_reg();
static void set_label_offsets ();
static int eliminate_regs_in_insn ();
DUMPFILE is the global-reg debugging dump file stream, or 0.
If it is nonzero, messages are written to it to describe
which registers are seized as reload regs, which pseudo regs
- are spilled from them, and where the pseudo regs are reallocated to. */
+ are spilled from them, and where the pseudo regs are reallocated to.
-void
+ Return value is nonzero if reload failed
+ and we must not do any more for this function. */
+
+int
reload (first, global, dumpfile)
rtx first;
int global;
enum reg_class caller_save_spill_class = NO_REGS;
int caller_save_group_size = 1;
+ /* Nonzero means we couldn't get enough spill regs. */
+ int failure = 0;
+
/* The basic block number currently being processed for INSN. */
int this_block;
they must be the same size and equally restrictive for that class,
otherwise we can't handle the complexity. */
enum machine_mode group_mode[N_REG_CLASSES];
+ /* Record the insn where each maximum need is first found. */
+ rtx max_needs_insn[N_REG_CLASSES];
+ rtx max_groups_insn[N_REG_CLASSES];
+ rtx max_nongroups_insn[N_REG_CLASSES];
rtx x;
something_changed = 0;
bzero (max_needs, sizeof max_needs);
bzero (max_groups, sizeof max_groups);
bzero (max_nongroups, sizeof max_nongroups);
+ bzero (max_needs_insn, sizeof max_needs_insn);
+ bzero (max_groups_insn, sizeof max_groups_insn);
+ bzero (max_nongroups_insn, sizeof max_nongroups_insn);
bzero (group_size, sizeof group_size);
for (i = 0; i < N_REG_CLASSES; i++)
group_mode[i] = VOIDmode;
for (i = 0; i < N_REG_CLASSES; i++)
{
if (max_needs[i] < insn_needs[i])
- max_needs[i] = insn_needs[i];
+ {
+ max_needs[i] = insn_needs[i];
+ max_needs_insn[i] = insn;
+ }
if (max_groups[i] < insn_groups[i])
- max_groups[i] = insn_groups[i];
+ {
+ max_groups[i] = insn_groups[i];
+ max_groups_insn[i] = insn;
+ }
if (insn_total_groups > 0)
if (max_nongroups[i] < insn_needs[i])
- max_nongroups[i] = insn_needs[i];
+ {
+ max_nongroups[i] = insn_needs[i];
+ max_nongroups_insn[i] = insn;
+ }
}
}
/* Note that there is a continue statement above. */
/* I should be the index in potential_reload_regs
of the new reload reg we have found. */
- something_changed
- |= new_spill_reg (i, class, max_needs, 0,
- global, dumpfile);
+ if (i >= FIRST_PSEUDO_REGISTER)
+ {
+ /* There are no groups left to spill. */
+ spill_failure (max_groups_insn[class]);
+ failure = 1;
+ goto failed;
+ }
+ else
+ something_changed
+ |= new_spill_reg (i, class, max_needs, 0,
+ global, dumpfile);
}
else
{
for (idx = 0; idx < FIRST_PSEUDO_REGISTER; idx++)
if (potential_reload_regs[idx] == j + k)
break;
- something_changed
- |= new_spill_reg (idx, class, max_needs, 0,
- global, dumpfile);
+ if (i >= FIRST_PSEUDO_REGISTER)
+ {
+ /* There are no groups left. */
+ spill_failure (max_groups_insn[class]);
+ failure = 1;
+ goto failed;
+ }
+ else
+ something_changed
+ |= new_spill_reg (idx, class, max_needs, 0,
+ global, dumpfile);
}
/* We have found one that will complete a group,
/* I should be the index in potential_reload_regs
of the new reload reg we have found. */
- something_changed
- |= new_spill_reg (i, class, max_needs, max_nongroups,
- global, dumpfile);
+ if (i >= FIRST_PSEUDO_REGISTER)
+ {
+ /* There are no possible registers left to spill. */
+ spill_failure (max_needs[class] > 0 ? max_needs_insn[class]
+ : max_nongroups_insn[class]);
+ failure = 1;
+ goto failed;
+ }
+ else
+ something_changed
+ |= new_spill_reg (i, class, max_needs, max_nongroups,
+ global, dumpfile);
}
}
}
reload_in_progress = 0;
+ /* Come here (with failure set nonzero) if we can't get enough spill regs
+ and we decide not to abort about it. */
+ failed:
+
/* Now eliminate all pseudo regs by modifying them into
their equivalent memory references.
The REG-rtx's for the pseudos are modified in place,
/* Indicate that we no longer have known memory locations or constants. */
reg_equiv_constant = 0;
reg_equiv_memory_loc = 0;
+
+ return failure;
}
\f
/* Nonzero if, after spilling reg REGNO for non-groups,
return 1;
}
+/* Handle the failure to find a register to spill.
+ INSN should be one of the insns which needed this particular spill reg. */
+
+static void
+spill_failure (insn)
+ rtx insn;
+{
+ if (asm_noperands (PATTERN (insn)) >= 0)
+ error_for_asm (insn, "`asm' needs too many reloads");
+ else
+ abort ();
+}
+
/* Add a new register to the tables of available spill-registers
(as well as spilling all pseudos allocated to the register).
I is the index of this register in potential_reload_regs.