* Released under the GPL
*/
#ifdef HAVE_CONFIG_H
-#include <config.h>
+#include "config.h"
#endif
#include <stdlib.h>
return pos < 0 ? &rd->req : &rd->in_req;
}
-static inline arch_register_req_t *get_req(const ir_node *node, int pos)
+static INLINE arch_register_req_t *get_req(const ir_node *node, int pos)
{
be_req_t *bereq = get_be_req(node, pos);
return &bereq->req;
op_be_Keep = new_ir_op(beo_base + beo_Keep, "be_Keep", op_pin_state_pinned, K, oparity_dynamic, 0, sizeof(be_node_attr_t), &be_node_op_ops);
op_be_CopyKeep = new_ir_op(beo_base + beo_CopyKeep, "be_CopyKeep", 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, "be_Call", op_pin_state_pinned, F, oparity_variable, 0, sizeof(be_call_attr_t), &be_node_op_ops);
- op_be_Return = new_ir_op(beo_base + beo_Return, "be_Return", op_pin_state_pinned, X, oparity_variable, 0, sizeof(be_return_attr_t), &be_node_op_ops);
+ op_be_Return = new_ir_op(beo_base + beo_Return, "be_Return", op_pin_state_pinned, X, oparity_dynamic, 0, sizeof(be_return_attr_t), &be_node_op_ops);
op_be_AddSP = new_ir_op(beo_base + beo_AddSP, "be_AddSP", op_pin_state_pinned, N, oparity_unary, 0, sizeof(be_node_attr_t), &be_node_op_ops);
op_be_SubSP = new_ir_op(beo_base + beo_SubSP, "be_SubSP", 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, "be_SetSP", op_pin_state_pinned, N, oparity_binary, 0, sizeof(be_stack_attr_t), &be_node_op_ops);
}
/* Construct a new be_Return. */
-ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *bl, int n_res, int n, ir_node *in[])
+ir_node *be_new_Return(dbg_info *dbg, ir_graph *irg, ir_node *block, int n_res,
+ int n, ir_node *in[])
{
be_return_attr_t *a;
- ir_node *irn = new_ir_node(dbg, irg, bl, op_be_Return, mode_X, n, in);
- init_node_attr(irn, n);
- a = get_irn_attr(irn);
+ ir_node *res;
+ int i;
+
+ res = new_ir_node(dbg, irg, block, op_be_Return, mode_X, -1, NULL);
+ init_node_attr(res, -1);
+ for(i = 0; i < n; ++i) {
+ add_irn_n(res, in[i]);
+ add_register_req(res);
+ }
+
+ a = get_irn_attr(res);
a->num_ret_vals = n_res;
- return irn;
+ return res;
}
/* Returns the number of real returns values */
return a->num_ret_vals;
}
+int be_Return_append_node(ir_node *ret, ir_node *node)
+{
+ int pos;
+
+ pos = add_irn_n(ret, node);
+ add_register_req(ret);
+
+ return pos;
+}
+
ir_node *be_new_IncSP(const arch_register_t *sp, ir_graph *irg, ir_node *bl, ir_node *old_sp, int offset)
{
be_stack_attr_t *a;
assert(be_is_RegParams(regparams));
proj = new_r_Proj(irg, block, regparams, mode, n);
add_register_req(regparams);
- be_set_constr_single_reg(regparams, n, reg);
+ be_set_constr_single_reg(regparams, BE_OUT_POS(n), reg);
arch_set_irn_register(arch_env, proj, reg);
/* TODO decide, whether we need to set ignore/modify sp flags here? */
ir_node *block = get_nodes_block(barrier);
ir_mode *mode = get_irn_mode(node);
int n = add_irn_n(barrier, node);
+
ir_node *proj = new_r_Proj(irg, block, barrier, mode, n);
add_register_req(barrier);
typedef struct {
const arch_register_t *reg;
- arch_register_req_t req;
+ arch_register_req_t req;
+ arch_irn_flags_t flags;
} phi_attr_t;
typedef struct {
#define get_phi_handler_from_handler(h) container_of(h, phi_handler_t, irn_handler)
#define get_phi_handler_from_ops(h) container_of(h, phi_handler_t, irn_ops)
-static const void *phi_get_irn_ops(const arch_irn_handler_t *handler, const ir_node *irn)
+static
+const void *phi_get_irn_ops(const arch_irn_handler_t *handler,
+ const ir_node *irn)
{
- const phi_handler_t *h = get_phi_handler_from_handler(handler);
- return is_Phi(irn) && mode_is_datab(get_irn_mode(irn)) ? &h->irn_ops : NULL;
+ const phi_handler_t *h;
+ if(!is_Phi(irn) || !mode_is_datab(get_irn_mode(irn)))
+ return NULL;
+
+ h = get_phi_handler_from_handler(handler);
+ return &h->irn_ops;
}
-static INLINE phi_attr_t *get_Phi_attr(const phi_handler_t *handler,
- const ir_node *phi)
+static INLINE
+phi_attr_t *get_Phi_attr(const phi_handler_t *handler, const ir_node *phi)
{
phi_attr_t *attr = pmap_get(handler->phi_attrs, (void*) phi);
if(attr == NULL) {
return &attr->req;
}
-static void phi_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
+void be_set_phi_reg_req(const arch_env_t *arch_env, ir_node *node,
+ const arch_register_req_t *req)
+{
+ const arch_irn_ops_t *ops = arch_get_irn_ops(arch_env, node);
+ const phi_handler_t *handler = get_phi_handler_from_ops(ops);
+ phi_attr_t *attr;
+
+ assert(mode_is_datab(get_irn_mode(node)));
+
+ attr = get_Phi_attr(handler, node);
+ memcpy(&attr->req, req, sizeof(req[0]));
+}
+
+void be_set_phi_flags(const arch_env_t *arch_env, ir_node *node,
+ arch_irn_flags_t flags)
+{
+ const arch_irn_ops_t *ops = arch_get_irn_ops(arch_env, node);
+ const phi_handler_t *handler = get_phi_handler_from_ops(ops);
+ phi_attr_t *attr;
+
+ assert(mode_is_datab(get_irn_mode(node)));
+
+ attr = get_Phi_attr(handler, node);
+ attr->flags = flags;
+}
+
+static
+void phi_set_irn_reg(const void *self, ir_node *irn, const arch_register_t *reg)
{
phi_handler_t *h = get_phi_handler_from_ops(self);
phi_attr_t *attr = get_Phi_attr(h, irn);
attr->reg = reg;
}
-static const arch_register_t *phi_get_irn_reg(const void *self, const ir_node *irn)
+static
+const arch_register_t *phi_get_irn_reg(const void *self, const ir_node *irn)
{
phi_handler_t *h = get_phi_handler_from_ops(self);
phi_attr_t *attr = get_Phi_attr(h, irn);
return attr->reg;
}
-static arch_irn_class_t phi_classify(const void *_self, const ir_node *irn)
+static
+arch_irn_class_t phi_classify(const void *self, const ir_node *irn)
{
return arch_irn_class_normal;
}
-static arch_irn_flags_t phi_get_flags(const void *_self, const ir_node *irn)
+static
+arch_irn_flags_t phi_get_flags(const void *self, const ir_node *irn)
{
- return arch_irn_flags_none;
+ phi_handler_t *h = get_phi_handler_from_ops(self);
+ phi_attr_t *attr = get_Phi_attr(h, irn);
+ return attr->flags;
}
-static ir_entity *phi_get_frame_entity(const void *_self, const ir_node *irn)
+static
+ir_entity *phi_get_frame_entity(const void *_self, const ir_node *irn)
{
return NULL;
}
-static void phi_set_frame_entity(const void *_self, ir_node *irn, ir_entity *ent)
+static
+void phi_set_frame_entity(const void *_self, ir_node *irn, ir_entity *ent)
{
+ assert(0);
}
-static void phi_set_frame_offset(const void *_self, ir_node *irn, int bias)
+static
+void phi_set_frame_offset(const void *_self, ir_node *irn, int bias)
{
+ assert(0);
}
-static int phi_get_sp_bias(const void* self, const ir_node *irn)
+static
+int phi_get_sp_bias(const void* self, const ir_node *irn)
{
return 0;
}
-static const arch_irn_ops_if_t phi_irn_ops = {
+static
+const arch_irn_ops_if_t phi_irn_ops = {
phi_get_irn_reg_req,
phi_set_irn_reg,
phi_get_irn_reg,
NULL, /* perform_memory_operand */
};
-static const arch_irn_handler_t phi_irn_handler = {
- phi_get_irn_ops
-};
-
arch_irn_handler_t *be_phi_handler_new(const arch_env_t *arch_env)
{
phi_handler_t *h = xmalloc(sizeof(h[0]));
free(handler);
}
-const void *be_phi_get_irn_ops(const arch_irn_handler_t *self, const ir_node *irn)
-{
- phi_handler_t *phi_handler = get_phi_handler_from_handler(self);
- return is_Phi(irn) ? &phi_handler->irn_ops : NULL;
-}
-
void be_phi_handler_reset(arch_irn_handler_t *handler)
{
phi_handler_t *h = get_phi_handler_from_handler(handler);