Index: llvm/lib/ExecutionEngine/Interpreter/Interpreter.h =================================================================== --- llvm/lib/ExecutionEngine/Interpreter/Interpreter.h +++ llvm/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -24,11 +24,10 @@ namespace llvm { class IntrinsicLowering; -template class generic_gep_type_iterator; +template class generic_gep_type_iterator; class ConstantExpr; typedef generic_gep_type_iterator gep_type_iterator; - // AllocaHolder - Object to track all of the blocks of memory allocated by // alloca. When the function returns, this object is popped off the execution // stack, which causes the dtor to be run, which frees all the alloca'd memory. @@ -57,22 +56,24 @@ // executing. // struct ExecutionContext { - Function *CurFunction;// The currently executing function - BasicBlock *CurBB; // The currently executing BB - BasicBlock::iterator CurInst; // The next instruction to execute - CallBase *Caller; // Holds the call that called subframes. - // NULL if main func or debugger invoked fn + Function *CurFunction; // The currently executing function + BasicBlock *CurBB; // The currently executing BB + BasicBlock::iterator CurInst; // The next instruction to execute + CallBase *Caller; // Holds the call that called subframes. + // NULL if main func or debugger invoked fn std::map Values; // LLVM values used in this invocation - std::vector VarArgs; // Values passed through an ellipsis - AllocaHolder Allocas; // Track memory allocated by alloca + std::vector VarArgs; // Values passed through an ellipsis + AllocaHolder Allocas; // Track memory allocated by alloca - ExecutionContext() : CurFunction(nullptr), CurBB(nullptr), CurInst(nullptr) {} + ExecutionContext() + : CurFunction(nullptr), CurBB(nullptr), CurInst(nullptr), + Caller(nullptr) {} }; // Interpreter - This class represents the entirety of the interpreter. // class Interpreter : public ExecutionEngine, public InstVisitor { - GenericValue ExitValue; // The return value of the called function + GenericValue ExitValue; // The return value of the called function IntrinsicLowering *IL; // The runtime stack of executing code. The top of the stack is the current @@ -81,7 +82,7 @@ // AtExitHandlers - List of functions to call when the program exits, // registered with the atexit() library function. - std::vector AtExitHandlers; + std::vector AtExitHandlers; public: explicit Interpreter(std::unique_ptr M); @@ -92,9 +93,7 @@ /// void runAtExitHandlers(); - static void Register() { - InterpCtor = create; - } + static void Register() { InterpCtor = create; } /// Create an interpreter ExecutionEngine. /// @@ -115,7 +114,7 @@ // Methods used to execute code: // Place a call on the stack void callFunction(Function *F, ArrayRef ArgVals); - void run(); // Execute instructions until nothing left to do + void run(); // Execute instructions until nothing left to do // Opcode Implementations void visitReturnInst(ReturnInst &I); @@ -176,15 +175,11 @@ ArrayRef ArgVals); void exitCalled(GenericValue GV); - void addAtExitHandler(Function *F) { - AtExitHandlers.push_back(F); - } + void addAtExitHandler(Function *F) { AtExitHandlers.push_back(F); } - GenericValue *getFirstVarArg () { - return &(ECStack.back ().VarArgs[0]); - } + GenericValue *getFirstVarArg() { return &(ECStack.back().VarArgs[0]); } -private: // Helper functions +private: // Helper functions GenericValue executeGEPOperation(Value *Ptr, gep_type_iterator I, gep_type_iterator E, ExecutionContext &SF); @@ -194,9 +189,9 @@ // void SwitchToNewBasicBlock(BasicBlock *Dest, ExecutionContext &SF); - void *getPointerToFunction(Function *F) override { return (void*)F; } + void *getPointerToFunction(Function *F) override { return (void *)F; } - void initializeExecutionEngine() { } + void initializeExecutionEngine() {} void initializeExternalFunctions(); GenericValue getConstantExprValue(ConstantExpr *CE, ExecutionContext &SF); GenericValue getOperandValue(Value *V, ExecutionContext &SF); @@ -227,9 +222,8 @@ GenericValue executeCastOperation(Instruction::CastOps opcode, Value *SrcVal, Type *Ty, ExecutionContext &SF); void popStackAndReturnValueToCaller(Type *RetTy, GenericValue Result); - }; -} // End llvm namespace +} // namespace llvm #endif