[llvm-commits] CVS: llvm/tools/lli/Execution.cpp Interpreter.h UserInput.cpp

Chris Lattner lattner at cs.uiuc.edu
Thu Nov 7 13:30:01 PST 2002


Changes in directory llvm/tools/lli:

Execution.cpp updated: 1.70 -> 1.71
Interpreter.h updated: 1.23 -> 1.24
UserInput.cpp updated: 1.22 -> 1.23

---
Log message:

Make command line arguments setup be endian correct!!


---
Diffs of the changes:

Index: llvm/tools/lli/Execution.cpp
diff -u llvm/tools/lli/Execution.cpp:1.70 llvm/tools/lli/Execution.cpp:1.71
--- llvm/tools/lli/Execution.cpp:1.70	Wed Oct 30 15:47:57 2002
+++ llvm/tools/lli/Execution.cpp	Thu Nov  7 13:29:31 2002
@@ -980,6 +980,28 @@
 }
 
 
+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
 //===----------------------------------------------------------------------===//


Index: llvm/tools/lli/Interpreter.h
diff -u llvm/tools/lli/Interpreter.h:1.23 llvm/tools/lli/Interpreter.h:1.24
--- llvm/tools/lli/Interpreter.h:1.23	Tue Oct 15 15:34:05 2002
+++ llvm/tools/lli/Interpreter.h	Thu Nov  7 13:29:31 2002
@@ -126,9 +126,9 @@
   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


Index: llvm/tools/lli/UserInput.cpp
diff -u llvm/tools/lli/UserInput.cpp:1.22 llvm/tools/lli/UserInput.cpp:1.23
--- llvm/tools/lli/UserInput.cpp:1.22	Mon Sep  2 20:08:28 2002
+++ llvm/tools/lli/UserInput.cpp	Thu Nov  7 13:29:31 2002
@@ -238,23 +238,6 @@
   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 @@
       return true;
     }
 
-    GenericValue GV; GV.PointerVal = (uint64_t)CreateArgv(InputArgv);
-    Args.push_back(GV);
+    Args.push_back(CreateArgv(InputArgv));
   }
     // fallthrough
   case 1:





More information about the llvm-commits mailing list