ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
ETISS.h
Go to the documentation of this file.
1 
53 #ifndef ETISS_INCLUDE_ETISS_H_
54 #define ETISS_INCLUDE_ETISS_H_
55 
56 #include "etiss/config.h"
57 
58 #include <map>
59 #include <memory>
60 #include <mutex>
61 #include <string>
62 #include <type_traits>
63 
64 #include "etiss/CPUCore.h"
65 #include "etiss/Misc.h"
66 
67 #include "etiss/LibraryInterface.h"
68 
69 namespace etiss
70 {
71 
84 std::set<std::string> listCPUArchs();
85 
93 std::set<std::string> listJITs();
94 
102 std::set<std::string> listPlugins();
103 
111 void preloadLibraries();
112 
123 std::shared_ptr<JIT> getJIT(std::string name,
124  std::map<std::string, std::string> options = std::map<std::string, std::string>());
125 
136 std::shared_ptr<CPUArch> getCPUArch(std::string name,
137  std::map<std::string, std::string> options = std::map<std::string, std::string>());
138 
149 std::shared_ptr<Plugin> getPlugin(std::string name,
150  std::map<std::string, std::string> options = std::map<std::string, std::string>());
151 
168 bool loadLibrary(std::string path, std::string name);
169 
181 void addLibrary(std::shared_ptr<etiss::LibraryInterface> libInterface);
182 
191 std::set<std::string> listLibraries();
192 
201 std::set<std::string> listLibraryPrefixes();
202 
209 void initialize(std::vector<std::string>& args);
217 std::shared_ptr<etiss::JIT> getDefaultJIT();
218 
228 void shutdown();
229 
253 {
254  private:
267  template <typename T, typename... lisT>
268  void toList(std::vector<std::string> &vec, T t, lisT... args)
269  {
270  vec.push_back(etiss::toString(t));
271  toList(vec, args...);
272  }
273 
277  inline void toList(std::vector<std::string> &vec) {}
278 
281  void loadIni(std::list<std::string> *files);
282 
294  template <typename T, typename... lisT>
296  {
297  static_assert(!std::is_arithmetic<T>::value, "This implementation of the Initializer constructor does not take "
298  "integral variables as first variadic parameter");
299  }
300 
305 
306  public:
310  void loadIniPlugins(std::shared_ptr<etiss::CPUCore> cpu);
314  void loadIniJIT(std::shared_ptr<etiss::CPUCore> cpu);
315 
331  template <typename argvT, typename... lisT>
332  Initializer(int argc, argvT **argv, lisT... args_append)
333  {
334  // const and non const *argv[] are allowed. This assertion is
335  // easier than duplicing the constructor.
336  static_assert(std::is_same<const char, argvT>::value || std::is_same<char, argvT>::value,
337  "argv must be of type const char or char");
338  std::vector<std::string> args;
339  for (int i = 1; i < argc; i++)
340  {
341  args.push_back(std::string(argv[i]));
342  }
343  toList(args, args_append...);
344  initialize(args);
345  }
346 
347  Initializer(std::list<std::string> *files, int argc, const char* argv[])
348  {
349  std::vector<std::string> args;
350  for (int i = 1; i < argc; i++)
351  {
352  args.push_back(std::string(argv[i]));
353  }
354  loadIni(files);
355  initialize(args);
356  }
357 
371  template <typename... listT>
372  Initializer(listT... args)
373  {
374  // At the moment, it doesn't make sense to call this version of the
375  // constructor with a number as first arguement (at compile-time!)
377  std::vector<std::string> argv;
378  toList(argv, args...);
379  initialize(argv);
380  }
381 
399  template <typename argvT, typename... lisT>
400  Initializer(std::list<std::string> *files, int argc, argvT **argv, lisT... args_append)
401  {
402  // const and non const *argv[] are allowed. This assertion is
403  // easier than duplicing the constructor.
404  static_assert(std::is_same<const char, argvT>::value || std::is_same<char, argvT>::value,
405  "argv must be of type const char or char");
406  std::vector<std::string> args;
407  for (int i = 1; i < argc; i++)
408  {
409  args.push_back(std::string(argv[i]));
410  }
411  toList(args, args_append...);
412  loadIni(files);
413  initialize(args);
414  }
415 
431  template <typename... listT>
432  Initializer(std::list<std::string> *files, listT... args)
433  {
434  // At the moment, it doesn't make sense to call this version of the
435  // constructor with a number as first arguement (at compile-time!)
437  std::vector<std::string> argv;
438  toList(argv, args...);
439  loadIni(files);
440  initialize(argv);
441  }
442 
448  ~Initializer();
449 };
450 
457 std::string errorMessage(etiss::int32 code, CPUArch *arch = 0);
458  // end of @addtogoup ETISS_Frontend
461 
476 void forceInitialization();
477  // end of @addtogoup ETISS_Internals
480 
481 namespace py
482 {
483 void init();
484 void shutdown();
485 void console();
486 bool supported();
487 void runString(std::string s);
488 void run(std::function<void(void)> func);
489 void runEXT(std::function<void(void)> func);
490 } // namespace py
491 
492 } // namespace etiss
493 
494 #endif
etiss_int32 int32
Definition: 386-GCC.h:81
ETISS_PLUGIN_EXPORT etiss::CPUArch std::map< std::string, std::string > options
create new instance of the CPUArch type at index
defines main cpu core interface
#define static_assert(x, y)
Definition: Fault.cpp:60
class for simple library access.
general configuration and logging
__device__ __2f16 float bool s
Wrapper for the initialize and shutdown of the ETISS environment.
Definition: ETISS.h:253
Initializer(std::list< std::string > *files, int argc, argvT **argv, lisT... args_append)
Constructor that initializes ETISS.
Definition: ETISS.h:400
Initializer(std::list< std::string > *files, int argc, const char *argv[])
Definition: ETISS.h:347
Initializer(listT... args)
Constructor that initializes ETISS.
Definition: ETISS.h:372
Initializer(int argc, argvT **argv, lisT... args_append)
Constructor that initializes ETISS.
Definition: ETISS.h:332
void loadIni(std::list< std::string > *files)
creates a simpleIni object which holds the data of the given .ini file.
Definition: ETISS.cpp:399
void loadIniPlugins(std::shared_ptr< etiss::CPUCore > cpu)
loads the plugins given with the previous loaded .ini files
Definition: ETISS.cpp:556
void toList(std::vector< std::string > &vec)
Break condition for empty argument list.
Definition: ETISS.h:277
Initializer(std::list< std::string > *files, listT... args)
Constructor that initializes ETISS.
Definition: ETISS.h:432
void static_assertFirstParamNotArithmetic(T t, lisT... args)
Make sure that the first variadic parameter at compiletime is no number.
Definition: ETISS.h:295
void loadIniJIT(std::shared_ptr< etiss::CPUCore > cpu)
sets the JIT given with the previous loaded .ini files
Definition: ETISS.cpp:665
~Initializer()
Destructor that shutdowns ETISS.
Definition: ETISS.cpp:984
void static_assertFirstParamNotArithmetic()
version of static_assertFirstParamNotArithmetic for the case that no parameter is given.
Definition: ETISS.h:304
void toList(std::vector< std::string > &vec, T t, lisT... args)
Add argument list to a string vector.
Definition: ETISS.h:268
contains defines to configure ETISS.
std::shared_ptr< etiss::JIT > getDefaultJIT()
Get the default JIT implementation.
Definition: ETISS.cpp:344
bool loadLibrary(std::string path, std::string name)
Load a library.
Definition: ETISS.cpp:288
std::shared_ptr< Plugin > getPlugin(std::string name, std::map< std::string, std::string > options=std::map< std::string, std::string >())
Get a present Plugin plug-in by name.
Definition: ETISS.cpp:241
std::string errorMessage(etiss::int32 code, CPUArch *arch=0)
Get the error message for an error code for a specific CPUArch plug-in.
Definition: ETISS.cpp:991
std::set< std::string > listLibraryPrefixes()
Create a set with strings of the library names.
Definition: ETISS.cpp:333
std::set< std::string > listJITs()
Create a set with all identifier names of the known JIT plug-ins.
Definition: ETISS.cpp:97
void preloadLibraries()
Search and try to load libraries.
Definition: ETISSInit.cpp:192
std::set< std::string > listPlugins()
Create a set with all identifier names of the known plug-ins.
Definition: ETISS.cpp:125
std::shared_ptr< JIT > getJIT(std::string name, std::map< std::string, std::string > options=std::map< std::string, std::string >())
Get a present JIT plug-in by name.
Definition: ETISS.cpp:153
std::shared_ptr< CPUArch > getCPUArch(std::string name, std::map< std::string, std::string > options=std::map< std::string, std::string >())
Get a present CPUArch plug-in by name.
Definition: ETISS.cpp:197
void shutdown()
Shutdown ETISS.
Definition: ETISS.cpp:914
std::set< std::string > listCPUArchs()
Create a set with all identifier names of the known CPUArch plug-ins.
Definition: ETISS.cpp:69
void addLibrary(std::shared_ptr< etiss::LibraryInterface > libInterface)
Add a LibraryInterface to the ETISS environment.
Definition: ETISS.cpp:301
void initialize(std::vector< std::string > &args)
Initialize and configure ETISS.
Definition: ETISS.cpp:881
std::set< std::string > listLibraries()
Create a set with strings of the library names and some information appended in square brackets.
Definition: ETISS.cpp:322
void forceInitialization()
Force the initialization of ETISS.
Definition: ETISS.cpp:886
void console()
bool supported()
void runString(std::string s)
void run(std::function< void(void)> func)
void init()
void shutdown()
void runEXT(std::function< void(void)> func)
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition: Benchmark.h:53
std::string toString(const T &val)
conversion of type T to std::string.
Definition: Misc.h:174