#include <stdlib.h>
+#include "beirg.h"
#include "obst.h"
#include "set.h"
#include "pmap.h"
return be_nodes_equal(a, b);
}
-static arch_register_req_t *allocate_reg_req(const ir_node *node)
+static arch_register_req_t *allocate_reg_req(ir_graph *const irg)
{
- ir_graph *irg = get_irn_irg(node);
struct obstack *obst = be_get_be_obst(irg);
arch_register_req_t *req = OALLOCZ(obst, arch_register_req_t);
*/
static void init_node_attr(ir_node *node, int n_inputs, int n_outputs)
{
+ assert(n_outputs >= 0);
+
ir_graph *irg = get_irn_irg(node);
struct obstack *obst = be_get_be_obst(irg);
backend_info_t *info = be_get_info(node);
}
info->in_reqs = in_reqs;
- if (n_outputs >= 0) {
- int i;
- info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_outputs);
- memset(info->out_infos, 0, n_outputs * sizeof(info->out_infos[0]));
- for (i = 0; i < n_outputs; ++i) {
- info->out_infos[i].req = arch_no_register_req;
- }
- } else {
- info->out_infos = NEW_ARR_F(reg_out_info_t, 0);
+ info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_outputs);
+ memset(info->out_infos, 0, n_outputs * sizeof(info->out_infos[0]));
+ for (int i = 0; i < n_outputs; ++i) {
+ info->out_infos[i].req = arch_no_register_req;
}
}
be_set_constr_in(irn, i, cls->class_req);
be_set_constr_out(irn, i, cls->class_req);
} else {
- arch_register_req_t *new_req = allocate_reg_req(irn);
+ arch_register_req_t *const new_req = allocate_reg_req(irg);
new_req->cls = cls;
new_req->type = (req->type & arch_register_req_type_aligned);
new_req->width = req->width;
{
ir_node *in[1];
ir_node *res;
- arch_register_req_t *req;
be_node_attr_t *attr;
ir_graph *irg = get_Block_irg(bl);
const arch_register_req_t *in_req = arch_get_irn_register_req(op);
be_node_set_reg_class_in(res, 0, cls);
be_node_set_reg_class_out(res, 0, cls);
- req = allocate_reg_req(res);
+ arch_register_req_t *const req = allocate_reg_req(irg);
req->cls = cls;
req->type = arch_register_req_type_should_be_same
| (in_req->type & arch_register_req_type_aligned);
be_node_get_frame_entity,
be_node_set_frame_offset,
be_node_get_sp_bias,
- NULL, /* get_inverse */
NULL, /* get_op_estimated_cost */
NULL, /* possible_memory_operand */
NULL, /* perform_memory_operand */
static int get_start_reg_index(ir_graph *irg, const arch_register_t *reg)
{
ir_node *start = get_irg_start(irg);
- unsigned n_outs = arch_get_irn_n_outs(start);
- int i;
/* do a naive linear search... */
- for (i = 0; i < (int)n_outs; ++i) {
- const arch_register_req_t *out_req
- = arch_get_irn_register_req_out(start, i);
- if (! (out_req->type & arch_register_req_type_limited))
+ be_foreach_out(start, i) {
+ arch_register_req_t const *const out_req = arch_get_irn_register_req_out(start, i);
+ if (!arch_register_req_is(out_req, limited))
continue;
if (out_req->cls != reg->reg_class)
continue;
return new_r_Proj(start, mode, i);
}
-int be_find_return_reg_input(ir_node *ret, const arch_register_t *reg)
-{
- int arity = get_irn_arity(ret);
- int i;
- /* do a naive linear search... */
- for (i = 0; i < arity; ++i) {
- const arch_register_req_t *req = arch_get_irn_register_req_in(ret, i);
- if (! (req->type & arch_register_req_type_limited))
- continue;
- if (req->cls != reg->reg_class)
- continue;
- if (!rbitset_is_set(req->limited, reg->index))
- continue;
- return i;
- }
- panic("Tried querying undefined register '%s' at Return", reg->name);
-}
-
static ir_entity* dummy_get_frame_entity(const ir_node *node)
{
(void) node;
dummy_get_frame_entity,
dummy_set_frame_offset,
dummy_get_sp_bias,
- NULL, /* get_inverse */
NULL, /* get_op_estimated_cost */
NULL, /* possible_memory_operand */
NULL, /* perform_memory_operand */
dummy_get_frame_entity,
dummy_set_frame_offset,
dummy_get_sp_bias,
- NULL, /* get_inverse */
NULL, /* get_op_estimated_cost */
NULL, /* possible_memory_operand */
NULL, /* perform_memory_operand */
memcpy(new_attr, old_attr, get_op_attr_size(get_irn_op(old_node)));
- new_info->flags = old_info->flags;
- if (old_info->out_infos != NULL) {
- size_t n_outs = ARR_LEN(old_info->out_infos);
- /* need dyanmic out infos? */
- if (be_is_Perm(new_node)) {
- new_info->out_infos = NEW_ARR_F(reg_out_info_t, n_outs);
- } else {
- new_info->out_infos = NEW_ARR_D(reg_out_info_t, obst, n_outs);
- }
- memcpy(new_info->out_infos, old_info->out_infos,
- n_outs * sizeof(new_info->out_infos[0]));
- } else {
- new_info->out_infos = NULL;
- }
+ new_info->flags = old_info->flags;
+ new_info->out_infos = old_info->out_infos ? DUP_ARR_D(reg_out_info_t, obst, old_info->out_infos) : NULL;
/* input infos */
if (old_info->in_reqs != NULL) {