forked from OSchip/llvm-project
Interpret the new varargs intrinsics correctly
llvm-svn: 9222
This commit is contained in:
parent
9d57347490
commit
fefd3bebc4
|
@ -845,27 +845,17 @@ void Interpreter::visitCastInst(CastInst &I) {
|
|||
SetValue(&I, executeCastOperation(I.getOperand(0), I.getType(), SF), SF);
|
||||
}
|
||||
|
||||
void Interpreter::visitVarArgInst(VarArgInst &I) {
|
||||
void Interpreter::visitVANextInst(VANextInst &I) {
|
||||
ExecutionContext &SF = ECStack.back();
|
||||
|
||||
// Get the pointer to the valist element. LLI treats the valist in memory as
|
||||
// an integer.
|
||||
GenericValue VAListPtr = getOperandValue(I.getOperand(0), SF);
|
||||
|
||||
// Load the pointer
|
||||
GenericValue VAList =
|
||||
TheEE->LoadValueFromMemory((GenericValue *)GVTOP(VAListPtr), Type::UIntTy);
|
||||
// Get the incoming valist element. LLI treats the valist as an integer.
|
||||
GenericValue VAList = getOperandValue(I.getOperand(0), SF);
|
||||
|
||||
// Move to the next operand.
|
||||
unsigned Argument = VAList.IntVal++;
|
||||
|
||||
// Update the valist to point to the next argument...
|
||||
TheEE->StoreValueToMemory(VAList, (GenericValue *)GVTOP(VAListPtr),
|
||||
Type::UIntTy);
|
||||
|
||||
// Set the value...
|
||||
assert(Argument < SF.VarArgs.size() &&
|
||||
"Accessing past the last vararg argument!");
|
||||
SetValue(&I, SF.VarArgs[Argument], SF);
|
||||
SetValue(&I, VAList, SF);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
|
|
@ -687,14 +687,12 @@ GenericValue lle_X_fprintf(FunctionType *M, const vector<GenericValue> &Args) {
|
|||
// LLVM Intrinsic Functions...
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// void llvm.va_start(<va_list> *) - Implement the va_start operation...
|
||||
// <va_list> llvm.va_start() - Implement the va_start operation...
|
||||
GenericValue llvm_va_start(FunctionType *F, const vector<GenericValue> &Args) {
|
||||
assert(Args.size() == 1);
|
||||
GenericValue *VAListP = (GenericValue *)GVTOP(Args[0]);
|
||||
assert(Args.size() == 0);
|
||||
GenericValue Val;
|
||||
Val.UIntVal = 0; // Start at the first '...' argument...
|
||||
TheInterpreter->StoreValueToMemory(Val, VAListP, Type::UIntTy);
|
||||
return GenericValue();
|
||||
return Val;
|
||||
}
|
||||
|
||||
// void llvm.va_end(<va_list> *) - Implement the va_end operation...
|
||||
|
@ -703,13 +701,10 @@ GenericValue llvm_va_end(FunctionType *F, const vector<GenericValue> &Args) {
|
|||
return GenericValue(); // Noop!
|
||||
}
|
||||
|
||||
// void llvm.va_copy(<va_list> *, <va_list>) - Implement the va_copy
|
||||
// operation...
|
||||
// <va_list> llvm.va_copy(<va_list>) - Implement the va_copy operation...
|
||||
GenericValue llvm_va_copy(FunctionType *F, const vector<GenericValue> &Args) {
|
||||
assert(Args.size() == 2);
|
||||
GenericValue *DestVAList = (GenericValue*)GVTOP(Args[0]);
|
||||
TheInterpreter->StoreValueToMemory(Args[1], DestVAList, Type::UIntTy);
|
||||
return GenericValue();
|
||||
assert(Args.size() == 1);
|
||||
return Args[0];
|
||||
}
|
||||
|
||||
} // End extern "C"
|
||||
|
|
|
@ -131,7 +131,7 @@ public:
|
|||
void visitCallInst(CallInst &I);
|
||||
void visitShl(ShiftInst &I);
|
||||
void visitShr(ShiftInst &I);
|
||||
void visitVarArgInst(VarArgInst &I);
|
||||
void visitVANextInst(VANextInst &I);
|
||||
void visitInstruction(Instruction &I) {
|
||||
std::cerr << I;
|
||||
assert(0 && "Instruction not interpretable yet!");
|
||||
|
|
Loading…
Reference in New Issue