18BOOL CALLBACK etiss_tcc_allsym(PSYMBOL_INFO pSymInfo, ULONG SymbolSize, PVOID UserContext)
20 std::map<std::string, void *> &map = *(std::map<std::string, void *> *)UserContext;
22 map.insert(std::pair<std::string, void *>(pSymInfo->Name, (
void *)pSymInfo->Address));
23 std::cout <<
"Found Symbol: " << pSymInfo->Name <<
"@0x" << std::hex << (
void *)pSymInfo->Address << std::endl;
27static void addAllSymbols(std::map<std::string, void *> &ptrs)
30 HANDLE hProcess = GetCurrentProcess();
34 status = SymInitialize(hProcess,
NULL, TRUE);
44 filter = std::string(
"*!") + lib +
"_*";
45 std::cout <<
"searching in library " << lib << std::endl;
46 if (SymEnumSymbols(hProcess,
56 std::cout <<
"Failed to iterate over all symbols for library " << lib <<
":" << GetLastError() << std::endl;
72void *
TCCJIT::translate(std::string code, std::set<std::string> headerpaths, std::set<std::string> librarypaths,
73 std::set<std::string> libraries, std::string &error,
bool debug)
76 TCCState *
s = tcc_new();
79 error =
"Could not create tcc state";
87 tcc_set_output_type(
s, TCC_OUTPUT_MEMORY);
90 for (
auto iter = headerpaths.begin(); iter != headerpaths.end(); iter++)
92 tcc_add_include_path(
s, iter->c_str());
96 if (tcc_compile_string(
s, code.c_str()) == -1)
98 error =
"Failed to compile code: \n";
106 tcc_add_symbol(
s, sym.first.c_str(), sym.second);
115 for (
const auto &libpath : librarypaths)
117 if (tcc_add_library_path(
s, libpath.c_str()))
119 error +=
"could not add library path: " + libpath;
123 for (
const auto &lib : libraries)
125 if (tcc_add_library(
s, lib.c_str()))
127 error +=
"could not add library: " + lib;
133 if (tcc_relocate(
s) < 0)
135 error =
"Failed to link";
145 return tcc_get_symbol((TCCState *)handle, name.c_str());
149 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.