Make CreateArgv part of lli rather than part of ExecutionEngine.

Switch Interpreter and JIT's "run" methods to take a Function and a vector of
 GenericValues.
Move (almost all of) the stuff that constructs a canonical call to main()
 into lli (new methods "callAsMain", "makeStringVector").
Nuke getCurrentExecutablePath(), enableTracing(), getCurrentFunction(),
 isStopped(), and many dead decls from interpreter.
Add linux strdup() support to interpreter.
Make interpreter's atexit handler runner and JIT's runAtExitHandlers() look
 more alike, in preparation for refactoring.
atexit() is spelled "atexit", not "at_exit".


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8366 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Brian Gaeke
2003-09-05 18:42:01 +00:00
parent 5bea411ad2
commit 70975eef57
10 changed files with 168 additions and 198 deletions

View File

@ -316,45 +316,6 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
}
}
void *ExecutionEngine::CreateArgv(const std::vector<std::string> &InputArgv) {
if (getTargetData().getPointerSize() == 8) { // 64 bit target?
PointerTy *Result = new PointerTy[InputArgv.size()+1];
DEBUG(std::cerr << "ARGV = " << (void*)Result << "\n");
for (unsigned i = 0; i < InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1;
char *Dest = new char[Size];
DEBUG(std::cerr << "ARGV[" << i << "] = " << (void*)Dest << "\n");
copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
Dest[Size-1] = 0;
// Endian safe: Result[i] = (PointerTy)Dest;
StoreValueToMemory(PTOGV(Dest), (GenericValue*)(Result+i), Type::LongTy);
}
Result[InputArgv.size()] = 0;
return Result;
} else { // 32 bit target?
int *Result = new int[InputArgv.size()+1];
DEBUG(std::cerr << "ARGV = " << (void*)Result << "\n");
for (unsigned i = 0; i < InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1;
char *Dest = new char[Size];
DEBUG(std::cerr << "ARGV[" << i << "] = " << (void*)Dest << "\n");
copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
Dest[Size-1] = 0;
// Endian safe: Result[i] = (PointerTy)Dest;
StoreValueToMemory(PTOGV(Dest), (GenericValue*)(Result+i), Type::IntTy);
}
Result[InputArgv.size()] = 0; // null terminate it
return Result;
}
}
/// EmitGlobals - Emit all of the global variables to memory, storing their
/// addresses into GlobalAddress. This must make sure to copy the contents of
/// their initializers into the memory.