Otawa  0.10
Platform.h
Go to the documentation of this file.
1 /*
2  * Platform class implementation
3  *
4  * This file is part of OTAWA
5  * Copyright (c) 2005-13, IRIT UPS.
6  *
7  * OTAWA is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 2 of the License, or
10  * (at your option) any later version.
11  *
12  * OTAWA is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with OTAWA; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 #ifndef OTAWA_HARD_PLATFORM_H
22 #define OTAWA_HARD_PLATFORM_H
23 
24 #include <elm/system/Path.h>
25 #include <otawa/properties.h>
26 #include <otawa/hard/Register.h>
27 #include <otawa/prog/Manager.h>
28 
29 // External classes
30 namespace elm {
31  namespace xom {
32  class Element;
33  }
34 }
35 
36 namespace otawa {
37 
38 class Manager;
39 
40 namespace hard {
41 
42 // Extern Classes
43 class CacheConfiguration;
44 class Memory;
45 class Processor;
46 
47 // Platform class
48 class Platform {
49 public:
51 
52  static const elm::String ANY;
53 
54  // Architecture
55  static const elm::String POWERPC;
56 
57  // ABI
58  static const elm::String ELF;
59  static const elm::String EABI;
60  static const elm::String LINUX;
61  static const elm::String LINUX_2_4;
62  static const elm::String LINUX_2_6;
63 
64  // Platform
65  static const elm::String MAC;
66  static const elm::String SIM;
67 
68  // Platform identification
74  void split(void);
75  public:
77  Identification(const elm::String& arch, const elm::String& abi,
78  const elm::String& mach = ANY);
79  inline const elm::String& name(void) const;
80  inline const elm::String& architecture(void) const;
81  inline const elm::String& abi(void) const;
82  inline const elm::String& machine(void) const;
83  bool matches(const Identification& id);
85  void print(io::Output& out) const;
86  };
87 
88  // Constructors
90  Platform(const Identification& id, const PropList& props = PropList::EMPTY);
91  Platform(const Platform& platform, const PropList& props = PropList::EMPTY);
92 
93  // Identification
94  inline const Identification& identification(void) const;
95  virtual bool accept(const Identification& id);
96  inline bool accept(elm::CString name);
97  inline bool accept(const elm::String& name);
98 
99  // Register bank access
100  inline const banks_t& banks(void) const;
101  inline int regCount(void) const { return rcnt; }
102  Register *findReg(int uniq) const;
103  const Register *findReg(const string& name) const;
104  virtual const Register *getSP(void) const;
105  virtual const Register *getPC(void) const;
106 
107  // deprecated
108  inline const CacheConfiguration& cache(void) const;
109  void loadCacheConfig(const elm::system::Path& path);
110  void loadCacheConfig(elm::xom::Element *element);
111  inline const Memory& memory(void) const { return *_memory; }
112  void loadMemory(const elm::system::Path& path) throw(otawa::LoadException);
113  void loadMemory(elm::xom::Element *element) throw(otawa::LoadException);
114  void loadProcessor(const elm::system::Path& path);
115  void loadProcessor(elm::xom::Element *element);
116  inline const Processor *processor(void) const { return _processor; };
117  inline const int pipelineDepth(void) const;
118 
119 protected:
120  friend class otawa::Manager;
121  static const banks_t null_banks;
122  virtual ~Platform(void);
123  void setBanks(const banks_t& banks);
124 
125 private:
126  static const unsigned long HAS_PROCESSOR = 0x00000001;
127  static const unsigned long HAS_CACHE = 0x00000002;
128  static const unsigned long HAS_MEMORY = 0x00000004;
129  unsigned long flags;
133  const Memory *_memory;
134  int depth;
135  int rcnt;
136  const banks_t *_banks;
137 
138  void configure(const PropList& props);
139 };
140 inline io::Output& operator<<(io::Output& out, const Platform::Identification& id) { id.print(out); return out; }
141 
142 // Inlines
144  return id;
145 }
146 
147 inline const CacheConfiguration& Platform::cache(void) const {
148  return *_cache;
149 }
150 
151 inline const int Platform::pipelineDepth(void) const {
152  return depth;
153 }
154 
156  return accept(Identification(name));
157 }
158 
159 inline bool Platform::accept(const elm::String& name) {
160  return accept(Identification(name));
161 }
162 
164  return *_banks;
165 }
166 
167 
168 // Platform::Identification inlines
170  return _arch;
171 }
172 
173 inline const elm::String& Platform::Identification::abi(void) const {
174  return _abi;
175 }
176 
178  return _mach;
179 }
180 
181 inline const elm::String& Platform::Identification::name(void) const {
182  return _name;
183 }
184 
185 } } // otawa::hard
186 
187 #endif // OTAWA_HARD_PLATFORM_H
const CacheConfiguration & cache(void) const
Get the cache configuration.
Definition: Platform.h:147
static const Identification ANY_PLATFORM
Represents any platform.
Definition: Platform.h:89
virtual ~Platform(void)
Definition: hardware_Platform.cpp:273
virtual const Register * getPC(void) const
Get the register containing the Program Counter.
Definition: hardware_Platform.cpp:718
int depth
Definition: Platform.h:134
const CacheConfiguration * _cache
Definition: Platform.h:131
static const banks_t null_banks
Empty register bank table.
Definition: Platform.h:121
const elm::String & architecture(void) const
Get the architecture component of the platform identifier.
Definition: Platform.h:169
int regCount(void) const
Get the count of registers in the current platform.
Definition: Platform.h:101
static const PropList EMPTY
This is an empty proplist for convenience.
Definition: PropList.h:66
Definition: Platform.h:69
const Memory & memory(void) const
Definition: Platform.h:111
elm::String _abi
Definition: Platform.h:72
Description of a processor pipeline.
Definition: Processor.h:136
Identification(const elm::String &name)
Build a platform identifier from a string.
Definition: hardware_Platform.cpp:443
const elm::String & machine(void) const
Get the machine component of the platform identifier.
Definition: Platform.h:177
static const elm::String LINUX_2_4
Represents the Linux 2.4 ABI.
Definition: Platform.h:61
void loadProcessor(const elm::system::Path &path)
Load the processor configuration.
Definition: hardware_Platform.cpp:538
Identification id
Definition: Platform.h:130
Class to represent the whole memory of the platform.
Definition: Memory.h:173
void loadCacheConfig(const elm::system::Path &path)
Load a cache configuration from the given path.
Definition: hardware_Platform.cpp:586
void configure(const PropList &props)
Definition: hardware_Platform.cpp:146
The manager class providesfacilities for storing, grouping and retrieving shared resources like loade...
Definition: Manager.h:58
static const elm::String LINUX
Represents the Linux ABI.
Definition: Platform.h:60
Processor * _processor
Definition: Platform.h:132
static const elm::String LINUX_2_6
Represents the Linux 2.6 ABI.
Definition: Platform.h:62
static const elm::String POWERPC
Represents the PowerPC architecture.
Definition: Platform.h:55
io::Output & operator<<(io::Output &out, const Platform::Identification &id)
Definition: Platform.h:140
const Memory * _memory
Definition: Platform.h:133
elm::String _name
Definition: Platform.h:70
const Identification & identification(void) const
Get identification of the current platform.
Definition: Platform.h:143
static const elm::String MAC
Represents a Macintosh machine (seems to be too wide, must be refined).
Definition: Platform.h:65
const banks_t & banks(void) const
Definition: Platform.h:163
virtual const Register * getSP(void) const
Get the register, usually (depending on the ABI), devoted to contain the stack pointer.
Definition: hardware_Platform.cpp:709
sys::SystemOutStream & out
static const unsigned long HAS_CACHE
Definition: Platform.h:127
static const unsigned long HAS_MEMORY
Definition: Platform.h:128
const int pipelineDepth(void) const
Get the depth of the pipeline of the platform processor.
Definition: Platform.h:151
static const elm::String EABI
Represents the EABI ABI.
Definition: Platform.h:59
bool matches(const Identification &id)
Check if the current identification matches the given one.
Definition: hardware_Platform.cpp:505
elm::String _arch
Definition: Platform.h:71
elm::String _mach
Definition: Platform.h:73
Identification & operator=(const Identification &id)
Copy the given identification in the current one.
Definition: hardware_Platform.cpp:488
This class records information about the architecture where the processed program will run...
Definition: Platform.h:48
void setBanks(const banks_t &banks)
Set the list of banks for an actual platform.
Definition: hardware_Platform.cpp:653
elm::genstruct::Table< const hard::RegBank * > banks_t
Definition: Platform.h:50
const banks_t * _banks
Definition: Platform.h:136
cstring name
Definition: odisasm.cpp:107
const elm::String & abi(void) const
Get the ABI component of the platform identifier.
Definition: Platform.h:173
Exception thrown when a loader encounters an error during load.
Definition: Manager.h:52
static const elm::String ELF
Represents the ELF ABI.
Definition: Platform.h:58
virtual bool accept(const Identification &id)
Check if the platform handle the given platform description.
Definition: hardware_Platform.cpp:295
This a list of properties.
Definition: PropList.h:63
const elm::String & name(void) const
Get the full name of the identification.
Definition: Platform.h:181
static const elm::String ANY
Represents any architecture, platform, machine.
Definition: Platform.h:52
void loadMemory(const elm::system::Path &path)
Load a memory configuration from the given path.
Definition: hardware_Platform.cpp:624
static const unsigned long HAS_PROCESSOR
Definition: Platform.h:126
Objects of this class are simple machine register, more accurately unbreakable atomic registers...
Definition: Register.h:38
Register * findReg(int uniq) const
Find the register matching the given unique identifier.
Definition: hardware_Platform.cpp:674
unsigned long flags
Definition: Platform.h:129
void split(void)
Split the platform name into its components.
Definition: hardware_Platform.cpp:413
int rcnt
Definition: Platform.h:135
void print(io::Output &out) const
Display the identification.
Definition: hardware_Platform.cpp:686
This class represents the full configuration of caches of a processor.
Definition: CacheConfiguration.h:37
static const elm::String SIM
Represents a simulator machine.
Definition: Platform.h:66
Platform(const Identification &id, const PropList &props=PropList::EMPTY)
Build a platform from the given description.
Definition: hardware_Platform.cpp:238
const Processor * processor(void) const
Get the current processor (possibly derivated from the current configuration).
Definition: Platform.h:116