mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-26 13:10:34 +00:00
These only really work if returning int or void
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@15796 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
95f114c5a9
commit
d297aea5f2
@ -63,23 +63,27 @@ GenericValue JIT::runFunction(Function *F,
|
||||
|
||||
void *FPtr = getPointerToFunction(F);
|
||||
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
|
||||
const Type *RetTy = F->getReturnType();
|
||||
|
||||
if (ArgValues.size() == 3) {
|
||||
int (*PF)(int, char **, const char **) =
|
||||
(int(*)(int, char **, const char **))FPtr;
|
||||
|
||||
// Call the function.
|
||||
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
||||
(const char **)GVTOP(ArgValues[2]));
|
||||
return rv;
|
||||
} else if (ArgValues.size() == 1) {
|
||||
int (*PF)(int) = (int(*)(int))FPtr;
|
||||
rv.IntVal = PF(ArgValues[0].IntVal);
|
||||
return rv;
|
||||
} else if (ArgValues.size() == 0) {
|
||||
int (*PF)() = (int(*)())FPtr;
|
||||
rv.IntVal = PF();
|
||||
return rv;
|
||||
// Handle some common cases first.
|
||||
if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) {
|
||||
if (ArgValues.size() == 3) {
|
||||
int (*PF)(int, char **, const char **) =
|
||||
(int(*)(int, char **, const char **))FPtr;
|
||||
|
||||
// Call the function.
|
||||
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
||||
(const char **)GVTOP(ArgValues[2]));
|
||||
return rv;
|
||||
} else if (ArgValues.size() == 1) {
|
||||
int (*PF)(int) = (int(*)(int))FPtr;
|
||||
rv.IntVal = PF(ArgValues[0].IntVal);
|
||||
return rv;
|
||||
} else if (ArgValues.size() == 0) {
|
||||
int (*PF)() = (int(*)())FPtr;
|
||||
rv.IntVal = PF();
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: This code should handle a couple of common cases efficiently, but
|
||||
|
Loading…
Reference in New Issue
Block a user