mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-12 13:38:21 +00:00
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:
@ -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.
|
||||
|
Reference in New Issue
Block a user