X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Fmips%2Fmips_scheduler.c;h=5ab8ca69714e6414aee269102d17a91abc005b8c;hb=f7dfa0917a2f0469129bbf9b4c0884d37810abcd;hp=b2fdda304cb2e2656405a4a22db206ed1c456347;hpb=18dfdacb6faf2f93d4f6f9a6362584f8c7eb30a1;p=libfirm diff --git a/ir/be/mips/mips_scheduler.c b/ir/be/mips/mips_scheduler.c index b2fdda304..5ab8ca697 100644 --- a/ir/be/mips/mips_scheduler.c +++ b/ir/be/mips/mips_scheduler.c @@ -1,6 +1,28 @@ -/* Mips implementation of list scheduler selector */ -/* $Id$ */ +/* + * Copyright (C) 1995-2007 University of Karlsruhe. All right reserved. + * + * This file is part of libFirm. + * + * This file may be distributed and/or modified under the terms of the + * GNU General Public License version 2 as published by the Free Software + * Foundation and appearing in the file LICENSE.GPL included in the + * packaging of this file. + * + * Licensees holding valid libFirm Professional Edition licenses may use + * this file in accordance with the libFirm Commercial License. + * Agreement provided with the Software. + * + * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE + * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE. + */ +/** + * @file + * @brief Mips implementation of list scheduler selector + * @author Matthias Braun, Mehdi + * @version $Id$ + */ #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -12,7 +34,7 @@ #include "mips_scheduler.h" #include "../besched_t.h" -#include "../be.h" +#include "be.h" #include "../beabi.h" #include "iredges.h" #include "ircons.h" @@ -30,12 +52,15 @@ typedef struct { * have to pass before we can access that register again * (because mips will write the register value back in the WB phase of the pipeline) */ - int busy_registers[N_mips_general_purpose_REGS]; + int busy_registers[N_mips_gp_REGS]; /// current block ir_node* block; ir_node* last_nop; } mips_sched_env_t; +/* Matze: deprecated and totally broken */ +#if 0 + static void *mips_scheduler_init_graph(const list_sched_selector_t *vtab, const arch_env_t *arch_env, ir_graph *irg) { mips_sched_env_t *sched_env = xmalloc(sizeof(sched_env[0])); @@ -71,6 +96,8 @@ static void mips_scheduler_finish_block(void* graph_env) // attach last nop to end node (so that firm doesn't discard it) if(sched_env->last_nop != NULL) { ir_node* end = get_irg_end(get_irn_irg(sched_env->block)); + (void) end; + // TODO } sched_env->block = NULL; } @@ -115,7 +142,7 @@ static int mips_scheduler_node_allowed(mips_sched_env_t *sched_env, ir_node* nod return 1; } -static ir_node *mips_scheduler_select(void *block_env, pset *ready_set) +static ir_node *mips_scheduler_select(void *block_env, nodeset *ready_set, nodeset *live_set) { mips_sched_env_t *sched_env = (mips_sched_env_t*) block_env; const arch_env_t *arch_env = (const arch_env_t*) sched_env->arch_env; @@ -127,22 +154,22 @@ static ir_node *mips_scheduler_select(void *block_env, pset *ready_set) // test all nodes in the ready set and take the first non-branch that // is allowed - for(node = pset_first(ready_set); node != NULL; node = pset_next(ready_set)) { - if(arch_irn_classify(arch_env, node) == arch_irn_class_branch) { - if(is_irn_forking(node)) + for (node = nodeset_first(ready_set); node != NULL; node = nodeset_next(ready_set)) { + if (arch_irn_class_is(arch_env, node, branch)) { + if (is_irn_forking(node)) condjmp = node; continue; } have_non_branch_nodes = 1; - if(mips_scheduler_node_allowed(sched_env, node)) + if (mips_scheduler_node_allowed(sched_env, node)) { - pset_break(ready_set); + nodeset_break(ready_set); // TODO update busy_registers - if(is_mips_div(node) || is_mips_mult(node)) { + if (is_mips_div(node) || is_mips_mult(node)) { mips_collect_mflohis(sched_env->div_set, node); } else if(is_mips_mflo(node) || is_mips_mfhi(node)) { pset_remove_ptr(sched_env->div_set, node); @@ -160,9 +187,9 @@ static ir_node *mips_scheduler_select(void *block_env, pset *ready_set) if(condjmp != NULL) { return condjmp; } - node = pset_first(ready_set); - assert(arch_irn_classify(arch_env, node) == arch_irn_class_branch); - pset_break(ready_set); + node = nodeset_first(ready_set); + assert(arch_irn_class_is(arch_env, node, branch)); + nodeset_break(ready_set); return node; } @@ -172,11 +199,31 @@ static ir_node *mips_scheduler_select(void *block_env, pset *ready_set) return node; } +#endif + +static +int mips_to_appear_in_schedule(void *block_env, const ir_node *node) +{ + (void) block_env; + + if(!is_mips_irn(node)) + return -1; + if(is_mips_zero(node) || is_mips_Immediate(node)) + return 0; + + return 1; +} + +list_sched_selector_t mips_selector; + /** * Returns the reg_pressure scheduler with to_appear_in_schedule() overloaded */ -const list_sched_selector_t *mips_get_list_sched_selector(const void *self) +const list_sched_selector_t *mips_get_list_sched_selector(const void *self, + list_sched_selector_t *selector) { + (void) self; +#if 0 memset(&mips_sched_selector, 0, sizeof(mips_sched_selector)); mips_sched_selector.init_graph = mips_scheduler_init_graph; mips_sched_selector.init_block = mips_scheduler_init_block; @@ -184,5 +231,16 @@ const list_sched_selector_t *mips_get_list_sched_selector(const void *self) mips_sched_selector.to_appear_in_schedule = mips_scheduler_to_appear_in_schedule; mips_sched_selector.finish_block = mips_scheduler_finish_block; mips_sched_selector.finish_graph = mips_scheduler_finish_graph; - return &mips_sched_selector; + //return &mips_sched_selector; +#endif + memcpy(&mips_selector, selector, sizeof(mips_selector)); + mips_selector.to_appear_in_schedule = mips_to_appear_in_schedule; + + return &mips_selector; +} + +const ilp_sched_selector_t *mips_get_ilp_sched_selector(const void *self) +{ + (void) self; + return NULL; }