mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-02-27 02:31:09 +00:00
Implement vaarg instruction. This is not quite perfect: 2003-08-11-VaListArg
still causes a crash. But it's better than before. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9794 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
52709450c8
commit
c1a2be18ea
@ -820,6 +820,41 @@ void Interpreter::visitVANextInst(VANextInst &I) {
|
||||
SetValue(&I, VAList, SF);
|
||||
}
|
||||
|
||||
#define IMPLEMENT_VAARG(TY) \
|
||||
case Type::TY##TyID: Dest.TY##Val = Src.TY##Val; break
|
||||
|
||||
void Interpreter::visitVAArgInst(VAArgInst &I) {
|
||||
ExecutionContext &SF = ECStack.back();
|
||||
|
||||
// Get the incoming valist element. LLI treats the valist as an integer.
|
||||
GenericValue VAList = getOperandValue(I.getOperand(0), SF);
|
||||
unsigned Argument = VAList.IntVal;
|
||||
assert(Argument < SF.VarArgs.size() &&
|
||||
"Accessing past the last vararg argument!");
|
||||
GenericValue Dest, Src = SF.VarArgs[Argument];
|
||||
const Type *Ty = I.getType();
|
||||
switch (Ty->getPrimitiveID()) {
|
||||
IMPLEMENT_VAARG(UByte);
|
||||
IMPLEMENT_VAARG(SByte);
|
||||
IMPLEMENT_VAARG(UShort);
|
||||
IMPLEMENT_VAARG(Short);
|
||||
IMPLEMENT_VAARG(UInt);
|
||||
IMPLEMENT_VAARG(Int);
|
||||
IMPLEMENT_VAARG(ULong);
|
||||
IMPLEMENT_VAARG(Long);
|
||||
IMPLEMENT_VAARG(Pointer);
|
||||
IMPLEMENT_VAARG(Float);
|
||||
IMPLEMENT_VAARG(Double);
|
||||
IMPLEMENT_VAARG(Bool);
|
||||
default:
|
||||
std::cout << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
|
||||
abort();
|
||||
}
|
||||
|
||||
// Set the Value of this Instruction.
|
||||
SetValue(&I, Dest, SF);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Dispatch and Execution Code
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -130,6 +130,7 @@ public:
|
||||
void visitShl(ShiftInst &I);
|
||||
void visitShr(ShiftInst &I);
|
||||
void visitVANextInst(VANextInst &I);
|
||||
void visitVAArgInst(VAArgInst &I);
|
||||
void visitInstruction(Instruction &I) {
|
||||
std::cerr << I;
|
||||
assert(0 && "Instruction not interpretable yet!");
|
||||
|
Loading…
x
Reference in New Issue
Block a user