00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Touati Sid * 00003 * Sid-nospam.Touati-nospam@univ-cotedazur.fr * 00004 * Copyright INRIA and the University of Versailles * 00005 * This program is free software; you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation; either version 2 of the License, or * 00008 * (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU Library General Public * 00016 * License along with this program (LGPL); if not, write to the * 00017 * Free Software Foundation, Inc., * 00018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00019 * Exception : this software requires a licence of the LEDA libary. * 00020 * If you are from academia, you can get a free leda binary licence 00021 * allowing you to use freely our DDG library. * 00022 * Otherwise, you can buy a LEDA licence from algorithmic-solutions * 00023 * http://www.algorithmic-solutions.com * 00024 * LEDA binaries and source codes are excluded from this LGPL. * 00025 * Obtaining a LEDA licence is not mandatory to use our GPL software * 00026 * If the user wants, he can create a free source-compatible replacement* 00027 * for LEDA, and he is allowed to use our software under LGPL. * 00028 ***************************************************************************/ 00029 00033 #include "DDG.h" // the header file of the DDG library. To be included by the user. 00034 00035 #include <iostream> 00036 #include <cstdlib> 00037 00038 00039 using namespace std; 00040 using namespace DDG; // the namespace of the DDG library. 00041 00042 char *getStringForArgument(char * s, int argc, char *argv[]) 00043 { 00044 for (int i = 1 ; i<argc; i++) 00045 { 00046 if (strcmp(argv[i],s) == 0) 00047 { 00048 if (i+1<argc){ 00049 return argv[i+1];} 00050 else 00051 fprintf(stderr,"Argument value missing for %s\n",s); 00052 return(NULL); 00053 } 00054 } 00055 return(NULL); 00056 } 00057 00058 00059 int main(int argc, char *argv[]) 00060 { 00061 // some strings for file names 00062 char *ifi; 00063 char cc[400], str[400]; 00064 00065 // some objects for graphs 00066 DDG::LOOP loop; //declare a DDG of a loop (cyclic data dependence graph) 00067 ARCHITECTURE isa_example; 00068 00069 ifi = getStringForArgument("-i",argc,argv); 00070 if (ifi==NULL) { // no line commande arguments 00071 cout<<"gl2vcg exports a DDG from gl format to xvcg format for visualization"<<endl; 00072 cout<<"usage: gl2vcg -i inputDDG.gl -o outputDDG.vcg [-a arch_desc]"<<endl; 00073 return EXIT_FAILURE; 00074 } 00075 strcpy(cc,ifi); 00076 00077 ifi = getStringForArgument("-a",argc,argv); 00078 //check wether the user specifies an ISA description or not 00079 if (ifi!=NULL) { 00080 //build an empty DDG loop with a user defined ISA description 00081 isa_example.read_from_arch(ifi); 00082 if (isa_example.check()) 00083 loop=LOOP(isa_example); 00084 else exit(1); 00085 } 00086 00087 loop.read_from_gl(cc); // reads the DDG loop from a gl file 00088 00089 ifi = getStringForArgument("-o",argc,argv); 00090 if (ifi==NULL) { // no line commande arguments 00091 cout<<"gl2vcg exports a DDG from gl format to xvcg format for visualization"<<endl; 00092 cout<<"usage: gl2vcg -i inputDDG.gl -o outputDDG.vcg [-a arch_desc]"<<endl; 00093 return EXIT_FAILURE; 00094 } 00095 //outputs the DDG loop to a vcg file to be visualized by the xvcg tool 00096 loop.write_to_vcg(ifi); 00097 return EXIT_SUCCESS; 00098 } 00099