instructions_types.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 __instructions_types_H
00031 #define __instructions_types_H
00032 
00037 #include <LEDA/core/list.h>
00038 #include <LEDA/core/d_array.h>
00039 #include "register_types.h"
00040 using namespace std;
00041 namespace DDG{
00042 
00043 
00062 class INSTRUCTIONS_TYPES{
00063     int inst_type_id;
00064     int lat; // hardware latency of the instruction in processor clock cycles
00065     int dr; // architecturally visible delay of reading from a register
00066     LEDA::d_array<int,int> dw; // architecturally visible delay of writing into a register 
00067     std::string str_opcode;
00068     bool write_into_reg;
00069     leda::list<int> list_reg_id;
00070     
00071     public:
00076         INSTRUCTIONS_TYPES() ;
00077 
00078         ~INSTRUCTIONS_TYPES(){}
00079         
00085         INSTRUCTIONS_TYPES(std::string sopcode, int id);
00086 
00087         
00093         INSTRUCTIONS_TYPES(const char *sopcode, int id);
00094 
00095     
00101         INSTRUCTIONS_TYPES(const char *sopcode, int id,  int latency);
00102 
00103 
00109         INSTRUCTIONS_TYPES(std::string sopcode, int id, int latency);
00110 
00111         INSTRUCTIONS_TYPES(const INSTRUCTIONS_TYPES &it);
00112 
00114         
00115         
00119         int opcode_id() const 
00120         {
00121             return inst_type_id;
00122         }
00123 
00125         int delta_r() const
00126         {
00127             return dr;
00128         }
00129         
00130     
00132         int delta_w(int regtype_id) const
00133         {
00134             if (dw.defined(regtype_id)&&is_value()) return dw[regtype_id];
00135             else return -1;
00136         }
00137 
00139         int latency() const
00140         {
00141             return lat;
00142         }
00143     
00144     
00146         std::string opcode() const 
00147         {
00148             return str_opcode;
00149         }
00151         const char *opcode_str() const 
00152         {
00153             return (str_opcode.c_str());
00154         }
00156         bool is_value()  const
00157         {
00158             return write_into_reg;
00159         }
00161         leda::list<int> get_list_reg_id(){
00162             return list_reg_id;
00163         }
00166         leda::list<int> get_list_regtypes_id() const;
00167         
00169         int nb_write_reg() const;
00170         
00172         bool is_value(int t)  const
00173         {
00174             return does_write_into_reg(t);
00175         }
00176     
00178         bool does_write_into_reg()  const
00179         {return is_value();}; 
00180         
00182         bool does_write_into_reg(int regtype_id)  const
00183         {
00184             return ( (list_reg_id.search(regtype_id)!=nil) && is_value());
00185         }; 
00187         bool check() const;
00189                
00193         void set_opcode_id(const int& theValue) 
00194         {
00195            inst_type_id = theValue;
00196         }
00197 
00199         void set_opcode(const std::string& theValue) 
00200         {
00201             str_opcode = theValue;
00202         }
00203     
00205         void set_delta_r(int dr_value);
00206 
00207     
00209         bool set_delta_w(int regtype_id, int dw_value) ;
00210 
00212         void set_latency(int latency_value) ;
00214         void add_write_reg_id(int t);
00216         void add_write_reg_id(int regtype_id, int deltaw);
00217         
00219 
00222     friend ostream& operator<<(ostream &os,  INSTRUCTIONS_TYPES x);
00223     
00225     friend istream& operator>>(istream &is, INSTRUCTIONS_TYPES & x);
00226     
00228         
00229 };
00230 
00231 
00236 bool operator==(INSTRUCTIONS_TYPES a, INSTRUCTIONS_TYPES b);
00237 
00238 
00239 }
00240 #endif

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