sparc: Fix gen_Const on 64-bit machines.
[libfirm] / ir / be / beschedtrivial.c
1 /*
2  * Copyright (C) 1995-2008 University of Karlsruhe.  All right reserved.
3  *
4  * This file is part of libFirm.
5  *
6  * This file may be distributed and/or modified under the terms of the
7  * GNU General Public License version 2 as published by the Free Software
8  * Foundation and appearing in the file LICENSE.GPL included in the
9  * packaging of this file.
10  *
11  * Licensees holding valid libFirm Professional Edition licenses may use
12  * this file in accordance with the libFirm Commercial License.
13  * Agreement provided with the Software.
14  *
15  * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16  * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
17  * PURPOSE.
18  */
19
20 /**
21  * @file
22  * @brief       Trivial node selector.
23  * @author      Sebastian Hack
24  * @date        29.08.2006
25  */
26 #include "config.h"
27
28 #include <stdlib.h>
29
30 #include "irgraph.h"
31 #include "irnode.h"
32 #include "irnodeset.h"
33
34 #include "bearch.h"
35 #include "belistsched.h"
36 #include "bemodule.h"
37 #include "besched.h"
38
39 /**
40  * The trivial selector:
41  * Just assure that branches are executed last, otherwise select
42  * the first node ready.
43  */
44 static ir_node *trivial_select(void *block_env, ir_nodeset_t *ready_set)
45 {
46         ir_node               *irn;
47         ir_nodeset_iterator_t  iter;
48         (void)block_env;
49
50         /* assure that branches and constants are executed last */
51         foreach_ir_nodeset(ready_set, irn, iter) {
52                 if (!is_cfop(irn)) {
53                         return irn;
54                 }
55         }
56
57         /* at last: schedule branches */
58         return ir_nodeset_first(ready_set);
59 }
60
61 static void *trivial_init_graph(ir_graph *irg)
62 {
63         (void)irg;
64         return NULL;
65 }
66
67 static void *trivial_init_block(void *graph_env, ir_node *block)
68 {
69         (void)graph_env;
70         (void)block;
71         return NULL;
72 }
73
74 static void sched_trivial(ir_graph *irg)
75 {
76         static const list_sched_selector_t trivial_selector = {
77                 trivial_init_graph,
78                 trivial_init_block,
79                 trivial_select,
80                 NULL,                /* node_ready */
81                 NULL,                /* node_selected */
82                 NULL,                /* finish_block */
83                 NULL                 /* finish_graph */
84         };
85         be_list_sched_graph(irg, &trivial_selector);
86 }
87
88 BE_REGISTER_MODULE_CONSTRUCTOR(be_init_sched_trivial)
89 void be_init_sched_trivial(void)
90 {
91         be_register_scheduler("trivial", sched_trivial);
92 }