ETISS 0.11.2
ExtendableTranslatingInstructionSetSimulator(version0.11.2)
Loading...
Searching...
No Matches
ETISS.h
Go to the documentation of this file.
1// SPDX-License-Identifier: BSD-3-Clause
2//
3// This file is part of ETISS. It is licensed under the BSD 3-Clause License; you may not use this file except in
4// compliance with the License. You should have received a copy of the license along with this project. If not, see the
5// LICENSE file.
6
15#ifndef ETISS_INCLUDE_ETISS_H_
16#define ETISS_INCLUDE_ETISS_H_
17
18#include "etiss/config.h"
19
20#include <map>
21#include <memory>
22#include <mutex>
23#include <string>
24#include <type_traits>
25#include "etiss/Misc.h"
26
27namespace etiss
28{
29
42std::set<std::string> listCPUArchs();
43
51std::set<std::string> listJITs();
52
60std::set<std::string> listPlugins();
61
69void preloadLibraries();
70
81std::shared_ptr<JIT> getJIT(std::string name,
82 std::map<std::string, std::string> options = std::map<std::string, std::string>());
83
94std::shared_ptr<CPUArch> getCPUArch(std::string name,
95 std::map<std::string, std::string> options = std::map<std::string, std::string>());
96
107std::shared_ptr<Plugin> getPlugin(std::string name,
108 std::map<std::string, std::string> options = std::map<std::string, std::string>());
109
126bool loadLibrary(std::string path, std::string name);
127
139void addLibrary(std::shared_ptr<etiss::LibraryInterface> libInterface);
140
149std::set<std::string> listLibraries();
150
159std::set<std::string> listLibraryPrefixes();
160
167void initialize(std::vector<std::string> &args);
175std::shared_ptr<etiss::JIT> getDefaultJIT();
176
190void initialize_virtualstruct(std::shared_ptr<etiss::CPUCore> cpu_core);
196void initialize_virtualstruct(std::shared_ptr<etiss::CPUCore> cpu_core,
197 std::function<bool(const etiss::fault::Fault &, const etiss::fault::Action &,
198 std::string & /*errormsg*/)> const &fcustom_action);
199
209void shutdown();
210
234{
235 private:
248 template <typename T, typename... lisT>
249 void toList(std::vector<std::string> &vec, T t, lisT... args)
250 {
251 vec.push_back(etiss::toString(t));
252 toList(vec, args...);
253 }
254
258 inline void toList(std::vector<std::string> &vec) {}
259
262 void loadIni(std::list<std::string> *files);
263
275 template <typename T, typename... lisT>
277 {
278 static_assert(!std::is_arithmetic<T>::value, "This implementation of the Initializer constructor does not take "
279 "integral variables as first variadic parameter");
280 }
281
286
287 public:
291 void loadIniPlugins(std::shared_ptr<etiss::CPUCore> cpu);
295 void loadIniJIT(std::shared_ptr<etiss::CPUCore> cpu);
296
312 template <typename argvT, typename... lisT>
313 Initializer(int argc, argvT **argv, lisT... args_append)
314 {
315 // const and non const *argv[] are allowed. This assertion is
316 // easier than duplicing the constructor.
317 static_assert(std::is_same<const char, argvT>::value || std::is_same<char, argvT>::value,
318 "argv must be of type const char or char");
319 std::vector<std::string> args;
320 for (int i = 1; i < argc; i++)
321 {
322 args.push_back(std::string(argv[i]));
323 }
324 toList(args, args_append...);
325 initialize(args);
326 }
327
328 Initializer(std::list<std::string> *files, int argc, const char *argv[])
329 {
330 std::vector<std::string> args;
331 for (int i = 1; i < argc; i++)
332 {
333 args.push_back(std::string(argv[i]));
334 }
335 loadIni(files);
336 initialize(args);
337 }
338
352 template <typename... listT>
353 Initializer(listT... args)
354 {
355 // At the moment, it doesn't make sense to call this version of the
356 // constructor with a number as first arguement (at compile-time!)
358 std::vector<std::string> argv;
359 toList(argv, args...);
360 initialize(argv);
361 }
362
380 template <typename argvT, typename... lisT>
381 Initializer(std::list<std::string> *files, int argc, argvT **argv, lisT... args_append)
382 {
383 // const and non const *argv[] are allowed. This assertion is
384 // easier than duplicing the constructor.
385 static_assert(std::is_same<const char, argvT>::value || std::is_same<char, argvT>::value,
386 "argv must be of type const char or char");
387 std::vector<std::string> args;
388 for (int i = 1; i < argc; i++)
389 {
390 args.push_back(std::string(argv[i]));
391 }
392 toList(args, args_append...);
393 loadIni(files);
394 initialize(args);
395 }
396
412 template <typename... listT>
413 Initializer(std::list<std::string> *files, listT... args)
414 {
415 // At the moment, it doesn't make sense to call this version of the
416 // constructor with a number as first arguement (at compile-time!)
418 std::vector<std::string> argv;
419 toList(argv, args...);
420 loadIni(files);
421 initialize(argv);
422 }
423
429 ~Initializer();
430};
431
438std::string errorMessage(etiss::int32 code, CPUArch *arch = 0);
439
// end of @addtogoup ETISS_Frontend
442
458
// end of @addtogoup ETISS_Internals
461
462namespace py
463{
464void init();
465void shutdown();
466void console();
467bool supported();
468void runString(std::string s);
469void run(std::function<void(void)> func);
470void runEXT(std::function<void(void)> func);
471} // namespace py
472
473} // namespace etiss
474
475#endif
ETISS_PLUGIN_EXPORT etiss::CPUArch std::map< std::string, std::string > options
create new instance of the CPUArch type at index
general configuration and logging
__device__ __2f16 float bool s
Wrapper for the initialize and shutdown of the ETISS environment.
Definition ETISS.h:234
Initializer(std::list< std::string > *files, int argc, argvT **argv, lisT... args_append)
Constructor that initializes ETISS.
Definition ETISS.h:381
Initializer(std::list< std::string > *files, int argc, const char *argv[])
Definition ETISS.h:328
Initializer(listT... args)
Constructor that initializes ETISS.
Definition ETISS.h:353
Initializer(int argc, argvT **argv, lisT... args_append)
Constructor that initializes ETISS.
Definition ETISS.h:313
void loadIni(std::list< std::string > *files)
creates a simpleIni object which holds the data of the given .ini file.
Definition ETISS.cpp:381
void loadIniPlugins(std::shared_ptr< etiss::CPUCore > cpu)
loads the plugins given with the previous loaded .ini files
Definition ETISS.cpp:548
void toList(std::vector< std::string > &vec)
Break condition for empty argument list.
Definition ETISS.h:258
Initializer(std::list< std::string > *files, listT... args)
Constructor that initializes ETISS.
Definition ETISS.h:413
void static_assertFirstParamNotArithmetic(T t, lisT... args)
Make sure that the first variadic parameter at compiletime is no number.
Definition ETISS.h:276
void loadIniJIT(std::shared_ptr< etiss::CPUCore > cpu)
sets the JIT given with the previous loaded .ini files
Definition ETISS.cpp:663
~Initializer()
Destructor that shutdowns ETISS.
Definition ETISS.cpp:1034
void static_assertFirstParamNotArithmetic()
version of static_assertFirstParamNotArithmetic for the case that no parameter is given.
Definition ETISS.h:285
void toList(std::vector< std::string > &vec, T t, lisT... args)
Add argument list to a string vector.
Definition ETISS.h:249
contains defines to configure ETISS.
std::shared_ptr< etiss::JIT > getDefaultJIT()
Get the default JIT implementation.
Definition ETISS.cpp:326
bool loadLibrary(std::string path, std::string name)
Load a library.
Definition ETISS.cpp:270
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:223
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:1041
std::set< std::string > listLibraryPrefixes()
Create a set with strings of the library names.
Definition ETISS.cpp:315
std::set< std::string > listJITs()
Create a set with all identifier names of the known JIT plug-ins.
Definition ETISS.cpp:79
void preloadLibraries()
Search and try to load libraries.
std::set< std::string > listPlugins()
Create a set with all identifier names of the known plug-ins.
Definition ETISS.cpp:107
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:135
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:179
void shutdown()
Shutdown ETISS.
Definition ETISS.cpp:964
std::set< std::string > listCPUArchs()
Create a set with all identifier names of the known CPUArch plug-ins.
Definition ETISS.cpp:51
void addLibrary(std::shared_ptr< etiss::LibraryInterface > libInterface)
Add a LibraryInterface to the ETISS environment.
Definition ETISS.cpp:283
void initialize(std::vector< std::string > &args)
Initialize and configure ETISS.
Definition ETISS.cpp:877
void initialize_virtualstruct(std::shared_ptr< etiss::CPUCore > cpu_core)
Initialize and configure etiss::VirtualStruct root with etiss::CPUCore cpu_core.
Definition ETISS.cpp:910
std::set< std::string > listLibraries()
Create a set with strings of the library names and some information appended in square brackets.
Definition ETISS.cpp:304
void forceInitialization()
Force the initialization of ETISS.
Definition ETISS.cpp:882
void console()
bool supported()
void runString(std::string s)
void run(std::function< void(void)> func)
void shutdown()
void runEXT(std::function< void(void)> func)
forwards: include/jit/*
Definition Benchmark.h:17
std::string toString(const T &val)
conversion of type T to std::string.
Definition Misc.h:133