};
struct isl_arg bound_options_arg[] = {
-ISL_ARG_CHILD(struct bound_options, isl, "isl", isl_options_arg)
-ISL_ARG_BOOL(struct bound_options, verify, 'T', "verify", 0)
-ISL_ARG_BOOL(struct bound_options, print_all, 'A', "print-all", 0)
-ISL_ARG_BOOL(struct bound_options, continue_on_error, '\0', "continue-on-error", 0)
+ISL_ARG_CHILD(struct bound_options, isl, "isl", isl_options_arg, "isl options")
+ISL_ARG_BOOL(struct bound_options, verify, 'T', "verify", 0, NULL)
+ISL_ARG_BOOL(struct bound_options, print_all, 'A', "print-all", 0, NULL)
+ISL_ARG_BOOL(struct bound_options, continue_on_error, '\0', "continue-on-error", 0, NULL)
ISL_ARG_END
};
};
struct isl_arg cat_options_arg[] = {
-ISL_ARG_CHILD(struct cat_options, isl, "isl", isl_options_arg)
+ISL_ARG_CHILD(struct cat_options, isl, "isl", isl_options_arg, "isl options")
ISL_ARG_CHOICE(struct cat_options, format, 0, "format", \
- cat_format, ISL_FORMAT_ISL)
+ cat_format, ISL_FORMAT_ISL, "output format")
ISL_ARG_END
};
char short_name;
const char *long_name;
size_t offset;
+ const char *help_msg;
union {
struct {
struct isl_arg_choice *choice;
} u;
};
-#define ISL_ARG_CHOICE(st,f,s,l,c,d) { \
+#define ISL_ARG_CHOICE(st,f,s,l,c,d,h) { \
.type = isl_arg_choice, \
.short_name = s, \
.long_name = l, \
.offset = offsetof(st, f), \
+ .help_msg = h, \
.u = { .choice = { .choice = c, .default_value = d } } \
},
-#define ISL_ARG_BOOL(st,f,s,l,d) { \
+#define ISL_ARG_BOOL(st,f,s,l,d,h) { \
.type = isl_arg_bool, \
.short_name = s, \
.long_name = l, \
.offset = offsetof(st, f), \
+ .help_msg = h, \
.u = { .b = { .default_value = d } } \
},
-#define ISL_ARG_CHILD(st,f,l,c) { \
+#define ISL_ARG_CHILD(st,f,l,c,h) { \
.type = isl_arg_child, \
.long_name = l, \
.offset = offsetof(st, f), \
+ .help_msg = h, \
.u = { .child = { .child = c, .size = sizeof(*((st *)NULL)->f) } }\
},
#define ISL_ARG_END { isl_arg_end }
}
}
-static void print_arg_help(struct isl_arg *decl, const char *prefix)
+static int print_arg_help(struct isl_arg *decl, const char *prefix)
{
+ int len = 0;
+
if (decl->short_name)
printf(" -%c, --", decl->short_name);
else
printf(" --");
- if (prefix)
+ len += 8;
+
+ if (prefix) {
printf("%s-", prefix);
+ len += strlen(prefix) + 1;
+ }
printf("%s", decl->long_name);
+ len += strlen(decl->long_name);
+
+ return len;
+}
+
+const void *isl_memrchr(const void *s, int c, size_t n)
+{
+ const char *p = s;
+ while (n-- > 0)
+ if (p[n] == c)
+ return s + n;
+ return NULL;
+}
+
+static int print_help_msg(struct isl_arg *decl, int pos)
+{
+ int len;
+ const char *s;
+
+ if (!decl->help_msg)
+ return pos;
+
+ if (pos >= 29)
+ printf("\n%30s", "");
+ else
+ printf("%*s", 30 - pos, "");
+
+ s = decl->help_msg;
+ len = strlen(s);
+ while (len > 45) {
+ const char *space = isl_memrchr(s, ' ', 45);
+ int l;
+
+ if (!space)
+ space = strchr(s + 45, ' ');
+ if (!space)
+ break;
+ l = space - s;
+ printf("%.*s", l, s);
+ s = space + 1;
+ len -= l + 1;
+ printf("\n%30s", "");
+ }
+
+ printf("%s", s);
+ return len;
+}
+
+static void print_default_choice(struct isl_arg *decl, int pos)
+{
+ int i;
+ const char *default_prefix = "[default: ";
+ const char *default_suffix = "]";
+ const char *s = "none";
+ int len = strlen(default_prefix) + strlen(s) + strlen(default_suffix);
+
+ for (i = 0; decl->u.choice.choice[i].name; ++i)
+ if (decl->u.choice.choice[i].value == decl->u.choice.default_value) {
+ s = decl->u.choice.choice[i].name;
+ break;
+ }
+
+ if (!decl->help_msg) {
+ if (pos >= 29)
+ printf("\n%30s", "");
+ else
+ printf("%*s", 30 - pos, "");
+ pos = 0;
+ }
+
+ if (pos && pos + len >= 48)
+ printf("\n%30s", "");
+ else
+ printf(" ");
+ printf("%s%s%s", default_prefix, s, default_suffix);
}
static void print_choice_help(struct isl_arg *decl, const char *prefix)
{
int i;
+ int pos;
- print_arg_help(decl, prefix);
+ pos = print_arg_help(decl, prefix);
printf("=");
+ pos++;
for (i = 0; decl->u.choice.choice[i].name; ++i) {
- if (i)
+ if (i) {
printf("|");
+ pos++;
+ }
printf("%s", decl->u.choice.choice[i].name);
+ pos += strlen(decl->u.choice.choice[i].name);
}
+ pos = print_help_msg(decl, pos);
+ print_default_choice(decl, pos);
+
printf("\n");
}
static void print_bool_help(struct isl_arg *decl, const char *prefix)
{
- print_arg_help(decl, prefix);
+ int pos;
+ pos = print_arg_help(decl, prefix);
+ print_help_msg(decl, pos);
printf("\n");
}
struct isl_arg isl_options_arg[] = {
ISL_ARG_CHOICE(struct isl_options, lp_solver, 0, "lp-solver", \
- isl_lp_solver_choice, ISL_LP_TAB)
+ isl_lp_solver_choice, ISL_LP_TAB, "lp solver to use")
ISL_ARG_CHOICE(struct isl_options, ilp_solver, 0, "ilp-solver", \
- isl_ilp_solver_choice, ISL_ILP_GBR)
+ isl_ilp_solver_choice, ISL_ILP_GBR, "ilp solver to use")
ISL_ARG_CHOICE(struct isl_options, pip, 0, "pip", \
- isl_pip_solver_choice, ISL_PIP_TAB)
+ isl_pip_solver_choice, ISL_PIP_TAB, "pip solver to use")
ISL_ARG_CHOICE(struct isl_options, context, 0, "context", \
- isl_pip_context_choice, ISL_CONTEXT_GBR)
+ isl_pip_context_choice, ISL_CONTEXT_GBR,
+ "how to handle the pip context tableau")
ISL_ARG_CHOICE(struct isl_options, gbr, 0, "gbr", \
- isl_gbr_choice, ISL_GBR_ONCE)
+ isl_gbr_choice, ISL_GBR_ONCE,
+ "how often to use generalized basis reduction")
ISL_ARG_CHOICE(struct isl_options, closure, 0, "closure", \
- isl_closure_choice, ISL_CLOSURE_ISL)
-ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0)
+ isl_closure_choice, ISL_CLOSURE_ISL,
+ "closure operation to use")
+ISL_ARG_BOOL(struct isl_options, gbr_only_first, 0, "gbr-only-first", 0,
+ "only perform basis reduction in first direction")
ISL_ARG_END
};
};
struct isl_arg pip_options_arg[] = {
-ISL_ARG_CHILD(struct pip_options, isl, "isl", isl_options_arg)
-ISL_ARG_BOOL(struct pip_options, verify, 'T', "verify", 0)
+ISL_ARG_CHILD(struct pip_options, isl, "isl", isl_options_arg, "isl options")
+ISL_ARG_BOOL(struct pip_options, verify, 'T', "verify", 0, NULL)
ISL_ARG_END
};