Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.30 -> 1.31
Reader.cpp updated: 1.229 -> 1.230
Reader.h updated: 1.43 -> 1.44
---
Log message:

For PR411: http://llvm.org/PR411 :
This patch replaces the SymbolTable class with ValueSymbolTable which does
not support types planes. This means that all symbol names in LLVM must now
be unique. The patch addresses the necessary changes to deal with this and
removes code no longer needed as a result. This completes the bulk of the
changes for this PR. Some cleanup patches will follow.


---
Diffs of the changes:  (+38 -33)

 Analyzer.cpp |   43 ++++++++++++++++++++++---------------------
 Reader.cpp   |   20 +++++++++++---------
 Reader.h     |    8 +++++---
 3 files changed, 38 insertions(+), 33 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.30 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.31
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.30  Tue Jan 30 13:36:46 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp       Mon Feb  5 14:47:20 2007
@@ -270,19 +270,15 @@
       *os << "      } END BLOCK: CompactionTable\n";
   }
 
-  virtual void handleSymbolTableBegin(Function* CF, SymbolTable* ST) {
+  virtual void handleTypeSymbolTableBegin(TypeSymbolTable* ST) {
     bca.numSymTab++;
     if (os)
-      *os << "    BLOCK: SymbolTable {\n";
+      *os << "    BLOCK: TypeSymbolTable {\n";
   }
-
-  virtual void handleSymbolTablePlane(unsigned Ty, unsigned NumEntries,
-    const Type* Typ) {
-    if (os) {
-      *os << "      Plane: Ty=" << Ty << " Size=" << NumEntries << " Type: ";
-      WriteTypeSymbolic(*os,Typ,M);
-      *os << "\n";
-    }
+  virtual void handleValueSymbolTableBegin(Function* CF, ValueSymbolTable* ST) 
{
+    bca.numSymTab++;
+    if (os)
+      *os << "    BLOCK: ValueSymbolTable {\n";
   }
 
   virtual void handleSymbolTableType(unsigned i, unsigned TypSlot,
@@ -292,18 +288,23 @@
          << " Name: " << name << "\n";
   }
 
-  virtual void handleSymbolTableValue(unsigned i, unsigned ValSlot,
-    const std::string& name ) {
+  virtual void handleSymbolTableValue(unsigned TySlot, unsigned ValSlot, 
+                                      const std::string& name) {
     if (os)
-      *os << "        Value " << i << " Slot=" << ValSlot
+      *os << "        Value " << TySlot << " Slot=" << ValSlot
          << " Name: " << name << "\n";
     if (ValSlot > bca.maxValueSlot)
       bca.maxValueSlot = ValSlot;
   }
 
-  virtual void handleSymbolTableEnd() {
+  virtual void handleValueSymbolTableEnd() {
     if (os)
-      *os << "    } END BLOCK: SymbolTable\n";
+      *os << "    } END BLOCK: ValueSymbolTable\n";
+  }
+
+  virtual void handleTypeSymbolTableEnd() {
+    if (os)
+      *os << "    } END BLOCK: TypeSymbolTable\n";
   }
 
   virtual void handleFunctionBegin(Function* Func, unsigned Size) {
@@ -358,15 +359,15 @@
   }
 
   virtual bool handleInstruction( unsigned Opcode, const Type* iType,
-                                std::vector<unsigned>& Operands, unsigned 
Size){
+                                std::vector<unsigned>& Operands, 
+                                Instruction *Inst,
+                                unsigned Size){
     if (os) {
       *os << "        INST: OpCode="
-         << Instruction::getOpcodeName(Opcode) << " Type=\"";
-      WriteTypeSymbolic(*os,iType,M);
-      *os << "\"";
+         << Instruction::getOpcodeName(Opcode);
       for ( unsigned i = 0; i < Operands.size(); ++i )
-        *os << " Op(" << i << ")=Slot(" << Operands[i] << ")";
-      *os << "\n";
+        *os << " Op(" << Operands[i] << ")";
+      *os << *Inst;
     }
 
     bca.numInstructions++;


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.229 
llvm/lib/Bytecode/Reader/Reader.cpp:1.230
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.229   Thu Feb  1 20:16:22 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Feb  5 14:47:20 2007
@@ -23,7 +23,6 @@
 #include "llvm/Constants.h"
 #include "llvm/InlineAsm.h"
 #include "llvm/Instructions.h"
-#include "llvm/SymbolTable.h"
 #include "llvm/TypeSymbolTable.h"
 #include "llvm/Bytecode/Format.h"
 #include "llvm/Config/alloca.h"
@@ -55,6 +54,7 @@
 inline void BytecodeReader::error(const std::string& err) {
   ErrorMsg = err + " (Vers=" + itostr(RevisionNum) + ", Pos=" 
     + itostr(At-MemStart) + ")";
+  if (Handler) Handler->handleError(ErrorMsg);
   longjmp(context,1);
 }
 
@@ -443,10 +443,6 @@
   // of opcodes.
   Instruction* Result = 0;
 
-  // We have enough info to inform the handler now.
-  if (Handler) 
-    Handler->handleInstruction(Opcode, InstTy, Oprnds, At-SaveAt);
-
   // First, handle the easy binary operators case
   if (Opcode >= Instruction::BinaryOpsBegin &&
       Opcode <  Instruction::BinaryOpsEnd  && Oprnds.size() == 2) {
@@ -861,6 +857,10 @@
   else
     TypeSlot = getTypeSlot(Result->getType());
 
+  // We have enough info to inform the handler now.
+  if (Handler) 
+    Handler->handleInstruction(Opcode, InstTy, Oprnds, Result, At-SaveAt);
+
   insertValue(Result, TypeSlot, FunctionValues);
 }
 
@@ -936,9 +936,9 @@
 /// CurrentFunction's symbol table. For Module level symbol tables, the
 /// CurrentFunction argument must be zero.
 void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
-                                           SymbolTable *ST) {
+                                           ValueSymbolTable *VST) {
                                       
-  if (Handler) Handler->handleSymbolTableBegin(CurrentFunction,ST);
+  if (Handler) Handler->handleValueSymbolTableBegin(CurrentFunction,VST);
 
   // Allow efficient basic block lookup by number.
   std::vector<BasicBlock*> BBMap;
@@ -963,13 +963,15 @@
       } else {
         V = getValue(Typ, slot, false); // Find mapping...
       }
+      if (Handler) Handler->handleSymbolTableValue(Typ, slot, Name);
       if (V == 0)
-        error("Failed value look-up for name '" + Name + "'");
+        error("Failed value look-up for name '" + Name + "', type #" + 
+              utostr(Typ) + " slot #" + utostr(slot));
       V->setName(Name);
     }
   }
   checkPastBlockEnd("Symbol Table");
-  if (Handler) Handler->handleSymbolTableEnd();
+  if (Handler) Handler->handleValueSymbolTableEnd();
 }
 
 // Parse a single type. The typeid is read in first. If its a primitive type


Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.43 
llvm/lib/Bytecode/Reader/Reader.h:1.44
--- llvm/lib/Bytecode/Reader/Reader.h:1.43      Tue Jan 30 13:36:46 2007
+++ llvm/lib/Bytecode/Reader/Reader.h   Mon Feb  5 14:47:20 2007
@@ -28,8 +28,10 @@
 
 namespace llvm {
 
-class BytecodeHandler; ///< Forward declare the handler interface
-class TypeSymbolTable; ///< Forward declare
+// Forward declarations
+class BytecodeHandler; 
+class TypeSymbolTable; 
+class ValueSymbolTable; 
 
 /// This class defines the interface for parsing a buffer of bytecode. The
 /// parser itself takes no action except to call the various functions of
@@ -204,7 +206,7 @@
   void ParseTypeSymbolTable(TypeSymbolTable *ST);
 
   /// @brief Parse a value symbol table
-  void ParseValueSymbolTable(Function* Func, SymbolTable *ST);
+  void ParseValueSymbolTable(Function* Func, ValueSymbolTable *ST);
 
   /// @brief Parse functions lazily.
   void ParseFunctionLazily();



_______________________________________________
llvm-commits mailing list
llvm-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

Reply via email to