* 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
This commit is contained in:
Chris Lattner
2001-11-26 18:18:18 +00:00
parent a8b3015d40
commit 782b939db1
2 changed files with 69 additions and 24 deletions

View File

@ -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;