aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
diff options
context:
space:
mode:
authorZhou Sheng <zhousheng00@gmail.com>2007-12-12 04:55:43 +0000
committerZhou Sheng <zhousheng00@gmail.com>2007-12-12 04:55:43 +0000
commit6a7951ce9bc9e5f21fcee7314893345acd4e77d7 (patch)
treece6938f883912f83722403d787a6353033fe5fc2 /lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
parent7f135cc802435171ab09ebd6a514db26a122b99a (diff)
downloadexternal_llvm-6a7951ce9bc9e5f21fcee7314893345acd4e77d7.zip
external_llvm-6a7951ce9bc9e5f21fcee7314893345acd4e77d7.tar.gz
external_llvm-6a7951ce9bc9e5f21fcee7314893345acd4e77d7.tar.bz2
Fixed PR1629.
Make lli interpreter correctly call external functions sin()/cos(), __cxa_guard_acquire() and __cxa_guard_release(). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@44910 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp')
-rw-r--r--lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
index ab05414..12bfb8e 100644
--- a/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
+++ b/lib/ExecutionEngine/Interpreter/ExternalFunctions.cpp
@@ -29,6 +29,7 @@
#include <csignal>
#include <map>
#include <cmath>
+#include <cxxabi.h>
using std::vector;
using namespace llvm;
@@ -200,6 +201,22 @@ GenericValue lle_X_pow(FunctionType *FT, const vector<GenericValue> &Args) {
return GV;
}
+// double sin(double)
+GenericValue lle_X_sin(FunctionType *FT, const vector<GenericValue> &Args) {
+ assert(Args.size() == 1);
+ GenericValue GV;
+ GV.DoubleVal = sin(Args[0].DoubleVal);
+ return GV;
+}
+
+// double cos(double)
+GenericValue lle_X_cos(FunctionType *FT, const vector<GenericValue> &Args) {
+ assert(Args.size() == 1);
+ GenericValue GV;
+ GV.DoubleVal = cos(Args[0].DoubleVal);
+ return GV;
+}
+
// double exp(double)
GenericValue lle_X_exp(FunctionType *FT, const vector<GenericValue> &Args) {
assert(Args.size() == 1);
@@ -705,6 +722,24 @@ GenericValue lle_X_fprintf(FunctionType *FT, const vector<GenericValue> &Args) {
return GV;
}
+// int __cxa_guard_acquire (__guard *g);
+GenericValue lle_X___cxa_guard_acquire(FunctionType *FT,
+ const vector<GenericValue> &Args) {
+ assert(Args.size() == 1);
+ GenericValue GV;
+ GV.IntVal = APInt(32, __cxxabiv1::__cxa_guard_acquire (
+ (__cxxabiv1::__guard*)GVTOP(Args[0])));
+ return GV;
+}
+
+// void __cxa_guard_release (__guard *g);
+GenericValue lle_X___cxa_guard_release(FunctionType *FT,
+ const vector<GenericValue> &Args) {
+ assert(Args.size() == 1);
+ __cxxabiv1::__cxa_guard_release ((__cxxabiv1::__guard*)GVTOP(Args[0]));
+ return GenericValue();
+}
+
} // End extern "C"
@@ -719,6 +754,8 @@ void Interpreter::initializeExternalFunctions() {
FuncNames["lle_X_free"] = lle_X_free;
FuncNames["lle_X_atoi"] = lle_X_atoi;
FuncNames["lle_X_pow"] = lle_X_pow;
+ FuncNames["lle_X_sin"] = lle_X_sin;
+ FuncNames["lle_X_cos"] = lle_X_cos;
FuncNames["lle_X_exp"] = lle_X_exp;
FuncNames["lle_X_log"] = lle_X_log;
FuncNames["lle_X_floor"] = lle_X_floor;
@@ -759,5 +796,8 @@ void Interpreter::initializeExternalFunctions() {
FuncNames["lle_X_ungetc"] = lle_X_ungetc;
FuncNames["lle_X_fprintf"] = lle_X_fprintf;
FuncNames["lle_X_freopen"] = lle_X_freopen;
+
+ FuncNames["lle_X___cxa_guard_acquire"] = lle_X___cxa_guard_acquire;
+ FuncNames["lle_X____cxa_guard_release"] = lle_X___cxa_guard_release;
}