Commit bb523cb9 authored by Matthias Braun's avatar Matthias Braun
Browse files

bestack: add support for nodes resetting the stack

parent 23df3482
......@@ -40,6 +40,13 @@
#include "beirg.h"
#include "error.h"
/**
* this constant is returned by the get_sp_bias functions if the stack
* is reset (usually because the frame pointer is copied to the stack
* pointer
*/
#define SP_BIAS_RESET INT_MIN
typedef enum arch_register_class_flags_t {
arch_register_class_flag_none = 0,
/** don't do automatic register allocation for this class */
......
......@@ -183,9 +183,8 @@ static int process_stack_bias(ir_node *bl, int real_bias)
* If the node modifies the stack pointer by a constant offset,
* record that in the bias.
*/
ofs = arch_get_sp_bias(irn);
if (be_is_IncSP(irn)) {
ofs = be_get_IncSP_offset(irn);
/* fill in real stack frame size */
if (ofs == BE_STACK_FRAME_SIZE_EXPAND) {
ir_type *frame_type = get_irg_frame_type(irg);
......@@ -217,10 +216,18 @@ static int process_stack_bias(ir_node *bl, int real_bias)
}
}
}
real_bias += ofs;
wanted_bias += ofs;
} else {
ofs = arch_get_sp_bias(irn);
if (ofs == SP_BIAS_RESET) {
real_bias = 0;
wanted_bias = 0;
} else {
real_bias += ofs;
wanted_bias += ofs;
}
}
real_bias += ofs;
wanted_bias += ofs;
}
assert(real_bias == wanted_bias);
......
......@@ -258,6 +258,11 @@ static int ia32_get_sp_bias(const ir_node *node)
if (is_ia32_Pop(node) || is_ia32_PopMem(node))
return -4;
if (is_ia32_Leave(node) || (be_is_Copy(node)
&& arch_get_irn_register(node) == &ia32_registers[REG_ESP])) {
return SP_BIAS_RESET;
}
return 0;
}
......
......@@ -117,6 +117,8 @@ static int sparc_get_sp_bias(const ir_node *node)
* calculates that! */
assert(attr->immediate_value <= -SPARC_MIN_STACKSIZE);
return attr->immediate_value + SPARC_MIN_STACKSIZE;
} else if (is_sparc_RestoreZero(node)) {
return SP_BIAS_RESET;
}
return 0;
}
......
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