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
20struct 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
28struct 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
36struct 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
44struct isl_arg_choice isl_pip_context_choice[] = {
45	{"gbr",		ISL_CONTEXT_GBR},
46	{"lexmin",	ISL_CONTEXT_LEXMIN},
47	{0}
48};
49
50struct 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
57struct isl_arg_choice isl_closure_choice[] = {
58	{"isl",		ISL_CLOSURE_ISL},
59	{"box",		ISL_CLOSURE_BOX},
60	{0}
61};
62
63static struct isl_arg_choice bound[] = {
64	{"bernstein",	ISL_BOUND_BERNSTEIN},
65	{"range",	ISL_BOUND_RANGE},
66	{0}
67};
68
69static 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
76static struct isl_arg_choice isl_schedule_algorithm_choice[] = {
77	{"isl",		ISL_SCHEDULE_ALGORITHM_ISL},
78	{"feautrier",   ISL_SCHEDULE_ALGORITHM_FEAUTRIER},
79	{0}
80};
81
82static 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
93static struct isl_arg_choice convex[] = {
94	{"wrap",	ISL_CONVEX_HULL_WRAP},
95	{"fm",		ISL_CONVEX_HULL_FM},
96	{0}
97};
98
99static struct isl_arg_choice fuse[] = {
100	{"max",		ISL_SCHEDULE_FUSE_MAX},
101	{"min",		ISL_SCHEDULE_FUSE_MIN},
102	{0}
103};
104
105static 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
111static void print_version(void)
112{
113	printf("%s", isl_version());
114}
115
116ISL_ARGS_START(struct isl_options, isl_options_args)
117ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
118	isl_lp_solver_choice,	ISL_LP_TAB, "lp solver to use")
119ISL_ARG_CHOICE(struct isl_options, ilp_solver, 0, "ilp-solver", \
120	isl_ilp_solver_choice,	ISL_ILP_GBR, "ilp solver to use")
121ISL_ARG_CHOICE(struct isl_options, pip, 0, "pip", \
122	isl_pip_solver_choice,	ISL_PIP_TAB, "pip solver to use")
123ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
124	isl_pip_context_choice,	ISL_CONTEXT_GBR,
125	"how to handle the pip context tableau")
126ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
127	isl_gbr_choice,	ISL_GBR_ALWAYS,
128	"how often to use generalized basis reduction")
129ISL_ARG_CHOICE(struct isl_options, closure, 0, "closure", \
130	isl_closure_choice,	ISL_CLOSURE_ISL,
131	"closure operation to use")
132ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0,
133	"only perform basis reduction in first direction")
134ISL_ARG_CHOICE(struct isl_options, bound, 0, "bound", bound,
135	ISL_BOUND_BERNSTEIN, "algorithm to use for computing bounds")
136ISL_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")
138ISL_ARG_FLAGS(struct isl_options, bernstein_recurse, 0,
139	"bernstein-recurse", bernstein_recurse, ISL_BERNSTEIN_FACTORS, NULL)
140ISL_ARG_BOOL(struct isl_options, bernstein_triangulate, 0,
141	"bernstein-triangulate", 1,
142	"triangulate domains during Bernstein expansion")
143ISL_ARG_BOOL(struct isl_options, pip_symmetry, 0, "pip-symmetry", 1,
144	"detect simple symmetries in PIP input")
145ISL_ARG_CHOICE(struct isl_options, convex, 0, "convex-hull", \
146	convex,	ISL_CONVEX_HULL_WRAP, "convex hull algorithm to use")
147ISL_ARG_BOOL(struct isl_options, coalesce_bounded_wrapping, 0,
148	"coalesce-bounded-wrapping", 1, "bound wrapping during coalescing")
149ISL_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.")
153ISL_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.")
157ISL_ARG_BOOL(struct isl_options, schedule_parametric, 0,
158	"schedule-parametric", 1, "construct possibly parametric schedules")
159ISL_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")
163ISL_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")
166ISL_ARG_BOOL(struct isl_options, schedule_split_scaled, 0,
167	"schedule-split-scaled", 1,
168	"split non-tilable bands with scaled schedules")
169ISL_ARG_BOOL(struct isl_options, schedule_separate_components, 0,
170	"schedule-separate-components", 1,
171	"separate components in dependence graph")
172ISL_ARG_CHOICE(struct isl_options, schedule_algorithm, 0,
173	"schedule-algorithm", isl_schedule_algorithm_choice,
174	ISL_SCHEDULE_ALGORITHM_ISL, "scheduling algorithm to use")
175ISL_ARG_CHOICE(struct isl_options, schedule_fuse, 0, "schedule-fuse", fuse,
176	ISL_SCHEDULE_FUSE_MAX, "level of fusion during scheduling")
177ISL_ARG_BOOL(struct isl_options, tile_scale_tile_loops, 0,
178	"tile-scale-tile-loops", 1, "scale tile loops")
179ISL_ARG_BOOL(struct isl_options, tile_shift_point_loops, 0,
180	"tile-shift-point-loops", 1, "shift point loops to start at zero")
181ISL_ARG_STR(struct isl_options, ast_iterator_type, 0,
182	"ast-iterator-type", "type", "int",
183	"type used for iterators during printing of AST")
184ISL_ARG_BOOL(struct isl_options, ast_build_atomic_upper_bound, 0,
185	"ast-build-atomic-upper-bound", 1, "generate atomic upper bounds")
186ISL_ARG_BOOL(struct isl_options, ast_build_prefer_pdiv, 0,
187	"ast-build-prefer-pdiv", 1, "prefer pdiv operation over fdiv")
188ISL_ARG_BOOL(struct isl_options, ast_build_exploit_nested_bounds, 0,
189	"ast-build-exploit-nested-bounds", 1,
190	"simplify conditions based on bounds of nested for loops")
191ISL_ARG_BOOL(struct isl_options, ast_build_group_coscheduled, 0,
192	"ast-build-group-coscheduled", 0,
193	"keep coscheduled domain elements together")
194ISL_ARG_CHOICE(struct isl_options, ast_build_separation_bounds, 0,
195	"ast-build-separation-bounds", separation_bounds,
196	ISL_AST_BUILD_SEPARATION_BOUNDS_EXPLICIT,
197	"bounds to use during separation")
198ISL_ARG_BOOL(struct isl_options, ast_build_scale_strides, 0,
199	"ast-build-scale-strides", 1,
200	"allow iterators of strided loops to be scaled down")
201ISL_ARG_BOOL(struct isl_options, ast_build_allow_else, 0,
202	"ast-build-allow-else", 1, "generate if statements with else branches")
203ISL_ARG_BOOL(struct isl_options, ast_build_allow_or, 0,
204	"ast-build-allow-or", 1, "generate if conditions with disjunctions")
205ISL_ARG_VERSION(print_version)
206ISL_ARGS_END
207
208ISL_ARG_DEF(isl_options, struct isl_options, isl_options_args)
209
210ISL_ARG_CTX_DEF(isl_options, struct isl_options, isl_options_args)
211
212ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
213ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args, bound)
214
215ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
216	on_error)
217ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
218	on_error)
219
220ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
221	coalesce_bounded_wrapping)
222ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
223	coalesce_bounded_wrapping)
224
225ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
226	gbr_only_first)
227ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
228	gbr_only_first)
229
230ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
231	schedule_max_coefficient)
232ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
233	schedule_max_coefficient)
234
235ISL_CTX_SET_INT_DEF(isl_options, struct isl_options, isl_options_args,
236	schedule_max_constant_term)
237ISL_CTX_GET_INT_DEF(isl_options, struct isl_options, isl_options_args,
238	schedule_max_constant_term)
239
240ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
241	schedule_maximize_band_depth)
242ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
243	schedule_maximize_band_depth)
244
245ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
246	schedule_split_scaled)
247ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
248	schedule_split_scaled)
249
250ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
251	schedule_separate_components)
252ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
253	schedule_separate_components)
254
255ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
256	schedule_outer_zero_distance)
257ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
258	schedule_outer_zero_distance)
259
260ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
261	schedule_algorithm)
262ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
263	schedule_algorithm)
264
265ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
266	schedule_fuse)
267ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
268	schedule_fuse)
269
270ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
271	tile_scale_tile_loops)
272ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
273	tile_scale_tile_loops)
274
275ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
276	tile_shift_point_loops)
277ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
278	tile_shift_point_loops)
279
280ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
281	ast_build_atomic_upper_bound)
282ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
283	ast_build_atomic_upper_bound)
284
285ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
286	ast_build_prefer_pdiv)
287ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
288	ast_build_prefer_pdiv)
289
290ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
291	ast_build_exploit_nested_bounds)
292ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
293	ast_build_exploit_nested_bounds)
294
295ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
296	ast_build_group_coscheduled)
297ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
298	ast_build_group_coscheduled)
299
300ISL_CTX_SET_STR_DEF(isl_options, struct isl_options, isl_options_args,
301	ast_iterator_type)
302ISL_CTX_GET_STR_DEF(isl_options, struct isl_options, isl_options_args,
303	ast_iterator_type)
304
305ISL_CTX_SET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
306	ast_build_separation_bounds)
307ISL_CTX_GET_CHOICE_DEF(isl_options, struct isl_options, isl_options_args,
308	ast_build_separation_bounds)
309
310ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
311	ast_build_scale_strides)
312ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
313	ast_build_scale_strides)
314
315ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
316	ast_build_allow_else)
317ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
318	ast_build_allow_else)
319
320ISL_CTX_SET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
321	ast_build_allow_or)
322ISL_CTX_GET_BOOL_DEF(isl_options, struct isl_options, isl_options_args,
323	ast_build_allow_or)
324