Fixed a bug (obstack is not freed)
[libfirm] / ir / be / beconstrperm.c
1 /**
2  * Author:      Daniel Grund
3  * Date:                15.12.2005
4  * Copyright:   (c) Universitaet Karlsruhe
5  * Licence:     This file protected by GPL -  GNU GENERAL PUBLIC LICENSE.
6  *
7  */
8 #ifdef HAVE_CONFIG_H
9 #include "config.h"
10 #endif
11
12 #include "irgraph_t.h"
13 #include "irnode_t.h"
14 #include "irgwalk.h"
15
16 #include "bearch.h"
17 #include "benode_t.h"
18 #include "besched_t.h"
19 #include "beconstrperm.h"
20
21 static void walker_insert_constr_perms(ir_node *irn, void *env) {
22         be_chordal_env_t *cenv = env;
23         const be_main_env_t *menv = cenv->main_env;
24         const arch_env_t *aenv = menv->arch_env;
25         arch_register_req_t req;
26         int pos, max;
27
28         /* check for a restriction of the result (-1) and the operands (0..n) */
29         max = get_irn_arity(irn);
30         for(pos=-1; pos<max; ++pos) {
31                 arch_get_register_req(aenv, &req, irn, pos);
32                 /* if a restriction is found, insert a perm before the irn */
33                 if (req.type == arch_register_req_type_limited) {
34                         insert_Perm_after(menv, cenv->cls, cenv->dom_front, sched_prev(irn));
35                         break;
36                 }
37         }
38 }
39
40 void be_insert_constr_perms(be_chordal_env_t *cenv) {
41         irg_walk_graph(cenv->irg, walker_insert_constr_perms, NULL, cenv);
42 }