From 88cfda212272096661ca14d5600435c4a74b7e47 Mon Sep 17 00:00:00 2001 From: Reid Spencer Date: Sun, 31 Dec 2006 05:44:24 +0000 Subject: For PR950: Update for signless integer types and parameter attribute implementation. Of significant note: 1. This changes the bytecode format yet again. 2. There are 1/2 as many integer type planes (this is a good thing) 3. GEP indices now use only 1 bit to identify their type which means more GEP instructions won't be relegated to format 0 (size win) 4. Parameter attributes are implemented but currently being stored verbosely for each function type. Some other day this needs to be optimized for size. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@32783 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Bytecode/Writer/Writer.cpp | 35 ++++++++++++++--------------------- 1 file changed, 14 insertions(+), 21 deletions(-) (limited to 'lib/Bytecode/Writer/Writer.cpp') diff --git a/lib/Bytecode/Writer/Writer.cpp b/lib/Bytecode/Writer/Writer.cpp index 44a654b..58cc13a 100644 --- a/lib/Bytecode/Writer/Writer.cpp +++ b/lib/Bytecode/Writer/Writer.cpp @@ -214,16 +214,20 @@ void BytecodeWriter::outputType(const Type *T) { int Slot = Table.getSlot(MT->getReturnType()); assert(Slot != -1 && "Type used but not available!!"); output_typeid((unsigned)Slot); + output_vbr(unsigned(MT->getParamAttrs(0))); // Output the number of arguments to function (+1 if varargs): output_vbr((unsigned)MT->getNumParams()+MT->isVarArg()); // Output all of the arguments... FunctionType::param_iterator I = MT->param_begin(); + unsigned Idx = 1; for (; I != MT->param_end(); ++I) { Slot = Table.getSlot(*I); assert(Slot != -1 && "Type used but not available!!"); output_typeid((unsigned)Slot); + output_vbr(unsigned(MT->getParamAttrs(Idx))); + Idx++; } // Terminate list with VoidTy if we are a varargs function... @@ -323,20 +327,13 @@ void BytecodeWriter::outputConstant(const Constant *CPV) { output_vbr(0U); break; - case Type::UByteTyID: // Unsigned integer types... - case Type::UShortTyID: - case Type::UIntTyID: - case Type::ULongTyID: + case Type::Int8TyID: // Unsigned integer types... + case Type::Int16TyID: + case Type::Int32TyID: + case Type::Int64TyID: output_vbr(cast(CPV)->getZExtValue()); break; - case Type::SByteTyID: // Signed integer types... - case Type::ShortTyID: - case Type::IntTyID: - case Type::LongTyID: - output_vbr(cast(CPV)->getSExtValue()); - break; - case Type::ArrayTyID: { const ConstantArray *CPA = cast(CPV); assert(!CPA->isString() && "Constant strings should be handled specially!"); @@ -489,12 +486,10 @@ void BytecodeWriter::outputInstructionFormat0(const Instruction *I, unsigned IdxId; switch (I->getOperand(Idx)->getType()->getTypeID()) { default: assert(0 && "Unknown index type!"); - case Type::UIntTyID: IdxId = 0; break; - case Type::IntTyID: IdxId = 1; break; - case Type::ULongTyID: IdxId = 2; break; - case Type::LongTyID: IdxId = 3; break; + case Type::Int32TyID: IdxId = 0; break; + case Type::Int64TyID: IdxId = 1; break; } - Slot = (Slot << 2) | IdxId; + Slot = (Slot << 1) | IdxId; } output_vbr(unsigned(Slot)); } @@ -742,12 +737,10 @@ void BytecodeWriter::outputInstruction(const Instruction &I) { unsigned IdxId; switch (GEP->getOperand(Idx)->getType()->getTypeID()) { default: assert(0 && "Unknown index type!"); - case Type::UIntTyID: IdxId = 0; break; - case Type::IntTyID: IdxId = 1; break; - case Type::ULongTyID: IdxId = 2; break; - case Type::LongTyID: IdxId = 3; break; + case Type::Int32TyID: IdxId = 0; break; + case Type::Int64TyID: IdxId = 1; break; } - Slots[Idx] = (Slots[Idx] << 2) | IdxId; + Slots[Idx] = (Slots[Idx] << 1) | IdxId; if (Slots[Idx] > MaxOpSlot) MaxOpSlot = Slots[Idx]; } } else if (Opcode == 58) { -- cgit v1.1