From 38287bdfde17249ed4725aa906ec15c59ccfe610 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 6 May 2005 06:13:34 +0000 Subject: [PATCH] add bytecode reader support for tail calls git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21727 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Reader/Reader.cpp | 2 ++ lib/Bytecode/Writer/Writer.cpp | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp index 82a73fa5998..24875e42fd1 100644 --- a/lib/Bytecode/Reader/Reader.cpp +++ b/lib/Bytecode/Reader/Reader.cpp @@ -720,6 +720,7 @@ void BytecodeReader::ParseInstruction(std::vector &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 &Oprnds, } Result = new CallInst(F, Params); + if (Opcode == 61) cast(Result)->setTailCall(true); break; } case Instruction::Invoke: { diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index f6d09c82201..5f614fddf08 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -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(I) && cast(I).isTailCall()) + Opcode = 61; if (isa(I) && cast(I).isVolatile()) Opcode = 62; if (isa(I) && cast(I).isVolatile()) -- 2.34.1