From 782b939db105c1ead1ee9420d95fae8c341dbf47 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 26 Nov 2001 18:18:18 +0000 Subject: * Implement array indexing in lli * Add external atoi method as well as floor, and srand git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@1355 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../Interpreter/ExternalFunctions.cpp | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp') diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp index 00549a41be..b42fb50ecd 100644 --- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp +++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp @@ -213,6 +213,14 @@ GenericValue lle_X_free(MethodType *M, const vector &Args) { return GenericValue(); } +// int atoi(char *) +GenericValue lle_X_atoi(MethodType *M, const vector &Args) { + assert(Args.size() == 1); + GenericValue GV; + GV.IntVal = atoi((char*)Args[0].PointerVal); + return GV; +} + // double pow(double, double) GenericValue lle_X_pow(MethodType *M, const vector &Args) { assert(Args.size() == 2); @@ -237,6 +245,14 @@ GenericValue lle_X_log(MethodType *M, const vector &Args) { return GV; } +// double floor(double) +GenericValue lle_X_floor(MethodType *M, const vector &Args) { + assert(Args.size() == 1); + GenericValue GV; + GV.DoubleVal = floor(Args[0].DoubleVal); + return GV; +} + // double drand48() GenericValue lle_X_drand48(MethodType *M, const vector &Args) { assert(Args.size() == 0); @@ -260,6 +276,12 @@ GenericValue lle_X_srand48(MethodType *M, const vector &Args) { return GenericValue(); } +// void srand(uint) +GenericValue lle_X_srand(MethodType *M, const vector &Args) { + assert(Args.size() == 1); + srand(Args[0].UIntVal); + return GenericValue(); +} // int printf(sbyte *, ...) - a very rough implementation to make output useful. GenericValue lle_X_printf(MethodType *M, const vector &Args) { @@ -352,8 +374,11 @@ void Interpreter::initializeExternalMethods() { FuncNames["lle_X_exit"] = lle_X_exit; FuncNames["lle_X_malloc"] = lle_X_malloc; FuncNames["lle_X_free"] = lle_X_free; + FuncNames["lle_X_atoi"] = lle_X_atoi; FuncNames["lle_X_pow"] = lle_X_pow; FuncNames["lle_X_log"] = lle_X_log; + FuncNames["lle_X_floor"] = lle_X_floor; + FuncNames["lle_X_srand"] = lle_X_srand; FuncNames["lle_X_drand48"] = lle_X_drand48; FuncNames["lle_X_srand48"] = lle_X_srand48; FuncNames["lle_X_lrand48"] = lle_X_lrand48; -- cgit v1.2.3-18-g5258