#include "ia32_x87.h"
#include "ia32_architecture.h"
-#define MASK_TOS(x) ((x) & (N_ia32_st_REGS - 1))
-
/** the debug handle */
DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
typedef struct x87_state {
st_entry st[N_ia32_st_REGS]; /**< the register stack */
int depth; /**< the current stack depth */
- int tos; /**< position of the tos */
x87_simulator *sim; /**< The simulator. */
} x87_state;
/** An empty state, used for blocks without fp instructions. */
-static x87_state _empty = { { {0, NULL}, }, 0, 0, NULL };
+static x87_state _empty = { { {0, NULL}, }, 0, NULL };
static x87_state *empty = (x87_state *)&_empty;
/**
static st_entry *x87_get_entry(x87_state *const state, int const pos)
{
assert(0 <= pos && pos < state->depth);
- return &state->st[MASK_TOS(state->tos + pos)];
+ return &state->st[N_ia32_st_REGS - state->depth + pos];
}
/**
assert(state->depth < N_ia32_st_REGS && "stack overrun");
++state->depth;
- state->tos = MASK_TOS(state->tos - 1);
st_entry *const entry = x87_get_entry(state, 0);
entry->reg_idx = reg_idx;
entry->node = node;
assert(state->depth > 0 && "stack underrun");
--state->depth;
- state->tos = MASK_TOS(state->tos + 1);
DB((dbg, LEVEL_2, "After POP: ")); DEBUG_ONLY(x87_dump_stack(state);)
}
static void x87_emms(x87_state *state)
{
state->depth = 0;
- state->tos = 0;
}
/**