Otawa  0.10
Register.h
Go to the documentation of this file.
1 /*
2  * $Id$
3  * Register and RegBank classes interface
4  *
5  * This file is part of OTAWA
6  * Copyright (c) 2003-08, IRIT UPS.
7  *
8  * OTAWA is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * OTAWA is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with OTAWA; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22 #ifndef OTAWA_HARD_REGISTER_H
23 #define OTAWA_HARD_REGISTER_H
24 
25 #include <elm/assert.h>
26 #include <elm/string.h>
27 #include <elm/genstruct/Table.h>
28 #include <elm/io.h>
29 
30 namespace otawa { namespace hard {
31 
32 // Predeclaration of classes
33 class Platform;
34 class Register;
35 class RegBank;
36 
37 // Register class
38 class Register {
39 public:
40  typedef enum kind_t {
41  NONE = 0,
43  INT,
46  } kind_t;
47 
48  Register(const elm::String& name, kind_t kind, int size);
49  inline int number(void) const { return _number; }
50  inline RegBank *bank(void) const { return _bank; }
51  inline const elm::String& name(void) const { return _name; }
52  inline kind_t kind(void) const { return _kind; }
53  inline int size(void) const { return _size; }
54  inline int platformNumber(void) const { return pfnum; }
55 
56 private:
57  friend class Platform;
58  friend class RegBank;
59  int _number;
61  int _size;
64  int pfnum;
65 };
66 
67 // RegBank class
68 class RegBank {
69  friend class Register;
70 public:
71  inline elm::CString name(void) const { return _name; }
72  inline Register::kind_t kind(void) const { return _kind; }
73  inline int size(void) const { return _size; }
74  inline int count(void) const { return _regs.count(); }
75  inline Register *get(int index) const { ASSERT(index < _regs.count()); return _regs[index]; }
76  inline Register *operator[](int index) const { return get(index); }
77  inline const elm::genstruct::Table<Register *>& registers() const { return _regs; }
78 protected:
81  int _size;
85  inline ~RegBank(void) { };
86  inline void set(int index, Register *reg)
87  { ASSERT(index < _regs.count()); reg->_number = index; _regs[index] = reg; reg->_bank = this; }
88 };
89 
90 
91 // PlainBank class
92 class PlainBank: public RegBank {
93 public:
95  elm::CString pattern, int count);
96  ~PlainBank(void);
97 };
98 
99 
100 // MeltedBank class
101 class MeltedBank: public RegBank {
102 public:
104  ~MeltedBank(void);
105 };
106 
108  out << reg->name();
109  return out;
110 }
111 
112 
113 } } // otawa::hard
114 
115 #endif // OTAWA_HARD_REGISTER_H
Register::kind_t kind(void) const
Get the kind of registers in the bank.
Definition: Register.h:72
This class represents a bank of registers.
Definition: Register.h:68
MeltedBank(elm::CString name,...)
Build a melted bank with the registers passed in the variable list arguments (ended by null)...
Definition: hard_Register.cpp:291
A register specialized for containing float value.
Definition: Register.h:44
int _size
Definition: Register.h:81
A register specialized for containing an address.
Definition: Register.h:42
RegBank * bank(void) const
Get the owner bank of the register.
Definition: Register.h:50
const elm::genstruct::Table< Register * > & registers() const
Definition: Register.h:77
int count(void) const
Get the count of register in the bank.
Definition: Register.h:74
elm::String _name
Definition: Register.h:62
A melted bank may contains registers with different sizes and kinds.
Definition: Register.h:101
RegBank * _bank
Definition: Register.h:63
int _size
Definition: Register.h:61
int number(void) const
Get the register number.
Definition: Register.h:49
uint32 size
int _number
Definition: Register.h:59
~PlainBank(void)
Definition: hard_Register.cpp:271
io::Output & operator<<(io::Output &out, const Platform::Identification &id)
Definition: Platform.h:140
kind_t _kind
Definition: Register.h:60
RegBank(elm::CString name, Register::kind_t kind, int size)
Buil a new register bank.
Definition: hard_Register.cpp:183
elm::CString _name
Definition: Register.h:79
int size(void) const
Get the size, in bits, of the registers in the bank.
Definition: Register.h:73
kind_t
This enumeration represents the differents kind of value found in hardware registers.
Definition: Register.h:40
void set(int index, Register *reg)
Definition: Register.h:86
A register specialized for containing an integer value.
Definition: Register.h:43
int pfnum
Definition: Register.h:64
sys::SystemOutStream & out
PlainBank(elm::CString name, Register::kind_t kind, int size, elm::CString pattern, int count)
Buila new plain bank.
Definition: hard_Register.cpp:260
~MeltedBank(void)
Definition: hard_Register.cpp:308
This class records information about the architecture where the processed program will run...
Definition: Platform.h:48
This kind defines registers not specialized in other kinds.
Definition: Register.h:45
int size(void) const
Definition: Register.h:53
int platformNumber(void) const
Gives a number which is unique for this platform.
Definition: Register.h:54
Usually only used as null value for register kinds.
Definition: Register.h:41
elm::genstruct::AllocatedTable< Register * > _regs
Definition: Register.h:82
~RegBank(void)
Definition: Register.h:85
const elm::String & name(void) const
Get the name of the register.
Definition: Register.h:51
Register * operator[](int index) const
Short to RegBank::get().
Definition: Register.h:76
Register(const elm::String &name, kind_t kind, int size)
Build a new register.
Definition: hard_Register.cpp:129
Objects of this class are simple machine register, more accurately unbreakable atomic registers...
Definition: Register.h:38
kind_t kind(void) const
Get the kind of a register.
Definition: Register.h:52
Register::kind_t _kind
Definition: Register.h:80
elm::CString name(void) const
Get the name of the bank.
Definition: Register.h:71
A plain bank is a register bank whose registers have the same size and the same type.
Definition: Register.h:92