Substantial changes to refactor LLI to incorporate both the Jello JIT and
the traditional LLI interpreter


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5125 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/ExecutionEngine/Interpreter/UserInput.cpp b/lib/ExecutionEngine/Interpreter/UserInput.cpp
index f0975a7..3d2b1de 100644
--- a/lib/ExecutionEngine/Interpreter/UserInput.cpp
+++ b/lib/ExecutionEngine/Interpreter/UserInput.cpp
@@ -7,6 +7,7 @@
 #include "Interpreter.h"
 #include "llvm/Bytecode/Reader.h"
 #include "llvm/DerivedTypes.h"
+#include "llvm/Function.h"
 #include "llvm/Transforms/Utils/Linker.h"
 #include <algorithm>
 using std::string;
@@ -18,8 +19,8 @@
   Print, Info, List, StackTrace, Up, Down,    // Inspection
   Next, Step, Run, Finish, Call,              // Control flow changes
   Break, Watch,                               // Debugging
-  Load, Flush,
-  TraceOpt, ProfileOpt                              // Toggle features
+  Flush,
+  TraceOpt,                                   // Toggle features
 };
 
 // CommandTable - Build a lookup table for the commands available to the user...
@@ -53,11 +54,9 @@
   { "break"    , Break      }, { "b", Break },
   { "watch"    , Watch      },
 
-  { "load"     , Load       },
   { "flush"    , Flush      },
 
   { "trace"    , TraceOpt   },
-  { "profile"  , ProfileOpt },
 };
 static CommandTableElement *CommandTableEnd = 
    CommandTable+sizeof(CommandTable)/sizeof(CommandTable[0]);
@@ -90,11 +89,6 @@
 
     switch (E->CID) {
     case Quit:       UserQuit = true;   break;
-    case Load:
-      cin >> Command;
-      loadModule(Command);
-      break;
-    case Flush: flushModule(); break;
     case Print:
       cin >> Command;
       print(Command);
@@ -132,11 +126,6 @@
       cout << "Tracing " << (Trace ? "enabled\n" : "disabled\n");
       break;
 
-    case ProfileOpt:
-      Profile = !Profile;
-      cout << "Profiling " << (Trace ? "enabled\n" : "disabled\n");
-      break;
-
     default:
       cout << "Command '" << Command << "' unimplemented!\n";
       break;
@@ -146,61 +135,6 @@
 }
 
 //===----------------------------------------------------------------------===//
-// loadModule - Load a new module to execute...
-//
-void Interpreter::loadModule(const string &Filename) {
-  string ErrorMsg;
-  if (CurMod && !flushModule()) return;  // Kill current execution
-
-  CurMod = ParseBytecodeFile(Filename, &ErrorMsg);
-  if (CurMod == 0) {
-    cout << "Error parsing '" << Filename << "': No module loaded: "
-         << ErrorMsg << "\n";
-    return;
-  }
-  CW.setModule(CurMod);  // Update Writer
-
-#if 0
-  string RuntimeLib = getCurrentExecutablePath();
-  if (!RuntimeLib.empty()) RuntimeLib += "/";
-  RuntimeLib += "RuntimeLib.bc";
-
-  if (Module *SupportLib = ParseBytecodeFile(RuntimeLib, &ErrorMsg)) {
-    if (LinkModules(CurMod, SupportLib, &ErrorMsg))
-      std::cerr << "Error Linking runtime library into current module: "
-                << ErrorMsg << "\n";
-  } else {
-    std::cerr << "Error loading runtime library '"+RuntimeLib+"': "
-              << ErrorMsg << "\n";
-  }
-#endif
-}
-
-
-//===----------------------------------------------------------------------===//
-// flushModule - Return true if the current program has been unloaded.
-//
-bool Interpreter::flushModule() {
-  if (CurMod == 0) {
-    cout << "Error flushing: No module loaded!\n";
-    return false;
-  }
-
-  if (!ECStack.empty()) {
-    // TODO: if use is not sure, return false
-    cout << "Killing current execution!\n";
-    ECStack.clear();
-    CurFrame = -1;
-  }
-
-  CW.setModule(0);
-  delete CurMod;
-  CurMod = 0;
-  ExitCode = 0;
-  return true;
-}
-
-//===----------------------------------------------------------------------===//
 // setBreakpoint - Enable a breakpoint at the specified location
 //
 void Interpreter::setBreakpoint(const string &Name) {
@@ -272,7 +206,7 @@
       return true;
     }
 
-    Args.push_back(CreateArgv(InputArgv));
+    Args.push_back(PTOGV(CreateArgv(InputArgv)));
   }
     // fallthrough
   case 1: