diff options
author | Chris Lattner <sabre@nondot.org> | 2003-05-08 02:44:12 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-05-08 02:44:12 +0000 |
commit | f70da10697770f1d4015d7ecd35fd8664c4d0228 (patch) | |
tree | 191647225f0db537df7c99a14fa5cf8fe2a55141 /llvm/lib/Bytecode | |
parent | e10061e202d0b7546194da30de66db24a51966b2 (diff) | |
download | bcm5719-llvm-f70da10697770f1d4015d7ecd35fd8664c4d0228.tar.gz bcm5719-llvm-f70da10697770f1d4015d7ecd35fd8664c4d0228.zip |
Add support for the new va_arg instruction
llvm-svn: 6029
Diffstat (limited to 'llvm/lib/Bytecode')
-rw-r--r-- | llvm/lib/Bytecode/Reader/InstructionReader.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/Bytecode/Writer/InstructionWriter.cpp | 8 |
2 files changed, 9 insertions, 5 deletions
diff --git a/llvm/lib/Bytecode/Reader/InstructionReader.cpp b/llvm/lib/Bytecode/Reader/InstructionReader.cpp index e2c8336e95d..2fc52ad71a9 100644 --- a/llvm/lib/Bytecode/Reader/InstructionReader.cpp +++ b/llvm/lib/Bytecode/Reader/InstructionReader.cpp @@ -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: { diff --git a/llvm/lib/Bytecode/Writer/InstructionWriter.cpp b/llvm/lib/Bytecode/Writer/InstructionWriter.cpp index 587e6d1be62..63aede198e4 100644 --- a/llvm/lib/Bytecode/Writer/InstructionWriter.cpp +++ b/llvm/lib/Bytecode/Writer/InstructionWriter.cpp @@ -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()); |