Commit 8d14210e authored by Christoph Mallon's avatar Christoph Mallon
Browse files

be: Give the none register requirement a register class.

Now register requirements always have have a register class.
This is more consistent and removes some null pointer checks.
parent 4652701d
......@@ -19,8 +19,18 @@
#include "raw_bitset.h"
#include "util.h"
static arch_register_class_t arch_none_cls = {
.name = "none",
.mode = NULL,
.regs = NULL,
.class_req = arch_no_register_req,
.index = (unsigned)-1,
.n_regs = 0,
.manual_ra = true,
};
arch_register_req_t const arch_no_requirement = {
.cls = NULL,
.cls = &arch_none_cls,
};
static reg_out_info_t *get_out_info_n(const ir_node *node, unsigned pos)
......@@ -134,7 +144,7 @@ ir_node *be_get_start_proj(ir_graph *const irg, be_start_info_t *const info)
/* This is already the transformed start node. */
ir_node *const start = get_irg_start(irg);
arch_register_class_t const *const cls = arch_get_irn_register_req_out(start, info->pos)->cls;
info->irn = new_r_Proj(start, cls ? cls->mode : mode_M, info->pos);
info->irn = new_r_Proj(start, cls->mode ? cls->mode : mode_M, info->pos);
}
return info->irn;
}
......
......@@ -146,11 +146,6 @@ static void dump_register_req(FILE *const F, arch_register_req_t const *const re
}
arch_register_class_t const *const cls = req->cls;
if (!cls) {
fputs("none", F);
return;
}
fputs(cls->name, F);
if (req->limited != NULL) {
......@@ -166,7 +161,7 @@ static void dump_register_req(FILE *const F, arch_register_req_t const *const re
if (req->must_be_different != 0)
dump_bitmask(F, " different from", req->must_be_different);
if (req->width != 1)
if (req->width > 1)
fprintf(F, " width:%d", req->width);
if (req->aligned)
fputs(" aligned", F);
......
......@@ -692,11 +692,6 @@ static void prepare_constr_insn(ir_node *const node)
* TODO: This really just checks precolored registers at the moment and
* ignores the general case of not matching in/out constraints */
foreach_irn_in(node, i, op) {
const arch_register_req_t *const req
= arch_get_irn_register_req_in(node, i);
if (req->cls == NULL)
continue;
const arch_register_t *const reg = arch_get_irn_register(op);
if (reg == NULL)
continue;
......@@ -706,6 +701,7 @@ static void prepare_constr_insn(ir_node *const node)
rbitset_is_set(birg->allocatable_regs, reg->global_index))
continue;
arch_register_req_t const *const req = arch_get_irn_register_req_in(node, i);
if (req->limited == NULL)
continue;
if (rbitset_is_set(req->limited, reg->index))
......@@ -724,9 +720,6 @@ static void prepare_constr_insn(ir_node *const node)
for (int i = 0, arity = get_irn_arity(node); i < arity; ++i) {
const arch_register_req_t *const req
= arch_get_irn_register_req_in(node, i);
const arch_register_class_t *const cls = req->cls;
if (cls == NULL)
continue;
if (req->limited == NULL)
continue;
......@@ -734,6 +727,7 @@ static void prepare_constr_insn(ir_node *const node)
const arch_register_req_t *const in_req = arch_get_irn_register_req(in);
if (in_req->ignore)
continue;
arch_register_class_t const *const cls = req->cls;
for (int i2 = i + 1; i2 < arity; ++i2) {
const arch_register_req_t *const req2
= arch_get_irn_register_req_in(node, i2);
......@@ -766,13 +760,11 @@ static void prepare_constr_insn(ir_node *const node)
unsigned *def_constr = NULL;
be_foreach_value(node, value,
const arch_register_req_t *const req = arch_get_irn_register_req(value);
const arch_register_class_t *const cls = req->cls;
if (cls == NULL)
continue;
if (req->limited == NULL)
continue;
if (def_constr == NULL)
def_constr = rbitset_alloca(isa_if->n_registers);
arch_register_class_t const *const cls = req->cls;
rbitset_foreach(req->limited, cls->n_regs, e) {
const arch_register_t *reg = arch_register_for_index(cls, e);
rbitset_set(def_constr, reg->global_index);
......@@ -791,9 +783,6 @@ static void prepare_constr_insn(ir_node *const node)
* 3) is constrained to a register occurring in out constraints. */
const arch_register_req_t *const req
= arch_get_irn_register_req_in(node, i);
const arch_register_class_t *const cls = req->cls;
if (cls == NULL)
continue;
if (req->limited == NULL)
continue;
ir_node *in = get_irn_n(node, i);
......@@ -809,7 +798,8 @@ static void prepare_constr_insn(ir_node *const node)
if (!be_value_live_after(in, node))
continue;
bool common_limits = false;
bool common_limits = false;
arch_register_class_t const *const cls = req->cls;
rbitset_foreach(req->limited, cls->n_regs, e) {
const arch_register_t *reg = arch_register_for_index(cls, e);
if (rbitset_is_set(def_constr, reg->global_index)) {
......@@ -1114,7 +1104,7 @@ static void add_missing_keep_walker(ir_node *node, void *data)
for (unsigned i = 0; i < n_outs; ++i) {
arch_register_req_t const *const req = arch_get_irn_register_req_out(node, i);
arch_register_class_t const *const cls = req->cls;
if (cls && !cls->manual_ra) {
if (!cls->manual_ra) {
ir_node *value = existing_projs[i];
if (!value) {
value = new_r_Proj(node, cls->mode, i);
......@@ -1132,7 +1122,7 @@ static void add_missing_keep_walker(ir_node *node, void *data)
} else if (!is_Proj(node)) {
arch_register_req_t const *const req = arch_get_irn_register_req(node);
arch_register_class_t const *const cls = req->cls;
if (cls && !cls->manual_ra) {
if (!cls->manual_ra) {
if (!has_real_user(node)) {
ir_node *const keep = be_new_Keep_one(node);
sched_add_after(node, keep);
......
......@@ -222,7 +222,7 @@ static void block_count_values(ir_node *block, void *data)
be_foreach_value(node, value,
arch_register_req_t const *const req
= arch_get_irn_register_req(value);
if (req->cls == NULL)
if (!req->cls->regs)
continue;
++stats->values;
if (req->should_be_same != 0 || is_Phi(value))
......@@ -232,7 +232,7 @@ static void block_count_values(ir_node *block, void *data)
);
for (int i = 0, arity = get_irn_arity(node); i < arity; ++i) {
const arch_register_req_t *req = arch_get_irn_register_req_in(node, i);
if (req->cls == NULL)
if (!req->cls->regs)
continue;
++stats->uses;
if (be_is_Keep(node)) {
......
......@@ -63,7 +63,7 @@ ir_node *be_transform_phi(ir_node *node, const arch_register_req_t *req)
* and fix this later */
ir_node **ins = get_irn_in(node)+1;
int arity = get_irn_arity(node);
ir_mode *mode = req->cls != NULL ? req->cls->mode : get_irn_mode(node);
ir_mode *mode = req->cls->mode ? req->cls->mode : get_irn_mode(node);
ir_node *phi = new_ir_node(dbgi, irg, block, op_Phi, mode, arity, ins);
copy_node_attr(irg, node, phi);
......
......@@ -558,7 +558,7 @@ typedef struct be_verify_reg_alloc_env_t {
static void check_output_constraints(be_verify_reg_alloc_env_t *const env, const ir_node *node)
{
arch_register_req_t const *const req = arch_get_irn_register_req(node);
if (!req->cls)
if (!req->cls->regs)
return;
/* verify output register */
......@@ -596,7 +596,7 @@ static void check_input_constraints(be_verify_reg_alloc_env_t *const env, ir_nod
env->problem_found = true;
}
if (req->cls == NULL)
if (!req->cls->regs)
continue;
if (req->width > pred_req->width) {
......
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