Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions m2isar/backends/etiss/templates/etiss_arch_h.mako
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ class ${core_name}Arch : public etiss::CPUArch
*/
virtual etiss::int32 handleException(etiss::int32 code, ETISS_CPU *cpu);

/**
@brief This function will return the base installation directory of the ArchLib

@see ${core_name}ArchSpecificImp.h
*/
virtual std::string installDir() const;

/**
@brief This function will return the include prefix relative to the base installation directory of the ArchLib

@see ${core_name}ArchSpecificImp.h
*/
virtual std::string jitFiles() const;

/**
@brief This function is called during CPUArch initialization

Expand Down
53 changes: 53 additions & 0 deletions m2isar/backends/etiss/templates/etiss_arch_specific_cpp.mako
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "${core_name}Arch.h"
#include "${core_name}ArchSpecificImp.h"
#include "${core_name}Funcs.h"
#include "etiss/Memory.h"

/**
@brief This function will be called automatically in order to handling exceptions such as interrupt, system call,
Expand Down Expand Up @@ -48,6 +49,58 @@ etiss::int32 ${core_name}Arch::handleException(etiss::int32 cause, ETISS_CPU *cp
return 0;
}

/**
@brief See etiss/src/Misc.cpp
*/
static etiss::ModuleHandle GetCurrentModule()
{
static etiss::ModuleHandle hModule = 0;

if (!hModule)
{
hModule = etiss::GetModuleByAddress((uintptr_t)GetCurrentModule);
}

return hModule;
}

/**
@brief See etiss/src/Misc.cpp
*/
static std::string GetCurrentModulePath()
{
static std::string modulePath;

if (modulePath == "")
{
modulePath = etiss::GetModulePath(GetCurrentModule());
}

return modulePath;
}

/**
@brief Resolves the ETISS install dir for both in-tree as well as out-of-tree builds
*/
std::string ${core_name}Arch::installDir() const
{
auto archLib = GetCurrentModulePath();
auto libPathLoc = archLib.find_last_of("/\\");
auto libPath = archLib.substr(0, libPathLoc);
auto pluginsPathLoc = libPath.find_last_of("/\\");
auto pluginsPath = libPath.substr(0, pluginsPathLoc);
auto archPathLoc = pluginsPath.find_last_of("/\\");
return libPath.substr(0, archPathLoc);
}

/**
@brief This function is called during InstrSet initialization returns path to jit includes
*/
std::string ${core_name}Arch::jitFiles() const
{
return installDir() + "/include/jit";
}

/**
@brief This function is called during CPUArch initialization

Expand Down
3 changes: 2 additions & 1 deletion m2isar/backends/etiss/templates/etiss_jit_extensions.mako
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
std::string requiredJitFilesPath = jitFiles();
/* Set default JIT Extensions. Read Parameters set from ETISS configuration and append with architecturally needed */
std::string cfgPar = "";
cfgPar = etiss::cfg().get<std::string>("jit.external_headers", ";");
Expand All @@ -8,7 +9,7 @@
etiss::cfg().set<std::string>("jit.external_libs", cfgPar + "${extra_libs}");

cfgPar = etiss::cfg().get<std::string>("jit.external_header_paths", ";");
etiss::cfg().set<std::string>("jit.external_header_paths", cfgPar + "${extra_header_paths}");
etiss::cfg().set<std::string>("jit.external_header_paths", cfgPar + "${extra_header_paths}" + requiredJitFilesPath);

cfgPar = etiss::cfg().get<std::string>("jit.external_lib_paths", ";");
etiss::cfg().set<std::string>("jit.external_lib_paths", cfgPar + "${extra_lib_paths}");
Expand Down