info_edge.h

Go to the documentation of this file.
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 #ifndef __info_edge_H
00030 #define __info_edge_H
00031 #include <iostream>
00032 #include <string> 
00037 using namespace std;
00038 namespace DDG{
00039 class INFO_NODE;
00040 class INFO_EDGE;
00041 class DAG;
00042 class LOOP;
00043 
00044 /******************** List of Types *****************/
00045 
00050 typedef enum  {
00051 flowdep_reg=1, // flow dependence through register
00052 antidep_reg, // WAR dependence through register
00053 outputdep_reg, // WAW dependence through register
00054 inputdep_reg, // RAR dependence through register
00055 flowdep_mem, // flow dependence through memory
00056 antidep_mem, // WAR dependence through memory
00057 outputdep_mem, // WAW dependence through memory
00058 inputdep_mem, // RAR dependence through memory
00059 spilldep_mem, //Spill memory dependence arc
00060 other_mem, // other dependence through memory
00061 serial, // any serial arc
00062 killerdep,  // Register consumer node to its killer node.
00063 reusedep,  // Register reuse edge, from a killer to a producer node.
00064 } edge_type; /* flow if flow dep through register */
00068 std::string  edge_type_to_string(const edge_type);
00069 
00073 edge_type  string_to_edge_type(const std::string);
00074 
00084 class INFO_EDGE
00085 {
00086   friend class DDG::DAG;
00087   friend class DDG::LOOP;
00088   edge_type kind;
00089   int duration;
00090   int distance;
00091   int regtype_id;
00092   double val_duration; 
00093   double sigma() const
00094   {return val_duration;}
00095   void set_sigma(double val)
00096   {val_duration=val;}
00097   
00098   public:
00104     INFO_EDGE() ;
00105 
00109     INFO_EDGE(edge_type et) ;
00110 
00112     INFO_EDGE(int dur, int dis, edge_type et);
00113 
00117     INFO_EDGE(int dur, edge_type et);
00118 
00119     
00120     INFO_EDGE(const INFO_EDGE &ie);
00121 
00123     
00127     bool is_flow() const
00128     {if (kind==flowdep_reg || kind==flowdep_mem) return true; else return false;}
00129     
00130 
00131 
00133     edge_type etype() const
00134     {return kind;}
00135         
00137     int delta() const
00138     {return duration;}
00139     
00141     int lambda() const
00142     {return distance;}
00144     bool check();
00146     int get_register_type_id() const {return regtype_id;}
00148     bool is_flow_reg(int regtypeid) const;
00150     bool is_flow_reg() const;
00152     bool is_dep_reg() const;
00154     
00157     
00159     void set_etype( const edge_type& et )
00160     {
00161         kind = et;
00162     }
00163     
00165     bool set_register_type_id(int regtypeid);
00166 
00168     void set_delta(int val)
00169     {duration=val; val_duration=(double) val;}
00170     
00172     void set_lambda(int lambda) 
00173     {distance=lambda;}
00174     
00176 
00182     friend ostream& operator<<(ostream &os,  INFO_EDGE x) ; 
00183     
00187     friend istream& operator>>(istream &is, INFO_EDGE & x);  
00188     
00189 
00191 };
00192 
00193 
00197 bool operator==(const INFO_EDGE, const INFO_EDGE);
00198 }
00199 #endif

January 2009, by Sid Touati (Copyright INRIA and University of Versailles)