[llvm-commits] [llvm] r47471 - in /llvm/trunk: include/llvm/Bitcode/LLVMBitCodes.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp

Chris Lattner clattner at apple.com
Thu Feb 21 21:56:59 PST 2008


On Feb 21, 2008, at 6:49 PM, Devang Patel wrote:

> Author: dpatel
> Date: Thu Feb 21 20:49:49 2008
> New Revision: 47471
>
> URL: http://llvm.org/viewvc/llvm-project?rev=47471&view=rev
> Log:
> Read and write getresult.

Ok:

> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
> +++ llvm/trunk/lib/Bitcode/Writer/BitcodeWriter.cpp Thu Feb 21  
> 20:49:49 2008
> @@ -744,6 +744,11 @@
>     Vals.push_back(VE.getValueID(I.getOperand(1)));
>     Vals.push_back(cast<CmpInst>(I).getPredicate());
>     break;
> +  case Instruction::GetResult:
> +    Code = bitc::FUNC_CODE_INST_GETRESULT;
> +    PushValueAndType(I.getOperand(0), InstID, Vals, VE);
> +    Vals.push_back(Log2_32(cast<GetResultInst>(I).getIndex())+1);
> +    break;

You don't need to (and can't) use Log2+1 here.  Unlike alignment, any  
index is valid, not just powers of 2.

> +++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Thu Feb 21  
> 20:49:49 2008
> +    case bitc::FUNC_CODE_INST_GETRESULT: { // GETRESULT: [ty, val, n]
> +      if (Record.size() != 2)
> +        return Error("Invalid GETRESULT record");
> +      unsigned OpNum = 0;
> +      Value *Op;
> +      getValueTypePair(Record, OpNum, NextValueNo, Op);
> +      unsigned Index = Record[1];
> +      I = new GetResultInst(Op, Index);
> +      break;

Does this actually work?

-Chris




More information about the llvm-commits mailing list