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

Brian Gaeke gaeke at cs.uiuc.edu
Thu Aug 19 23:01:08 PDT 2004



Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.12 -> 1.13
Reader.cpp updated: 1.124 -> 1.125
---
Log message:

Packed types, brought to you by Brad Jones


---
Diffs of the changes:  (+41 -0)

Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.12 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.13
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.12	Tue Aug  3 19:19:23 2004
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp	Fri Aug 20 01:00:57 2004
@@ -387,6 +387,27 @@
     bca.numValues++;
   }
 
+  virtual void handleConstantPacked( 
+    const PackedType* PT,                
+    std::vector<Constant*>& Elements,
+    unsigned TypeSlot,                  
+    Constant* PackedVal) 
+  {
+    dump << "      PACKD: " << PT->getDescription() 
+         << " TypeSlot=" << TypeSlot << "\n";
+    for ( unsigned i = 0; i < Elements.size(); ++i ) {
+      dump << "        #" << i;
+      Elements[i]->print(dump);
+      dump << "\n";
+    }
+    dump << "        Value=";
+    PackedVal->print(dump);
+    dump << "\n";
+
+    bca.numConstants++;
+    bca.numValues++;
+  }
+
   virtual void handleConstantPointer( const PointerType* PT, 
       unsigned Slot, GlobalValue* GV ) {
     dump << "       PNTR: " << PT->getDescription() 


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.124 llvm/lib/Bytecode/Reader/Reader.cpp:1.125
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.124	Tue Aug 17 02:45:14 2004
+++ llvm/lib/Bytecode/Reader/Reader.cpp	Fri Aug 20 01:00:57 2004
@@ -1170,6 +1170,12 @@
     Result =  ArrayType::get(ElementType, NumElements);
     break;
   }
+  case Type::PackedTyID: {
+    const Type *ElementType = readSanitizedType();
+    unsigned NumElements = read_vbr_uint();
+    Result =  PackedType::get(ElementType, NumElements);
+    break;
+  }
   case Type::StructTyID: {
     std::vector<const Type*> Elements;
     unsigned Typ = 0;
@@ -1396,6 +1402,20 @@
     return Result;
   }    
 
+  case Type::PackedTyID: {
+    const PackedType *PT = cast<PackedType>(Ty);
+    unsigned NumElements = PT->getNumElements();
+    unsigned TypeSlot = getTypeSlot(PT->getElementType());
+    std::vector<Constant*> Elements;
+    Elements.reserve(NumElements);
+    while (NumElements--)     // Read all of the elements of the constant.
+      Elements.push_back(getConstantValue(TypeSlot,
+                                          read_vbr_uint()));
+    Constant* Result = ConstantPacked::get(PT, Elements);
+    if (Handler) Handler->handleConstantPacked(PT, Elements, TypeSlot, Result);
+    return Result;
+  }
+
   case Type::PointerTyID: {  // ConstantPointerRef value...
     const PointerType *PT = cast<PointerType>(Ty);
     unsigned Slot = read_vbr_uint();






More information about the llvm-commits mailing list