Commit d88edf66 authored by Christoph Mallon's avatar Christoph Mallon
Browse files

ia32: Check that the x87 simulator was requested when there is x87 code.

Do this by always running the x87 simulator in debug builds and asserting on push to the simulated x87 stack that the request flag is set.
parent c3f0ee22
......@@ -1114,11 +1114,8 @@ static void ia32_emit(ir_graph *irg)
be_dump(DUMP_RA, irg, "2addr");
/* we might have to rewrite x87 virtual registers */
ia32_irg_data_t const *const irg_data = ia32_get_irg_data(irg);
if (irg_data->do_x87_sim) {
ia32_x87_simulate_graph(irg);
be_dump(DUMP_RA, irg, "x87");
}
ia32_x87_simulate_graph(irg);
be_dump(DUMP_RA, irg, "x87");
/* do peephole optimizations */
ia32_peephole_optimization(irg);
......
......@@ -11,6 +11,7 @@
*/
#include <assert.h>
#include "bearch_ia32_t.h"
#include "beirg.h"
#include "beutil.h"
#include "irnode_t.h"
......@@ -40,6 +41,12 @@
#define N_FLOAT_REGS (N_ia32_fp_REGS-1) // exclude NOREG
static bool requested_x87_sim(ir_graph const *const irg)
{
ia32_irg_data_t const *const irg_data = ia32_get_irg_data(irg);
return irg_data->do_x87_sim;
}
/** the debug handle */
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
......@@ -218,6 +225,7 @@ static unsigned is_at_pos(x87_state const *const state, ir_node const *const val
*/
static void x87_push(x87_state *const state, ir_node *const node)
{
assert(requested_x87_sim(get_irn_irg(node)));
assert(x87_on_stack(state, node) == (unsigned)-1 && "double push");
assert(state->depth < N_FLOAT_REGS && "stack overrun");
......@@ -1430,6 +1438,11 @@ static void register_sim(ir_op *op, sim_func func)
*/
static void x87_init_simulator(x87_simulator *sim, ir_graph *irg)
{
#ifndef DEBUG_libfirm
if (!requested_x87_sim(irg))
return;
#endif
obstack_init(&sim->obst);
sim->blk_states = pmap_create();
sim->n_idx = get_irg_last_idx(irg);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment