summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-11-07 19:29:31 +0000
committerChris Lattner <sabre@nondot.org>2002-11-07 19:29:31 +0000
commita2b4c6cc492bfadc3cd8ebc4f167e28bc81d0268 (patch)
treeb67f7e3d9f775c2489bd54f7a130b4220ab3752c /llvm/lib
parent6f7e74ccbb7286b69572c6f7132b62c298c5b52e (diff)
downloadbcm5719-llvm-a2b4c6cc492bfadc3cd8ebc4f167e28bc81d0268.tar.gz
bcm5719-llvm-a2b4c6cc492bfadc3cd8ebc4f167e28bc81d0268.zip
Make command line arguments setup be endian correct!!
llvm-svn: 4605
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Execution.cpp22
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/Interpreter.h2
-rw-r--r--llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp20
3 files changed, 24 insertions, 20 deletions
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
index b8d1c34d867..d11ed6e5218 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -980,6 +980,28 @@ static void executeStoreInst(StoreInst &I, ExecutionContext &SF) {
}
+GenericValue Interpreter::CreateArgv(const std::vector<std::string> &InputArgv){
+ // Pointers are 64 bits...
+ PointerTy *Result = new PointerTy[InputArgv.size()+1]; // 64 bit assumption
+
+ for (unsigned i = 0; i < InputArgv.size(); ++i) {
+ unsigned Size = InputArgv[i].size()+1;
+ char *Dest = new char[Size];
+ copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
+ Dest[Size-1] = 0;
+
+ GenericValue GV; GV.PointerVal = (PointerTy)Dest;
+ // Endian safe: Result[i] = (PointerTy)Dest;
+ StoreValueToMemory(GV, (GenericValue*)(Result+i),
+ Type::LongTy); // 64 bit assumption
+ }
+
+ Result[InputArgv.size()] = 0;
+ GenericValue GV; GV.PointerVal = (PointerTy)Result;
+ return GV;
+}
+
+
//===----------------------------------------------------------------------===//
// Miscellaneous Instruction Implementations
//===----------------------------------------------------------------------===//
diff --git a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
index a02a0abd05c..c0d8b75aca5 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/llvm/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -126,9 +126,9 @@ public:
static void print(const Type *Ty, GenericValue V);
static void printValue(const Type *Ty, GenericValue V);
- // Hack until we can parse command line args...
bool callMainMethod(const std::string &MainName,
const std::vector<std::string> &InputFilename);
+ GenericValue CreateArgv(const std::vector<std::string> &InputArgv);
void list(); // Do the 'list' command
void printStackTrace(); // Do the 'backtrace' command
diff --git a/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp b/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
index 4ef7fdcacf5..f0975a72d8f 100644
--- a/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/llvm/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -238,23 +238,6 @@ bool Interpreter::callMethod(const string &Name) {
return false;
}
-static void *CreateArgv(const std::vector<string> &InputArgv) {
- // Pointers are 64 bits...
- uint64_t *Result = new PointerTy[InputArgv.size()+1];
-
- for (unsigned i = 0; i < InputArgv.size(); ++i) {
- unsigned Size = InputArgv[i].size()+1;
- char *Dest = new char[Size];
- copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
- Dest[Size-1] = 0;
- Result[i] = (PointerTy)Dest;
- }
-
- Result[InputArgv.size()] = 0;
- return Result;
-}
-
-
// callMainMethod - This is a nasty gross hack that will dissapear when
// callMethod can parse command line options and stuff for us.
//
@@ -289,8 +272,7 @@ bool Interpreter::callMainMethod(const string &Name,
return true;
}
- GenericValue GV; GV.PointerVal = (uint64_t)CreateArgv(InputArgv);
- Args.push_back(GV);
+ Args.push_back(CreateArgv(InputArgv));
}
// fallthrough
case 1:
OpenPOWER on IntegriCloud