add isl_multi_aff_sub
[platform/upstream/isl.git] / isl_options.c
1 /*
2  * Copyright 2008-2009 Katholieke Universiteit Leuven
3  *
4  * Use of this software is governed by the MIT license
5  *
6  * Written by Sven Verdoolaege, K.U.Leuven, Departement
7  * Computerwetenschappen, Celestijnenlaan 200A, B-3001 Leuven, Belgium
8  */
9
10 #include <stdio.h>
11 #include <stdlib.h>
12 #include <string.h>
13
14 #include <isl/ctx.h>
15 #include <isl_options_private.h>
16 #include <isl/ast_build.h>
17 #include <isl/schedule.h>
18 #include <isl/version.h>
19
20 struct isl_arg_choice isl_lp_solver_choice[] = {
21         {"tab",         ISL_LP_TAB},
22 #ifdef ISL_PIPLIB
23         {"pip",         ISL_LP_PIP},
24 #endif
25         {0}
26 };
27
28 struct isl_arg_choice isl_ilp_solver_choice[] = {
29         {"gbr",         ISL_ILP_GBR},
30 #ifdef ISL_PIPLIB
31         {"pip",         ISL_ILP_PIP},
32 #endif
33         {0}
34 };
35
36 struct isl_arg_choice isl_pip_solver_choice[] = {
37         {"tab",         ISL_PIP_TAB},
38 #ifdef ISL_PIPLIB
39         {"pip",         ISL_PIP_PIP},
40 #endif
41         {0}
42 };
43
44 struct isl_arg_choice isl_pip_context_choice[] = {
45         {"gbr",         ISL_CONTEXT_GBR},
46         {"lexmin",      ISL_CONTEXT_LEXMIN},
47         {0}
48 };
49
50 struct isl_arg_choice isl_gbr_choice[] = {
51         {"never",       ISL_GBR_NEVER},
52         {"once",        ISL_GBR_ONCE},
53         {"always",      ISL_GBR_ALWAYS},
54         {0}
55 };
56
57 struct isl_arg_choice isl_closure_choice[] = {
58         {"isl",         ISL_CLOSURE_ISL},
59         {"box",         ISL_CLOSURE_BOX},
60         {0}
61 };
62
63 static struct isl_arg_choice bound[] = {
64         {"bernstein",   ISL_BOUND_BERNSTEIN},
65         {"range",       ISL_BOUND_RANGE},
66         {0}
67 };
68
69 static struct isl_arg_choice on_error[] = {
70         {"warn",        ISL_ON_ERROR_WARN},
71         {"continue",    ISL_ON_ERROR_CONTINUE},
72         {"abort",       ISL_ON_ERROR_ABORT},
73         {0}
74 };
75
76 static struct isl_arg_choice isl_schedule_algorithm_choice[] = {
77         {"isl",         ISL_SCHEDULE_ALGORITHM_ISL},
78         {"feautrier",   ISL_SCHEDULE_ALGORITHM_FEAUTRIER},
79         {0}
80 };
81
82 static struct isl_arg_flags bernstein_recurse[] = {
83         {"none",        ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS, 0},
84         {"factors",     ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
85                         ISL_BERNSTEIN_FACTORS},
86         {"intervals",   ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
87                         ISL_BERNSTEIN_INTERVALS},
88         {"full",        ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS,
89                         ISL_BERNSTEIN_FACTORS | ISL_BERNSTEIN_INTERVALS},
90         {0}
91 };
92
93 static struct isl_arg_choice convex[] = {
94         {"wrap",        ISL_CONVEX_HULL_WRAP},
95         {"fm",          ISL_CONVEX_HULL_FM},
96         {0}
97 };
98
99 static struct isl_arg_choice fuse[] = {
100         {"max",         ISL_SCHEDULE_FUSE_MAX},
101         {"min",         ISL_SCHEDULE_FUSE_MIN},
102         {0}
103 };
104
105 static struct isl_arg_choice separation_bounds[] = {
106         {"explicit",    ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT},
107         {"implicit",    ISL_AST_BUILD_SEPARATION_BOUNDS_IMPLICIT},
108         {0}
109 };
110
111 static void print_version(void)
112 {
113         printf("%s", isl_version());
114 }
115
116 ISL_ARGS_START(struct isl_options, isl_options_args)
117 ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
118         isl_lp_solver_choice,   ISL_LP_TAB, "lp solver to use")
119 ISL_ARG_CHOICE(struct isl_options, ilp_solver, 0, "ilp-solver", \
120         isl_ilp_solver_choice,  ISL_ILP_GBR, "ilp solver to use")
121 ISL_ARG_CHOICE(struct isl_options, pip, 0, "pip", \
122         isl_pip_solver_choice,  ISL_PIP_TAB, "pip solver to use")
123 ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
124         isl_pip_context_choice, ISL_CONTEXT_GBR,
125         "how to handle the pip context tableau")
126 ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
127         isl_gbr_choice, ISL_GBR_ALWAYS,
128         "how often to use generalized basis reduction")
129 ISL_ARG_CHOICE(struct isl_options, closure, 0, "closure", \
130         isl_closure_choice,     ISL_CLOSURE_ISL,
131         "closure operation to use")
132 ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0,
133         "only perform basis reduction in first direction")
134 ISL_ARG_CHOICE(struct isl_options, bound, 0, "bound", bound,
135         ISL_BOUND_BERNSTEIN, "algorithm to use for computing bounds")
136 ISL_ARG_CHOICE(struct isl_options, on_error, 0, "on-error", on_error,
137         ISL_ON_ERROR_WARN, "how to react if an error is detected")
138 ISL_ARG_FLAGS(struct isl_options, bernstein_recurse, 0,
139         "bernstein-recurse", bernstein_recurse, ISL_BERNSTEIN_FACTORS, NULL)
140 ISL_ARG_BOOL(struct isl_options, bernstein_triangulate, 0,
141         "bernstein-triangulate", 1,
142         "triangulate domains during Bernstein expansion")
143 ISL_ARG_BOOL(struct isl_options, pip_symmetry, 0, "pip-symmetry", 1,
144         "detect simple symmetries in PIP input")
145 ISL_ARG_CHOICE(struct isl_options, convex, 0, "convex-hull", \
146         convex, ISL_CONVEX_HULL_WRAP, "convex hull algorithm to use")
147 ISL_ARG_BOOL(struct isl_options, coalesce_bounded_wrapping, 0,
148         "coalesce-bounded-wrapping", 1, "bound wrapping during coalescing")
149 ISL_ARG_INT(struct isl_options, schedule_max_coefficient, 0,
150         "schedule-max-coefficient", "limit", -1, "Only consider schedules "
151         "where the coefficients of the variable and parameter dimensions "
152         "do not exceed <limit>. A value of -1 allows arbitrary coefficients.")
153 ISL_ARG_INT(struct isl_options, schedule_max_constant_term, 0,
154         "schedule-max-constant-term", "limit", -1, "Only consider schedules "
155         "where the coefficients of the constant dimension do not exceed "
156         "<limit>. A value of -1 allows arbitrary coefficients.")
157 ISL_ARG_BOOL(struct isl_options, schedule_parametric, 0,
158         "schedule-parametric", 1, "construct possibly parametric schedules")
159 ISL_ARG_BOOL(struct isl_options, schedule_outer_zero_distance, 0,
160         "schedule-outer-zero-distance", 0,
161         "try to construct schedules with outer zero distances over "
162         "proximity dependences")
163 ISL_ARG_BOOL(struct isl_options, schedule_maximize_band_depth, 0,
164         "schedule-maximize-band-depth", 0,
165         "maximize the number of scheduling dimensions in a band")
166 ISL_ARG_BOOL(struct isl_options, schedule_split_scaled, 0,
167         "schedule-split-scaled", 1,
168         "split non-tilable bands with scaled schedules")
169 ISL_ARG_BOOL(struct isl_options, schedule_separate_components, 0,
170         "schedule-separate-components", 1,
171         "separate components in dependence graph")
172 ISL_ARG_CHOICE(struct isl_options, schedule_algorithm, 0,
173         "schedule-algorithm", isl_schedule_algorithm_choice,
174         ISL_SCHEDULE_ALGORITHM_ISL, "scheduling algorithm to use")
175 ISL_ARG_CHOICE(struct isl_options, schedule_fuse, 0, "schedule-fuse", fuse,
176         ISL_SCHEDULE_FUSE_MAX, "level of fusion during scheduling")
177 ISL_ARG_BOOL(struct isl_options, tile_scale_tile_loops, 0,
178         "tile-scale-tile-loops", 1, "scale tile loops")
179 ISL_ARG_STR(struct isl_options, ast_iterator_type, 0,
180         "ast-iterator-type", "type", "int",
181         "type used for iterators during printing of AST")
182 ISL_ARG_BOOL(struct isl_options, ast_build_atomic_upper_bound, 0,
183         "ast-build-atomic-upper-bound", 1, "generate atomic upper bounds")
184 ISL_ARG_BOOL(struct isl_options, ast_build_prefer_pdiv, 0,
185         "ast-build-prefer-pdiv", 1, "prefer pdiv operation over fdiv")
186 ISL_ARG_BOOL(struct isl_options, ast_build_exploit_nested_bounds, 0,
187         "ast-build-exploit-nested-bounds", 1,
188         "simplify conditions based on bounds of nested for loops")
189 ISL_ARG_BOOL(struct isl_options, ast_build_group_coscheduled, 0,
190         "ast-build-group-coscheduled", 0,
191         "keep coscheduled domain elements together")
192 ISL_ARG_CHOICE(struct isl_options, ast_build_separation_bounds, 0,
193         "ast-build-separation-bounds", separation_bounds,
194         ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT,
195         "bounds to use during separation")
196 ISL_ARG_BOOL(struct isl_options, ast_build_scale_strides, 0,
197         "ast-build-scale-strides", 1,
198         "allow iterators of strided loops to be scaled down")
199 ISL_ARG_BOOL(struct isl_options, ast_build_allow_else, 0,
200         "ast-build-allow-else", 1, "generate if statements with else branches")
201 ISL_ARG_BOOL(struct isl_options, ast_build_allow_or, 0,
202         "ast-build-allow-or", 1, "generate if conditions with disjunctions")
203 ISL_ARG_VERSION(print_version)
204 ISL_ARGS_END
205
206 ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
207
208 ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
209
210 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
211 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
212
213 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
214         on_error)
215 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
216         on_error)
217
218 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
219         coalesce_bounded_wrapping)
220 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
221         coalesce_bounded_wrapping)
222
223 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
224         gbr_only_first)
225 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
226         gbr_only_first)
227
228 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
229         schedule_max_coefficient)
230 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
231         schedule_max_coefficient)
232
233 ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
234         schedule_max_constant_term)
235 ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
236         schedule_max_constant_term)
237
238 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
239         schedule_maximize_band_depth)
240 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
241         schedule_maximize_band_depth)
242
243 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
244         schedule_split_scaled)
245 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
246         schedule_split_scaled)
247
248 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
249         schedule_separate_components)
250 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
251         schedule_separate_components)
252
253 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
254         schedule_outer_zero_distance)
255 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
256         schedule_outer_zero_distance)
257
258 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
259         schedule_algorithm)
260 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
261         schedule_algorithm)
262
263 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
264         schedule_fuse)
265 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
266         schedule_fuse)
267
268 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
269         tile_scale_tile_loops)
270 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
271         tile_scale_tile_loops)
272
273 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
274         ast_build_atomic_upper_bound)
275 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
276         ast_build_atomic_upper_bound)
277
278 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
279         ast_build_prefer_pdiv)
280 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
281         ast_build_prefer_pdiv)
282
283 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
284         ast_build_exploit_nested_bounds)
285 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
286         ast_build_exploit_nested_bounds)
287
288 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
289         ast_build_group_coscheduled)
290 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
291         ast_build_group_coscheduled)
292
293 ISL_CTX_SET_STR_DEF(isl_options, struct isl_options, isl_options_args,
294         ast_iterator_type)
295 ISL_CTX_GET_STR_DEF(isl_options, struct isl_options, isl_options_args,
296         ast_iterator_type)
297
298 ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
299         ast_build_separation_bounds)
300 ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
301         ast_build_separation_bounds)
302
303 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
304         ast_build_scale_strides)
305 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
306         ast_build_scale_strides)
307
308 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
309         ast_build_allow_else)
310 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
311         ast_build_allow_else)
312
313 ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
314         ast_build_allow_or)
315 ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
316         ast_build_allow_or)