[llvm-commits] CVS: llvm/lib/Bytecode/Writer/Writer.cpp

Chris Lattner lattner at cs.uiuc.edu
Wed Oct 13 18:46:18 PDT 2004



Changes in directory llvm/lib/Bytecode/Writer:

Writer.cpp updated: 1.79 -> 1.80
---
Log message:

Wrap to 80 cols, delete some seriously old debugging printouts


---
Diffs of the changes:  (+15 -26)

Index: llvm/lib/Bytecode/Writer/Writer.cpp
diff -u llvm/lib/Bytecode/Writer/Writer.cpp:1.79 llvm/lib/Bytecode/Writer/Writer.cpp:1.80
--- llvm/lib/Bytecode/Writer/Writer.cpp:1.79	Wed Oct 13 20:35:17 2004
+++ llvm/lib/Bytecode/Writer/Writer.cpp	Wed Oct 13 20:46:07 2004
@@ -235,8 +235,6 @@
     int Slot = Table.getSlot(AT->getElementType());
     assert(Slot != -1 && "Type used but not available!!");
     output_typeid((unsigned)Slot);
-    //std::cerr << "Type slot = " << Slot << " Type = " << T->getName() << endl;
-
     output_vbr(AT->getNumElements());
     break;
   }
@@ -426,9 +424,10 @@
 //
 // Format: [opcode] [type] [numargs] [arg0] [arg1] ... [arg<numargs-1>]
 //
-void BytecodeWriter::outputInstructionFormat0(const Instruction *I, unsigned Opcode,
-				     const SlotCalculator &Table,
-				     unsigned Type) {
+void BytecodeWriter::outputInstructionFormat0(const Instruction *I,
+                                              unsigned Opcode,
+                                              const SlotCalculator &Table,
+                                              unsigned Type) {
   // Opcode must have top two bits clear...
   output_vbr(Opcode << 2);                  // Instruction Opcode ID
   output_typeid(Type);                      // Result type
@@ -554,9 +553,7 @@
   // 19-08: Resulting type plane
   // 31-20: Operand #1 (if set to (2^12-1), then zero operands)
   //
-  unsigned Bits = 1 | (Opcode << 2) | (Type << 8) | (Slots[0] << 20);
-  //  cerr << "1 " << IType << " " << Type << " " << Slots[0] << endl;
-  output(Bits);
+  output(1 | (Opcode << 2) | (Type << 8) | (Slots[0] << 20));
 }
 
 
@@ -575,11 +572,7 @@
   // 23-16: Operand #1
   // 31-24: Operand #2  
   //
-  unsigned Bits = 2 | (Opcode << 2) | (Type << 8) |
-                    (Slots[0] << 16) | (Slots[1] << 24);
-  //  cerr << "2 " << IType << " " << Type << " " << Slots[0] << " " 
-  //       << Slots[1] << endl;
-  output(Bits);
+  output(2 | (Opcode << 2) | (Type << 8) | (Slots[0] << 16) | (Slots[1] << 24));
 }
 
 
@@ -599,11 +592,8 @@
   // 25-20: Operand #2
   // 31-26: Operand #3
   //
-  unsigned Bits = 3 | (Opcode << 2) | (Type << 8) |
+  output(3 | (Opcode << 2) | (Type << 8) |
           (Slots[0] << 14) | (Slots[1] << 20) | (Slots[2] << 26);
-  //cerr << "3 " << IType << " " << Type << " " << Slots[0] << " " 
-  //     << Slots[1] << " " << Slots[2] << endl;
-  output(Bits);
 }
 
 void BytecodeWriter::outputInstruction(const Instruction &I) {
@@ -790,8 +780,7 @@
   outputSymbolTable(M->getSymbolTable());
 }
 
-void BytecodeWriter::outputTypes(unsigned TypeNum)
-{
+void BytecodeWriter::outputTypes(unsigned TypeNum) {
   // Write the type plane for types first because earlier planes (e.g. for a
   // primitive type like float) may have constants constructed using types
   // coming later (e.g., via getelementptr from a pointer type).  The type
@@ -864,7 +853,7 @@
     // Output the type plane before any constants!
     outputTypes( Table.getModuleTypeLevel() );
   else
-    // Output module-level string constants before any other constants.x
+    // Output module-level string constants before any other constants.
     outputConstantStrings();
 
   for (unsigned pno = 0; pno != NumPlanes; pno++) {
@@ -1035,7 +1024,8 @@
       (!Table.CompactionTableIsEmpty())) {
     BytecodeBlock CTB(BytecodeFormat::CompactionTableBlockID, *this, 
                       true/*ElideIfEmpty*/);
-    const std::vector<std::vector<const Value*> > &CT =Table.getCompactionTable();
+    const std::vector<std::vector<const Value*> > &CT =
+      Table.getCompactionTable();
     
     // First things first, emit the type compaction table if there is one.
     outputCompactionTypes(Type::FirstDerivedTyID);
@@ -1048,10 +1038,10 @@
 void BytecodeWriter::outputSymbolTable(const SymbolTable &MST) {
   // Do not output the Bytecode block for an empty symbol table, it just wastes
   // space!
-  if ( MST.isEmpty() ) return;
+  if (MST.isEmpty()) return;
 
   BytecodeBlock SymTabBlock(BytecodeFormat::SymbolTableBlockID, *this,
-                            true/* ElideIfEmpty*/);
+                            true/*ElideIfEmpty*/);
 
   // Write the number of types 
   output_vbr(MST.num_types());
@@ -1108,9 +1098,8 @@
   // sequential in memory, however, so write out as much as possible in big
   // chunks, until we're done.
   //
-
-  std::vector<unsigned char>::const_iterator I = Buffer.begin(),E = Buffer.end();
-  while (I != E) {                           // Loop until it's all written
+  for (std::vector<unsigned char>::const_iterator I = Buffer.begin(),
+         E = Buffer.end(); I != E; ++I) {
     // Scan to see how big this chunk is...
     const unsigned char *ChunkPtr = &*I;
     const unsigned char *LastPtr = ChunkPtr;






More information about the llvm-commits mailing list