Changes in directory llvm/lib/Bytecode/Writer:
Writer.cpp updated: 1.128 -> 1.129 --- Log message: For PR950: http://llvm.org/PR950 : The long awaited CAST patch. This introduces 12 new instructions into LLVM to replace the cast instruction. Corresponding changes throughout LLVM are provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the exception of 175.vpr which fails only on a slight floating point output difference. --- Diffs of the changes: (+12 -18) Writer.cpp | 30 ++++++++++++------------------ 1 files changed, 12 insertions(+), 18 deletions(-) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.128 llvm/lib/Bytecode/Writer/Writer.cpp:1.129 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.128 Wed Nov 8 15:27:54 2006 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Nov 26 19:05:09 2006 @@ -291,7 +291,7 @@ if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(CPV)) { // FIXME: Encoding of constant exprs could be much more compact! assert(CE->getNumOperands() > 0 && "ConstantExpr with 0 operands"); - assert(CE->getNumOperands() != 1 || CE->getOpcode() == Instruction::Cast); + assert(CE->getNumOperands() != 1 || CE->isCast()); output_vbr(1+CE->getNumOperands()); // flags as an expr output_vbr(CE->getOpcode()); // Put out the CE op code @@ -446,8 +446,8 @@ output_typeid(Type); // Result type unsigned NumArgs = I->getNumOperands(); - output_vbr(NumArgs + (isa<CastInst>(I) || - isa<VAArgInst>(I) || Opcode == 56 || Opcode == 58)); + output_vbr(NumArgs + (isa<CastInst>(I) || isa<InvokeInst>(I) || + isa<VAArgInst>(I) || Opcode == 58)); if (!isa<GetElementPtrInst>(&I)) { for (unsigned i = 0; i < NumArgs; ++i) { @@ -460,7 +460,7 @@ int Slot = Table.getSlot(I->getType()); assert(Slot != -1 && "Cast return type unknown?"); output_typeid((unsigned)Slot); - } else if (Opcode == 56) { // Invoke escape sequence + } else if (isa<InvokeInst>(I)) { output_vbr(cast<InvokeInst>(I)->getCallingConv()); } else if (Opcode == 58) { // Call escape sequence output_vbr((cast<CallInst>(I)->getCallingConv() << 1) | @@ -528,8 +528,8 @@ // variable argument. NumFixedOperands = 3+NumParams; } - output_vbr(2 * I->getNumOperands()-NumFixedOperands + - unsigned(Opcode == 56 || Opcode == 58)); + output_vbr(2 * I->getNumOperands()-NumFixedOperands + + unsigned(Opcode == 58 || isa<InvokeInst>(I))); // The type for the function has already been emitted in the type field of the // instruction. Just emit the slot # now. @@ -551,12 +551,12 @@ output_vbr((unsigned)Slot); } - // If this is the escape sequence for call, emit the tailcall/cc info. - if (Opcode == 58) { + if (isa<InvokeInst>(I)) { + // Emit the tail call/calling conv for invoke instructions + output_vbr(cast<InvokeInst>(I)->getCallingConv()); + } else if (Opcode == 58) { const CallInst *CI = cast<CallInst>(I); output_vbr((CI->getCallingConv() << 1) | unsigned(CI->isTailCall())); - } else if (Opcode == 56) { // Invoke escape sequence. - output_vbr(cast<InvokeInst>(I)->getCallingConv()); } } @@ -619,7 +619,7 @@ } void BytecodeWriter::outputInstruction(const Instruction &I) { - assert(I.getOpcode() < 56 && "Opcode too big???"); + assert(I.getOpcode() < 57 && "Opcode too big???"); unsigned Opcode = I.getOpcode(); unsigned NumOperands = I.getNumOperands(); @@ -639,12 +639,6 @@ } else { Opcode = 58; // Call escape sequence. } - } else if (const InvokeInst *II = dyn_cast<InvokeInst>(&I)) { - if (II->getCallingConv() == CallingConv::Fast) - Opcode = 57; // FastCC invoke. - else if (II->getCallingConv() != CallingConv::C) - Opcode = 56; // Invoke escape sequence. - } else if (isa<LoadInst>(I) && cast<LoadInst>(I).isVolatile()) { Opcode = 62; } else if (isa<StoreInst>(I) && cast<StoreInst>(I).isVolatile()) { @@ -750,7 +744,7 @@ if (Slots[NumOperands-1] > MaxOpSlot) MaxOpSlot = Slots[NumOperands-1]; } - } else if (Opcode == 56) { + } else if (isa<InvokeInst>(I)) { // Invoke escape seq has at least 4 operands to encode. ++NumOperands; } _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits