add bytecode reader support for tail calls
authorChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 06:13:34 +0000 (06:13 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 6 May 2005 06:13:34 +0000 (06:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21727 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bytecode/Reader/Reader.cpp
lib/Bytecode/Writer/Writer.cpp

index 82a73fa59983f76e57d5c900ea183c0d279e46da..24875e42fd154f60e8eb1e09923617724e6e9e13 100644 (file)
@@ -720,6 +720,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
     break;
   }
 
+  case 61:  // tail call
   case Instruction::Call: {
     if (Oprnds.size() == 0)
       error("Invalid call instruction encountered!");
@@ -765,6 +766,7 @@ void BytecodeReader::ParseInstruction(std::vector<unsigned> &Oprnds,
     }
 
     Result = new CallInst(F, Params);
+    if (Opcode == 61) cast<CallInst>(Result)->setTailCall(true);
     break;
   }
   case Instruction::Invoke: {
index f6d09c822012c850768702e13a68394f05be6525..5f614fddf081d9980eb468ca56a7644f499fc5df 100644 (file)
@@ -606,7 +606,10 @@ void BytecodeWriter::outputInstruction(const Instruction &I) {
   unsigned Opcode = I.getOpcode();
   unsigned NumOperands = I.getNumOperands();
 
-  // Encode 'volatile load' as 62 and 'volatile store' as 63.
+  // Encode 'tail call' as 61, 'volatile load' as 62, and 'volatile store' as
+  // 63.
+  if (isa<CallInst>(I) && cast<CallInst>(I).isTailCall())
+    Opcode = 61;
   if (isa<LoadInst>(I) && cast<LoadInst>(I).isVolatile())
     Opcode = 62;
   if (isa<StoreInst>(I) && cast<StoreInst>(I).isVolatile())