44 #include <osl/macros.h> 45 #include <clan/macros.h> 62 fprintf(foo,
"Options:\n");
64 if (options->
name != NULL)
65 fprintf(foo,
"name = %s,\n", options->
name);
67 fprintf(foo,
"name = NULL,\n");
69 fprintf(foo,
"castle = %3d,\n", options->
castle);
70 fprintf(foo,
"structure = %3d.\n", options->
structure);
71 fprintf(foo,
"autoscop = %3d.\n", options->
autoscop);
72 fprintf(foo,
"autopragma = %3d.\n", options->
autopragma);
73 fprintf(foo,
"autoinsert = %3d.\n", options->
autoinsert);
74 fprintf(foo,
"inputscop = %3d.\n", options->
inputscop);
76 fprintf(foo,
"noloopcontext = %3d.\n", options->
noloopcontext);
77 fprintf(foo,
"nosimplify = %3d.\n", options->
nosimplify);
78 fprintf(foo,
"extbody = %3d.\n", options->
extbody);
111 "Usage: clan [ options | file ] ...\n");
113 "\nGeneral options:\n" 114 " -o <output> Name of the output file; 'stdout' is a special\n" 115 " value: when used, output is standard output\n" 116 " (default setting: stdout).\n" 117 " -autoscop Automatic SCoP extraction.\n" 118 " -autopragma Automatic insertion of SCoP pragmas in input code.\n" 119 " -autoinsert Automatic insertion of SCoP pragmas in input file.\n" 120 " -inputscop Read a .scop as the input.\n" 121 " -precision <value> 32 to work in 32 bits, 64 for 64 bits, 0 for GMP.\n" 122 " -boundedctxt Bound all global parameters to be >= -1.\n" 123 " -noloopctxt Do not include loop context (simplifies domains).\n" 124 " -nosimplify Do not simplify iteration domains.\n" 125 " -outscoplib Print to the SCoPLib format.\n" 126 " -extbody Will generate the extbody.\n" 127 " -v, --version Display the release information (and more).\n" 128 " -h, --help Display this information.\n\n");
130 "The special value 'stdin' for 'file' or the special option '-' makes clan\n" 131 "to read data on standard input.\n\n" 132 "For bug reporting or any suggestions, please send an email to the author\n" 133 "Cedric Bastoul <cedric.bastoul@inria.fr>.\n");
144 printf(
"clan %s ", CLAN_VERSION);
145 printf(
" The Chunky Loop Analyzer\n");
149 "This is a polyhedral representation extractor for imperative programs using " 150 "a C\ngrammar for control flow and array accesses (this includes C, C++," 151 " Java, C#\nand probably few toy languages too). This program is distributed " 152 "under the\nterms of the GNU Lesser General Public License, see details of " 153 "the licence at\nhttp://www.gnu.org/copyleft/lgpl.html\n" 156 "It would be fair to refer the following paper in any publication " 157 "resulting from\nthe use of this software or its library (it defines SCoPs):\n" 158 "@InProceedings{Bas03,\n" 159 "author = {Cedric Bastoul and Albert Cohen and Sylvain Girbal and\n" 160 " Saurabh Sharma and Olivier Temam},\n" 161 "title = {Putting Polyhedral Loop Transformations to Work},\n" 162 "booktitle = {LCPC'16 International Workshop on Languages and\n" 163 " Compilers for Parallel Computers, LNCS 2958},\n" 164 "pages = {209--225},\n" 165 "month = {october},\n" 167 "address = {College Station, Texas}\n" 171 "For any information, please send an email to the author\n" 172 "Cedric Bastoul <cedric.bastoul@inria.fr>.\n");
188 if (*number+1 >= argv)
189 CLAN_error(
"an option lacks of argument");
192 *option = strtol(argc[*number+1], endptr, 10);
193 if (endptr != NULL) {
194 fprintf(stderr,
"[Clan] Error: %s value for %s option is not valid.\n",
195 argc[*number + 1], argc[*number]);
198 *number = *number + 1;
215 options->
name = NULL;
244 char*** input_files, FILE** output) {
245 int i, infos=0, input_is_stdin=0;
247 int nb_input_files = 0;
257 CLAN_malloc(*input_files,
char**,
sizeof(
char*));
258 (*input_files)[0] = NULL;
260 for (i=1; i < argv; i++) {
261 if (argc[i][0] ==
'-') {
262 if (argc[i][1] ==
'\0') {
266 CLAN_realloc(*input_files,
char**,
sizeof(
char*) * (nb_input_files+1));
267 CLAN_strdup((*input_files)[nb_input_files-1],
"stdin");
268 (*input_files)[nb_input_files] = NULL;
270 }
else if (strcmp(argc[i],
"-castle") == 0) {
272 }
else if (strcmp(argc[i],
"-structure") == 0) {
274 }
else if (strcmp(argc[i],
"-autoscop") == 0) {
276 }
else if (strcmp(argc[i],
"-autopragma") == 0) {
279 }
else if (strcmp(argc[i],
"-autoinsert") == 0) {
282 }
else if (strcmp(argc[i],
"-inputscop") == 0) {
284 }
else if (strcmp(argc[i],
"-boundedctxt") == 0) {
286 }
else if (strcmp(argc[i],
"-noloopctxt") == 0) {
288 }
else if (strcmp(argc[i],
"-nosimplify") == 0) {
290 }
else if (strcmp(argc[i],
"-outscoplib") == 0) {
292 }
else if (strcmp(argc[i],
"-extbody") == 0) {
294 }
else if (strcmp(argc[i],
"-precision") == 0) {
296 }
else if ((strcmp(argc[i],
"--help") == 0) ||
297 (strcmp(argc[i],
"-h") == 0)) {
300 }
else if ((strcmp(argc[i],
"--version") == 0) ||
301 (strcmp(argc[i],
"-v") == 0)) {
304 }
else if (strcmp(argc[i],
"-o") == 0) {
306 CLAN_error(
"no output name for -o option");
309 if (strcmp(argc[i+1],
"stdout") == 0) {
312 *output = fopen(argc[i+1],
"w");
314 CLAN_error(
"cannot open the output file");
318 fprintf(stderr,
"[Clan] Warning: unknown %s option.\n", argc[i]);
321 if (!input_is_stdin) {
323 CLAN_realloc(*input_files,
char**,
sizeof(
char*) * (nb_input_files+1));
324 CLAN_strdup((*input_files)[nb_input_files-1], argc[i]);
325 (*input_files)[nb_input_files] = NULL;
327 if (strcmp(argc[i],
"stdin") == 0) {
332 CLAN_error(
"Cannot have multiple input files with stdin");
337 if ((options->
precision != OSL_PRECISION_MP) &&
338 (options->
precision != OSL_PRECISION_SP) &&
339 (options->
precision != OSL_PRECISION_DP))
340 CLAN_error(
"invalid precision (use 32, 64 or 0 for GMP)");
344 CLAN_error(
"autoscop/autopragma/autoinsert options need an input file");
346 if (!input_is_stdin && !nb_input_files && !infos)
347 CLAN_error(
"no input file (-h for help)");
359 static char clan_autopragma_filename[128] = { 0 };
360 if (!clan_autopragma_filename[0])
362 strcpy(clan_autopragma_filename,
"/tmp/clan_autopragmaXXXXXX");
363 int fd = mkstemp(clan_autopragma_filename);
365 CLAN_error(
"mkstemp");
366 if (unlink(clan_autopragma_filename) == -1)
367 CLAN_error(
"unlink");
372 return clan_autopragma_filename;
void clan_options_version()
clan_options_p clan_options_read(int argv, char **argc, char ***input_files, FILE **output)
void clan_options_free(clan_options_p options)
const char * clan_options_autopragma_file(void)
clan_options_p clan_options_malloc(void)
void clan_options_set(int *option, int argv, char **argc, int *number)
void clan_options_print(FILE *foo, clan_options_p options)