aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter/Interpreter.h
diff options
context:
space:
mode:
authorBrian Gaeke <gaeke@uiuc.edu>2003-09-05 18:42:01 +0000
committerBrian Gaeke <gaeke@uiuc.edu>2003-09-05 18:42:01 +0000
commit70975eef572b9e132bbaade16ba9edb76f15f287 (patch)
treeedbaec8a92e10f18d1195cdb5d0fc1b59b4520d2 /lib/ExecutionEngine/Interpreter/Interpreter.h
parent5bea411ad288ea6f25ac296ae2d75a4bfab8bf98 (diff)
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
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/Interpreter.h')
-rw-r--r--lib/ExecutionEngine/Interpreter/Interpreter.h53
1 files changed, 15 insertions, 38 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h
index 5434fe0b81..ef0540c1fe 100644
--- a/lib/ExecutionEngine/Interpreter/Interpreter.h
+++ b/lib/ExecutionEngine/Interpreter/Interpreter.h
@@ -79,41 +79,38 @@ class Interpreter : public ExecutionEngine, public InstVisitor<Interpreter> {
// function record.
std::vector<ExecutionContext> ECStack;
- // AtExitHandlers - List of functions to call when the program exits.
+ // AtExitHandlers - List of functions to call when the program exits,
+ // registered with the atexit() library function.
std::vector<Function*> AtExitHandlers;
public:
Interpreter(Module *M, bool isLittleEndian, bool isLongPointer,
bool TraceMode);
inline ~Interpreter() { CW.setModule(0); }
+ /// runAtExitHandlers - Run any functions registered by the
+ /// program's calls to atexit(3), which we intercept and store in
+ /// AtExitHandlers.
+ ///
+ void runAtExitHandlers ();
+
/// create - Create an interpreter ExecutionEngine. This can never fail.
///
static ExecutionEngine *create(Module *M, bool TraceMode);
/// run - Start execution with the specified function and arguments.
///
- virtual int run(const std::string &FnName,
- const std::vector<std::string> &Args,
- const char ** envp);
-
-
- void enableTracing() { Trace = true; }
+ virtual GenericValue run(Function *F,
+ const std::vector<GenericValue> &ArgValues);
- void handleUserInput();
-
- // User Interation Methods...
- bool callFunction(const std::string &Name); // return true on failure
+ // Methods used for debug printouts:
static void print(const Type *Ty, GenericValue V);
static void printValue(const Type *Ty, GenericValue V);
- bool callMainFunction(const std::string &MainName,
- const std::vector<std::string> &InputFilename);
-
- // Code execution methods...
+ // Methods used to execute code:
+ // Place a call on the stack
void callFunction(Function *F, const std::vector<GenericValue> &ArgVals);
- void executeInstruction(); // Execute one instruction...
-
- void run(); // Do the 'run' command
+ void executeInstruction(); // Execute one instruction
+ void run(); // Execute instructions until nothing left to do
// Opcode Implementations
void visitReturnInst(ReturnInst &I);
@@ -142,16 +139,6 @@ public:
const std::vector<GenericValue> &ArgVals);
void exitCalled(GenericValue GV);
- // getCurrentFunction - Return the currently executing function
- inline Function *getCurrentFunction() const {
- return CurFrame < 0 ? 0 : ECStack[CurFrame].CurFunction;
- }
-
- // isStopped - Return true if a program is stopped. Return false if no
- // program is running.
- //
- inline bool isStopped() const { return !ECStack.empty(); }
-
void addAtExitHandler(Function *F) {
AtExitHandlers.push_back(F);
}
@@ -170,16 +157,6 @@ private: // Helper functions
void *getPointerToFunction(Function *F) { return (void*)F; }
- // getCurrentExecutablePath() - Return the directory that the lli executable
- // lives in.
- //
- std::string getCurrentExecutablePath() const;
-
- // printCurrentInstruction - Print out the instruction that the virtual PC is
- // at, or fail silently if no program is running.
- //
- void printCurrentInstruction();
-
void initializeExecutionEngine();
void initializeExternalFunctions();
};