aboutsummaryrefslogtreecommitdiff
path: root/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2001-11-26 18:18:18 +0000
committerChris Lattner <sabre@nondot.org>2001-11-26 18:18:18 +0000
commit782b939db105c1ead1ee9420d95fae8c341dbf47 (patch)
treebb9ba6583ccd29a14a1252b0e6de2ec56da9a1be /lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
parenta8b3015d4039b6cf20d57cf3176b002f8d8978f5 (diff)
* 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
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp')
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp25
1 files changed, 25 insertions, 0 deletions
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<GenericValue> &Args) {
return GenericValue();
}
+// int atoi(char *)
+GenericValue lle_X_atoi(MethodType *M, const vector<GenericValue> &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<GenericValue> &Args) {
assert(Args.size() == 2);
@@ -237,6 +245,14 @@ GenericValue lle_X_log(MethodType *M, const vector<GenericValue> &Args) {
return GV;
}
+// double floor(double)
+GenericValue lle_X_floor(MethodType *M, const vector<GenericValue> &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<GenericValue> &Args) {
assert(Args.size() == 0);
@@ -260,6 +276,12 @@ GenericValue lle_X_srand48(MethodType *M, const vector<GenericValue> &Args) {
return GenericValue();
}
+// void srand(uint)
+GenericValue lle_X_srand(MethodType *M, const vector<GenericValue> &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<GenericValue> &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;