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

2007-04-28 Thread Anton Korobeynikov


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.41 - 1.42
Reader.cpp updated: 1.255 - 1.256
Reader.h updated: 1.52 - 1.53
---
Log message:

Implement review feedback. Aliasees can be either GlobalValue's or 
bitcasts of them.


---
Diffs of the changes:  (+61 -10)

 Analyzer.cpp |   21 +
 Reader.cpp   |   41 +++--
 Reader.h |9 +
 3 files changed, 61 insertions(+), 10 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.41 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.42
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.41  Tue Apr 24 12:20:52 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Sat Apr 28 08:44:59 2007
@@ -179,6 +179,27 @@
 
   }
 
+  virtual void handleGlobalAlias(
+const Type* ElemType,
+GlobalValue::LinkageTypes Linkage,
+unsigned TypeSlotNum,
+unsigned AliaseeSlot) {
+if (os) {
+  *osGA: 
+Linkage=  Linkage
+Type=;
+  //WriteTypeSymbolic(*os, ElemType, M);
+  *os   Slot=  TypeSlotNum   AliaseeSlot=  AliaseeSlot
+   \n;
+}
+
+bca.numValues++;
+if (TypeSlotNum  bca.maxValueSlot)
+  bca.maxValueSlot = TypeSlotNum;
+if (AliaseeSlot  bca.maxValueSlot)
+  bca.maxValueSlot = AliaseeSlot;
+  }
+
   virtual void handleTypeList(unsigned numEntries) {
 bca.maxTypeSlot = numEntries - 1;
   }


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.255 
llvm/lib/Bytecode/Reader/Reader.cpp:1.256
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.255   Wed Apr 25 09:27:10 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Sat Apr 28 08:44:59 2007
@@ -1923,12 +1923,10 @@
 // Read aliases...
 unsigned VarType = read_vbr_uint();
 while (VarType != Type::VoidTyID) { // List is terminated by Void
-  unsigned TypeSlotNo = VarType  2;
+  unsigned TypeSlotNo = VarType  3;
   unsigned EncodedLinkage = VarType  3;
-  unsigned AliaseeTypeSlotNo, AliaseeSlotNo;
-
-  AliaseeTypeSlotNo = read_vbr_uint();
-  AliaseeSlotNo = read_vbr_uint();
+  bool isConstantAliasee  = (VarType  2)  1;
+  unsigned AliaseeSlotNo  = read_vbr_uint();
 
   const Type *Ty = getType(TypeSlotNo);
   if (!Ty)
@@ -1937,11 +1935,11 @@
   if (!isaPointerType(Ty))
 error(Alias not a pointer type! Ty=  + Ty-getDescription());
   
-  Value* V = getValue(AliaseeTypeSlotNo, AliaseeSlotNo, false);
-  if (!V)
-error(Invalid aliasee! TypeSlotNo= + utostr(AliaseeTypeSlotNo) +
+  Value* V = getValue(TypeSlotNo, AliaseeSlotNo, false);
+  if (!V  !isConstantAliasee)
+error(Invalid aliasee! TypeSlotNo= + utostr(TypeSlotNo) +
SlotNo= + utostr(AliaseeSlotNo));
-  if (!isaGlobalValue(V))
+  if (!isConstantAliasee  !isaGlobalValue(V))
 error(Aliasee is not global value! SlotNo= + utostr(AliaseeSlotNo));
 
   GlobalValue::LinkageTypes Linkage;
@@ -1960,8 +1958,14 @@
   }
   
   GlobalAlias *GA = new GlobalAlias(Ty, Linkage, ,
-dyn_castGlobalValue(V), TheModule);
+dyn_cast_or_nullConstant(V),
+TheModule);
   insertValue(GA, TypeSlotNo, ModuleValues);
+  if (!V  isConstantAliasee)
+Aliasees.push_back(std::make_pair(GA, AliaseeSlotNo));
+
+  if (Handler) Handler-handleGlobalAlias(Ty, Linkage,
+  TypeSlotNo, AliaseeSlotNo);
   VarType = read_vbr_uint();
 }
   }  
@@ -2068,6 +2072,23 @@
   error(Cannot find initializer value.);
   }
 
+  // And aliasees
+  while (!Aliasees.empty()) {
+GlobalAlias *GA = Aliasees.back().first;
+unsigned Slot = Aliasees.back().second;
+Aliasees.pop_back();
+
+// Look up the aliasee value...
+const llvm::PointerType* GAType = GA-getType();
+unsigned TypeSlot = getTypeSlot(GAType);
+if (Constant *CV = getConstantValue(TypeSlot, Slot)) {
+  if (GA-getAliasee())
+error(Aliasee was *already* set?!);
+  GA-setAliasee(CV);
+} else
+  error(Cannot find aliasee value.);
+  }
+
   if (!ConstantFwdRefs.empty())
 error(Use of undefined constants in a module);
 


Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.52 
llvm/lib/Bytecode/Reader/Reader.h:1.53
--- llvm/lib/Bytecode/Reader/Reader.h:1.52  Mon Apr  9 01:14:31 2007
+++ llvm/lib/Bytecode/Reader/Reader.h   Sat Apr 28 08:44:59 2007
@@ -129,6 +129,9 @@
   /// them.
   typedef std::vectorstd::pairGlobalVariable*, unsigned  GlobalInitsList;
 
+  /// @brief A list of global aliases and the slot number for constant aliasees
+  typedef std::vectorstd::pairGlobalAlias*, unsigned  AliaseeList;
+
   /// This type maps a typeslot/valueslot pair to the corresponding Value*.
   /// It is used for dealing with 

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

2007-04-24 Thread Chris Lattner


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.40 - 1.41
Reader.cpp updated: 1.253 - 1.254
---
Log message:

fix a memory leak



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

 Analyzer.cpp |   18 +-
 Reader.cpp   |   11 ++-
 2 files changed, 15 insertions(+), 14 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.40 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.41
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.40  Thu Apr 12 13:32:50 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Tue Apr 24 12:20:52 2007
@@ -165,7 +165,7 @@
 Linkage=  Linkage
 Visibility= Visibility
 Type=;
-  WriteTypeSymbolic(*os, ElemType, M);
+  //WriteTypeSymbolic(*os, ElemType, M);
   *os   Slot=  SlotNum   InitSlot=  initSlot
\n;
 }
@@ -187,7 +187,7 @@
 bca.numTypes++;
 if (os) {
   *osType: ;
-  WriteTypeSymbolic(*os,Ty,M);
+  //WriteTypeSymbolic(*os,Ty,M);
   *os  \n;
 }
   }
@@ -199,7 +199,7 @@
 bca.numValues++;
 if (os) {
   *osFunction Decl: ;
-  WriteTypeSymbolic(*os,Func-getType(),M);
+  //WriteTypeSymbolic(*os,Func-getType(),M);
   *os , Linkage=  Func-getLinkage();
   *os , Visibility=  Func-getVisibility();
   *os  \n;
@@ -276,13 +276,13 @@
  Linkage:   Func-getLinkage()  \n
  Visibility:   Func-getVisibility()  \n
  Type: ;
-  WriteTypeSymbolic(*os,Func-getType(),M);
+  //WriteTypeSymbolic(*os,Func-getType(),M);
   *os  \n;
 }
 
 currFunc = bca.FunctionInfo[Func];
 std::ostringstream tmp;
-WriteTypeSymbolic(tmp,Func-getType(),M);
+//WriteTypeSymbolic(tmp,Func-getType(),M);
 currFunc-description = tmp.str();
 currFunc-name = Func-getName();
 currFunc-byteSize = Size;
@@ -388,7 +388,7 @@
   Constant* ArrayVal ) {
 if (os) {
   *osARRAY: ;
-  WriteTypeSymbolic(*os,AT,M);
+  //WriteTypeSymbolic(*os,AT,M);
   *os   TypeSlot=  TypeSlot  \n;
   for (unsigned i = 0; i != NumElts; ++i) {
 *os  #  i;
@@ -411,7 +411,7 @@
   {
 if (os) {
   *osSTRUC: ;
-  WriteTypeSymbolic(*os,ST,M);
+  //WriteTypeSymbolic(*os,ST,M);
   *os  \n;
   for ( unsigned i = 0; i != NumElts; ++i) {
 *os  #  i   ; Elements[i]-print(*os);
@@ -433,7 +433,7 @@
   {
 if (os) {
   *osPACKD: ;
-  WriteTypeSymbolic(*os,PT,M);
+  //WriteTypeSymbolic(*os,PT,M);
   *os   TypeSlot=  TypeSlot  \n;
   for ( unsigned i = 0; i != NumElts; ++i ) {
 *os  #  i;
@@ -453,7 +453,7 @@
   unsigned Slot, GlobalValue* GV ) {
 if (os) {
   *os PNTR: ;
-  WriteTypeSymbolic(*os,PT,M);
+  //WriteTypeSymbolic(*os,PT,M);
   *os   Slot=  Slot   GlobalValue=;
   GV-print(*os);
   *os  \n;


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.253 
llvm/lib/Bytecode/Reader/Reader.cpp:1.254
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.253   Sun Apr 22 17:22:02 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Apr 24 12:20:52 2007
@@ -1299,11 +1299,12 @@
   Result = ConstantInt::get(IT, Val);
   if (Handler) Handler-handleConstantValue(Result);
 } else {
-  uint32_t numWords = read_vbr_uint();
-  uint64_t *data = new uint64_t[numWords];
-  for (uint32_t i = 0; i  numWords; ++i)
-data[i] = read_vbr_uint64();
-  Result = ConstantInt::get(APInt(IT-getBitWidth(), numWords, data));
+  uint32_t NumWords = read_vbr_uint();
+  SmallVectoruint64_t, 8 Words;
+  Words.resize(NumWords);
+  for (uint32_t i = 0; i  NumWords; ++i)
+Words[i] = read_vbr_uint64();
+  Result = ConstantInt::get(APInt(IT-getBitWidth(), NumWords, Words[0]));
   if (Handler) Handler-handleConstantValue(Result);
 }
 break;



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


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

2007-04-12 Thread Lauro Ramos Venancio


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.39 - 1.40
Reader.cpp updated: 1.247 - 1.248
---
Log message:

Implement the thread_local keyword.


---
Diffs of the changes:  (+8 -5)

 Analyzer.cpp |4 +++-
 Reader.cpp   |9 +
 2 files changed, 8 insertions(+), 5 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.39 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.40
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.39  Wed Feb 14 21:39:18 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Thu Apr 12 13:32:50 2007
@@ -154,12 +154,14 @@
 GlobalValue::LinkageTypes Linkage,
 GlobalValue::VisibilityTypes Visibility,
 unsigned SlotNum,
-unsigned initSlot
+unsigned initSlot,
+bool isThreadLocal
   ) {
 if (os) {
   *osGV: 
( initSlot == 0 ? Uni : I )  nitialized, 
( isConstant? Constant,  : Variable, )
+Thread Local =   ( isThreadLocal? yes,  : no, )
 Linkage=  Linkage
 Visibility= Visibility
 Type=;


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.247 
llvm/lib/Bytecode/Reader/Reader.cpp:1.248
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.247   Mon Apr  9 15:28:40 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Thu Apr 12 13:32:50 2007
@@ -1704,11 +1704,12 @@
   unsigned VarType = read_vbr_uint();
   while (VarType != Type::VoidTyID) { // List is terminated by Void
 // VarType Fields: bit0 = isConstant, bit1 = hasInitializer, bit2,3,4 =
-// Linkage, bit4+ = slot#
-unsigned SlotNo = VarType  5;
+// Linkage, bit5 = isThreadLocal, bit6+ = slot#
+unsigned SlotNo = VarType  6;
 unsigned LinkageID = (VarType  2)  7;
 unsigned VisibilityID = 0;
 bool isConstant = VarType  1;
+bool isThreadLocal = (VarType  5)  1;
 bool hasInitializer = (VarType  2) != 0;
 unsigned Alignment = 0;
 unsigned GlobalSectionID = 0;
@@ -1764,7 +1765,7 @@
 
 // Create the global variable...
 GlobalVariable *GV = new GlobalVariable(ElTy, isConstant, Linkage,
-0, , TheModule);
+0, , TheModule, isThreadLocal);
 GV-setAlignment(Alignment);
 GV-setVisibility(Visibility);
 insertValue(GV, SlotNo, ModuleValues);
@@ -1781,7 +1782,7 @@
 // Notify handler about the global value.
 if (Handler)
   Handler-handleGlobalVariable(ElTy, isConstant, Linkage, Visibility,
-SlotNo, initSlot);
+SlotNo, initSlot, isThreadLocal);
 
 // Get next item
 VarType = read_vbr_uint();



___
llvm-commits mailing list
[EMAIL PROTECTED]
http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits


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

2007-02-14 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.37 - 1.38
Reader.cpp updated: 1.239 - 1.240
---
Log message:

For PR1195: http://llvm.org/PR1195 :
Rename PackedType - VectorType, ConstantPacked - ConstantVector, and
PackedTyID - VectorTyID. No functional changes.


---
Diffs of the changes:  (+12 -12)

 Analyzer.cpp |4 ++--
 Reader.cpp   |   20 ++--
 2 files changed, 12 insertions(+), 12 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.37 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.38
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.37  Mon Feb 12 12:53:42 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Wed Feb 14 20:26:09 2007
@@ -423,8 +423,8 @@
 bca.numValues++;
   }
 
-  virtual void handleConstantPacked(
-const PackedType* PT,
+  virtual void handleConstantVector(
+const VectorType* PT,
 Constant**Elements, unsigned NumElts,
 unsigned TypeSlot,
 Constant* PackedVal)


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.239 
llvm/lib/Bytecode/Reader/Reader.cpp:1.240
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.239   Wed Feb 14 00:20:04 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Wed Feb 14 20:26:09 2007
@@ -482,7 +482,7 @@
   break;
 }
 case Instruction::InsertElement: {
-  const PackedType *PackedTy = dyn_castPackedType(InstTy);
+  const VectorType *PackedTy = dyn_castVectorType(InstTy);
   if (!PackedTy || Oprnds.size() != 3)
 error(Invalid insertelement instruction!);
   
@@ -496,13 +496,13 @@
   break;
 }
 case Instruction::ShuffleVector: {
-  const PackedType *PackedTy = dyn_castPackedType(InstTy);
+  const VectorType *PackedTy = dyn_castVectorType(InstTy);
   if (!PackedTy || Oprnds.size() != 3)
 error(Invalid shufflevector instruction!);
   Value *V1 = getValue(iType, Oprnds[0]);
   Value *V2 = getValue(iType, Oprnds[1]);
-  const PackedType *EltTy = 
-PackedType::get(Type::Int32Ty, PackedTy-getNumElements());
+  const VectorType *EltTy = 
+VectorType::get(Type::Int32Ty, PackedTy-getNumElements());
   Value *V3 = getValue(getTypeSlot(EltTy), Oprnds[2]);
   if (!ShuffleVectorInst::isValidOperands(V1, V2, V3))
 error(Invalid shufflevector instruction!);
@@ -1029,10 +1029,10 @@
 Result =  ArrayType::get(ElementType, NumElements);
 break;
   }
-  case Type::PackedTyID: {
+  case Type::VectorTyID: {
 const Type *ElementType = readType();
 unsigned NumElements = read_vbr_uint();
-Result =  PackedType::get(ElementType, NumElements);
+Result =  VectorType::get(ElementType, NumElements);
 break;
   }
   case Type::StructTyID: {
@@ -1314,8 +1314,8 @@
 break;
   }
 
-  case Type::PackedTyID: {
-const PackedType *PT = castPackedType(Ty);
+  case Type::VectorTyID: {
+const VectorType *PT = castVectorType(Ty);
 unsigned NumElements = PT-getNumElements();
 unsigned TypeSlot = getTypeSlot(PT-getElementType());
 std::vectorConstant* Elements;
@@ -1323,8 +1323,8 @@
 while (NumElements--) // Read all of the elements of the constant.
   Elements.push_back(getConstantValue(TypeSlot,
   read_vbr_uint()));
-Result = ConstantPacked::get(PT, Elements);
-if (Handler) Handler-handleConstantPacked(PT, 
Elements[0],Elements.size(),
+Result = ConstantVector::get(PT, Elements);
+if (Handler) Handler-handleConstantVector(PT, 
Elements[0],Elements.size(),
TypeSlot, Result);
 break;
   }



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


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

2007-02-14 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.38 - 1.39
Reader.cpp updated: 1.240 - 1.241
---
Log message:

For PR1195: http://llvm.org/PR1195 :
Change use of packed term to vector in comments, strings, variable
names, etc.


---
Diffs of the changes:  (+8 -8)

 Analyzer.cpp |4 ++--
 Reader.cpp   |   12 ++--
 2 files changed, 8 insertions(+), 8 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.38 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.39
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.38  Wed Feb 14 20:26:09 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Wed Feb 14 21:39:18 2007
@@ -427,7 +427,7 @@
 const VectorType* PT,
 Constant**Elements, unsigned NumElts,
 unsigned TypeSlot,
-Constant* PackedVal)
+Constant* VectorVal)
   {
 if (os) {
   *osPACKD: ;
@@ -439,7 +439,7 @@
 *os  \n;
   }
   *os  Value=;
-  PackedVal-print(*os);
+  VectorVal-print(*os);
   *os  \n;
 }
 


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.240 
llvm/lib/Bytecode/Reader/Reader.cpp:1.241
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.240   Wed Feb 14 20:26:09 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Wed Feb 14 21:39:18 2007
@@ -482,12 +482,12 @@
   break;
 }
 case Instruction::InsertElement: {
-  const VectorType *PackedTy = dyn_castVectorType(InstTy);
-  if (!PackedTy || Oprnds.size() != 3)
+  const VectorType *VectorTy = dyn_castVectorType(InstTy);
+  if (!VectorTy || Oprnds.size() != 3)
 error(Invalid insertelement instruction!);
   
   Value *V1 = getValue(iType, Oprnds[0]);
-  Value *V2 = getValue(getTypeSlot(PackedTy-getElementType()),Oprnds[1]);
+  Value *V2 = getValue(getTypeSlot(VectorTy-getElementType()),Oprnds[1]);
   Value *V3 = getValue(Int32TySlot, Oprnds[2]);
 
   if (!InsertElementInst::isValidOperands(V1, V2, V3))
@@ -496,13 +496,13 @@
   break;
 }
 case Instruction::ShuffleVector: {
-  const VectorType *PackedTy = dyn_castVectorType(InstTy);
-  if (!PackedTy || Oprnds.size() != 3)
+  const VectorType *VectorTy = dyn_castVectorType(InstTy);
+  if (!VectorTy || Oprnds.size() != 3)
 error(Invalid shufflevector instruction!);
   Value *V1 = getValue(iType, Oprnds[0]);
   Value *V2 = getValue(iType, Oprnds[1]);
   const VectorType *EltTy = 
-VectorType::get(Type::Int32Ty, PackedTy-getNumElements());
+VectorType::get(Type::Int32Ty, VectorTy-getNumElements());
   Value *V3 = getValue(getTypeSlot(EltTy), Oprnds[2]);
   if (!ShuffleVectorInst::isValidOperands(V1, V2, V3))
 error(Invalid shufflevector instruction!);



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


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

2007-02-12 Thread Chris Lattner


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.36 - 1.37
Reader.cpp updated: 1.235 - 1.236
Reader.h updated: 1.48 - 1.49
---
Log message:

avoid creating a temporary string when reading the symbol table for a
module.  This speeds up the bcreader 11%.


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

 Analyzer.cpp |4 ++--
 Reader.cpp   |   30 +++---
 Reader.h |1 +
 3 files changed, 26 insertions(+), 9 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.36 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.37
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.36  Sat Feb 10 08:07:56 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Mon Feb 12 12:53:42 2007
@@ -250,10 +250,10 @@
   }
 
   virtual void handleSymbolTableValue(unsigned TySlot, unsigned ValSlot, 
-  const std::string name) {
+  const char *Name, unsigned NameLen) {
 if (os)
   *os  Value   TySlot   Slot=  ValSlot
-   Name:   name  \n;
+Name:   std::string(Name, Name+NameLen)  \n;
 if (ValSlot  bca.maxValueSlot)
   bca.maxValueSlot = ValSlot;
   }


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.235 
llvm/lib/Bytecode/Reader/Reader.cpp:1.236
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.235   Wed Feb  7 15:41:01 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Feb 12 12:53:43 2007
@@ -132,6 +132,17 @@
   return std::string((char*)OldAt, Size);
 }
 
+void BytecodeReader::read_str(SmallVectorImplchar StrData) {
+  StrData.clear();
+  unsigned Size = read_vbr_uint();
+  const unsigned char *OldAt = At;
+  At += Size;
+  if (At  BlockEnd) // Size invalid?
+error(Ran out of data reading a string!);
+  StrData.append(OldAt, At);
+}
+
+
 /// Read an arbitrary block of data
 inline void BytecodeReader::read_data(void *Ptr, void *End) {
   unsigned char *Start = (unsigned char *)Ptr;
@@ -943,6 +954,8 @@
E = CurrentFunction-end(); I != E; ++I)
   BBMap.push_back(I);
 
+  SmallVectorchar, 32 NameStr;
+  
   while (moreInBlock()) {
 // Symtab block header: [num entries][type id number]
 unsigned NumEntries = read_vbr_uint();
@@ -951,19 +964,22 @@
 for (unsigned i = 0; i != NumEntries; ++i) {
   // Symtab entry: [def slot #][name]
   unsigned slot = read_vbr_uint();
-  std::string Name = read_str();
+  read_str(NameStr);
   Value *V = 0;
   if (Typ == LabelTySlot) {
-if (slot  BBMap.size())
-  V = BBMap[slot];
+V = (slot  BBMap.size()) ? BBMap[slot] : 0;
   } else {
-V = getValue(Typ, slot, false); // Find mapping...
+V = getValue(Typ, slot, false); // Find mapping.
   }
-  if (Handler) Handler-handleSymbolTableValue(Typ, slot, Name);
+  if (Handler) Handler-handleSymbolTableValue(Typ, slot,
+   NameStr[0], 
NameStr.size());
   if (V == 0)
-error(Failed value look-up for name ' + Name + ', type # + 
+error(Failed value look-up for name ' + 
+  std::string(NameStr.begin(), NameStr.end()) + ', type # + 
   utostr(Typ) +  slot # + utostr(slot));
-  V-setName(Name);
+  V-setName(NameStr[0], NameStr.size());
+  
+  NameStr.clear();
 }
   }
   checkPastBlockEnd(Symbol Table);


Index: llvm/lib/Bytecode/Reader/Reader.h
diff -u llvm/lib/Bytecode/Reader/Reader.h:1.48 
llvm/lib/Bytecode/Reader/Reader.h:1.49
--- llvm/lib/Bytecode/Reader/Reader.h:1.48  Wed Feb  7 17:46:55 2007
+++ llvm/lib/Bytecode/Reader/Reader.h   Mon Feb 12 12:53:43 2007
@@ -438,6 +438,7 @@
 
   /// @brief Read a string
   inline std::string read_str();
+  inline void read_str(SmallVectorImplchar StrData);
 
   /// @brief Read a float value
   inline void read_float(float FloatVal);



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


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

2007-02-06 Thread Chris Lattner


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.31 - 1.32
Reader.cpp updated: 1.230 - 1.231
Reader.h updated: 1.44 - 1.45
---
Log message:

Eliminate std::vectors from the bcanalyzer interface.



---
Diffs of the changes:  (+45 -32)

 Analyzer.cpp |   28 ++--
 Reader.cpp   |   45 +
 Reader.h |4 ++--
 3 files changed, 45 insertions(+), 32 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.31 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.32
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.31  Mon Feb  5 14:47:20 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Tue Feb  6 23:08:39 2007
@@ -359,13 +359,13 @@
   }
 
   virtual bool handleInstruction( unsigned Opcode, const Type* iType,
-std::vectorunsigned Operands, 
+unsigned *Operands, unsigned NumOps, 
 Instruction *Inst,
 unsigned Size){
 if (os) {
   *os  INST: OpCode=
   Instruction::getOpcodeName(Opcode);
-  for ( unsigned i = 0; i  Operands.size(); ++i )
+  for (unsigned i = 0; i != NumOps; ++i)
 *os   Op(  Operands[i]  );
   *os  *Inst;
 }
@@ -374,15 +374,15 @@
 bca.numValues++;
 bca.instructionSize += Size;
 if (Size  4 ) bca.longInstructions++;
-bca.numOperands += Operands.size();
-for (unsigned i = 0; i  Operands.size(); ++i )
+bca.numOperands += NumOps;
+for (unsigned i = 0; i != NumOps; ++i)
   if (Operands[i]  bca.maxValueSlot)
 bca.maxValueSlot = Operands[i];
 if ( currFunc ) {
   currFunc-numInstructions++;
   currFunc-instructionSize += Size;
   if (Size  4 ) currFunc-longInstructions++;
-  if ( Opcode == Instruction::PHI ) currFunc-numPhis++;
+  if (Opcode == Instruction::PHI) currFunc-numPhis++;
 }
 return Instruction::isTerminator(Opcode);
   }
@@ -397,11 +397,11 @@
   *os  BLOCK: GlobalConstants {\n;
   }
 
-  virtual void handleConstantExpression( unsigned Opcode,
-  std::vectorConstant* ArgVec, Constant* C ) {
+  virtual void handleConstantExpression(unsigned Opcode,
+  Constant**ArgVec, unsigned NumArgs, Constant* C) {
 if (os) {
   *osEXPR:   Instruction::getOpcodeName(Opcode)  \n;
-  for ( unsigned i = 0; i  ArgVec.size(); ++i ) {
+  for ( unsigned i = 0; i != NumArgs; ++i ) {
 *os  Arg#  i   ; ArgVec[i]-print(*os);
 *os  \n;
   }
@@ -424,14 +424,14 @@
   }
 
   virtual void handleConstantArray( const ArrayType* AT,
-  std::vectorConstant* Elements,
+  Constant**Elements, unsigned NumElts,
   unsigned TypeSlot,
   Constant* ArrayVal ) {
 if (os) {
   *osARRAY: ;
   WriteTypeSymbolic(*os,AT,M);
   *os   TypeSlot=  TypeSlot  \n;
-  for ( unsigned i = 0; i  Elements.size(); ++i ) {
+  for (unsigned i = 0; i != NumElts; ++i) {
 *os  #  i;
 Elements[i]-print(*os);
 *os  \n;
@@ -447,14 +447,14 @@
 
   virtual void handleConstantStruct(
 const StructType* ST,
-std::vectorConstant* Elements,
+Constant**Elements, unsigned NumElts,
 Constant* StructVal)
   {
 if (os) {
   *osSTRUC: ;
   WriteTypeSymbolic(*os,ST,M);
   *os  \n;
-  for ( unsigned i = 0; i  Elements.size(); ++i ) {
+  for ( unsigned i = 0; i != NumElts; ++i) {
 *os  #  i   ; Elements[i]-print(*os);
 *os  \n;
   }
@@ -468,7 +468,7 @@
 
   virtual void handleConstantPacked(
 const PackedType* PT,
-std::vectorConstant* Elements,
+Constant**Elements, unsigned NumElts,
 unsigned TypeSlot,
 Constant* PackedVal)
   {
@@ -476,7 +476,7 @@
   *osPACKD: ;
   WriteTypeSymbolic(*os,PT,M);
   *os   TypeSlot=  TypeSlot  \n;
-  for ( unsigned i = 0; i  Elements.size(); ++i ) {
+  for ( unsigned i = 0; i != NumElts; ++i ) {
 *os  #  i;
 Elements[i]-print(*os);
 *os  \n;


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.230 
llvm/lib/Bytecode/Reader/Reader.cpp:1.231
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.230   Mon Feb  5 14:47:20 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Feb  6 23:08:39 2007
@@ -366,7 +366,7 @@
 /// This method parses a single instruction. The instruction is
 /// inserted at the end of the \p BB provided. The arguments of
 /// the instruction are provided in the \p Oprnds vector.
-void BytecodeReader::ParseInstruction(std::vectorunsigned Oprnds,
+void BytecodeReader::ParseInstruction(SmallVectorunsigned, 8 Oprnds,
   BasicBlock* BB) {
   BufPtr SaveAt = At;
 
@@ -859,7 +859,8 @@
 
   // We have enough info to inform the handler now.
   if (Handler) 
-

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

2007-02-06 Thread Chris Lattner


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.32 - 1.33
Reader.cpp updated: 1.232 - 1.233
---
Log message:

remove the handleVBR32/handleVBR64 callbacks.  They are very fine-grained.


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

 Analyzer.cpp |   22 --
 Reader.cpp   |4 
 2 files changed, 26 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.32 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.33
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.32  Tue Feb  6 23:08:39 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Wed Feb  7 00:53:02 2007
@@ -26,7 +26,6 @@
 #include iomanip
 #include sstream
 #include ios
-
 using namespace llvm;
 
 namespace {
@@ -542,27 +541,6 @@
   bca.BlockSizes[llvm::BytecodeFormat::Reserved_DoNotUse] += 4;
   }
 
-  virtual void handleVBR32(unsigned Size ) {
-bca.vbrCount32++;
-bca.vbrCompBytes += Size;
-bca.vbrExpdBytes += sizeof(uint32_t);
-if (currFunc) {
-  currFunc-vbrCount32++;
-  currFunc-vbrCompBytes += Size;
-  currFunc-vbrExpdBytes += sizeof(uint32_t);
-}
-  }
-
-  virtual void handleVBR64(unsigned Size ) {
-bca.vbrCount64++;
-bca.vbrCompBytes += Size;
-bca.vbrExpdBytes += sizeof(uint64_t);
-if ( currFunc ) {
-  currFunc-vbrCount64++;
-  currFunc-vbrCompBytes += Size;
-  currFunc-vbrExpdBytes += sizeof(uint64_t);
-}
-  }
 };
 
 


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.232 
llvm/lib/Bytecode/Reader/Reader.cpp:1.233
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.232   Tue Feb  6 23:15:28 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Wed Feb  7 00:53:02 2007
@@ -86,7 +86,6 @@
 inline unsigned BytecodeReader::read_vbr_uint() {
   unsigned Shift = 0;
   unsigned Result = 0;
-  BufPtr Save = At;
 
   do {
 if (At == BlockEnd)
@@ -94,7 +93,6 @@
 Result |= (unsigned)((*At++)  0x7F)  Shift;
 Shift += 7;
   } while (At[-1]  0x80);
-  if (Handler) Handler-handleVBR32(At-Save);
   return Result;
 }
 
@@ -102,7 +100,6 @@
 inline uint64_t BytecodeReader::read_vbr_uint64() {
   unsigned Shift = 0;
   uint64_t Result = 0;
-  BufPtr Save = At;
 
   do {
 if (At == BlockEnd)
@@ -110,7 +107,6 @@
 Result |= (uint64_t)((*At++)  0x7F)  Shift;
 Shift += 7;
   } while (At[-1]  0x80);
-  if (Handler) Handler-handleVBR64(At-Save);
   return Result;
 }
 



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


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

2007-02-06 Thread Reid Spencer
Chris,

This patch isn't finished. You've prevented collection of any vbr data
by llvm-bcanalyzer. Please update llvm-bcanalyzer to not print out
0 (or possibly divide by zero) for the vbr stats that use vbrCount32,
vbrCompBytes, vbrExpdBytes and vbrCount64.

Thanks,

Reid.

On Wed, 2007-02-07 at 00:53 -0600, Chris Lattner wrote:
 
 Changes in directory llvm/lib/Bytecode/Reader:
 
 Analyzer.cpp updated: 1.32 - 1.33
 Reader.cpp updated: 1.232 - 1.233
 ---
 Log message:
 
 remove the handleVBR32/handleVBR64 callbacks.  They are very fine-grained.
 
 
 ---
 Diffs of the changes:  (+0 -26)
 
  Analyzer.cpp |   22 --
  Reader.cpp   |4 
  2 files changed, 26 deletions(-)
 
 
 Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
 diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.32 
 llvm/lib/Bytecode/Reader/Analyzer.cpp:1.33
 --- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.32Tue Feb  6 23:08:39 2007
 +++ llvm/lib/Bytecode/Reader/Analyzer.cpp Wed Feb  7 00:53:02 2007
 @@ -26,7 +26,6 @@
  #include iomanip
  #include sstream
  #include ios
 -
  using namespace llvm;
  
  namespace {
 @@ -542,27 +541,6 @@
bca.BlockSizes[llvm::BytecodeFormat::Reserved_DoNotUse] += 4;
}
  
 -  virtual void handleVBR32(unsigned Size ) {
 -bca.vbrCount32++;
 -bca.vbrCompBytes += Size;
 -bca.vbrExpdBytes += sizeof(uint32_t);
 -if (currFunc) {
 -  currFunc-vbrCount32++;
 -  currFunc-vbrCompBytes += Size;
 -  currFunc-vbrExpdBytes += sizeof(uint32_t);
 -}
 -  }
 -
 -  virtual void handleVBR64(unsigned Size ) {
 -bca.vbrCount64++;
 -bca.vbrCompBytes += Size;
 -bca.vbrExpdBytes += sizeof(uint64_t);
 -if ( currFunc ) {
 -  currFunc-vbrCount64++;
 -  currFunc-vbrCompBytes += Size;
 -  currFunc-vbrExpdBytes += sizeof(uint64_t);
 -}
 -  }
  };
  
 
 
 
 Index: llvm/lib/Bytecode/Reader/Reader.cpp
 diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.232 
 llvm/lib/Bytecode/Reader/Reader.cpp:1.233
 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.232 Tue Feb  6 23:15:28 2007
 +++ llvm/lib/Bytecode/Reader/Reader.cpp   Wed Feb  7 00:53:02 2007
 @@ -86,7 +86,6 @@
  inline unsigned BytecodeReader::read_vbr_uint() {
unsigned Shift = 0;
unsigned Result = 0;
 -  BufPtr Save = At;
  
do {
  if (At == BlockEnd)
 @@ -94,7 +93,6 @@
  Result |= (unsigned)((*At++)  0x7F)  Shift;
  Shift += 7;
} while (At[-1]  0x80);
 -  if (Handler) Handler-handleVBR32(At-Save);
return Result;
  }
  
 @@ -102,7 +100,6 @@
  inline uint64_t BytecodeReader::read_vbr_uint64() {
unsigned Shift = 0;
uint64_t Result = 0;
 -  BufPtr Save = At;
  
do {
  if (At == BlockEnd)
 @@ -110,7 +107,6 @@
  Result |= (uint64_t)((*At++)  0x7F)  Shift;
  Shift += 7;
} while (At[-1]  0x80);
 -  if (Handler) Handler-handleVBR64(At-Save);
return Result;
  }
  
 
 
 
 ___
 llvm-commits mailing list
 llvm-commits@cs.uiuc.edu
 http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

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


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

2007-01-30 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.29 - 1.30
Reader.cpp updated: 1.225 - 1.226
Reader.h updated: 1.42 - 1.43
---
Log message:

Bye, Bye Compaction Tables. The benefit compaction tables provides doesn't
outweight its computational costs. This patch removes all compaction
table handling from the bcreader and bcwriter. For the record, here's the
difference betweeen having and not having compaction tables for some tests:

Test With   Without   Size Chg
Olden/mst   5,602 5,598  +0.1%
viterbi18,02617,795  +1.3%
obsequi   162,133   166,663  -2.8%
burg  224,090   228,148  -1.8%
kimwitu++   4,933,263 5,121,159  -3.8%
176.gcc 8,470,424 9,141,539  -7.3%

It seems that it is more beneficial to larger files, but even on the largest
test case we have (176.gcc) it only amounts ot an I/O saving of 7.3%. 


---
Diffs of the changes:  (+18 -229)

 Analyzer.cpp |4 -
 Reader.cpp   |  217 ---
 Reader.h |   26 ---
 3 files changed, 18 insertions(+), 229 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.29 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.30
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.29  Fri Jan 26 02:10:24 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Tue Jan 30 13:36:46 2007
@@ -100,7 +100,6 @@
 bca.BlockSizes[BytecodeFormat::ModuleGlobalInfoBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::GlobalTypePlaneBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::InstructionListBlockID] = 0;
-bca.BlockSizes[BytecodeFormat::CompactionTableBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::TypeSymbolTableBlockID] = 0;
   }
 
@@ -635,9 +634,6 @@
   print(Out, Instruction List Bytes,
 double(bca.BlockSizes[BytecodeFormat::InstructionListBlockID]),
 double(bca.byteSize));
-  print(Out, Compaction Table Bytes,
-double(bca.BlockSizes[BytecodeFormat::CompactionTableBlockID]),
-double(bca.byteSize));
   print(Out, Value Symbol Table Bytes,
 double(bca.BlockSizes[BytecodeFormat::ValueSymbolTableBlockID]),
 double(bca.byteSize));


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.225 
llvm/lib/Bytecode/Reader/Reader.cpp:1.226
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.225   Fri Jan 26 02:10:24 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Tue Jan 30 13:36:46 2007
@@ -186,8 +186,8 @@
   return TyID != Type::LabelTyID  TyID != Type::VoidTyID;
 }
 
-/// Obtain a type given a typeid and account for things like compaction tables,
-/// function level vs module level, and the offsetting for the primitive types.
+/// Obtain a type given a typeid and account for things like function level vs 
+/// module level, and the offsetting for the primitive types.
 const Type *BytecodeReader::getType(unsigned ID) {
   if (ID = Type::LastPrimitiveTyID)
 if (const Type *T = Type::getPrimitiveType((Type::TypeID)ID))
@@ -196,12 +196,6 @@
   // Otherwise, derived types need offset...
   ID -= Type::FirstDerivedTyID;
 
-  if (!CompactionTypes.empty()) {
-if (ID = CompactionTypes.size())
-  error(Type ID out of range for compaction table!);
-return CompactionTypes[ID].first;
-  }
-
   // Is it a module-level type?
   if (ID  ModuleTypes.size())
 return ModuleTypes[ID].get();
@@ -223,20 +217,11 @@
 }
 
 /// Get the slot number associated with a type accounting for primitive
-/// types, compaction tables, and function level vs module level.
+/// types and function level vs module level.
 unsigned BytecodeReader::getTypeSlot(const Type *Ty) {
   if (Ty-isPrimitiveType())
 return Ty-getTypeID();
 
-  // Scan the compaction table for the type if needed.
-  if (!CompactionTypes.empty()) {
-for (unsigned i = 0, e = CompactionTypes.size(); i != e; ++i)
-  if (CompactionTypes[i].first == Ty)
-return Type::FirstDerivedTyID + i;
-
-error(Couldn't find type specified in compaction table!);
-  }
-
   // Check the function level types first...
   TypeListTy::iterator I = std::find(FunctionTypes.begin(),
  FunctionTypes.end(), Ty);
@@ -266,84 +251,28 @@
   return Type::FirstDerivedTyID + IT-second;
 }
 
-/// This is just like getType, but when a compaction table is in use, it is
-/// ignored.  It also ignores function level types.
-/// @see getType
-const Type *BytecodeReader::getGlobalTableType(unsigned Slot) {
-  if (Slot  Type::FirstDerivedTyID) {
-const Type *Ty = Type::getPrimitiveType((Type::TypeID)Slot);
-if (!Ty)
-  error(Not a primitive type ID?);
-return Ty;
-  }
-  Slot -= Type::FirstDerivedTyID;
-  if (Slot = ModuleTypes.size())
-error(Illegal compaction table type reference!);
-  return ModuleTypes[Slot];
-}
-
-/// This is just like getTypeSlot, but when a compaction table is in use, it
-/// is ignored. It 

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

2007-01-26 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.28 - 1.29
Reader.cpp updated: 1.224 - 1.225
---
Log message:

For PR761: http://llvm.org/PR761 :
Remove the Endianness and PointerSize fields from the ModuleHeader and
replace it with the DataLayout field.


---
Diffs of the changes:  (+11 -25)

 Analyzer.cpp |8 ++--
 Reader.cpp   |   28 +---
 2 files changed, 11 insertions(+), 25 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.28 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.29
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.28  Fri Jan 12 13:20:46 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Fri Jan 26 02:10:24 2007
@@ -142,14 +142,10 @@
   }
 
   virtual void handleVersionInfo(
-unsigned char RevisionNum,/// Byte code revision number
-Module::Endianness Endianness,/// Endianness indicator
-Module::PointerSize PointerSize   /// PointerSize indicator
+unsigned char RevisionNum/// Byte code revision number
   ) {
 if (os)
-  *os  RevisionNum:   int(RevisionNum)
-   Endianness:   Endianness
-   PointerSize:   PointerSize  \n;
+  *os  RevisionNum:   int(RevisionNum)  \n;
 bca.version = RevisionNum;
   }
 


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.224 
llvm/lib/Bytecode/Reader/Reader.cpp:1.225
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.224   Thu Jan 18 18:07:16 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Jan 26 02:10:24 2007
@@ -2014,6 +2014,13 @@
   if (Handler)
 Handler-handleTargetTriple(triple);
   
+  // Read the data layout string and place into the module.
+  std::string datalayout = read_str();
+  TheModule-setDataLayout(datalayout);
+  // FIXME: Implement
+  // if (Handler)
+// Handler-handleDataLayout(datalayout);
+
   if (At != BlockEnd) {
 // If the file has section info in it, read the section names now.
 unsigned NumSections = read_vbr_uint();
@@ -2045,31 +2052,14 @@
 /// Parse the version information and decode it by setting flags on the
 /// Reader that enable backward compatibility of the reader.
 void BytecodeReader::ParseVersionInfo() {
-  unsigned Version = read_vbr_uint();
-
-  // Unpack version number: low four bits are for flags, top bits = version
-  Module::Endianness  Endianness;
-  Module::PointerSize PointerSize;
-  Endianness  = (Version  1) ? Module::BigEndian : Module::LittleEndian;
-  PointerSize = (Version  2) ? Module::Pointer64 : Module::Pointer32;
-
-  bool hasNoEndianness = Version  4;
-  bool hasNoPointerSize = Version  8;
-
-  RevisionNum = Version  4;
+  unsigned RevisionNum = read_vbr_uint();
 
   // We don't provide backwards compatibility in the Reader any more. To
   // upgrade, the user should use llvm-upgrade.
   if (RevisionNum  7)
 error(Bytecode formats  7 are no longer supported. Use llvm-upgrade.);
 
-  if (hasNoEndianness) Endianness  = Module::AnyEndianness;
-  if (hasNoPointerSize) PointerSize = Module::AnyPointerSize;
-
-  TheModule-setEndianness(Endianness);
-  TheModule-setPointerSize(PointerSize);
-
-  if (Handler) Handler-handleVersionInfo(RevisionNum, Endianness, 
PointerSize);
+  if (Handler) Handler-handleVersionInfo(RevisionNum);
 }
 
 /// Parse a whole module.



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


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

2007-01-12 Thread Anton Korobeynikov


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.27 - 1.28
Reader.cpp updated: 1.220 - 1.221
---
Log message:

* PIC codegen for X86/Linux has been implemented
* PIC-aware internal structures in X86 Codegen have been refactored
* Visibility (default/weak) has been added
* Docs fixes (external weak linkage, visibility, formatting)


---
Diffs of the changes:  (+37 -6)

 Analyzer.cpp |7 ++-
 Reader.cpp   |   36 +++-
 2 files changed, 37 insertions(+), 6 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.27 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.28
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.27  Sat Jan  6 01:24:43 2007
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Fri Jan 12 13:20:46 2007
@@ -162,6 +162,7 @@
 const Type* ElemType,
 bool isConstant,
 GlobalValue::LinkageTypes Linkage,
+GlobalValue::VisibilityTypes Visibility,
 unsigned SlotNum,
 unsigned initSlot
   ) {
@@ -169,7 +170,9 @@
   *osGV: 
( initSlot == 0 ? Uni : I )  nitialized, 
( isConstant? Constant,  : Variable, )
-Linkage=  Linkage   Type=;
+Linkage=  Linkage
+Visibility= Visibility
+Type=;
   WriteTypeSymbolic(*os, ElemType, M);
   *os   Slot=  SlotNum   InitSlot=  initSlot
\n;
@@ -206,6 +209,7 @@
   *osFunction Decl: ;
   WriteTypeSymbolic(*os,Func-getType(),M);
   *os , Linkage=  Func-getLinkage();
+  *os , Visibility=  Func-getVisibility();
   *os  \n;
 }
   }
@@ -311,6 +315,7 @@
 if (os) {
   *os  BLOCK: Function {\n
  Linkage:   Func-getLinkage()  \n
+ Visibility:   Func-getVisibility()  \n
  Type: ;
   WriteTypeSymbolic(*os,Func-getType(),M);
   *os  \n;


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.220 
llvm/lib/Bytecode/Reader/Reader.cpp:1.221
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.220   Fri Jan 12 01:05:13 2007
+++ llvm/lib/Bytecode/Reader/Reader.cpp Fri Jan 12 13:20:46 2007
@@ -1628,9 +1628,12 @@
 
   unsigned FuncSize = BlockEnd - At;
   GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage;
+  GlobalValue::VisibilityTypes Visibility = GlobalValue::DefaultVisibility;
 
-  unsigned LinkageType = read_vbr_uint();
-  switch (LinkageType) {
+  unsigned rWord = read_vbr_uint();
+  unsigned LinkageID =  rWord  65535;
+  unsigned VisibilityID = rWord  16;
+  switch (LinkageID) {
   case 0: Linkage = GlobalValue::ExternalLinkage; break;
   case 1: Linkage = GlobalValue::WeakLinkage; break;
   case 2: Linkage = GlobalValue::AppendingLinkage; break;
@@ -1644,8 +1647,17 @@
 Linkage = GlobalValue::InternalLinkage;
 break;
   }
+  switch (VisibilityID) {
+  case 0: Visibility = GlobalValue::DefaultVisibility; break;
+  case 1: Visibility = GlobalValue::HiddenVisibility; break;
+  default:
+   error(Unknown visibility type:  + utostr(VisibilityID));
+   Visibility = GlobalValue::DefaultVisibility;
+   break;
+  }
 
   F-setLinkage(Linkage);
+  F-setVisibility(Visibility);
   if (Handler) Handler-handleFunctionBegin(F,FuncSize);
 
   // Keep track of how many basic blocks we have read in...
@@ -1844,6 +1856,7 @@
 // Linkage, bit4+ = slot#
 unsigned SlotNo = VarType  5;
 unsigned LinkageID = (VarType  2)  7;
+unsigned VisibilityID = 0;
 bool isConstant = VarType  1;
 bool hasInitializer = (VarType  2) != 0;
 unsigned Alignment = 0;
@@ -1853,10 +1866,12 @@
 if (LinkageID == 3  !hasInitializer) {
   unsigned ExtWord = read_vbr_uint();
   // The extension word has this format: bit 0 = has initializer, bit 1-3 =
-  // linkage, bit 4-8 = alignment (log2), bits 10+ = future use.
+  // linkage, bit 4-8 = alignment (log2), bit 9 = has section,
+  // bits 10-12 = visibility, bits 13+ = future use.
   hasInitializer = ExtWord  1;
   LinkageID = (ExtWord  1)  7;
   Alignment = (1  ((ExtWord  4)  31))  1;
+  VisibilityID = (ExtWord  10)  7;
   
   if (ExtWord  (1  9))  // Has a section ID.
 GlobalSectionID = read_vbr_uint();
@@ -1877,7 +1892,16 @@
   Linkage = GlobalValue::InternalLinkage;
   break;
 }
-
+GlobalValue::VisibilityTypes Visibility;
+switch (VisibilityID) {
+case 0: Visibility = GlobalValue::DefaultVisibility; break;
+case 1: Visibility = GlobalValue::HiddenVisibility; break;
+default:
+  error(Unknown visibility type:  + utostr(VisibilityID));
+  Visibility = GlobalValue::DefaultVisibility;
+  break;
+}
+
 const Type *Ty = getType(SlotNo);
 if (!Ty)
   error(Global has no type! SlotNo= + utostr(SlotNo));
@@ -1891,6 +1915,7 @@
 GlobalVariable *GV = new GlobalVariable(ElTy, isConstant, Linkage,
 0, , TheModule);
 

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

2007-01-05 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.26 - 1.27
Reader.cpp updated: 1.215 - 1.216
Reader.h updated: 1.40 - 1.41
---
Log message:

For PR411: http://llvm.org/PR411 :
Take an incremental step towards type plane elimination. This change 
separates types from values in the symbol tables by finally making use
of the TypeSymbolTable class. This yields more natural interfaces for
dealing with types and unclutters the SymbolTable class.


---
Diffs of the changes:  (+43 -22)

 Analyzer.cpp |   10 +++---
 Reader.cpp   |   47 ++-
 Reader.h |8 ++--
 3 files changed, 43 insertions(+), 22 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.26 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.27
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.26  Fri Dec 15 15:46:37 2006
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Sat Jan  6 01:24:43 2007
@@ -96,11 +96,12 @@
 bca.BlockSizes[BytecodeFormat::ModuleBlockID] = theSize;
 bca.BlockSizes[BytecodeFormat::FunctionBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::ConstantPoolBlockID] = 0;
-bca.BlockSizes[BytecodeFormat::SymbolTableBlockID] = 0;
+bca.BlockSizes[BytecodeFormat::ValueSymbolTableBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::ModuleGlobalInfoBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::GlobalTypePlaneBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::InstructionListBlockID] = 0;
 bca.BlockSizes[BytecodeFormat::CompactionTableBlockID] = 0;
+bca.BlockSizes[BytecodeFormat::TypeSymbolTableBlockID] = 0;
   }
 
   virtual void handleFinish() {
@@ -636,8 +637,11 @@
   print(Out, Compaction Table Bytes,
 double(bca.BlockSizes[BytecodeFormat::CompactionTableBlockID]),
 double(bca.byteSize));
-  print(Out, Symbol Table Bytes,
-double(bca.BlockSizes[BytecodeFormat::SymbolTableBlockID]),
+  print(Out, Value Symbol Table Bytes,
+double(bca.BlockSizes[BytecodeFormat::ValueSymbolTableBlockID]),
+double(bca.byteSize));
+  print(Out, Type Symbol Table Bytes,
+double(bca.BlockSizes[BytecodeFormat::TypeSymbolTableBlockID]),
 double(bca.byteSize));
   print(Out, Alignment Bytes,
 double(bca.numAlignment), double(bca.byteSize));


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.215 
llvm/lib/Bytecode/Reader/Reader.cpp:1.216
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.215   Sat Dec 30 23:44:24 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp Sat Jan  6 01:24:43 2007
@@ -24,6 +24,7 @@
 #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
 #include llvm/Support/GetElementPtrTypeIterator.h
@@ -1023,13 +1024,27 @@
   return BlockNo;
 }
 
-/// Parse a symbol table. This works for both module level and function
+/// Parse a type symbol table.
+void BytecodeReader::ParseTypeSymbolTable(TypeSymbolTable *TST) {
+  // Type Symtab block header: [num entries]
+  unsigned NumEntries = read_vbr_uint();
+  for (unsigned i = 0; i  NumEntries; ++i) {
+// Symtab entry: [type slot #][name]
+unsigned slot = read_vbr_uint();
+std::string Name = read_str();
+const Type* T = getType(slot);
+TST-insert(Name, T);
+  }
+}
+
+/// Parse a value symbol table. This works for both module level and function
 /// level symbol tables.  For function level symbol tables, the CurrentFunction
 /// parameter must be non-zero and the ST parameter must correspond to
 /// CurrentFunction's symbol table. For Module level symbol tables, the
 /// CurrentFunction argument must be zero.
-void BytecodeReader::ParseSymbolTable(Function *CurrentFunction,
-  SymbolTable *ST) {
+void BytecodeReader::ParseValueSymbolTable(Function *CurrentFunction,
+   SymbolTable *ST) {
+  
   if (Handler) Handler-handleSymbolTableBegin(CurrentFunction,ST);
 
   // Allow efficient basic block lookup by number.
@@ -1039,16 +1054,6 @@
E = CurrentFunction-end(); I != E; ++I)
   BBMap.push_back(I);
 
-  // Symtab block header: [num entries]
-  unsigned NumEntries = read_vbr_uint();
-  for (unsigned i = 0; i  NumEntries; ++i) {
-// Symtab entry: [def slot #][name]
-unsigned slot = read_vbr_uint();
-std::string Name = read_str();
-const Type* T = getType(slot);
-ST-insert(Name, T);
-  }
-
   while (moreInBlock()) {
 // Symtab block header: [num entries][type id number]
 unsigned NumEntries = read_vbr_uint();
@@ -1683,8 +1688,12 @@
   break;
 }
 
-case BytecodeFormat::SymbolTableBlockID:
-  ParseSymbolTable(F, F-getSymbolTable());
+case BytecodeFormat::ValueSymbolTableBlockID:
+  ParseValueSymbolTable(F, F-getValueSymbolTable());
+  break;
+
+case 

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

2006-11-13 Thread Reid Spencer


Changes in directory llvm/lib/Bytecode/Reader:

Analyzer.cpp updated: 1.24 - 1.25
Reader.cpp updated: 1.204 - 1.205
Reader.h updated: 1.37 - 1.38
---
Log message:

Discard code that supported old bytecode formats. This makes the Bytecode
Reader code much easier to read and maintain. Backwards compatibility from
version 5 format has been retained. Older formats will produce an error.


---
Diffs of the changes:  (+146 -550)

 Analyzer.cpp |2 
 Reader.cpp   |  617 +--
 Reader.h |   77 ---
 3 files changed, 146 insertions(+), 550 deletions(-)


Index: llvm/lib/Bytecode/Reader/Analyzer.cpp
diff -u llvm/lib/Bytecode/Reader/Analyzer.cpp:1.24 
llvm/lib/Bytecode/Reader/Analyzer.cpp:1.25
--- llvm/lib/Bytecode/Reader/Analyzer.cpp:1.24  Thu Nov  2 19:44:51 2006
+++ llvm/lib/Bytecode/Reader/Analyzer.cpp   Mon Nov 13 22:47:22 2006
@@ -532,7 +532,7 @@
 assert(BType = BytecodeFormat::ModuleBlockID);
 assert(BType  BytecodeFormat::NumberOfBlockIDs);
 bca.BlockSizes[
-  llvm::BytecodeFormat::CompressedBytecodeBlockIdentifiers(BType)] += Size;
+  llvm::BytecodeFormat::BytecodeBlockIdentifiers(BType)] += Size;
 
 if (bca.version  3) // Check for long block headers versions
   bca.BlockSizes[llvm::BytecodeFormat::Reserved_DoNotUse] += 8;


Index: llvm/lib/Bytecode/Reader/Reader.cpp
diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.204 
llvm/lib/Bytecode/Reader/Reader.cpp:1.205
--- llvm/lib/Bytecode/Reader/Reader.cpp:1.204   Wed Nov  8 15:27:54 2006
+++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Nov 13 22:47:22 2006
@@ -73,18 +73,6 @@
block.);
 }
 
-/// Align the buffer position to a 32 bit boundary
-inline void BytecodeReader::align32() {
-  if (hasAlignment) {
-BufPtr Save = At;
-At = (const unsigned char *)((intptr_t)(At+3)  (~3UL));
-if (At  Save)
-  if (Handler) Handler-handleAlignment(At - Save);
-if (At  BlockEnd)
-  error(Ran out of data while aligning!);
-  }
-}
-
 /// Read a whole unsigned integer
 inline unsigned BytecodeReader::read_uint() {
   if (At+4  BlockEnd)
@@ -179,43 +167,9 @@
 
 /// Read a block header and obtain its type and size
 inline void BytecodeReader::read_block(unsigned Type, unsigned Size) {
-  if ( hasLongBlockHeaders ) {
-Type = read_uint();
-Size = read_uint();
-switch (Type) {
-case BytecodeFormat::Reserved_DoNotUse :
-  error(Reserved_DoNotUse used as Module Type?);
-  Type = BytecodeFormat::ModuleBlockID; break;
-case BytecodeFormat::Module:
-  Type = BytecodeFormat::ModuleBlockID; break;
-case BytecodeFormat::Function:
-  Type = BytecodeFormat::FunctionBlockID; break;
-case BytecodeFormat::ConstantPool:
-  Type = BytecodeFormat::ConstantPoolBlockID; break;
-case BytecodeFormat::SymbolTable:
-  Type = BytecodeFormat::SymbolTableBlockID; break;
-case BytecodeFormat::ModuleGlobalInfo:
-  Type = BytecodeFormat::ModuleGlobalInfoBlockID; break;
-case BytecodeFormat::GlobalTypePlane:
-  Type = BytecodeFormat::GlobalTypePlaneBlockID; break;
-case BytecodeFormat::InstructionList:
-  Type = BytecodeFormat::InstructionListBlockID; break;
-case BytecodeFormat::CompactionTable:
-  Type = BytecodeFormat::CompactionTableBlockID; break;
-case BytecodeFormat::BasicBlock:
-  /// This block type isn't used after version 1.1. However, we have to
-  /// still allow the value in case this is an old bc format file.
-  /// We just let its value creep thru.
-  break;
-default:
-  error(Invalid block id found:  + utostr(Type));
-  break;
-}
-  } else {
-Size = read_uint();
-Type = Size  0x1F; // mask low order five bits
-Size = 5; // get rid of five low order bits, leaving high 27
-  }
+  Size = read_uint(); // Read the header
+  Type = Size  0x1F; // mask low order five bits to get type
+  Size = 5; // high order 27 bits is the size
   BlockStart = At;
   if (At + Size  BlockEnd)
 error(Attempt to size a block past end of memory);
@@ -223,56 +177,13 @@
   if (Handler) Handler-handleBlock(Type, BlockStart, Size);
 }
 
-
-/// In LLVM 1.2 and before, Types were derived from Value and so they were
-/// written as part of the type planes along with any other Value. In LLVM
-/// 1.3 this changed so that Type does not derive from Value. Consequently,
-/// the BytecodeReader's containers for Values can't contain Types because
-/// there's no inheritance relationship. This means that the Type Type
-/// plane is defunct along with the Type::TypeTyID TypeID. In LLVM 1.3
-/// whenever a bytecode construct must have both types and values together,
-/// the types are always read/written first and then the Values. Furthermore
-/// since Type::TypeTyID no longer exists, its value (12) now corresponds to
-/// Type::LabelTyID. In order to overcome this we must sanitize all the
-/// type TypeIDs we encounter. For LLVM 1.3 bytecode files, there's no change.