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

Reid Spencer reid at x10sys.com
Sat Dec 30 21:44:43 PST 2006



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.76	Wed 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<ArrayType>(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<ConstantInt>(CPV)->getZExtValue());
     break;
 
-  case Type::SByteTyID:   // Signed integer types...
-  case Type::ShortTyID:
-  case Type::IntTyID:
-  case Type::LongTyID:
-    output_vbr(cast<ConstantInt>(CPV)->getSExtValue());
-    break;
-
   case Type::ArrayTyID: {
     const ConstantArray *CPA = cast<ConstantArray>(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) {






More information about the llvm-commits mailing list