Registers.h

Go to the documentation of this file.
00001 #ifndef ROSE_BINARY_REGISTERS_H
00002 #define ROSE_BINARY_REGISTERS_H
00003 
00004 #include <map>
00005 #include <string>
00006 
00025 class RegisterDictionary {
00026 public:
00027     typedef std::map<std::string/*name*/, RegisterDescriptor> Entries;
00028 
00029     /* Functions that return a dictionary for a particular machine architecute. (See implementation for documentation.) */
00030     static const RegisterDictionary *dictionary_i8086();
00031     static const RegisterDictionary *dictionary_i8088();
00032     static const RegisterDictionary *dictionary_i286();
00033     static const RegisterDictionary *dictionary_i386();
00034     static const RegisterDictionary *dictionary_i486();
00035     static const RegisterDictionary *dictionary_pentium();
00036     static const RegisterDictionary *dictionary_pentium4();
00037     static const RegisterDictionary *dictionary_amd64();
00038     static const RegisterDictionary *dictionary_arm7();
00039     static const RegisterDictionary *dictionary_powerpc();
00040 
00041     RegisterDictionary(const std::string &name)
00042         :name(name) {}
00043     RegisterDictionary(const RegisterDictionary& other) {
00044         *this = other;
00045     }
00046 
00048     const std::string &get_architecture_name() const {
00049         return name;
00050     }
00051 
00054     void set_architecture_name(const std::string &name) {
00055         this->name = name;
00056     }
00057 
00060     void insert(const std::string &name, const RegisterDescriptor&);
00061 
00064     void insert(const std::string &name, unsigned majr, unsigned minr, unsigned offset, unsigned nbits);
00065 
00068     void insert(const RegisterDictionary*);
00069 
00072     void insert(const RegisterDictionary&);
00073 
00077     void resize(const std::string &name, unsigned new_nbits);
00078 
00082     const RegisterDescriptor *lookup(const std::string &name) const;
00083 
00086     const std::string &lookup(const RegisterDescriptor&) const;
00087 
00089     const Entries& get_registers() const;
00091     Entries& get_registers();
00092 
00095     void print(std::ostream&) const;
00096     friend std::ostream& operator<<(std::ostream&, const RegisterDictionary&);
00097 
00098 private:
00099     typedef std::map<uint64_t/*desc_hash*/, std::vector<std::string> > Reverse;
00100     static uint64_t hash(const RegisterDescriptor&);
00101     std::string name; /*name of the dictionary, usually an architecture name like 'i386'*/
00102     Entries forward;
00103     Reverse reverse;
00104 
00105 };
00106 
00107 #endif 

Generated on Wed May 16 06:18:11 2012 for ROSE by  doxygen 1.4.7