00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
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;
00065 int dr;
00066 LEDA::d_array<int,int> dw;
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