From b7fbc8b228990410dd0e20e8dfdecc6169c74ae0 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Tue, 26 Feb 2008 01:29:32 +0000 Subject: Update bitcode reader and writer to handle multiple return values. Take 2. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@47583 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Writer/BitcodeWriter.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'lib/Bitcode/Writer') diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 9b2b93c..6a54514 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -747,15 +747,24 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, case Instruction::GetResult: Code = bitc::FUNC_CODE_INST_GETRESULT; PushValueAndType(I.getOperand(0), InstID, Vals, VE); - Vals.push_back(Log2_32(cast(I).getIndex())+1); + Vals.push_back(cast(I).getIndex()); break; - case Instruction::Ret: - Code = bitc::FUNC_CODE_INST_RET; - if (!I.getNumOperands()) - AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV; - else if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE)) - AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV; + case Instruction::Ret: + { + Code = bitc::FUNC_CODE_INST_RET; + unsigned NumOperands = I.getNumOperands(); + // printf ("dpatel write %d\n", NumOperands); + if (NumOperands == 0) + AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV; + else if (NumOperands == 1) { + if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE)) + AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV; + } else { + for (unsigned i = 0, e = NumOperands; i != e; ++i) + PushValueAndType(I.getOperand(i), InstID, Vals, VE); + } + } break; case Instruction::Br: Code = bitc::FUNC_CODE_INST_BR; -- cgit v1.1