5 #include "converter/converter.h"
10 printf("./converter 0 scoplib_scop_filename\n");
11 printf("./converter 1 osl_scop_filename\n");
14 int main( int argc
, char* argv
[]){
16 if(argc
<3 || argc
>3 ||
17 (strtol(argv
[0],NULL
,10)!=0 && strtol(argv
[0],NULL
,10)!=1) ){
23 //read osl scop from file
24 FILE * infile
= fopen( argv
[2], "r");
26 fprintf(stderr
, "Error: Unable to open infile:%s\n", argv
[2]);
31 scoplib_scop_p scop0
= NULL
;
32 osl_scop_p scop1
= NULL
;
34 if(strtol(argv
[1],NULL
, 10)==0){
35 printf("reading scoplib_scop\n");
36 scop0
= scoplib_scop_read( infile
);
37 //scoplib_scop_print_structure(stdout, scop0, 0);
38 //scoplib_scop_print_dot_scop(stdout, scop0);
39 printf("read scoplib_scop\n");
40 scop1
= convert_scop_scoplib2osl(scop0
);
41 printf("converted scoplib_scop to osl_scop\n");
42 // print osl scop to file
43 sprintf(o_filename
, "%s.osl", argv
[2]);
44 FILE *outfile0
= fopen(o_filename
, "w+");
45 osl_scop_print(outfile0
, scop1
);
47 printf("OSL scop printed to file\n");
50 printf("reading osl_scop\n");
51 scop1
= osl_scop_read ( infile
);
52 printf("read osl_scop\n");
57 //printf("oritinal scop:\n");
58 //osl_relation_print(stdout, scop1->context);
60 //convert osl to scoplib
61 scoplib_scop_p scop2
= convert_scop_osl2scoplib(scop1
);
63 printf("OSL to Scoplib conversion failed\n");
64 //scoplib_scop_print_structure(stdout, scop2, 0);
65 //print scoplib scop to file
66 sprintf(o_filename
, "%s.scoplib", argv
[2]);
67 FILE *outfile
= fopen(o_filename
, "w+");
68 scoplib_scop_print_dot_scop(outfile
, scop2
);
69 //printf("scoptagoptions:\n%s\n", scop2->optiontags);
71 printf("Scoplib scop printed to file\n");
72 //manually generate code and compare to original
73 //read scoplib scop from file
75 FILE *infile2
= fopen(o_filename
, "r");
76 scoplib_scop_p scop3
= NULL
;
77 scop3
= scoplib_scop_read( infile2
);
80 //scoplib_scop_print_structure(stdout, scop3, 0);
81 //printf("Scoplib scop read from file\n");
86 // convert scoplib to osl
87 osl_scop_p scop4
= convert_scop_scoplib2osl( scop2
);
90 printf("Scoplib scop converted to OSL scop\n");
93 // print osl scop to file
94 sprintf(o_filename
, "%s.scoplib.osl", argv
[2]);
95 FILE *outfile2
= fopen(o_filename
, "w+");
96 osl_scop_print(outfile2
, scop4
);
98 printf("OSL scop printed to file\n");
99 //manually generate code and compare to original
105 if(strtol(argv
[1],NULL
, 10)==1){
107 printf("scop1 language = %s\n", scop1
->language
);
108 CONVERTER_strdup(scop4
->language
, scop1
->language
);
110 if( convert_osl_scop_equal(scop1
, scop4
) )
111 printf("OSL -> Scoplib -> OSL works :D\n");
113 printf("OSL -> Scoplib -> OSL failed :(\n");
118 if( convert_scoplib_scop_equal(scop0
, scop2
) )
119 printf("Scoplib -> OSL -> Scoplib works :D\n");
121 printf("Scoplib -> OSL -> Scoplib failed :(\n");
127 if(scop0
) scoplib_scop_free( scop0
);
129 osl_statement_p stmt
= scop1
->statement
;
131 candl_statement_usr_cleanup(stmt
);
134 osl_scop_free( scop1
);
137 osl_statement_p stmt
= scop4
->statement
;
139 candl_statement_usr_cleanup(stmt
);
142 osl_scop_free( scop4
);
144 if(scop2
) scoplib_scop_free (scop2
);
145 if(scop3
) scoplib_scop_free (scop3
);