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 __architecture_H
00031 #define __architecture_H
00032
00040 #endif
00041 #ifndef DDGARCHITECTURE_H
00042 #define DDGARCHITECTURE_H
00043
00044 #include <LEDA/core/list.h>
00045 #include <LEDA/core/d_array.h>
00046 #include "ddg_exceptions.h"
00047
00048 #include "instructions_types.h"
00053 #ifndef MAX_STRING
00054 #define MAX_STRING 1000
00055 #endif
00056 namespace DDG {
00057
00061 class ARCHITECTURE{
00062 protected:
00063 int cpt_regtypes;
00064 int cpt_instructions_types;
00065 bool default_arch;
00066 bool is_ual_semantic;
00067 private:
00068 LEDA::d_array<int,REGISTER_TYPES> reg_types;
00069 LEDA::d_array<int,INSTRUCTIONS_TYPES> inst_types;
00070 public:
00071 ARCHITECTURE();
00072 ~ARCHITECTURE();
00073 bool read_from_xml(const char *);
00074 bool read_from_arch(const char *);
00075 void clear();
00076 bool check() const;
00077 void write_to_xml(const char*) const;
00078 LEDA::list<int> get_list_regtypes_id() const;
00079 LEDA::list<int> get_list_instructions_types_id() const;
00080 LEDA::d_array<int,REGISTER_TYPES> get_dictionary_regtypes() const {return reg_types;}
00081 LEDA::d_array<int,INSTRUCTIONS_TYPES> get_dictionary_instructions_types() const {return inst_types;}
00082
00083
00084 int get_register_type_id(std::string regtype_name) const;
00085 std::string get_register_typename(int regtype_id) const;
00086 bool exist_register_typename(std::string reg_typename) const;
00087 bool exist_register_type_id(int registertype_id) const;
00088 bool exist_instruction_type_id(int id) const;
00089 bool exist_instruction_type_opcode(std::string opcode) const;
00090
00091 int create_new_instruction_type_id();
00092 int create_new_regtype_id();
00093 void set_default_arch();
00094 void new_register_type(REGISTER_TYPES rt);
00095 void new_instruction_type(INSTRUCTIONS_TYPES it);
00096
00101 bool is_default_arch()
00102 {
00103 return default_arch;
00104 }
00105
00110 bool get_ual_semantic() const{
00111 return is_ual_semantic;
00112 }
00113
00118 void set_ual_semantic(bool ual){
00119 is_ual_semantic = ual;
00120 }
00121
00127 REGISTER_TYPES get_register_type_by_id(int id) const
00128 {
00129 if (exist_register_type_id(id)) return reg_types[id];
00130 else {
00131 throw BadRegType();
00132 }
00133 }
00134
00140 INSTRUCTIONS_TYPES get_instruction_type_by_id(int id) const
00141 {
00142 if (exist_instruction_type_id(id)) return inst_types[id];
00143 else throw BadInstructionType(id);
00144 }
00145 int number_of_registers_types() const;
00146 int number_of_instructions_types() const;
00147 int get_the_unique_register_type_id() const;
00148 INSTRUCTIONS_TYPES get_instruction_type_by_opcode(std::string opcode) const;
00149 void write_to_arch(const char * filename) const;
00150 LEDA::list<REGISTER_TYPES> get_list_register_types() const;
00155 LEDA::list<REGISTER_TYPES> T() const {return get_list_register_types();}
00156 int pick_an_instruction_type_id() const;
00157
00162 int get_instruction_type_id(std::string stropcode)const
00163 {
00164 return (this->get_instruction_type_by_opcode(stropcode)).opcode_id();
00165 }
00166
00167
00168 };
00169
00170 }
00171
00172 #endif