mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-28 04:33:05 +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);
|
void *FPtr = getPointerToFunction(F);
|
||||||
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
|
assert(FPtr && "Pointer to fn's code was null after getPointerToFunction");
|
||||||
|
const Type *RetTy = F->getReturnType();
|
||||||
|
|
||||||
if (ArgValues.size() == 3) {
|
// Handle some common cases first.
|
||||||
int (*PF)(int, char **, const char **) =
|
if (RetTy == Type::IntTy || RetTy == Type::UIntTy || RetTy == Type::VoidTy) {
|
||||||
(int(*)(int, char **, const char **))FPtr;
|
if (ArgValues.size() == 3) {
|
||||||
|
int (*PF)(int, char **, const char **) =
|
||||||
|
(int(*)(int, char **, const char **))FPtr;
|
||||||
|
|
||||||
// Call the function.
|
// Call the function.
|
||||||
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
rv.IntVal = PF(ArgValues[0].IntVal, (char **)GVTOP(ArgValues[1]),
|
||||||
(const char **)GVTOP(ArgValues[2]));
|
(const char **)GVTOP(ArgValues[2]));
|
||||||
return rv;
|
return rv;
|
||||||
} else if (ArgValues.size() == 1) {
|
} else if (ArgValues.size() == 1) {
|
||||||
int (*PF)(int) = (int(*)(int))FPtr;
|
int (*PF)(int) = (int(*)(int))FPtr;
|
||||||
rv.IntVal = PF(ArgValues[0].IntVal);
|
rv.IntVal = PF(ArgValues[0].IntVal);
|
||||||
return rv;
|
return rv;
|
||||||
} else if (ArgValues.size() == 0) {
|
} else if (ArgValues.size() == 0) {
|
||||||
int (*PF)() = (int(*)())FPtr;
|
int (*PF)() = (int(*)())FPtr;
|
||||||
rv.IntVal = PF();
|
rv.IntVal = PF();
|
||||||
return rv;
|
return rv;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This code should handle a couple of common cases efficiently, but
|
// FIXME: This code should handle a couple of common cases efficiently, but
|
||||||
|
Loading…
Reference in New Issue
Block a user