54 BOOL CALLBACK etiss_tcc_allsym(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
56 std::map<std::string, void *> &map = *(std::map<std::string, void *> *)UserContext;
58 map.insert(std::pair<std::string, void *>(pSymInfo->Name, (
void *)pSymInfo->Address));
59 std::cout <<
"Found Symbol: " << pSymInfo->Name <<
"@0x" << std::hex << (
void *)pSymInfo->Address << std::endl;
63 static void addAllSymbols(std::map<std::string, void *> &ptrs)
66 HANDLE hProcess = GetCurrentProcess();
70 status = SymInitialize(hProcess,
NULL,
TRUE);
80 filter = std::string(
"*!") + lib +
"_*";
81 std::cout <<
"searching in library " << lib << std::endl;
82 if (SymEnumSymbols(hProcess,
92 std::cout <<
"Failed to iterate over all symbols for library " << lib <<
":" << GetLastError() << std::endl;
103 #if ETISS_USE_GETPROC
108 void *
TCCJIT::translate(std::string code, std::set<std::string> headerpaths, std::set<std::string> librarypaths,
109 std::set<std::string> libraries, std::string &error,
bool debug)
112 TCCState *
s = tcc_new();
115 error =
"Could not create tcc state";
123 tcc_set_output_type(
s, TCC_OUTPUT_MEMORY);
126 for (
auto iter = headerpaths.begin(); iter != headerpaths.end(); iter++)
128 tcc_add_include_path(
s, iter->c_str());
132 if (tcc_compile_string(
s, code.c_str()) == -1)
134 error =
"Failed to compile code: \n";
139 #if ETISS_USE_GETPROC
142 tcc_add_symbol(
s, sym.first.c_str(), sym.second);
151 for (
const auto &libpath : librarypaths)
153 if (tcc_add_library_path(
s, libpath.c_str()))
155 error +=
"could not add library path: " + libpath;
159 for (
const auto &lib : libraries)
161 if (tcc_add_library(
s, lib.c_str()))
163 error +=
"could not add library: " + lib;
169 if (tcc_relocate(
s, TCC_RELOCATE_AUTO) < 0)
171 error =
"Failed to link";
181 return tcc_get_symbol((TCCState *)handle, name.c_str());
185 tcc_delete((TCCState *)handle);
Header file of the ETISS library.
general configuration and logging
__device__ __2f16 float bool s
std::map< std::string, void * > extsymbols
only use for windows.
virtual void free(void *handle)
clean up handled returned by etiss::JIT::translate
virtual void * translate(std::string code, std::set< std::string > headerpaths, std::set< std::string > librarypaths, std::set< std::string > libraries, std::string &error, bool debug=false)
translate C code to executable code and return a handle/pointer that identifies the compilation resul...
virtual void * getFunction(void *handle, std::string name, std::string &error)
returns a function pointer to a compiled function from the handle returned by etiss::JIT::translate
static void addSearchPath(const std::string &path)
contains defines to configure ETISS.
std::set< std::string > listLibraryPrefixes()
Create a set with strings of the library names.
std::string jitFiles()
Get ETISS JIT files path.
std::vector< std::string > jitExtLibPaths()
Get ETISS JIT external path.