info_node.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  
00030 #ifndef __info_node_H
00031 #define __info_node_H
00032 
00033 #include "instructions_types.h"
00034 #include <string> 
00039 using namespace std;
00040 namespace DDG{
00041 class INFO_NODE;
00042 class INFO_EDGE;
00043 class DAG;
00044 class LOOP;
00045 
00051 typedef enum {
00052   NodeFlag_Nothing = 0x0,     // Operation has no flag
00053   NodeFlag_PartialDef = 0x1,       // Operation is partial definition.
00054   NodeFlag_SpillCode = 0x2,        // Operation is spill code.
00055   NodeFlag_Volatile = 0x4,         // Operation has volatile effects.
00056   NodeFlag_SPUpdate = 0x8,         // Operation is a SP update.
00057   NodeFlag_Prefetch = 0x10,        // Operation is a memory prefetch.
00058   NodeFlag_Preload = 0x20,         // Operation is a memory preload.
00059   NodeFlag_Barrier = 0x40,         // Operation is a memory barrier.
00060   NodeFlag_Clobber = 0x80,         // Operation has a clobber RegisterSet.
00061   NodeFlag_Hoisted = 0x100,        // Operation has been hoisted from loop.
00062   NodeFlag_DeadCode = 0x200,       // Operation is dead code.
00063   NodeFlag_SafeAccess = 0x800,     // Operation is safe for side-effects.
00064   NodeFlag_SafePerfs = 0x1000,     // Operation is safe for performances.
00065   NodeFlag_EntryCode = 0x4000,     // Operation is part of Procedure entry.
00066   NodeFlag_ExitCode = 0x8000,      // Operation is part of Procedure exit.
00067   NodeFlag_KillOp = 0x5000,       // Operation is a kill node
00068 } NodeFlag;
00069 
00070 
00083 class INFO_NODE {
00084   friend class DDG::DAG;
00085   friend class DDG::LOOP;
00086   
00087   int identifier;
00088     std::string text; // the textual representation of the instruction, for instance "X=R+455". Not currently used
00089   INSTRUCTIONS_TYPES optype;
00090   NodeFlag node_flag;
00091     
00093   void set_id(int id)   {identifier=id;}
00094   
00095  public:
00101     INFO_NODE() ;
00102 
00103      
00108     INFO_NODE(int id, INSTRUCTIONS_TYPES opt);
00109 
00110     INFO_NODE(const INFO_NODE &in);
00111 
00117     INFO_NODE(int id, INSTRUCTIONS_TYPES opt, std::string inst_text);
00118            
00120      
00124     bool check();
00125     
00127     const int id() const
00128     {return identifier;} 
00129     
00131     const  INSTRUCTIONS_TYPES instruction_type() const
00132     {return optype;}
00133 
00135     std::string get_string_attribute() const
00136     {return text;}
00139     int instruction_type_id() const
00140     {
00141         return optype.opcode_id();
00142     }   
00144     NodeFlag get_node_flag() const
00145     {
00146         return node_flag;
00147     }
00149            
00153     void set_instruction_type(INSTRUCTIONS_TYPES opt)
00154     {optype=opt;}
00155 
00162     void set_string_attribute(std::string inst_text)
00163     {text=inst_text;}
00165     void set_node_flag ( const NodeFlag theValue )
00166     {
00167         node_flag = theValue;
00168     }
00170 
00173      friend ostream& operator<<(ostream &os,  INFO_NODE x) ;
00174      
00177      friend istream& operator>>(istream &is, INFO_NODE & x);
00178    
00179 
00180     
00182     
00183 }
00184 ;  
00185 
00186 }
00187 #endif

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