From abfbf85004b2114ee33e05fc9efe3a7bd044e402 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 6 May 2007 00:21:25 +0000 Subject: further reduce the redundancy of types in the instruction encoding. This shrinks function bodies in kc++ from 891913B to 884073B git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36817 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bitcode/Writer/BitcodeWriter.cpp | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) (limited to 'lib/Bitcode/Writer/BitcodeWriter.cpp') diff --git a/lib/Bitcode/Writer/BitcodeWriter.cpp b/lib/Bitcode/Writer/BitcodeWriter.cpp index 1797729b1c..7198bc0060 100644 --- a/lib/Bitcode/Writer/BitcodeWriter.cpp +++ b/lib/Bitcode/Writer/BitcodeWriter.cpp @@ -602,17 +602,15 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, default: if (Instruction::isCast(I.getOpcode())) { Code = bitc::FUNC_CODE_INST_CAST; - Vals.push_back(GetEncodedCastOpcode(I.getOpcode())); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getTypeID(I.getType())); - Vals.push_back(VE.getTypeID(I.getOperand(0)->getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); + Vals.push_back(GetEncodedCastOpcode(I.getOpcode())); } else { assert(isa(I) && "Unknown instruction!"); Code = bitc::FUNC_CODE_INST_BINOP; - Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode())); - Vals.push_back(VE.getTypeID(I.getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(1))); + Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode())); } break; @@ -623,28 +621,24 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, break; case Instruction::Select: Code = bitc::FUNC_CODE_INST_SELECT; - Vals.push_back(VE.getTypeID(I.getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); - Vals.push_back(VE.getValueID(I.getOperand(1))); + PushValueAndType(I.getOperand(1), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(2))); + Vals.push_back(VE.getValueID(I.getOperand(0))); break; case Instruction::ExtractElement: Code = bitc::FUNC_CODE_INST_EXTRACTELT; - Vals.push_back(VE.getTypeID(I.getOperand(0)->getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(1))); break; case Instruction::InsertElement: Code = bitc::FUNC_CODE_INST_INSERTELT; - Vals.push_back(VE.getTypeID(I.getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(1))); Vals.push_back(VE.getValueID(I.getOperand(2))); break; case Instruction::ShuffleVector: Code = bitc::FUNC_CODE_INST_SHUFFLEVEC; - Vals.push_back(VE.getTypeID(I.getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); Vals.push_back(VE.getValueID(I.getOperand(1))); Vals.push_back(VE.getValueID(I.getOperand(2))); break; @@ -719,8 +713,7 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, case Instruction::Free: Code = bitc::FUNC_CODE_INST_FREE; - Vals.push_back(VE.getTypeID(I.getOperand(0)->getType())); - Vals.push_back(VE.getValueID(I.getOperand(0))); + PushValueAndType(I.getOperand(0), InstID, Vals, VE); break; case Instruction::Alloca: @@ -740,9 +733,8 @@ static void WriteInstruction(const Instruction &I, unsigned InstID, break; case Instruction::Store: Code = bitc::FUNC_CODE_INST_STORE; - Vals.push_back(VE.getTypeID(I.getOperand(1)->getType())); // Pointer - Vals.push_back(VE.getValueID(I.getOperand(0))); // val. - Vals.push_back(VE.getValueID(I.getOperand(1))); // ptr. + PushValueAndType(I.getOperand(0), InstID, Vals, VE); // val. + Vals.push_back(VE.getValueID(I.getOperand(1))); // ptr. Vals.push_back(Log2_32(cast(I).getAlignment())+1); Vals.push_back(cast(I).isVolatile()); break; -- cgit v1.2.3-18-g5258