diff options
Diffstat (limited to 'lib/ExecutionEngine/Interpreter')
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Execution.cpp | 25 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | 24 | ||||
-rw-r--r-- | lib/ExecutionEngine/Interpreter/Interpreter.h | 7 |
3 files changed, 17 insertions, 39 deletions
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp index 27917da..3dce3b3 100644 --- a/lib/ExecutionEngine/Interpreter/Execution.cpp +++ b/lib/ExecutionEngine/Interpreter/Execution.cpp @@ -625,24 +625,6 @@ void Interpreter::visitReturnInst(ReturnInst &I) { popStackAndReturnValueToCaller(RetTy, Result); } -void Interpreter::visitUnwindInst(UnwindInst &I) { - // Unwind stack - Instruction *Inst; - do { - ECStack.pop_back(); - if (ECStack.empty()) - report_fatal_error("Empty stack during unwind!"); - Inst = ECStack.back().Caller.getInstruction(); - } while (!(Inst && isa<InvokeInst>(Inst))); - - // Return from invoke - ExecutionContext &InvokingSF = ECStack.back(); - InvokingSF.Caller = CallSite(); - - // Go to exceptional destination BB of invoke instruction - SwitchToNewBasicBlock(cast<InvokeInst>(Inst)->getUnwindDest(), InvokingSF); -} - void Interpreter::visitUnreachableInst(UnreachableInst &I) { report_fatal_error("Program executed an 'unreachable' instruction!"); } @@ -670,10 +652,10 @@ void Interpreter::visitSwitchInst(SwitchInst &I) { BasicBlock *Dest = 0; unsigned NumCases = I.getNumCases(); // Skip the first item since that's the default case. - for (unsigned i = 1; i < NumCases; ++i) { + for (unsigned i = 0; i < NumCases; ++i) { GenericValue CaseVal = getOperandValue(I.getCaseValue(i), SF); if (executeICMP_EQ(CondVal, CaseVal, ElTy).IntVal != 0) { - Dest = cast<BasicBlock>(I.getSuccessor(i)); + Dest = cast<BasicBlock>(I.getCaseSuccessor(i)); break; } } @@ -1253,8 +1235,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE, break; default: dbgs() << "Unhandled ConstantExpr: " << *CE << "\n"; - llvm_unreachable(0); - return GenericValue(); + llvm_unreachable("Unhandled ConstantExpr"); } return Dest; } diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 1bcdbe2..7a206eb 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -297,14 +297,8 @@ GenericValue Interpreter::callExternalFunction(Function *F, // Functions "exported" to the running application... // -// Visual Studio warns about returning GenericValue in extern "C" linkage -#ifdef _MSC_VER - #pragma warning(disable : 4190) -#endif - -extern "C" { // Don't add C++ manglings to llvm mangling :) - // void atexit(Function*) +static GenericValue lle_X_atexit(FunctionType *FT, const std::vector<GenericValue> &Args) { assert(Args.size() == 1); @@ -315,6 +309,7 @@ GenericValue lle_X_atexit(FunctionType *FT, } // void exit(int) +static GenericValue lle_X_exit(FunctionType *FT, const std::vector<GenericValue> &Args) { TheInterpreter->exitCalled(Args[0]); @@ -322,6 +317,7 @@ GenericValue lle_X_exit(FunctionType *FT, } // void abort(void) +static GenericValue lle_X_abort(FunctionType *FT, const std::vector<GenericValue> &Args) { //FIXME: should we report or raise here? @@ -332,6 +328,7 @@ GenericValue lle_X_abort(FunctionType *FT, // int sprintf(char *, const char *, ...) - a very rough implementation to make // output useful. +static GenericValue lle_X_sprintf(FunctionType *FT, const std::vector<GenericValue> &Args) { char *OutputBuffer = (char *)GVTOP(Args[0]); @@ -409,11 +406,11 @@ GenericValue lle_X_sprintf(FunctionType *FT, break; } } - return GV; } // int printf(const char *, ...) - a very rough implementation to make output // useful. +static GenericValue lle_X_printf(FunctionType *FT, const std::vector<GenericValue> &Args) { char Buffer[10000]; @@ -426,6 +423,7 @@ GenericValue lle_X_printf(FunctionType *FT, } // int sscanf(const char *format, ...); +static GenericValue lle_X_sscanf(FunctionType *FT, const std::vector<GenericValue> &args) { assert(args.size() < 10 && "Only handle up to 10 args to sscanf right now!"); @@ -441,6 +439,7 @@ GenericValue lle_X_sscanf(FunctionType *FT, } // int scanf(const char *format, ...); +static GenericValue lle_X_scanf(FunctionType *FT, const std::vector<GenericValue> &args) { assert(args.size() < 10 && "Only handle up to 10 args to scanf right now!"); @@ -457,6 +456,7 @@ GenericValue lle_X_scanf(FunctionType *FT, // int fprintf(FILE *, const char *, ...) - a very rough implementation to make // output useful. +static GenericValue lle_X_fprintf(FunctionType *FT, const std::vector<GenericValue> &Args) { assert(Args.size() >= 2); @@ -470,14 +470,6 @@ GenericValue lle_X_fprintf(FunctionType *FT, return GV; } -} // End extern "C" - -// Done with externals; turn the warning back on -#ifdef _MSC_VER - #pragma warning(default: 4190) -#endif - - void Interpreter::initializeExternalFunctions() { sys::ScopedLock Writer(*FunctionsLock); FuncNames["lle_X_atexit"] = lle_X_atexit; diff --git a/lib/ExecutionEngine/Interpreter/Interpreter.h b/lib/ExecutionEngine/Interpreter/Interpreter.h index ee2b459..28c5775 100644 --- a/lib/ExecutionEngine/Interpreter/Interpreter.h +++ b/lib/ExecutionEngine/Interpreter/Interpreter.h @@ -115,6 +115,12 @@ public: virtual GenericValue runFunction(Function *F, const std::vector<GenericValue> &ArgValues); + virtual void *getPointerToNamedFunction(const std::string &Name, + bool AbortOnFailure = true) { + // FIXME: not implemented. + return 0; + } + /// recompileAndRelinkFunction - For the interpreter, functions are always /// up-to-date. /// @@ -165,7 +171,6 @@ public: void visitCallSite(CallSite CS); void visitCallInst(CallInst &I) { visitCallSite (CallSite (&I)); } void visitInvokeInst(InvokeInst &I) { visitCallSite (CallSite (&I)); } - void visitUnwindInst(UnwindInst &I); void visitUnreachableInst(UnreachableInst &I); void visitShl(BinaryOperator &I); |