#include "irnode_t.h"
#include "ircons_t.h"
#include "irprintf.h"
+#include "irgwalk.h"
#include "be_t.h"
#include "belive_t.h"
op_be_Perm = new_ir_op(beo_base + beo_Perm, "Perm", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
op_be_Copy = new_ir_op(beo_base + beo_Copy, "Copy", op_pin_state_floats, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
op_be_Keep = new_ir_op(beo_base + beo_Keep, "Keep", op_pin_state_pinned, K, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
- op_be_Call = new_ir_op(beo_base + beo_Call, "Call", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
+ op_be_Call = new_ir_op(beo_base + beo_Call, "Call", op_pin_state_pinned, N, oparity_variable, 0, sizeof(be_call_attr_t), &be_node_op_ops);
op_be_Return = new_ir_op(beo_base + beo_Return, "Return", op_pin_state_pinned, X, oparity_variable, 0, sizeof(be_node_attr_t), &be_node_op_ops);
op_be_Alloca = new_ir_op(beo_base + beo_Alloca, "Alloca", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
op_be_SetSP = new_ir_op(beo_base + beo_SetSP, "SetSP", op_pin_state_pinned, N, oparity_binary, 0, sizeof(be_stack_attr_t), &be_node_op_ops);
return NULL;
}
-static void entity_copy_walker(ir_node *irn, void *data)
+static void link_reload_walker(ir_node *irn, void *data)
{
+ ir_node **root = (ir_node **) data;
if(be_is_Reload(irn)) {
- be_frame_attr_t *a = get_irn_attr(irn);
- entity *ent = be_get_spill_entity(irn);
-
- a->ent = ent;
+ set_irn_link(irn, *root);
+ *root = irn;
}
}
void be_copy_entities_to_reloads(ir_graph *irg)
{
- irg_walk_graph(irg, entity_copy_walker, NULL, NULL);
+ ir_node *irn = NULL;
+ irg_walk_graph(irg, link_reload_walker, NULL, (void *) &irn);
+
+ while(irn) {
+ be_frame_attr_t *a = get_irn_attr(irn);
+ entity *ent = be_get_spill_entity(irn);
+ a->ent = ent;
+ irn = get_irn_link(irn);
+ }
}
ir_node *be_spill(const arch_env_t *arch_env, ir_node *irn, ir_node *ctx)
* Here's one special case:
* If the spill is in the start block, the spill must be after the frame
* pointer is set up. This is checked here and fixed.
+ * If the insertion point is already the block, everything is fine, since
+ * the Spill gets inserted at the end of the block.
*/
- if(bl == get_irg_start_block(irg))
+ if(bl == get_irg_start_block(irg) && insert != bl && sched_comes_after(insert, frame))
insert = sched_next(frame);
sched_add_before(insert, spill);