-ir_node *be_spill(ir_node *block, ir_node *irn)
-{
- ir_graph *irg = get_irn_irg(block);
- ir_node *frame = get_irg_frame(irg);
- const arch_register_class_t *cls = arch_get_irn_reg_class(irn, -1);
- const arch_register_class_t *cls_frame = arch_get_irn_reg_class(frame, -1);
- ir_node *spill;
-
- spill = be_new_Spill(cls, cls_frame, irg, block, frame, irn);
- return spill;
-}
-
-ir_node *be_reload(const arch_register_class_t *cls, ir_node *insert, ir_mode *mode, ir_node *spill)
-{
- ir_node *reload;
- ir_node *bl = is_Block(insert) ? insert : get_nodes_block(insert);
- ir_graph *irg = get_irn_irg(bl);
- ir_node *frame = get_irg_frame(irg);
- const arch_register_class_t *cls_frame = arch_get_irn_reg_class(frame, -1);
-
- assert(be_is_Spill(spill) || (is_Phi(spill) && get_irn_mode(spill) == mode_M));
-
- reload = be_new_Reload(cls, cls_frame, irg, bl, frame, spill, mode);
-
- if (is_Block(insert)) {
- insert = sched_skip(insert, 0, sched_skip_cf_predicator, NULL);
- sched_add_after(insert, reload);
- } else {
- sched_add_before(insert, reload);
- }
-
- return reload;
-}
-
-/*
- ____ ____
- | _ \ ___ __ _ | _ \ ___ __ _ ___
- | |_) / _ \/ _` | | |_) / _ \/ _` / __|
- | _ < __/ (_| | | _ < __/ (_| \__ \
- |_| \_\___|\__, | |_| \_\___|\__, |___/
- |___/ |_|
-
-*/
-
-
-static const
-arch_register_req_t *get_out_reg_req(const ir_node *irn, int out_pos)
-{
- const be_node_attr_t *a = get_irn_attr_const(irn);
-
- if(out_pos >= ARR_LEN(a->reg_data)) {
- return arch_no_register_req;
- }
-
- return &a->reg_data[out_pos].req.req;
-}
-
-static const
-arch_register_req_t *get_in_reg_req(const ir_node *irn, int pos)
-{
- const be_node_attr_t *a = get_irn_attr_const(irn);
-
- if(pos >= get_irn_arity(irn) || pos >= ARR_LEN(a->reg_data))
- return arch_no_register_req;
-
- return &a->reg_data[pos].in_req.req;
-}
-
-static const arch_register_req_t *
-be_node_get_irn_reg_req(const ir_node *irn, int pos)
-{
- int out_pos = pos;
-
- if (pos < 0) {
- if (get_irn_mode(irn) == mode_T)
- return arch_no_register_req;
-
- out_pos = redir_proj((const ir_node **)&irn);
- assert(is_be_node(irn));
- return get_out_reg_req(irn, out_pos);
- } else if (is_be_node(irn)) {
- /*
- * For spills and reloads, we return "none" as requirement for frame
- * pointer, so every input is ok. Some backends need this (e.g. STA).
- */
- if ((be_is_Spill(irn) && pos == be_pos_Spill_frame) ||
- (be_is_Reload(irn) && pos == be_pos_Reload_frame))
- return arch_no_register_req;
-
- return get_in_reg_req(irn, pos);
- }
-
- return arch_no_register_req;
-}
-
-const arch_register_t *
-be_node_get_irn_reg(const ir_node *irn)
-{
- be_reg_data_t *r;
-
- if (get_irn_mode(irn) == mode_T)
- return NULL;
- r = retrieve_reg_data(irn);
- return r->reg;
-}
-
-static arch_irn_class_t be_node_classify(const ir_node *irn)
-{
-restart:
- switch (get_irn_opcode(irn)) {
-#define XXX(a,b) case a: return b
- XXX(beo_Spill, arch_irn_class_spill);
- XXX(beo_Reload, arch_irn_class_reload);
- XXX(beo_Perm, arch_irn_class_perm);
- XXX(beo_Copy, arch_irn_class_copy);
- XXX(beo_Return, arch_irn_class_branch);
-#undef XXX
- case iro_Proj:
- irn = get_Proj_pred(irn);
- if (is_Proj(irn)) {
- assert(get_irn_mode(irn) == mode_T);
- irn = get_Proj_pred(irn);
- }
- goto restart;
-
- default:
- return 0;
- }
-}
-
-static arch_irn_flags_t be_node_get_flags(const ir_node *node)
-{
- be_req_t *bereq;
- int pos = -1;
-
- if(is_Proj(node)) {
- pos = OUT_POS(get_Proj_proj(node));
- node = skip_Proj_const(node);
- }
-
- bereq = get_be_req(node, pos);
-
- return bereq->flags;
-}
-