diff options
Diffstat (limited to 'contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp')
-rw-r--r-- | contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp | 58 |
1 files changed, 22 insertions, 36 deletions
diff --git a/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index b022101..9b44042 100644 --- a/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/contrib/llvm/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -49,8 +49,7 @@ using namespace llvm; static ManagedStatic<sys::Mutex> FunctionsLock; -typedef GenericValue (*ExFunc)(FunctionType *, - const std::vector<GenericValue> &); +typedef GenericValue (*ExFunc)(FunctionType *, ArrayRef<GenericValue>); static ManagedStatic<std::map<const Function *, ExFunc> > ExportedFunctions; static ManagedStatic<std::map<std::string, ExFunc> > FuncNames; @@ -95,16 +94,15 @@ static ExFunc lookupFunction(const Function *F) { FunctionType *FT = F->getFunctionType(); for (unsigned i = 0, e = FT->getNumContainedTypes(); i != e; ++i) ExtName += getTypeID(FT->getContainedType(i)); - ExtName += "_" + F->getName().str(); + ExtName += ("_" + F->getName()).str(); sys::ScopedLock Writer(*FunctionsLock); ExFunc FnPtr = (*FuncNames)[ExtName]; if (!FnPtr) - FnPtr = (*FuncNames)["lle_X_" + F->getName().str()]; + FnPtr = (*FuncNames)[("lle_X_" + F->getName()).str()]; if (!FnPtr) // Try calling a generic function... if it exists... - FnPtr = (ExFunc)(intptr_t) - sys::DynamicLibrary::SearchForAddressOfSymbol("lle_X_" + - F->getName().str()); + FnPtr = (ExFunc)(intptr_t)sys::DynamicLibrary::SearchForAddressOfSymbol( + ("lle_X_" + F->getName()).str()); if (FnPtr) ExportedFunctions->insert(std::make_pair(F, FnPtr)); // Cache for later return FnPtr; @@ -179,8 +177,7 @@ static void *ffiValueFor(Type *Ty, const GenericValue &AV, return NULL; } -static bool ffiInvoke(RawFunc Fn, Function *F, - const std::vector<GenericValue> &ArgVals, +static bool ffiInvoke(RawFunc Fn, Function *F, ArrayRef<GenericValue> ArgVals, const DataLayout *TD, GenericValue &Result) { ffi_cif cif; FunctionType *FTy = F->getFunctionType(); @@ -246,7 +243,7 @@ static bool ffiInvoke(RawFunc Fn, Function *F, #endif // USE_LIBFFI GenericValue Interpreter::callExternalFunction(Function *F, - const std::vector<GenericValue> &ArgVals) { + ArrayRef<GenericValue> ArgVals) { TheInterpreter = this; unique_lock<sys::Mutex> Guard(*FunctionsLock); @@ -299,9 +296,8 @@ GenericValue Interpreter::callExternalFunction(Function *F, // // void atexit(Function*) -static -GenericValue lle_X_atexit(FunctionType *FT, - const std::vector<GenericValue> &Args) { +static GenericValue lle_X_atexit(FunctionType *FT, + ArrayRef<GenericValue> Args) { assert(Args.size() == 1); TheInterpreter->addAtExitHandler((Function*)GVTOP(Args[0])); GenericValue GV; @@ -310,17 +306,13 @@ GenericValue lle_X_atexit(FunctionType *FT, } // void exit(int) -static -GenericValue lle_X_exit(FunctionType *FT, - const std::vector<GenericValue> &Args) { +static GenericValue lle_X_exit(FunctionType *FT, ArrayRef<GenericValue> Args) { TheInterpreter->exitCalled(Args[0]); return GenericValue(); } // void abort(void) -static -GenericValue lle_X_abort(FunctionType *FT, - const std::vector<GenericValue> &Args) { +static GenericValue lle_X_abort(FunctionType *FT, ArrayRef<GenericValue> Args) { //FIXME: should we report or raise here? //report_fatal_error("Interpreted program raised SIGABRT"); raise (SIGABRT); @@ -329,9 +321,8 @@ 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) { +static GenericValue lle_X_sprintf(FunctionType *FT, + ArrayRef<GenericValue> Args) { char *OutputBuffer = (char *)GVTOP(Args[0]); const char *FmtStr = (const char *)GVTOP(Args[1]); unsigned ArgNo = 2; @@ -412,9 +403,8 @@ GenericValue lle_X_sprintf(FunctionType *FT, // int printf(const char *, ...) - a very rough implementation to make output // useful. -static -GenericValue lle_X_printf(FunctionType *FT, - const std::vector<GenericValue> &Args) { +static GenericValue lle_X_printf(FunctionType *FT, + ArrayRef<GenericValue> Args) { char Buffer[10000]; std::vector<GenericValue> NewArgs; NewArgs.push_back(PTOGV((void*)&Buffer[0])); @@ -425,9 +415,8 @@ GenericValue lle_X_printf(FunctionType *FT, } // int sscanf(const char *format, ...); -static -GenericValue lle_X_sscanf(FunctionType *FT, - const std::vector<GenericValue> &args) { +static GenericValue lle_X_sscanf(FunctionType *FT, + ArrayRef<GenericValue> args) { assert(args.size() < 10 && "Only handle up to 10 args to sscanf right now!"); char *Args[10]; @@ -441,9 +430,7 @@ GenericValue lle_X_sscanf(FunctionType *FT, } // int scanf(const char *format, ...); -static -GenericValue lle_X_scanf(FunctionType *FT, - const std::vector<GenericValue> &args) { +static GenericValue lle_X_scanf(FunctionType *FT, ArrayRef<GenericValue> args) { assert(args.size() < 10 && "Only handle up to 10 args to scanf right now!"); char *Args[10]; @@ -458,9 +445,8 @@ 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) { +static GenericValue lle_X_fprintf(FunctionType *FT, + ArrayRef<GenericValue> Args) { assert(Args.size() >= 2); char Buffer[10000]; std::vector<GenericValue> NewArgs; @@ -473,7 +459,7 @@ GenericValue lle_X_fprintf(FunctionType *FT, } static GenericValue lle_X_memset(FunctionType *FT, - const std::vector<GenericValue> &Args) { + ArrayRef<GenericValue> Args) { int val = (int)Args[1].IntVal.getSExtValue(); size_t len = (size_t)Args[2].IntVal.getZExtValue(); memset((void *)GVTOP(Args[0]), val, len); @@ -485,7 +471,7 @@ static GenericValue lle_X_memset(FunctionType *FT, } static GenericValue lle_X_memcpy(FunctionType *FT, - const std::vector<GenericValue> &Args) { + ArrayRef<GenericValue> Args) { memcpy(GVTOP(Args[0]), GVTOP(Args[1]), (size_t)(Args[2].IntVal.getLimitedValue())); |