8 #include <isl/ast_build.h>
14 static __isl_give isl_ast_node
*construct_ast(pdg::PDG
*pdg
);
16 #define ARRAY_SIZE(a) (sizeof(a)/sizeof(*a))
18 static isl_ast_node
*tree
;
22 static void do_proc(tree_proc
* tp
)
24 static context_info
*ctx
= new context_info
;
25 proc_sym
* psym
= tp
->proc();
27 construct_domains(tp
, 0, oldstyle
, ctx
);
29 isl_ast_node_free(tree
);
33 main(int argc
, char * argv
[])
35 isl_ctx
*ctx
= isl_ctx_alloc();
40 cmd_line_option my_options
[] = {
41 { CLO_STRING
, "-domains", "", &domains
},
42 { CLO_NOARG
, "-oldstyle", "", &oldstyle
},
45 start_suif(argc
, argv
);
48 parse_cmd_line(argc
, argv
, my_options
, ARRAY_SIZE(my_options
));
51 input
= fopen(domains
, "r");
53 pdg
= PDG::Load(input
, ctx
);
56 fprintf(stderr
, "Empty input\n");
60 tree
= construct_ast(pdg
);
62 suif_proc_iter(argc
, argv
, do_proc
, TRUE
);
75 static void free_ast_expr_list(void *user
)
77 isl_ast_expr_list_free((isl_ast_expr_list
*) user
);
80 static __isl_give isl_ast_node
*construct_ast(pdg::PDG
*pdg
)
82 isl_ctx
*ctx
= pdg
->get_isl_ctx();
87 isl_options_set_ast_build_atomic_upper_bound(ctx
, 1);
88 isl_options_set_ast_build_allow_else(ctx
, 0);
90 build
= isl_ast_build_from_context(pdg
->get_context_isl_set());
91 sched
= isl_union_map_empty(isl_space_params_alloc(ctx
, 0));
93 for (int i
= 0; i
< pdg
->nodes
.size(); ++i
) {
99 if (!pdg
->nodes
[i
]->schedule
) {
100 fprintf(stderr
, "Missing schedule\n");
104 source
= pdg
->nodes
[i
]->source
->get_isl_set(ctx
);
106 map
= pdg
->nodes
[i
]->schedule
->get_isl_map(ctx
);
107 map
= isl_map_intersect_domain(map
, source
);
108 snprintf(name
, sizeof(name
), "S%d", i
);
109 id
= isl_id_alloc(ctx
, name
, pdg
->nodes
[i
]);
110 map
= isl_map_set_tuple_id(map
, isl_dim_in
, id
);
112 sched
= isl_union_map_add_map(sched
, map
);
115 tree
= isl_ast_build_ast_from_schedule(build
, sched
);
116 isl_ast_build_free(build
);