mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-13 04:38:24 +00:00
Add support for the new va_arg instruction
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@6029 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -130,11 +130,15 @@ bool BytecodeParser::ParseInstruction(const uchar *&Buf, const uchar *EndBuf,
|
||||
|
||||
Value *V;
|
||||
switch (Raw.Opcode) {
|
||||
case Instruction::VarArg:
|
||||
case Instruction::Cast: {
|
||||
V = getValue(Raw.Ty, Raw.Arg1);
|
||||
const Type *Ty = getType(Raw.Arg2);
|
||||
if (V == 0 || Ty == 0) { std::cerr << "Invalid cast!\n"; return true; }
|
||||
Res = new CastInst(V, Ty);
|
||||
if (Raw.Opcode == Instruction::Cast)
|
||||
Res = new CastInst(V, Ty);
|
||||
else
|
||||
Res = new VarArgInst(V, Ty);
|
||||
return false;
|
||||
}
|
||||
case Instruction::PHINode: {
|
||||
|
@ -35,7 +35,7 @@ static void outputInstructionFormat0(const Instruction *I,
|
||||
output_vbr(Type, Out); // Result type
|
||||
|
||||
unsigned NumArgs = I->getNumOperands();
|
||||
output_vbr(NumArgs + isa<CastInst>(I), Out);
|
||||
output_vbr(NumArgs + (isa<CastInst>(I) || isa<VarArgInst>(I)), Out);
|
||||
|
||||
for (unsigned i = 0; i < NumArgs; ++i) {
|
||||
int Slot = Table.getValSlot(I->getOperand(i));
|
||||
@ -43,9 +43,9 @@ static void outputInstructionFormat0(const Instruction *I,
|
||||
output_vbr((unsigned)Slot, Out);
|
||||
}
|
||||
|
||||
if (isa<CastInst>(I)) {
|
||||
if (isa<CastInst>(I) || isa<VarArgInst>(I)) {
|
||||
int Slot = Table.getValSlot(I->getType());
|
||||
assert(Slot != -1 && "Cast return type unknown?");
|
||||
assert(Slot != -1 && "Cast/VarArg return type unknown?");
|
||||
output_vbr((unsigned)Slot, Out);
|
||||
}
|
||||
|
||||
@ -218,7 +218,7 @@ void BytecodeWriter::processInstruction(const Instruction &I) {
|
||||
if (Slot > MaxOpSlot) MaxOpSlot = Slot;
|
||||
|
||||
// Handle the special case for cast...
|
||||
if (isa<CastInst>(I)) {
|
||||
if (isa<CastInst>(I) || isa<VarArgInst>(I)) {
|
||||
// Cast has to encode the destination type as the second argument in the
|
||||
// packet, or else we won't know what type to cast to!
|
||||
Slots[1] = Table.getValSlot(I.getType());
|
||||
|
Reference in New Issue
Block a user