[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp
Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.112 -> 1.113 Writer.cpp updated: 1.177 -> 1.178 --- Log message: Implement review feedback. Aliasees can be either GlobalValue's or bitcasts of them. --- Diffs of the changes: (+19 -5) SlotCalculator.cpp | 13 + Writer.cpp | 11 ++- 2 files changed, 19 insertions(+), 5 deletions(-) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.112 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.113 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.112 Mon Apr 9 01:14:31 2007 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Sat Apr 28 08:44:59 2007 @@ -89,6 +89,12 @@ I != E; ++I) CreateSlotIfNeeded(I); + // Add all of the global aliases to the value table... + // + for (Module::const_alias_iterator I = TheModule->alias_begin(), + E = TheModule->alias_end(); I != E; ++I) +CreateSlotIfNeeded(I); + // Add all of the module level constants used as initializers // for (Module::const_global_iterator I = TheModule->global_begin(), @@ -96,6 +102,13 @@ if (I->hasInitializer()) CreateSlotIfNeeded(I->getInitializer()); + // Add all of the module level constants used as aliasees + // + for (Module::const_alias_iterator I = TheModule->alias_begin(), + E = TheModule->alias_end(); I != E; ++I) +if (I->getAliasee()) + CreateSlotIfNeeded(I->getAliasee()); + // Now that all global constants have been added, rearrange constant planes // that contain constant strings so that the strings occur at the start of the // plane, not somewhere in the middle. Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.177 llvm/lib/Bytecode/Writer/Writer.cpp:1.178 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.177 Wed Apr 25 09:27:10 2007 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sat Apr 28 08:44:59 2007 @@ -1095,9 +1095,11 @@ // Output aliases for (Module::const_alias_iterator I = M->alias_begin(), E = M->alias_end(); I != E; ++I) { -unsigned Slot = Table.getTypeSlot(I->getType()); -assert(((Slot << 2) >> 2) == Slot && "Slot # too big!"); +unsigned TypeSlotNo= Table.getTypeSlot(I->getType()); +unsigned AliaseeSlotNo = Table.getSlot(I->getAliasee()); +assert(((TypeSlotNo << 3) >> 3) == TypeSlotNo && "Slot # too big!"); unsigned aliasLinkage = 0; +unsigned isConstantAliasee = ((!isa(I->getAliasee())) << 2); switch (I->getLinkage()) { case GlobalValue::ExternalLinkage: aliasLinkage = 0; @@ -,9 +1113,8 @@ default: assert(0 && "Invalid alias linkage"); } -output_vbr((Slot << 2) | aliasLinkage); -output_vbr(Table.getTypeSlot(I->getAliasee()->getType())); -output_vbr(Table.getSlot(I->getAliasee())); +output_vbr((TypeSlotNo << 3) | isConstantAliasee | aliasLinkage); +output_vbr(AliaseeSlotNo); } output_typeid(Table.getTypeSlot(Type::VoidTy)); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp WriterInternals.h
Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.110 -> 1.111 Writer.cpp updated: 1.165 -> 1.166 WriterInternals.h updated: 1.32 -> 1.33 --- Log message: Switch ValueSymbolTable to use StringMap instead of std::map as its main datastructure. There are many improvements yet to be made, but this speeds up opt --std-compile-opts on 447.dealII by 7.3%. --- Diffs of the changes: (+11 -11) SlotCalculator.cpp |2 +- Writer.cpp | 15 ++- WriterInternals.h |5 - 3 files changed, 11 insertions(+), 11 deletions(-) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.110 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.111 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.110 Sat Feb 10 18:03:39 2007 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Sun Feb 11 23:18:08 2007 @@ -199,7 +199,7 @@ void SlotCalculator::processValueSymbolTable(const ValueSymbolTable *VST) { for (ValueSymbolTable::const_iterator VI = VST->begin(), VE = VST->end(); VI != VE; ++VI) -CreateSlotIfNeeded(VI->second); +CreateSlotIfNeeded(VI->getValue()); } void SlotCalculator::CreateSlotIfNeeded(const Value *V) { Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.165 llvm/lib/Bytecode/Writer/Writer.cpp:1.166 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.165 Sat Feb 10 01:42:59 2007 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sun Feb 11 23:18:08 2007 @@ -132,10 +132,9 @@ output_vbr((unsigned)i << 1); // Low order bit is clear. } -inline void BytecodeWriter::output(const std::string &s) { - unsigned Len = s.length(); +inline void BytecodeWriter::output_str(const char *Str, unsigned Len) { output_vbr(Len); // Strings may have an arbitrary length. - Out.insert(Out.end(), s.begin(), s.end()); + Out.insert(Out.end(), Str, Str+Len); } inline void BytecodeWriter::output_data(const void *Ptr, const void *End) { @@ -1088,14 +1087,12 @@ true/*ElideIfEmpty*/); // Organize the symbol table by type - typedef std::pair PlaneMapEntry; - typedef SmallVector PlaneMapVector; + typedef SmallVector PlaneMapVector; typedef DenseMap PlaneMap; PlaneMap Planes; for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end(); SI != SE; ++SI) -Planes[SI->second->getType()] - .push_back(std::make_pair(&SI->first, SI->second)); +Planes[SI->getValue()->getType()].push_back(&*SI); for (PlaneMap::iterator PI = Planes.begin(), PE = Planes.end(); PI != PE; ++PI) { @@ -1113,8 +1110,8 @@ // Write each of the values in this plane for (; I != End; ++I) { // Symtab entry: [def slot #][name] - output_vbr(Table.getSlot(I->second)); - output(*I->first); + output_vbr(Table.getSlot((*I)->getValue())); + output_str((*I)->getKeyData(), (*I)->getKeyLength()); } } } Index: llvm/lib/Bytecode/Writer/WriterInternals.h diff -u llvm/lib/Bytecode/Writer/WriterInternals.h:1.32 llvm/lib/Bytecode/Writer/WriterInternals.h:1.33 --- llvm/lib/Bytecode/Writer/WriterInternals.h:1.32 Sat Feb 10 01:42:59 2007 +++ llvm/lib/Bytecode/Writer/WriterInternals.h Sun Feb 11 23:18:08 2007 @@ -85,7 +85,10 @@ /// @brief Signed 32-bit variable bit rate output primitive. inline void output_vbr(int i); - inline void output(const std::string &s); + inline void output_str(const char *Str, unsigned Len); + inline void output(const std::string &s) { +output_str(&s[0], s.size()); + } inline void output_data(const void *Ptr, const void *End); ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp
Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.76 -> 1.77 Writer.cpp updated: 1.140 -> 1.141 --- Log message: For PR950: http://llvm.org/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. --- Diffs of the changes: (+15 -23) SlotCalculator.cpp |3 +-- Writer.cpp | 35 ++- 2 files changed, 15 insertions(+), 23 deletions(-) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.76 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.77 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.76Wed Dec 6 19:30:31 2006 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Sat Dec 30 23:44:24 2006 @@ -145,8 +145,7 @@ // for (unsigned plane = 0, e = Table.size(); plane != e; ++plane) { if (const ArrayType *AT = dyn_cast(Types[plane])) - if (AT->getElementType() == Type::SByteTy || - AT->getElementType() == Type::UByteTy) { + if (AT->getElementType() == Type::Int8Ty) { TypePlane &Plane = Table[plane]; unsigned FirstNonStringID = 0; for (unsigned i = 0, e = Plane.size(); i != e; ++i) Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.140 llvm/lib/Bytecode/Writer/Writer.cpp:1.141 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.140 Tue Dec 19 17:16:47 2006 +++ llvm/lib/Bytecode/Writer/Writer.cpp Sat Dec 30 23:44:24 2006 @@ -214,16 +214,20 @@ 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 @@ 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 @@ 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 @@ 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) { ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp
Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.75 -> 1.76 Writer.cpp updated: 1.135 -> 1.136 --- Log message: Changed llvm_ostream et all to OStream. llvm_cerr, llvm_cout, llvm_null, are now cerr, cout, and NullStream resp. --- Diffs of the changes: (+7 -7) SlotCalculator.cpp |2 +- Writer.cpp | 12 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.75 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.76 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.75Tue Nov 28 18:19:40 2006 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Wed Dec 6 19:30:31 2006 @@ -32,7 +32,7 @@ #if 0 #include "llvm/Support/Streams.h" -#define SC_DEBUG(X) llvm_cerr << X +#define SC_DEBUG(X) cerr << X #else #define SC_DEBUG(X) #endif Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.135 llvm/lib/Bytecode/Writer/Writer.cpp:1.136 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.135 Wed Dec 6 11:46:31 2006 +++ llvm/lib/Bytecode/Writer/Writer.cpp Wed Dec 6 19:30:31 2006 @@ -276,8 +276,8 @@ break; default: -llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" - << " Type '" << T->getDescription() << "'\n"; +cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" + << " Type '" << T->getDescription() << "'\n"; break; } } @@ -387,8 +387,8 @@ case Type::VoidTyID: case Type::LabelTyID: default: -llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" - << " type '" << *CPV->getType() << "'\n"; +cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" + << " type '" << *CPV->getType() << "'\n"; break; } return; @@ -1239,13 +1239,13 @@ } } -void llvm::WriteBytecodeToFile(const Module *M, llvm_ostream &Out, +void llvm::WriteBytecodeToFile(const Module *M, OStream &Out, bool compress) { assert(M && "You can't write a null module!!"); // Make sure that std::cout is put into binary mode for systems // that care. - if (Out == llvm_cout) + if (Out == cout) sys::Program::ChangeStdoutToBinary(); // Create a vector of unsigned char for the bytecode output. We ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
[llvm-commits] CVS: llvm/lib/Bytecode/Writer/SlotCalculator.cpp Writer.cpp
Changes in directory llvm/lib/Bytecode/Writer: SlotCalculator.cpp updated: 1.74 -> 1.75 Writer.cpp updated: 1.129 -> 1.130 --- Log message: Replacing std::iostreams with llvm iostreams. Some of these changes involve adding a temporary wrapper around the ostream to make it friendly to functions expecting an LLVM stream. This should be fixed in the future. --- Diffs of the changes: (+12 -11) SlotCalculator.cpp |6 +++--- Writer.cpp | 17 + 2 files changed, 12 insertions(+), 11 deletions(-) Index: llvm/lib/Bytecode/Writer/SlotCalculator.cpp diff -u llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.74 llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.75 --- llvm/lib/Bytecode/Writer/SlotCalculator.cpp:1.74Wed Jun 7 17:20:03 2006 +++ llvm/lib/Bytecode/Writer/SlotCalculator.cpp Tue Nov 28 18:19:40 2006 @@ -31,8 +31,8 @@ using namespace llvm; #if 0 -#include -#define SC_DEBUG(X) std::cerr << X +#include "llvm/Support/Streams.h" +#define SC_DEBUG(X) llvm_cerr << X #else #define SC_DEBUG(X) #endif @@ -800,7 +800,7 @@ // Used for debugging DefSlot=-1 assertion... //if (Typ == Type::TypeTy) - // cerr << "Inserting type '" << cast(D)->getDescription() << "'!\n"; + // llvm_cerr << "Inserting type '"<(D)->getDescription() <<"'!\n"; if (Typ->isDerivedType()) { int ValSlot; Index: llvm/lib/Bytecode/Writer/Writer.cpp diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.129 llvm/lib/Bytecode/Writer/Writer.cpp:1.130 --- llvm/lib/Bytecode/Writer/Writer.cpp:1.129 Sun Nov 26 19:05:09 2006 +++ llvm/lib/Bytecode/Writer/Writer.cpp Tue Nov 28 18:19:40 2006 @@ -29,6 +29,7 @@ #include "llvm/Support/GetElementPtrTypeIterator.h" #include "llvm/Support/Compressor.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Support/Streams.h" #include "llvm/System/Program.h" #include "llvm/ADT/STLExtras.h" #include "llvm/ADT/Statistic.h" @@ -275,7 +276,7 @@ break; default: -std::cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" +llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" << " Type '" << T->getDescription() << "'\n"; break; } @@ -384,7 +385,7 @@ case Type::VoidTyID: case Type::LabelTyID: default: -std::cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" +llvm_cerr << __FILE__ << ":" << __LINE__ << ": Don't know how to serialize" << " type '" << *CPV->getType() << "'\n"; break; } @@ -1225,13 +1226,13 @@ } } -void llvm::WriteBytecodeToFile(const Module *M, std::ostream &Out, +void llvm::WriteBytecodeToFile(const Module *M, llvm_ostream &Out, bool compress) { assert(M && "You can't write a null module!!"); // Make sure that std::cout is put into binary mode for systems // that care. - if (&Out == std::cout) + if (Out == llvm_cout) sys::Program::ChangeStdoutToBinary(); // Create a vector of unsigned char for the bytecode output. We @@ -1264,21 +1265,21 @@ compressed_magic[2] = 'v'; compressed_magic[3] = 'c'; -Out.write(compressed_magic,4); +Out.stream()->write(compressed_magic,4); // Compress everything after the magic number (which we altered) Compressor::compressToStream( (char*)(FirstByte+4),// Skip the magic number Buffer.size()-4, // Skip the magic number - Out // Where to write compressed data + *Out.stream()// Where to write compressed data ); } else { // We're not compressing, so just write the entire block. -Out.write((char*)FirstByte, Buffer.size()); +Out.stream()->write((char*)FirstByte, Buffer.size()); } // make sure it hits disk now - Out.flush(); + Out.stream()->flush(); } ___ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits