Commit d9607aa8 authored by Matthias Braun's avatar Matthias Braun Committed by Tobias Rapp
Browse files

cleanup, use C99

parent 577480e3
......@@ -36,12 +36,10 @@ DEBUG_ONLY(static firm_dbg_module_t *dbg = NULL;)
/**
* Returns the index of the first "same" register.
*/
static int get_first_same(arch_register_req_t const *const req)
static unsigned get_first_same(arch_register_req_t const *const req)
{
unsigned const other = req->other_same;
int i;
for (i = 0; i != 32; ++i) {
for (unsigned i = 0; i != 32; ++i) {
if (other & (1U << i))
return i;
}
......@@ -54,31 +52,33 @@ static int get_first_same(arch_register_req_t const *const req)
*/
static void assure_should_be_same_requirements(ir_node *const node)
{
int const n_res = arch_get_irn_n_outs(node);
int i;
unsigned const n_res = arch_get_irn_n_outs(node);
/* Check all OUT requirements, if there is a should_be_same. */
for (i = 0; i != n_res; i++) {
arch_register_req_t const *const req = arch_get_irn_register_req_out(node, i);
if (arch_register_req_is(req, should_be_same)) {
int const same_pos = get_first_same(req);
ir_node *const in_node = get_irn_n(node, same_pos);
arch_register_t const *const in_reg = arch_get_irn_register(in_node);
arch_register_t const *const out_reg = arch_get_irn_register_out(node, i);
if (in_reg != out_reg) {
ir_node *const block = get_nodes_block(node);
ir_node *const copy = be_new_Copy(block, in_node);
for (unsigned i = 0; i < n_res; ++i) {
arch_register_req_t const *const req
= arch_get_irn_register_req_out(node, i);
if (!arch_register_req_is(req, should_be_same))
continue;
unsigned const same_pos = get_first_same(req);
ir_node *const in_node = get_irn_n(node, same_pos);
arch_register_t const *const in_reg = arch_get_irn_register(in_node);
arch_register_t const *const out_reg
= arch_get_irn_register_out(node, i);
if (in_reg == out_reg)
continue;
/* Destination is the out register. */
arch_set_irn_register(copy, out_reg);
/* Insert copy before the node into the schedule. */
sched_add_before(node, copy);
/* Set copy as in. */
set_irn_n(node, same_pos, copy);
ir_node *const block = get_nodes_block(node);
ir_node *const copy = be_new_Copy(block, in_node);
DBG((dbg, LEVEL_1, "created copy %+F for should be same argument at input %d of %+F\n", copy, same_pos, node));
}
}
/* Destination is the out register. */
arch_set_irn_register(copy, out_reg);
/* Insert copy before the node into the schedule. */
sched_add_before(node, copy);
/* Set copy as in. */
set_irn_n(node, same_pos, copy);
DBG((dbg, LEVEL_1, "created copy %+F for should be same argument at input %d of %+F\n", copy, same_pos, node));
}
}
......@@ -87,12 +87,11 @@ static void assure_should_be_same_requirements(ir_node *const node)
*/
static void amd64_finish_irg_walker(ir_node *const block, void *const env)
{
ir_node *irn;
ir_node *next;
(void) env;
/* Insert should_be_same copies. */
for (irn = sched_first(block); ! sched_is_end(irn); irn = next) {
for (ir_node *irn = sched_first(block), *next; !sched_is_end(irn);
irn = next) {
next = sched_next(irn);
if (is_amd64_irn(irn)) {
assure_should_be_same_requirements(irn);
......
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