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

2007-05-11 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.52 - 1.53
---
Log message:

allow partially materialized modules to be written out, which just strips out
the functions which haven't been read.


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

 BitcodeWriter.cpp |1 +
 1 files changed, 1 insertion(+)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.52 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.53
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.52  Tue May  8 00:38:01 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May 11 18:51:59 2007
@@ -256,6 +256,7 @@
 static unsigned getEncodedLinkage(const GlobalValue *GV) {
   switch (GV-getLinkage()) {
   default: assert(0  Invalid linkage!);
+  case GlobalValue::GhostLinkage:  // Map ghost linkage onto external.
   case GlobalValue::ExternalLinkage: return 0;
   case GlobalValue::WeakLinkage: return 1;
   case GlobalValue::AppendingLinkage:return 2;



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


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

2007-05-07 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.51 - 1.52
---
Log message:

Make a preemptive bitcode format change to support PR1146: 
http://llvm.org/PR1146 .  This lets us do
pr1146: http://llvm.org/PR1146  in llvm 2.1 without ugly code to emulate old 
behavior.  This should
be merged into the 2.0 release branch.


---
Diffs of the changes:  (+23 -4)

 BitcodeWriter.cpp |   27 +++
 1 files changed, 23 insertions(+), 4 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.51 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.52
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.51  Sun May  6 14:19:23 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Tue May  8 00:38:01 2007
@@ -386,6 +386,12 @@
 Vals.push_back(F-getCallingConv());
 Vals.push_back(F-isDeclaration());
 Vals.push_back(getEncodedLinkage(F));
+
+// Note: we emit the param attr ID number for the function type of this
+// function.  In the future, we intend for attrs to be properties of
+// functions, instead of on the type.  This is to support this future work.
+Vals.push_back(VE.getParamAttrID(F-getFunctionType()-getParamAttrs()));
+
 Vals.push_back(Log2_32(F-getAlignment())+1);
 Vals.push_back(F-hasSection() ? SectionMap[F-getSection()] : 0);
 Vals.push_back(getEncodedVisibility(F));
@@ -736,15 +742,21 @@
   Vals.push_back(VE.getValueID(I.getOperand(i)));
 break;
   case Instruction::Invoke: {
+const PointerType *PTy = castPointerType(I.getOperand(0)-getType());
+const FunctionType *FTy = castFunctionType(PTy-getElementType());
 Code = bitc::FUNC_CODE_INST_INVOKE;
+
+// Note: we emit the param attr ID number for the function type of this
+// function.  In the future, we intend for attrs to be properties of
+// functions, instead of on the type.  This is to support this future work.
+Vals.push_back(VE.getParamAttrID(FTy-getParamAttrs()));
+
 Vals.push_back(castInvokeInst(I).getCallingConv());
 Vals.push_back(VE.getValueID(I.getOperand(1)));  // normal dest
 Vals.push_back(VE.getValueID(I.getOperand(2)));  // unwind dest
 PushValueAndType(I.getOperand(0), InstID, Vals, VE); // callee
 
 // Emit value #'s for the fixed parameters.
-const PointerType *PTy = castPointerType(I.getOperand(0)-getType());
-const FunctionType *FTy = castFunctionType(PTy-getElementType());
 for (unsigned i = 0, e = FTy-getNumParams(); i != e; ++i)
   Vals.push_back(VE.getValueID(I.getOperand(i+3)));  // fixed param.
 
@@ -806,14 +818,21 @@
 Vals.push_back(castStoreInst(I).isVolatile());
 break;
   case Instruction::Call: {
+const PointerType *PTy = castPointerType(I.getOperand(0)-getType());
+const FunctionType *FTy = castFunctionType(PTy-getElementType());
+
 Code = bitc::FUNC_CODE_INST_CALL;
+
+// Note: we emit the param attr ID number for the function type of this
+// function.  In the future, we intend for attrs to be properties of
+// functions, instead of on the type.  This is to support this future work.
+Vals.push_back(VE.getParamAttrID(FTy-getParamAttrs()));
+
 Vals.push_back((castCallInst(I).getCallingConv()  1) |
unsigned(castCallInst(I).isTailCall()));
 PushValueAndType(I.getOperand(0), InstID, Vals, VE);  // Callee
 
 // Emit value #'s for the fixed parameters.
-const PointerType *PTy = castPointerType(I.getOperand(0)-getType());
-const FunctionType *FTy = castFunctionType(PTy-getElementType());
 for (unsigned i = 0, e = FTy-getNumParams(); i != e; ++i)
   Vals.push_back(VE.getValueID(I.getOperand(i+1)));  // fixed param.
   



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


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

2007-05-06 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.50 - 1.51
---
Log message:

Flush the file after writing bitcode so that clients who don't close their
ofstreams will be ok.


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

 BitcodeWriter.cpp |3 +++
 1 files changed, 3 insertions(+)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.50 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.51
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.50  Sat May  5 22:12:47 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sun May  6 14:19:23 2007
@@ -1201,4 +1201,7 @@
   
   // Write the generated bitstream to Out.
   Out.write((char*)Buffer.front(), Buffer.size());
+  
+  // Make sure it hits disk now.
+  Out.flush();
 }



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.38 - 1.39
---
Log message:

Add abbreviations to the TYPE_BLOCK for pointers, functions, structs and arrays.
This shrinks the type_block of kc++ from 139901 bits to 99389 bits (0.55% to 
0.39%
of the file), a 40% reduction.

This shrink the record from:

  Block ID #10 (TYPE_BLOCK):
  Num Instances: 1
 Total Size: 139901b/17487.6B/4371.91W
  % of file: 0.549306
Num Abbrevs: 0
Num Records: 3203
  % Abbrev Recs: 0

to:

  Block ID #10 (TYPE_BLOCK):
  Num Instances: 1
 Total Size: 99389b/12423.6B/3105.91W
  % of file: 0.390862
Num Abbrevs: 4
Num Records: 3203
  % Abbrev Recs: 99.6566

With a common histogram of:

   Code Histogram:
1613POINTER
1100FUNCTION
255 STRUCT
224 ARRAY
5   INTEGER
2   OPAQUE
1   LABEL
1   DOUBLE
1   VOID
1   NUMENTRY



---
Diffs of the changes:  (+40 -3)

 BitcodeWriter.cpp |   43 ---
 1 files changed, 40 insertions(+), 3 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.38 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.39
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.38  Fri May  4 20:26:50 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 01:30:12 2007
@@ -121,7 +121,40 @@
   Stream.EnterSubblock(bitc::TYPE_BLOCK_ID, 4 /*count from # abbrevs */);
   SmallVectoruint64_t, 64 TypeVals;
   
-  // FIXME: Set up abbrevs now that we know the width of the type fields, etc.
+  // Abbrev for TYPE_CODE_POINTER.
+  BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::TYPE_CODE_POINTER));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+Log2_32_Ceil(VE.getTypes().size()+1)));
+  unsigned PtrAbbrev = Stream.EmitAbbrev(Abbv);
+  
+  // Abbrev for TYPE_CODE_FUNCTION.
+  Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::TYPE_CODE_FUNCTION));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));  // isvararg
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+Log2_32_Ceil(VE.getParamAttrs().size()+1)));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+Log2_32_Ceil(VE.getTypes().size()+1)));
+  unsigned FunctionAbbrev = Stream.EmitAbbrev(Abbv);
+  
+  // Abbrev for TYPE_CODE_STRUCT.
+  Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::TYPE_CODE_STRUCT));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));  // ispacked
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+Log2_32_Ceil(VE.getTypes().size()+1)));
+  unsigned StructAbbrev = Stream.EmitAbbrev(Abbv);
+ 
+  // Abbrev for TYPE_CODE_ARRAY.
+  Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::TYPE_CODE_ARRAY));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));   // size
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+Log2_32_Ceil(VE.getTypes().size()+1)));
+  unsigned ArrayAbbrev = Stream.EmitAbbrev(Abbv);
   
   // Emit an entry count so the reader can reserve space.
   TypeVals.push_back(TypeList.size());
@@ -151,28 +184,31 @@
   // POINTER: [pointee type]
   Code = bitc::TYPE_CODE_POINTER;
   TypeVals.push_back(VE.getTypeID(castPointerType(T)-getElementType()));
+  AbbrevToUse = PtrAbbrev;
   break;
 
 case Type::FunctionTyID: {
   const FunctionType *FT = castFunctionType(T);
-  // FUNCTION: [isvararg, attrid, #pararms, paramty x N]
+  // FUNCTION: [isvararg, attrid, retty, paramty x N]
   Code = bitc::TYPE_CODE_FUNCTION;
   TypeVals.push_back(FT-isVarArg());
   TypeVals.push_back(VE.getParamAttrID(FT-getParamAttrs()));
   TypeVals.push_back(VE.getTypeID(FT-getReturnType()));
   for (unsigned i = 0, e = FT-getNumParams(); i != e; ++i)
 TypeVals.push_back(VE.getTypeID(FT-getParamType(i)));
+  AbbrevToUse = FunctionAbbrev;
   break;
 }
 case Type::StructTyID: {
   const StructType *ST = castStructType(T);
-  // STRUCT: [ispacked, #elts, eltty x N]
+  // STRUCT: [ispacked, eltty x N]
   Code = bitc::TYPE_CODE_STRUCT;
   TypeVals.push_back(ST-isPacked());
   // Output all of the element types.
   for (StructType::element_iterator I = ST-element_begin(),
E = ST-element_end(); I != E; ++I)
 TypeVals.push_back(VE.getTypeID(*I));
+  AbbrevToUse = StructAbbrev;
   break;
 }
 case Type::ArrayTyID: {
@@ -181,6 +217,7 @@
   Code = bitc::TYPE_CODE_ARRAY;
   TypeVals.push_back(AT-getNumElements());
 

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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.39 - 1.40
---
Log message:

add abbrevs for the constants tables.  This shrinks it from 4.49755e6 bits
to 3.85972e6 bits in kc++


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

 BitcodeWriter.cpp |  184 --
 1 files changed, 123 insertions(+), 61 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.39 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.40
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.39  Sat May  5 01:30:12 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 02:36:14 2007
@@ -34,7 +34,13 @@
   VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
   VST_ENTRY_7_ABBREV,
   VST_ENTRY_6_ABBREV,
-  VST_BBENTRY_6_ABBREV
+  VST_BBENTRY_6_ABBREV,
+  
+  // CONSTANTS_BLOCK abbrev id's.
+  CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
+  CONSTANTS_INTEGER_ABBREV,
+  CONSTANTS_CE_CAST_Abbrev,
+  CONSTANTS_NULL_Abbrev
 };
 
 
@@ -396,11 +402,23 @@
 
 static void WriteConstants(unsigned FirstVal, unsigned LastVal,
const ValueEnumerator VE,
-   BitstreamWriter Stream) {
+   BitstreamWriter Stream, bool isGlobal) {
   if (FirstVal == LastVal) return;
   
-  Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 2);
+  Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4);
 
+  unsigned AggregateAbbrev = 0;
+  unsigned GEPAbbrev = 0;
+  // If this is a constant pool for the module, emit module-specific abbrevs.
+  if (isGlobal) {
+// Abbrev for CST_CODE_AGGREGATE.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::CST_CODE_AGGREGATE));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 
Log2_32_Ceil(LastVal+1)));
+AggregateAbbrev = Stream.EmitAbbrev(Abbv);
+  }  
+  
   // FIXME: Install and use abbrevs to reduce size.  Install them globally so
   // they don't need to be reemitted for each function body.
   
@@ -414,7 +432,8 @@
 if (V-getType() != LastTy) {
   LastTy = V-getType();
   Record.push_back(VE.getTypeID(LastTy));
-  Stream.EmitRecord(bitc::CST_CODE_SETTYPE, Record);
+  Stream.EmitRecord(bitc::CST_CODE_SETTYPE, Record,
+CONSTANTS_SETTYPE_ABBREV);
   Record.clear();
 }
 
@@ -437,6 +456,7 @@
 else
   Record.push_back((-V  1) | 1);
 Code = bitc::CST_CODE_INTEGER;
+AbbrevToUse = CONSTANTS_INTEGER_ABBREV;
   } else { // Wide integers,  64 bits in size.
 // We have an arbitrary precision integer value to write whose 
 // bit width is  64. However, in canonical unsigned integer 
@@ -466,6 +486,7 @@
   Code = bitc::CST_CODE_AGGREGATE;
   for (unsigned i = 0, e = C-getNumOperands(); i != e; ++i)
 Record.push_back(VE.getValueID(C-getOperand(i)));
+  AbbrevToUse = AggregateAbbrev;
 } else if (const ConstantExpr *CE = dyn_castConstantExpr(C)) {
   switch (CE-getOpcode()) {
   default:
@@ -474,6 +495,7 @@
   Record.push_back(GetEncodedCastOpcode(CE-getOpcode()));
   Record.push_back(VE.getTypeID(C-getOperand(0)-getType()));
   Record.push_back(VE.getValueID(C-getOperand(0)));
+  AbbrevToUse = CONSTANTS_CE_CAST_Abbrev;
 } else {
   assert(CE-getNumOperands() == 2  Unknown constant expr!);
   Code = bitc::CST_CODE_CE_BINOP;
@@ -488,6 +510,7 @@
   Record.push_back(VE.getTypeID(C-getOperand(i)-getType()));
   Record.push_back(VE.getValueID(C-getOperand(i)));
 }
+AbbrevToUse = GEPAbbrev;
 break;
   case Instruction::Select:
 Code = bitc::CST_CODE_CE_SELECT;
@@ -540,7 +563,7 @@
   // We know globalvalues have been emitted by WriteModuleInfo.
   for (unsigned i = 0, e = Vals.size(); i != e; ++i) {
 if (!isaGlobalValue(Vals[i].first)) {
-  WriteConstants(i, Vals.size(), VE, Stream);
+  WriteConstants(i, Vals.size(), VE, Stream, true);
   return;
 }
   }
@@ -821,7 +844,7 @@
   // If there are function-local constants, emit them now.
   unsigned CstStart, CstEnd;
   VE.getFunctionConstantRange(CstStart, CstEnd);
-  WriteConstants(CstStart, CstEnd, VE, Stream);
+  WriteConstants(CstStart, CstEnd, VE, Stream, false);
   
   // Finally, emit all the instructions, in order.
   for (Function::const_iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
@@ -875,6 +898,97 @@
   Stream.ExitBlock();
 }
 
+// Emit blockinfo, which defines the standard abbreviations etc.
+static void WriteBlockInfo(const ValueEnumerator VE, BitstreamWriter Stream) 
{
+  // We only want to emit block info records for blocks that have multiple
+  // instances: CONSTANTS_BLOCK, FUNCTION_BLOCK and VALUE_SYMTAB_BLOCK.  Other
+  // blocks can defined their abbrevs inline.
+  

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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.40 - 1.41
---
Log message:

add an abbrev for loads.  This shrinks the function block about 50K, from:

  Block ID #12 (FUNCTION_BLOCK):
  Num Instances: 2344
 Total Size: 8.8434e+06b/1.10542e+06B/276356W
  % of file: 35.6726
   Average Size: 3772.78b/471.598B/117.899W
  Tot/Avg SubBlocks: 4065/1.73422
Tot/Avg Abbrevs: 0/0
Tot/Avg Records: 128487/54.8153
  % Abbrev Recs: 0

to:

 Block ID #12 (FUNCTION_BLOCK):
  Num Instances: 2344
 Total Size: 8.44518e+06b/1.05565e+06B/263912W
  % of file: 34.6203
   Average Size: 3602.89b/450.362B/112.59W
  Tot/Avg SubBlocks: 4065/1.73422
Tot/Avg Abbrevs: 0/0
Tot/Avg Records: 128487/54.8153
  % Abbrev Recs: 22.2077



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

 BitcodeWriter.cpp |   23 ++-
 1 files changed, 22 insertions(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.40 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.41
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.40  Sat May  5 02:36:14 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 02:44:49 2007
@@ -40,7 +40,10 @@
   CONSTANTS_SETTYPE_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
   CONSTANTS_INTEGER_ABBREV,
   CONSTANTS_CE_CAST_Abbrev,
-  CONSTANTS_NULL_Abbrev
+  CONSTANTS_NULL_Abbrev,
+  
+  // FUNCTION_BLOCK abbrev id's.
+  FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV
 };
 
 
@@ -722,6 +725,7 @@
 Vals.push_back(VE.getValueID(I.getOperand(0))); // ptr.
 Vals.push_back(Log2_32(castLoadInst(I).getAlignment())+1);
 Vals.push_back(castLoadInst(I).isVolatile());
+AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
 break;
   case Instruction::Store:
 Code = bitc::FUNC_CODE_INST_STORE;
@@ -947,6 +951,8 @@
   assert(0  Unexpected abbrev ordering!);
   }
   
+  
+  
   { // SETTYPE abbrev for CONSTANTS_BLOCK.
 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
 Abbv-Add(BitCodeAbbrevOp(bitc::CST_CODE_SETTYPE));
@@ -986,6 +992,21 @@
   assert(0  Unexpected abbrev ordering!);
   }
   
+  // FIXME: This should only use space for first class types!
+ 
+  { // INST_LOAD abbrev for FUNCTION_BLOCK.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_LOAD));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,   // typeid
+  Log2_32_Ceil(VE.getTypes().size()+1)));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Ptr
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 4)); // Align
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // volatile
+if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+   Abbv) != FUNCTION_INST_LOAD_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  
   Stream.ExitBlock();
 }
 



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.41 - 1.42
---
Log message:

stop encoding type/value pairs when the type is implied by the value.
This shrinks the function block of kc++ from 1055K to 906K


---
Diffs of the changes:  (+48 -35)

 BitcodeWriter.cpp |   83 +++---
 1 files changed, 48 insertions(+), 35 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.41 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.42
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.41  Sat May  5 02:44:49 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 19:00:00 2007
@@ -572,9 +572,29 @@
   }
 }
 
+/// PushValueAndType - The file has to encode both the value and type id for
+/// many values, because we need to know what type to create for forward
+/// references.  However, most operands are not forward references, so this 
type
+/// field is not needed.
+///
+/// This function adds V's value ID to Vals.  If the value ID is higher than 
the
+/// instruction ID, then it is a forward reference, and it also includes the
+/// type ID.
+static bool PushValueAndType(Value *V, unsigned InstID,
+ SmallVectorunsigned, 64 Vals, 
+ ValueEnumerator VE) {
+  unsigned ValID = VE.getValueID(V);
+  Vals.push_back(ValID);
+  if (ValID = InstID) {
+Vals.push_back(VE.getTypeID(V-getType()));
+return true;
+  }
+  return false;
+}
+
 /// WriteInstruction - Emit an instruction to the specified stream.
-static void WriteInstruction(const Instruction I, ValueEnumerator VE, 
- BitstreamWriter Stream,
+static void WriteInstruction(const Instruction I, unsigned InstID,
+ ValueEnumerator VE, BitstreamWriter Stream,
  SmallVectorunsigned, 64 Vals) {
   unsigned Code = 0;
   unsigned AbbrevToUse = 0;
@@ -598,10 +618,8 @@
 
   case Instruction::GetElementPtr:
 Code = bitc::FUNC_CODE_INST_GEP;
-for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
-  Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));
-  Vals.push_back(VE.getValueID(I.getOperand(i)));
-}
+for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
+  PushValueAndType(I.getOperand(i), InstID, Vals, VE);
 break;
   case Instruction::Select:
 Code = bitc::FUNC_CODE_INST_SELECT;
@@ -633,18 +651,15 @@
   case Instruction::ICmp:
   case Instruction::FCmp:
 Code = bitc::FUNC_CODE_INST_CMP;
-Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));
+PushValueAndType(I.getOperand(0), InstID, Vals, VE);
 Vals.push_back(VE.getValueID(I.getOperand(1)));
 Vals.push_back(castCmpInst(I).getPredicate());
 break;
 
   case Instruction::Ret:
 Code = bitc::FUNC_CODE_INST_RET;
-if (I.getNumOperands()) {
-  Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-  Vals.push_back(VE.getValueID(I.getOperand(0)));
-}
+if (I.getNumOperands())
+  PushValueAndType(I.getOperand(0), InstID, Vals, VE);
 break;
   case Instruction::Br:
 Code = bitc::FUNC_CODE_INST_BR;
@@ -663,10 +678,9 @@
   case Instruction::Invoke: {
 Code = bitc::FUNC_CODE_INST_INVOKE;
 Vals.push_back(castInvokeInst(I).getCallingConv());
-Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));  // callee
-Vals.push_back(VE.getValueID(I.getOperand(1)));  // normal
-Vals.push_back(VE.getValueID(I.getOperand(2)));  // unwind
+Vals.push_back(VE.getValueID(I.getOperand(1)));  // normal dest
+Vals.push_back(VE.getValueID(I.getOperand(2)));  // unwind dest
+PushValueAndType(I.getOperand(0), InstID, Vals, VE); // callee
 
 // Emit value #'s for the fixed parameters.
 const PointerType *PTy = castPointerType(I.getOperand(0)-getType());
@@ -676,12 +690,9 @@
 
 // Emit type/value pairs for varargs params.
 if (FTy-isVarArg()) {
-  unsigned NumVarargs = I.getNumOperands()-3-FTy-getNumParams();
-  for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
-   i != e; ++i) {
-Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));
-Vals.push_back(VE.getValueID(I.getOperand(i)));
-  }
+  for (unsigned i = 3+FTy-getNumParams(), e = I.getNumOperands();
+   i != e; ++i)
+PushValueAndType(I.getOperand(i), InstID, Vals, VE); // vararg
 }
 break;
   }
@@ -721,11 +732,11 @@
 
   case Instruction::Load:
 Code = bitc::FUNC_CODE_INST_LOAD;
-Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0))); // ptr.
+if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))  // ptr
+  AbbrevToUse = FUNCTION_INST_LOAD_ABBREV;
+  
 

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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.42 - 1.43
---
Log message:

further reduce the redundancy of types in the instruction encoding.  This
shrinks function bodies in kc++ from 891913B to 884073B


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

 BitcodeWriter.cpp |   32 
 1 files changed, 12 insertions(+), 20 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.42 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.43
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.42  Sat May  5 19:00:00 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 19:21:25 2007
@@ -602,17 +602,15 @@
   default:
 if (Instruction::isCast(I.getOpcode())) {
   Code = bitc::FUNC_CODE_INST_CAST;
-  Vals.push_back(GetEncodedCastOpcode(I.getOpcode()));
+  PushValueAndType(I.getOperand(0), InstID, Vals, VE);
   Vals.push_back(VE.getTypeID(I.getType()));
-  Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-  Vals.push_back(VE.getValueID(I.getOperand(0)));
+  Vals.push_back(GetEncodedCastOpcode(I.getOpcode()));
 } else {
   assert(isaBinaryOperator(I)  Unknown instruction!);
   Code = bitc::FUNC_CODE_INST_BINOP;
-  Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode()));
-  Vals.push_back(VE.getTypeID(I.getType()));
-  Vals.push_back(VE.getValueID(I.getOperand(0)));
+  PushValueAndType(I.getOperand(0), InstID, Vals, VE);
   Vals.push_back(VE.getValueID(I.getOperand(1)));
+  Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode()));
 }
 break;
 
@@ -623,28 +621,24 @@
 break;
   case Instruction::Select:
 Code = bitc::FUNC_CODE_INST_SELECT;
-Vals.push_back(VE.getTypeID(I.getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));
-Vals.push_back(VE.getValueID(I.getOperand(1)));
+PushValueAndType(I.getOperand(1), InstID, Vals, VE);
 Vals.push_back(VE.getValueID(I.getOperand(2)));
+Vals.push_back(VE.getValueID(I.getOperand(0)));
 break;
   case Instruction::ExtractElement:
 Code = bitc::FUNC_CODE_INST_EXTRACTELT;
-Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));
+PushValueAndType(I.getOperand(0), InstID, Vals, VE);
 Vals.push_back(VE.getValueID(I.getOperand(1)));
 break;
   case Instruction::InsertElement:
 Code = bitc::FUNC_CODE_INST_INSERTELT;
-Vals.push_back(VE.getTypeID(I.getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));
+PushValueAndType(I.getOperand(0), InstID, Vals, VE);
 Vals.push_back(VE.getValueID(I.getOperand(1)));
 Vals.push_back(VE.getValueID(I.getOperand(2)));
 break;
   case Instruction::ShuffleVector:
 Code = bitc::FUNC_CODE_INST_SHUFFLEVEC;
-Vals.push_back(VE.getTypeID(I.getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));
+PushValueAndType(I.getOperand(0), InstID, Vals, VE);
 Vals.push_back(VE.getValueID(I.getOperand(1)));
 Vals.push_back(VE.getValueID(I.getOperand(2)));
 break;
@@ -719,8 +713,7 @@
 
   case Instruction::Free:
 Code = bitc::FUNC_CODE_INST_FREE;
-Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-Vals.push_back(VE.getValueID(I.getOperand(0)));
+PushValueAndType(I.getOperand(0), InstID, Vals, VE);
 break;
 
   case Instruction::Alloca:
@@ -740,9 +733,8 @@
 break;
   case Instruction::Store:
 Code = bitc::FUNC_CODE_INST_STORE;
-Vals.push_back(VE.getTypeID(I.getOperand(1)-getType()));   // Pointer
-Vals.push_back(VE.getValueID(I.getOperand(0))); // val.
-Vals.push_back(VE.getValueID(I.getOperand(1))); // ptr.
+PushValueAndType(I.getOperand(0), InstID, Vals, VE);  // val.
+Vals.push_back(VE.getValueID(I.getOperand(1)));   // ptr.
 Vals.push_back(Log2_32(castStoreInst(I).getAlignment())+1);
 Vals.push_back(castStoreInst(I).isVolatile());
 break;



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


[llvm-commits] CVS: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp ValueEnumerator.cpp

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.43 - 1.44
ValueEnumerator.cpp updated: 1.11 - 1.12
---
Log message:

implement the 'string constant' optimization.  This shrinks kc.bit from
2878544 to 2815788


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

 BitcodeWriter.cpp   |6 ++
 ValueEnumerator.cpp |9 +
 2 files changed, 11 insertions(+), 4 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.43 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.44
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.43  Sat May  5 19:21:25 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 19:35:24 2007
@@ -484,6 +484,12 @@
 assert (CFP-getType() == Type::DoubleTy  Unknown FP type!);
 Record.push_back(DoubleToBits((double)CFP-getValue()));
   }
+} else if (isaConstantArray(C)  castConstantArray(C)-isString()) {
+  // Emit constant strings specially.
+  Code = bitc::CST_CODE_STRING;
+  for (unsigned i = 0, e = C-getNumOperands(); i != e; ++i)
+Record.push_back(castConstantInt(C-getOperand(i))-getZExtValue());
+  
 } else if (isaConstantArray(C) || isaConstantStruct(V) ||
isaConstantVector(V)) {
   Code = bitc::CST_CODE_AGGREGATE;


Index: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.11 
llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.12
--- llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.11Fri May  4 00:21:47 2007
+++ llvm/lib/Bitcode/Writer/ValueEnumerator.cpp Sat May  5 19:35:24 2007
@@ -12,6 +12,7 @@
 
//===--===//
 
 #include ValueEnumerator.h
+#include llvm/Constants.h
 #include llvm/DerivedTypes.h
 #include llvm/Module.h
 #include llvm/TypeSymbolTable.h
@@ -65,8 +66,6 @@
I != E; ++I)
 EnumerateValue(I-getAliasee());
   
-  // FIXME: Implement the 'string constant' optimization.
-
   // Enumerate types used by the type symbol table.
   EnumerateTypeSymbolTable(M-getTypeSymbolTable());
 
@@ -105,8 +104,6 @@
   // Now that we rearranged the type table, rebuild TypeMap.
   for (unsigned i = 0, e = Types.size(); i != e; ++i)
 TypeMap[Types[i].first] = i+1;
-  
-  // FIXME: Sort value tables by frequency.
 }
 
 // Optimize constant ordering.
@@ -176,6 +173,10 @@
   if (const Constant *C = dyn_castConstant(V)) {
 if (isaGlobalValue(C)) {
   // Initializers for globals are handled explicitly elsewhere.
+} else if (isaConstantArray(C)  castConstantArray(C)-isString()) {
+  // Do not enumerate the initializers for an array of simple characters.
+  // The initializers just polute the value table, and we emit the strings
+  // specially.
 } else {
   // This makes sure that if a constant has uses (for example an array of
   // const ints), that they are inserted also.



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.44 - 1.45
---
Log message:

add an abbreviation for the string constants opzn, shrinking the constnats
block from:

  Block ID #11 (CONSTANTS_BLOCK):
  Num Instances: 1722
 Total Size: 3.85976e+06b/482470B/120617W
  % of file: 16.7609
   Average Size: 2241.44b/280.18B/70.045W
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 1/0.00058072
Tot/Avg Records: 26423/15.3444
  % Abbrev Recs: 69.1746

to:

 Block ID #11 (CONSTANTS_BLOCK):
  Num Instances: 1724
 Total Size: 2.62406e+06b/328008B/82001.9W
  % of file: 12.041
   Average Size: 1522.08b/190.26B/47.5649W
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 2/0.00116009
Tot/Avg Records: 26280/15.2436
  % Abbrev Recs: 68.9992

This shrinks kc++ from 2815788 to 2724088 bytes, which means the bitcode
file is now smaller than the bytecode file.



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

 BitcodeWriter.cpp |   21 -
 1 files changed, 16 insertions(+), 5 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.44 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.45
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.44  Sat May  5 19:35:24 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 19:42:18 2007
@@ -411,7 +411,7 @@
   Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4);
 
   unsigned AggregateAbbrev = 0;
-  unsigned GEPAbbrev = 0;
+  unsigned String7Abbrev = 0;
   // If this is a constant pool for the module, emit module-specific abbrevs.
   if (isGlobal) {
 // Abbrev for CST_CODE_AGGREGATE.
@@ -420,6 +420,13 @@
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 
Log2_32_Ceil(LastVal+1)));
 AggregateAbbrev = Stream.EmitAbbrev(Abbv);
+
+// Abbrev for CST_CODE_STRING.
+Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
+String7Abbrev = Stream.EmitAbbrev(Abbv);
   }  
   
   // FIXME: Install and use abbrevs to reduce size.  Install them globally so
@@ -487,9 +494,14 @@
 } else if (isaConstantArray(C)  castConstantArray(C)-isString()) {
   // Emit constant strings specially.
   Code = bitc::CST_CODE_STRING;
-  for (unsigned i = 0, e = C-getNumOperands(); i != e; ++i)
-Record.push_back(castConstantInt(C-getOperand(i))-getZExtValue());
-  
+  bool isStr7 = true;
+  for (unsigned i = 0, e = C-getNumOperands(); i != e; ++i) {
+unsigned char V = castConstantInt(C-getOperand(i))-getZExtValue();
+Record.push_back(V);
+isStr7 = (V  128) == 0;
+  }
+  if (isStr7)
+AbbrevToUse = String7Abbrev;
 } else if (isaConstantArray(C) || isaConstantStruct(V) ||
isaConstantVector(V)) {
   Code = bitc::CST_CODE_AGGREGATE;
@@ -519,7 +531,6 @@
   Record.push_back(VE.getTypeID(C-getOperand(i)-getType()));
   Record.push_back(VE.getValueID(C-getOperand(i)));
 }
-AbbrevToUse = GEPAbbrev;
 break;
   case Instruction::Select:
 Code = bitc::CST_CODE_CE_SELECT;



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.45 - 1.46
---
Log message:

add a denser encoding for null terminated strings, add a 6-bit abbrev as
well.  This shrinks kc++ from 2724088 to 2717360 bytes.



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

 BitcodeWriter.cpp |   44 
 1 files changed, 36 insertions(+), 8 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.45 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.46
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.45  Sat May  5 19:42:18 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 19:53:07 2007
@@ -411,7 +411,9 @@
   Stream.EnterSubblock(bitc::CONSTANTS_BLOCK_ID, 4);
 
   unsigned AggregateAbbrev = 0;
-  unsigned String7Abbrev = 0;
+  unsigned String8Abbrev = 0;
+  unsigned CString7Abbrev = 0;
+  unsigned CString6Abbrev = 0;
   // If this is a constant pool for the module, emit module-specific abbrevs.
   if (isGlobal) {
 // Abbrev for CST_CODE_AGGREGATE.
@@ -425,8 +427,20 @@
 Abbv = new BitCodeAbbrev();
 Abbv-Add(BitCodeAbbrevOp(bitc::CST_CODE_STRING));
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
+String8Abbrev = Stream.EmitAbbrev(Abbv);
+// Abbrev for CST_CODE_CSTRING.
+Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
-String7Abbrev = Stream.EmitAbbrev(Abbv);
+CString7Abbrev = Stream.EmitAbbrev(Abbv);
+// Abbrev for CST_CODE_CSTRING.
+Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::CST_CODE_CSTRING));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
+CString6Abbrev = Stream.EmitAbbrev(Abbv);
   }  
   
   // FIXME: Install and use abbrevs to reduce size.  Install them globally so
@@ -493,15 +507,29 @@
   }
 } else if (isaConstantArray(C)  castConstantArray(C)-isString()) {
   // Emit constant strings specially.
-  Code = bitc::CST_CODE_STRING;
-  bool isStr7 = true;
-  for (unsigned i = 0, e = C-getNumOperands(); i != e; ++i) {
+  unsigned NumOps = C-getNumOperands();
+  // If this is a null-terminated string, use the denser CSTRING encoding.
+  if (C-getOperand(NumOps-1)-isNullValue()) {
+Code = bitc::CST_CODE_CSTRING;
+--NumOps;  // Don't encode the null, which isn't allowed by char6.
+  } else {
+Code = bitc::CST_CODE_STRING;
+AbbrevToUse = String8Abbrev;
+  }
+  bool isCStr7 = Code == bitc::CST_CODE_CSTRING;
+  bool isCStrChar6 = Code == bitc::CST_CODE_CSTRING;
+  for (unsigned i = 0; i != NumOps; ++i) {
 unsigned char V = castConstantInt(C-getOperand(i))-getZExtValue();
 Record.push_back(V);
-isStr7 = (V  128) == 0;
+isCStr7 = (V  128) == 0;
+if (isCStrChar6) 
+  isCStrChar6 = BitCodeAbbrevOp::isChar6(V);
   }
-  if (isStr7)
-AbbrevToUse = String7Abbrev;
+  
+  if (isCStrChar6)
+AbbrevToUse = CString6Abbrev;
+  else if (isCStr7)
+AbbrevToUse = CString7Abbrev;
 } else if (isaConstantArray(C) || isaConstantStruct(V) ||
isaConstantVector(V)) {
   Code = bitc::CST_CODE_AGGREGATE;



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.46 - 1.47
---
Log message:

add some abbrevs for ret and unreachable, shrinking kc++ from 2717360-2705388


---
Diffs of the changes:  (+31 -3)

 BitcodeWriter.cpp |   34 +++---
 1 files changed, 31 insertions(+), 3 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.46 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.47
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.46  Sat May  5 19:53:07 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 20:28:01 2007
@@ -43,7 +43,10 @@
   CONSTANTS_NULL_Abbrev,
   
   // FUNCTION_BLOCK abbrev id's.
-  FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV
+  FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
+  FUNCTION_INST_RET_VOID_ABBREV,
+  FUNCTION_INST_RET_VAL_ABBREV,
+  FUNCTION_INST_UNREACHABLE_ABBREV
 };
 
 
@@ -697,8 +700,10 @@
 
   case Instruction::Ret:
 Code = bitc::FUNC_CODE_INST_RET;
-if (I.getNumOperands())
-  PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+if (!I.getNumOperands())
+  AbbrevToUse = FUNCTION_INST_RET_VOID_ABBREV;
+else if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
+  AbbrevToUse = FUNCTION_INST_RET_VAL_ABBREV;
 break;
   case Instruction::Br:
 Code = bitc::FUNC_CODE_INST_BR;
@@ -740,6 +745,7 @@
 break;
   case Instruction::Unreachable:
 Code = bitc::FUNC_CODE_INST_UNREACHABLE;
+AbbrevToUse = FUNCTION_INST_UNREACHABLE_ABBREV;
 break;
   
   case Instruction::PHI:
@@ -1056,6 +1062,28 @@
Abbv) != FUNCTION_INST_LOAD_ABBREV)
   assert(0  Unexpected abbrev ordering!);
   }
+  { // INST_RET abbrev for FUNCTION_BLOCK.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_RET));
+if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+   Abbv) != FUNCTION_INST_RET_VOID_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  { // INST_RET abbrev for FUNCTION_BLOCK.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_RET));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // ValID
+if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+   Abbv) != FUNCTION_INST_RET_VAL_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  { // INST_UNREACHABLE abbrev for FUNCTION_BLOCK.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_UNREACHABLE));
+if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+   Abbv) != FUNCTION_INST_UNREACHABLE_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
   
   Stream.ExitBlock();
 }



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.47 - 1.48
---
Log message:

implement reading/writing of inlineasm objects


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

 BitcodeWriter.cpp |   22 --
 1 files changed, 16 insertions(+), 6 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.47 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.48
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.47  Sat May  5 20:28:01 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 20:58:20 2007
@@ -17,6 +17,7 @@
 #include ValueEnumerator.h
 #include llvm/Constants.h
 #include llvm/DerivedTypes.h
+#include llvm/InlineAsm.h
 #include llvm/Instructions.h
 #include llvm/Module.h
 #include llvm/ParameterAttributes.h
@@ -446,9 +447,6 @@
 CString6Abbrev = Stream.EmitAbbrev(Abbv);
   }  
   
-  // FIXME: Install and use abbrevs to reduce size.  Install them globally so
-  // they don't need to be reemitted for each function body.
-  
   SmallVectoruint64_t, 64 Record;
 
   const ValueEnumerator::ValueList Vals = VE.getValues();
@@ -465,7 +463,21 @@
 }
 
 if (const InlineAsm *IA = dyn_castInlineAsm(V)) {
-  assert(0  IA  FIXME: Inline asm writing unimp!);
+  Record.push_back(unsigned(IA-hasSideEffects()));
+  
+  // Add the asm string.
+  const std::string AsmStr = IA-getAsmString();
+  Record.push_back(AsmStr.size());
+  for (unsigned i = 0, e = AsmStr.size(); i != e; ++i)
+Record.push_back(AsmStr[i]);
+  
+  // Add the constraint string.
+  const std::string ConstraintStr = IA-getConstraintString();
+  Record.push_back(ConstraintStr.size());
+  for (unsigned i = 0, e = ConstraintStr.size(); i != e; ++i)
+Record.push_back(ConstraintStr[i]);
+  Stream.EmitRecord(bitc::CST_CODE_INLINEASM, Record);
+  Record.clear();
   continue;
 }
 const Constant *C = castConstant(V);
@@ -894,8 +906,6 @@
   Stream.EmitRecord(bitc::FUNC_CODE_DECLAREBLOCKS, Vals);
   Vals.clear();
   
-  // FIXME: Function attributes?
-  
   // If there are function-local constants, emit them now.
   unsigned CstStart, CstEnd;
   VE.getFunctionConstantRange(CstStart, CstEnd);



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


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

2007-05-05 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.48 - 1.49
---
Log message:

add abbrevs for binops and casts.  This shrinks a testcase from 725132-682500 
bytes.


---
Diffs of the changes:  (+29 -3)

 BitcodeWriter.cpp |   32 +---
 1 files changed, 29 insertions(+), 3 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.48 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.49
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.48  Sat May  5 20:58:20 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 21:38:57 2007
@@ -45,6 +45,8 @@
   
   // FUNCTION_BLOCK abbrev id's.
   FUNCTION_INST_LOAD_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
+  FUNCTION_INST_BINOP_ABBREV,
+  FUNCTION_INST_CAST_ABBREV,
   FUNCTION_INST_RET_VOID_ABBREV,
   FUNCTION_INST_RET_VAL_ABBREV,
   FUNCTION_INST_UNREACHABLE_ABBREV
@@ -662,13 +664,15 @@
   default:
 if (Instruction::isCast(I.getOpcode())) {
   Code = bitc::FUNC_CODE_INST_CAST;
-  PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+  if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
+AbbrevToUse = FUNCTION_INST_CAST_ABBREV;
   Vals.push_back(VE.getTypeID(I.getType()));
   Vals.push_back(GetEncodedCastOpcode(I.getOpcode()));
 } else {
   assert(isaBinaryOperator(I)  Unknown instruction!);
   Code = bitc::FUNC_CODE_INST_BINOP;
-  PushValueAndType(I.getOperand(0), InstID, Vals, VE);
+  if (!PushValueAndType(I.getOperand(0), InstID, Vals, VE))
+AbbrevToUse = FUNCTION_INST_BINOP_ABBREV;
   Vals.push_back(VE.getValueID(I.getOperand(1)));
   Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode()));
 }
@@ -895,7 +899,7 @@
 /// WriteFunction - Emit a function body to the module stream.
 static void WriteFunction(const Function F, ValueEnumerator VE, 
   BitstreamWriter Stream) {
-  Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 3);
+  Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 4);
   VE.incorporateFunction(F);
 
   SmallVectorunsigned, 64 Vals;
@@ -1072,6 +1076,28 @@
Abbv) != FUNCTION_INST_LOAD_ABBREV)
   assert(0  Unexpected abbrev ordering!);
   }
+  { // INST_BINOP abbrev for FUNCTION_BLOCK.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_BINOP));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // LHS
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // RHS
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4)); // opc
+if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+   Abbv) != FUNCTION_INST_BINOP_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  { // INST_CAST abbrev for FUNCTION_BLOCK.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_CAST));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));// OpVal
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,   // dest ty
+  Log2_32_Ceil(VE.getTypes().size()+1)));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 4));  // opc
+if (Stream.EmitBlockInfoAbbrev(bitc::FUNCTION_BLOCK_ID,
+   Abbv) != FUNCTION_INST_CAST_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  
   { // INST_RET abbrev for FUNCTION_BLOCK.
 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
 Abbv-Add(BitCodeAbbrevOp(bitc::FUNC_CODE_INST_RET));



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


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

2007-05-05 Thread Jeff Cohen


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.49 - 1.50
---
Log message:

Unbreak VC++.

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

 BitcodeWriter.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.49 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.50
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.49  Sat May  5 21:38:57 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sat May  5 22:12:47 2007
@@ -808,7 +808,7 @@
   case Instruction::Call: {
 Code = bitc::FUNC_CODE_INST_CALL;
 Vals.push_back((castCallInst(I).getCallingConv()  1) |
-   castCallInst(I).isTailCall());
+   unsigned(castCallInst(I).isTailCall()));
 PushValueAndType(I.getOperand(0), InstID, Vals, VE);  // Callee
 
 // Emit value #'s for the fixed parameters.



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.29 - 1.30
---
Log message:

stub out creation of BLOCKINFO_BLOCK


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

 BitcodeWriter.cpp |   25 +
 1 files changed, 25 insertions(+)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.29 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.30
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.29  Thu May  3 22:52:24 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 13:26:27 2007
@@ -858,6 +858,28 @@
   Stream.ExitBlock();
 }
 
+// Emit blockinfo, which defines the standard abbreviations etc.
+static void WriteBlockInfo(BitstreamWriter Stream) {
+  // We only want to emit block info records for blocks that have multiple
+  // instances: CONSTANTS_BLOCK, FUNCTION_BLOCK and VALUE_SYMTAB_BLOCK.  Other
+  // blocks can defined their abbrevs inline.
+  Stream.EnterSubblock(bitc::BLOCKINFO_BLOCK_ID, 2);
+
+#if 0
+  // Configure TYPE_SYMTAB_BLOCK's.
+
+  // Add an abbrev for VST_ENTRY where the characters each fit in 7 bits.
+  BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8); // Value ID
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 3)); // Linkage.
+  
+  xxx = Stream.EmitAbbrev(Abbv);
+#endif
+  Stream.ExitBlock();
+}
+
+
 /// WriteBitcodeToFile - Write the specified module to the specified output
 /// stream.
 void llvm::WriteBitcodeToFile(const Module *M, std::ostream Out) {
@@ -874,6 +896,9 @@
   Stream.Emit(0xE, 4);
   Stream.Emit(0xD, 4);
 
+  // Emit blockinfo, which defines the standard abbreviations etc.
+  WriteBlockInfo(Stream);
+  
   // Emit the module.
   WriteModule(M, Stream);
   



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.30 - 1.31
---
Log message:

eliminate internal length fields from record.  Records already know their
total length



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

 BitcodeWriter.cpp |   23 ---
 1 files changed, 12 insertions(+), 11 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.30 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.31
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.30  Fri May  4 13:26:27 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 14:11:41 2007
@@ -72,8 +72,7 @@
   unsigned AbbrevToUse, BitstreamWriter Stream) {
   SmallVectorunsigned, 64 Vals;
   
-  // Code: [strlen, strchar x N]
-  Vals.push_back(Str.size());
+  // Code: [strchar x N]
   for (unsigned i = 0, e = Str.size(); i != e; ++i)
 Vals.push_back(Str[i]);
 
@@ -150,7 +149,6 @@
   TypeVals.push_back(FT-isVarArg());
   TypeVals.push_back(VE.getParamAttrID(FT-getParamAttrs()));
   TypeVals.push_back(VE.getTypeID(FT-getReturnType()));
-  TypeVals.push_back(FT-getNumParams());
   for (unsigned i = 0, e = FT-getNumParams(); i != e; ++i)
 TypeVals.push_back(VE.getTypeID(FT-getParamType(i)));
   break;
@@ -160,8 +158,7 @@
   // STRUCT: [ispacked, #elts, eltty x N]
   Code = bitc::TYPE_CODE_STRUCT;
   TypeVals.push_back(ST-isPacked());
-  TypeVals.push_back(ST-getNumElements());
-  // Output all of the element types...
+  // Output all of the element types.
   for (StructType::element_iterator I = ST-element_begin(),
E = ST-element_end(); I != E; ++I)
 TypeVals.push_back(VE.getTypeID(*I));
@@ -399,7 +396,6 @@
 // So, we only write the number of active words.
 unsigned NWords = IV-getValue().getActiveWords(); 
 const uint64_t *RawWords = IV-getValue().getRawData();
-Record.push_back(NWords);
 for (unsigned i = 0; i != NWords; ++i) {
   int64_t V = RawWords[i];
   if (V = 0)
@@ -420,7 +416,6 @@
 } else if (isaConstantArray(C) || isaConstantStruct(V) ||
isaConstantVector(V)) {
   Code = bitc::CST_CODE_AGGREGATE;
-  Record.push_back(C-getNumOperands());
   for (unsigned i = 0, e = C-getNumOperands(); i != e; ++i)
 Record.push_back(VE.getValueID(C-getOperand(i)));
 } else if (const ConstantExpr *CE = dyn_castConstantExpr(C)) {
@@ -441,7 +436,6 @@
 break;
   case Instruction::GetElementPtr:
 Code = bitc::CST_CODE_CE_GEP;
-Record.push_back(CE-getNumOperands());
 for (unsigned i = 0, e = CE-getNumOperands(); i != e; ++i) {
   Record.push_back(VE.getTypeID(C-getOperand(i)-getType()));
   Record.push_back(VE.getValueID(C-getOperand(i)));
@@ -627,7 +621,6 @@
   case Instruction::PHI:
 Code = bitc::FUNC_CODE_INST_PHI;
 Vals.push_back(VE.getTypeID(I.getType()));
-Vals.push_back(I.getNumOperands());
 for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
   Vals.push_back(VE.getValueID(I.getOperand(i)));
 break;
@@ -710,6 +703,16 @@
   if (VST.empty()) return;
   Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
   
+#if 0
+  BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::VST_ENTRY));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth,
+Log2_32_Ceil(MaxGlobalType+1)));
+  // Don't bother emitting vis + thread local.
+  SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv);
+#endif
+  
+  
   // FIXME: Set up the abbrev, we know how many values there are!
   // FIXME: We know if the type names can use 7-bit ascii.
   SmallVectorunsigned, 64 NameVals;
@@ -728,7 +731,6 @@
 }
 
 NameVals.push_back(VE.getValueID(SI-getValue()));
-NameVals.push_back(SI-getKeyLength());
 for (const char *P = SI-getKeyData(),
  *E = SI-getKeyData()+SI-getKeyLength(); P != E; ++P)
   NameVals.push_back((unsigned char)*P);
@@ -794,7 +796,6 @@
 NameVals.push_back(VE.getTypeID(TI-second));
 
 const std::string Str = TI-first;
-NameVals.push_back(Str.size());
 for (unsigned i = 0, e = Str.size(); i != e; ++i)
   NameVals.push_back(Str[i]);
 



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.31 - 1.32
---
Log message:

Encode all value symtab strings as arrays of 8-bit fixed width integers,
instead of the default inefficient encoding.  This shrinks kc++ from 4134K
to 3629K


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

 BitcodeWriter.cpp |   30 +++---
 1 files changed, 15 insertions(+), 15 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.31 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.32
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.31  Fri May  4 14:11:41 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 15:34:50 2007
@@ -267,22 +267,22 @@
 // Add an abbrev for common globals with no visibility or thread localness.
 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
 Abbv-Add(BitCodeAbbrevOp(bitc::MODULE_CODE_GLOBALVAR));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth,
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
   Log2_32_Ceil(MaxGlobalType+1)));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 1)); // Constant.
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1));  // Constant.
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6));// Initializer.
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 3)); // Linkage.
-if (MaxAlignment == 0) // Alignment.
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));  // Linkage.
+if (MaxAlignment == 0)  // Alignment.
   Abbv-Add(BitCodeAbbrevOp(0));
 else {
   unsigned MaxEncAlignment = Log2_32(MaxAlignment)+1;
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth,
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
Log2_32_Ceil(MaxEncAlignment+1)));
 }
 if (SectionMap.empty())// Section.
   Abbv-Add(BitCodeAbbrevOp(0));
 else
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth,
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
Log2_32_Ceil(SectionMap.size()+1)));
 // Don't bother emitting vis + thread local.
 SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv);
@@ -702,15 +702,14 @@
   BitstreamWriter Stream) {
   if (VST.empty()) return;
   Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
-  
-#if 0
+
+  // 8-bit fixed width VST_ENTRY strings.
   BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-  Abbv-Add(BitCodeAbbrevOp(bitc::VST_ENTRY));
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth,
-Log2_32_Ceil(MaxGlobalType+1)));
-  // Don't bother emitting vis + thread local.
-  SimpleGVarAbbrev = Stream.EmitAbbrev(Abbv);
-#endif
+  Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
+  unsigned AbbrevID = Stream.EmitAbbrev(Abbv);
   
   
   // FIXME: Set up the abbrev, we know how many values there are!
@@ -728,6 +727,7 @@
   Code = bitc::VST_CODE_BBENTRY;
 } else {
   Code = bitc::VST_CODE_ENTRY;
+  AbbrevToUse = AbbrevID;
 }
 
 NameVals.push_back(VE.getValueID(SI-getValue()));
@@ -873,7 +873,7 @@
   BitCodeAbbrev *Abbv = new BitCodeAbbrev();
   Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
   Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8); // Value ID
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::FixedWidth, 3)); // Linkage.
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage.
   
   xxx = Stream.EmitAbbrev(Abbv);
 #endif



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.32 - 1.33
---
Log message:

where possible, encode symtab names with 7 bits per char instead of 8.  This
shaves 110K off kc++ to 3514K.  Before:

  Block ID #14 (VALUE_SYMTAB):
  Num Instances: 2345
 Total Size: 1.50425e+07b/1.88031e+06B/470077W
   Average Size: 6414.69b/801.837B/200.459W
  % of file: 51.8057
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 2345/1
Tot/Avg Records: 120924/51.5667
  % Abbrev Recs: 85.1791

after:

  Block ID #14 (VALUE_SYMTAB):
  Num Instances: 2345
 Total Size: 1.41229e+07b/1.76536e+06B/441341W
   Average Size: 6022.56b/752.82B/188.205W
  % of file: 50.2295
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 4690/2
Tot/Avg Records: 120924/51.5667
  % Abbrev Recs: 85.1791



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

 BitcodeWriter.cpp |   56 +++---
 1 files changed, 45 insertions(+), 11 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.32 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.33
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.32  Fri May  4 15:34:50 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 15:52:02 2007
@@ -25,7 +25,17 @@
 #include llvm/Support/MathExtras.h
 using namespace llvm;
 
-static const unsigned CurVersion = 0;
+/// These are manifest constants used by the bitcode writer. They do not need 
to
+/// be kept in sync with the reader, but need to be consistent within this 
file.
+enum {
+  CurVersion = 0,
+  
+  // VALUE_SYMTAB_BLOCK abbrev id's.
+  VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
+  VST_ENTRY_7_ABBREV
+  
+};
+
 
 static unsigned GetEncodedCastOpcode(unsigned Opcode) {
   switch (Opcode) {
@@ -703,13 +713,25 @@
   if (VST.empty()) return;
   Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
 
-  // 8-bit fixed width VST_ENTRY strings.
-  BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-  Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
-  unsigned AbbrevID = Stream.EmitAbbrev(Abbv);
+  { // 8-bit fixed width VST_ENTRY strings.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
+if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_8_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  
+  { // 7-bit fixed width VST_ENTRY strings.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
+if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_7_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
   
   
   // FIXME: Set up the abbrev, we know how many values there are!
@@ -718,6 +740,18 @@
   
   for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
SI != SE; ++SI) {
+
+const ValueName Name = *SI;
+
+// Figure out the encoding to use for the name.
+bool is7Bit = true;
+for (unsigned i = 0, e = Name.getKeyLength(); i != e; ++i)
+  if ((unsigned char)Name.getKeyData()[i]  128) {
+is7Bit = false;
+break;
+  }
+
+
 unsigned AbbrevToUse = 0;
 
 // VST_ENTRY:   [valueid, namelen, namechar x N]
@@ -727,12 +761,12 @@
   Code = bitc::VST_CODE_BBENTRY;
 } else {
   Code = bitc::VST_CODE_ENTRY;
-  AbbrevToUse = AbbrevID;
+  AbbrevToUse = is7Bit ? VST_ENTRY_7_ABBREV : VST_ENTRY_8_ABBREV;
 }
 
 NameVals.push_back(VE.getValueID(SI-getValue()));
-for (const char *P = SI-getKeyData(),
- *E = SI-getKeyData()+SI-getKeyLength(); P != E; ++P)
+for (const char *P = Name.getKeyData(),
+ *E = Name.getKeyData()+Name.getKeyLength(); P != E; ++P)
   NameVals.push_back((unsigned char)*P);
 
 // Emit the finished record.



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.33 - 1.34
---
Log message:

shave another 150K off of kc++, by using a 7-bit encoding for BB names 
where we can.  This shrinks kc++'s down to 3368K, with a VST record of:

  Block ID #14 (VALUE_SYMTAB):
  Num Instances: 2345
 Total Size: 1.29508e+07b/1.61885e+06B/404713W
   Average Size: 5522.73b/690.342B/172.585W
  % of file: 48.0645
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 7035/3
Tot/Avg Records: 120924/51.5667
  % Abbrev Recs: 100

Isn't it nice to be able to optimizer bc size without touching the reader? :)


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

 BitcodeWriter.cpp |   13 -
 1 files changed, 12 insertions(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.33 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.34
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.33  Fri May  4 15:52:02 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 15:58:35 2007
@@ -32,7 +32,8 @@
   
   // VALUE_SYMTAB_BLOCK abbrev id's.
   VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
-  VST_ENTRY_7_ABBREV
+  VST_ENTRY_7_ABBREV,
+  VST_BBENTRY_7_ABBREV
   
 };
 
@@ -732,6 +733,15 @@
 if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_7_ABBREV)
   assert(0  Unexpected abbrev ordering!);
   }
+  { // 7-bit fixed width VST_BBENTRY strings.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_BBENTRY));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
+if (Stream.EmitAbbrev(Abbv) != VST_BBENTRY_7_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
   
   
   // FIXME: Set up the abbrev, we know how many values there are!
@@ -759,6 +769,7 @@
 unsigned Code;
 if (isaBasicBlock(SI-getValue())) {
   Code = bitc::VST_CODE_BBENTRY;
+  if (is7Bit) AbbrevToUse = VST_BBENTRY_7_ABBREV;
 } else {
   Code = bitc::VST_CODE_ENTRY;
   AbbrevToUse = is7Bit ? VST_ENTRY_7_ABBREV : VST_ENTRY_8_ABBREV;



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.34 - 1.35
---
Log message:

allow the 8-bit abbrev to be used for either bb or other values


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

 BitcodeWriter.cpp |   12 ++--
 1 files changed, 6 insertions(+), 6 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.34 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.35
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.34  Fri May  4 15:58:35 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 16:31:13 2007
@@ -714,9 +714,9 @@
   if (VST.empty()) return;
   Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
 
-  { // 8-bit fixed width VST_ENTRY strings.
+  { // 8-bit fixed-width VST_ENTRY/VST_BBENTRY strings.
 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
 Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
@@ -762,17 +762,17 @@
   }
 
 
-unsigned AbbrevToUse = 0;
+unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
 
-// VST_ENTRY:   [valueid, namelen, namechar x N]
-// VST_BBENTRY: [bbid, namelen, namechar x N]
+// VST_ENTRY:   [valueid, namechar x N]
+// VST_BBENTRY: [bbid, namechar x N]
 unsigned Code;
 if (isaBasicBlock(SI-getValue())) {
   Code = bitc::VST_CODE_BBENTRY;
   if (is7Bit) AbbrevToUse = VST_BBENTRY_7_ABBREV;
 } else {
   Code = bitc::VST_CODE_ENTRY;
-  AbbrevToUse = is7Bit ? VST_ENTRY_7_ABBREV : VST_ENTRY_8_ABBREV;
+  if (is7Bit) AbbrevToUse = VST_ENTRY_7_ABBREV;
 }
 
 NameVals.push_back(VE.getValueID(SI-getValue()));



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


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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.35 - 1.36
---
Log message:

Implement support for globally associating abbrevs with block IDs, which
relieves us from having to emit the abbrevs into each instance of the block.
This shrinks kc.bit from 3368K to K, but will be a more significant win
once instructions are abbreviated.

The VST went from:

  Block ID #14 (VALUE_SYMTAB):
  Num Instances: 2345
 Total Size: 1.29508e+07b/1.61885e+06B/404713W
   Average Size: 5522.73b/690.342B/172.585W
  % of file: 48.0645
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 7035/3
Tot/Avg Records: 120924/51.5667
  % Abbrev Recs: 100

to:

  Block ID #14 (VALUE_SYMTAB):
  Num Instances: 2345
 Total Size: 1.26713e+07b/1.58391e+06B/395978W
   Average Size: 5403.53b/675.442B/168.86W
  % of file: 47.5198
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 0/0
Tot/Avg Records: 120924/51.5667
  % Abbrev Recs: 100

because we didn't emit the same 3 abbrevs 2345 times :)



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

 BitcodeWriter.cpp |   75 +++---
 1 files changed, 33 insertions(+), 42 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.35 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.36
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.35  Fri May  4 16:31:13 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 19:17:00 2007
@@ -714,36 +714,6 @@
   if (VST.empty()) return;
   Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
 
-  { // 8-bit fixed-width VST_ENTRY/VST_BBENTRY strings.
-BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
-if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_8_ABBREV)
-  assert(0  Unexpected abbrev ordering!);
-  }
-  
-  { // 7-bit fixed width VST_ENTRY strings.
-BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
-if (Stream.EmitAbbrev(Abbv) != VST_ENTRY_7_ABBREV)
-  assert(0  Unexpected abbrev ordering!);
-  }
-  { // 7-bit fixed width VST_BBENTRY strings.
-BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_BBENTRY));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
-Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
-if (Stream.EmitAbbrev(Abbv) != VST_BBENTRY_7_ABBREV)
-  assert(0  Unexpected abbrev ordering!);
-  }
-  
-  
   // FIXME: Set up the abbrev, we know how many values there are!
   // FIXME: We know if the type names can use 7-bit ascii.
   SmallVectorunsigned, 64 NameVals;
@@ -909,19 +879,40 @@
   // We only want to emit block info records for blocks that have multiple
   // instances: CONSTANTS_BLOCK, FUNCTION_BLOCK and VALUE_SYMTAB_BLOCK.  Other
   // blocks can defined their abbrevs inline.
-  Stream.EnterSubblock(bitc::BLOCKINFO_BLOCK_ID, 2);
-
-#if 0
-  // Configure TYPE_SYMTAB_BLOCK's.
-
-  // Add an abbrev for VST_ENTRY where the characters each fit in 7 bits.
-  BitCodeAbbrev *Abbv = new BitCodeAbbrev();
-  Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8); // Value ID
-  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Linkage.
+  Stream.EnterBlockInfoBlock(2);
+  
+  { // 8-bit fixed-width VST_ENTRY/VST_BBENTRY strings.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8));
+if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID, 
+   Abbv) != VST_ENTRY_8_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  
+  { // 7-bit fixed width VST_ENTRY strings.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
+if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID,
+   Abbv) != VST_ENTRY_7_ABBREV)
+  assert(0  Unexpected abbrev ordering!);
+  }
+  { // 7-bit fixed width VST_BBENTRY strings.
+BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_BBENTRY));
+

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

2007-05-04 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.36 - 1.37
---
Log message:

add an abbreviation for the type symtab, this shrinks the TST from 175197 bits
to 103165 bits:

Old:
  Block ID #13 (TYPE_SYMTAB):
  Num Instances: 1
 Total Size: 175197b/21899.6B/5474.91W
   Average Size: 175197b/21899.6B/5474.91W
  % of file: 0.657023
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 0/0
Tot/Avg Records: 255/255
  % Abbrev Recs: 0

New:
  Block ID #13 (TYPE_SYMTAB):
  Num Instances: 1
 Total Size: 103165b/12895.6B/3223.91W
   Average Size: 103165b/12895.6B/3223.91W
  % of file: 0.387937
  Tot/Avg SubBlocks: 0/0
Tot/Avg Abbrevs: 1/1
Tot/Avg Records: 255/255
  % Abbrev Recs: 100




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

 BitcodeWriter.cpp |   24 
 1 files changed, 16 insertions(+), 8 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.36 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.37
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.36  Fri May  4 19:17:00 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Fri May  4 19:47:19 2007
@@ -798,24 +798,32 @@
   
   Stream.EnterSubblock(bitc::TYPE_SYMTAB_BLOCK_ID, 3);
   
-  // FIXME: Set up the abbrev, we know how many types there are!
-  // FIXME: We know if the type names can use 7-bit ascii.
+  // 7-bit fixed width VST_CODE_ENTRY strings.
+  BitCodeAbbrev *Abbv = new BitCodeAbbrev();
+  Abbv-Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed,
+Log2_32_Ceil(VE.getTypes().size()+1)));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
+  Abbv-Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
+  unsigned V7Abbrev = Stream.EmitAbbrev(Abbv);
   
   SmallVectorunsigned, 64 NameVals;
   
   for (TypeSymbolTable::const_iterator TI = TST.begin(), TE = TST.end(); 
TI != TE; ++TI) {
-unsigned AbbrevToUse = 0;
-
-// TST_ENTRY: [typeid, namelen, namechar x N]
+// TST_ENTRY: [typeid, namechar x N]
 NameVals.push_back(VE.getTypeID(TI-second));
 
 const std::string Str = TI-first;
-for (unsigned i = 0, e = Str.size(); i != e; ++i)
-  NameVals.push_back(Str[i]);
+bool is7Bit = true;
+for (unsigned i = 0, e = Str.size(); i != e; ++i) {
+  NameVals.push_back((unsigned char)Str[i]);
+  if (Str[i]  128)
+is7Bit = false;
+}
 
 // Emit the finished record.
-Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
+Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, is7Bit ? V7Abbrev : 0);
 NameVals.clear();
   }
   



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


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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.22 - 1.23
---
Log message:

don't bother encoding # varargs


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

 BitcodeWriter.cpp |1 -
 1 files changed, 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.22 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.23
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.22  Thu May  3 17:18:21 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 17:19:34 2007
@@ -660,7 +660,6 @@
 // Emit type/value pairs for varargs params.
 if (FTy-isVarArg()) {
   unsigned NumVarargs = I.getNumOperands()-1-FTy-getNumParams();
-  Vals.push_back(NumVarargs);
   for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
i != e; ++i) {
 Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));



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


[llvm-commits] CVS: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp ValueEnumerator.cpp

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.21 - 1.22
ValueEnumerator.cpp updated: 1.7 - 1.8
---
Log message:

fix encoding of BB names in the symtab


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

 BitcodeWriter.cpp   |   14 ++
 ValueEnumerator.cpp |2 +-
 2 files changed, 11 insertions(+), 5 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.21 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.22
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.21  Wed May  2 00:46:45 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 17:18:21 2007
@@ -669,7 +669,6 @@
 }
 break;
   }
-
   case Instruction::VAArg:
 Code = bitc::FUNC_CODE_INST_VAARG;
 Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));   // valistty
@@ -697,16 +696,23 @@
SI != SE; ++SI) {
 unsigned AbbrevToUse = 0;
 
-// VST_ENTRY: [valueid, namelen, namechar x N]
-NameVals.push_back(VE.getValueID(SI-getValue()));
+// VST_ENTRY:   [valueid, namelen, namechar x N]
+// VST_BBENTRY: [bbid, namelen, namechar x N]
+unsigned Code;
+if (isaBasicBlock(SI-getValue())) {
+  Code = bitc::VST_CODE_BBENTRY;
+} else {
+  Code = bitc::VST_CODE_ENTRY;
+}
 
+NameVals.push_back(VE.getValueID(SI-getValue()));
 NameVals.push_back(SI-getKeyLength());
 for (const char *P = SI-getKeyData(),
  *E = SI-getKeyData()+SI-getKeyLength(); P != E; ++P)
   NameVals.push_back((unsigned char)*P);
 
 // Emit the finished record.
-Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
+Stream.EmitRecord(Code, NameVals, AbbrevToUse);
 NameVals.clear();
   }
   Stream.ExitBlock();


Index: llvm/lib/Bitcode/Writer/ValueEnumerator.cpp
diff -u llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.7 
llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.8
--- llvm/lib/Bitcode/Writer/ValueEnumerator.cpp:1.7 Thu Apr 26 00:53:54 2007
+++ llvm/lib/Bitcode/Writer/ValueEnumerator.cpp Thu May  3 17:18:21 2007
@@ -180,8 +180,8 @@
 isaInlineAsm(*OI))
   EnumerateValue(*OI);
   }
-ValueMap[BB] = BasicBlocks.size();
 BasicBlocks.push_back(BB);
+ValueMap[BB] = BasicBlocks.size();
   }
   
   FirstInstID = Values.size();



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


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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.24 - 1.25
---
Log message:

trivial scaffolding for param attrs


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

 BitcodeWriter.cpp |   12 
 1 files changed, 12 insertions(+)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.24 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.25
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.24  Thu May  3 17:34:03 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 19:44:52 2007
@@ -80,6 +80,15 @@
   Stream.EmitRecord(Code, Vals, AbbrevToUse);
 }
 
+// Emit information about parameter attributes.
+static void WriteParamAttrTable(const ValueEnumerator VE, 
+BitstreamWriter Stream) {
+  const std::vectorconst ParamAttrsList* Attrs = VE.getParamAttrs();
+  if (Attrs.empty()) return;
+  
+  
+  
+}
 
 /// WriteTypeTable - Write out the type table for a module.
 static void WriteTypeTable(const ValueEnumerator VE, BitstreamWriter Stream) 
{
@@ -799,6 +808,9 @@
   // Analyze the module, enumerating globals, functions, etc.
   ValueEnumerator VE(M);
   
+  // Emit information about parameter attributes.
+  WriteParamAttrTable(VE, Stream);
+  
   // Emit information describing all of the types in the module.
   WriteTypeTable(VE, Stream);
   



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


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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.25 - 1.26
---
Log message:

add writer support for param attrs


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

 BitcodeWriter.cpp |   16 +++-
 1 files changed, 15 insertions(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.25 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.26
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.25  Thu May  3 19:44:52 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 21:59:04 2007
@@ -19,6 +19,7 @@
 #include llvm/DerivedTypes.h
 #include llvm/Instructions.h
 #include llvm/Module.h
+#include llvm/ParameterAttributes.h
 #include llvm/TypeSymbolTable.h
 #include llvm/ValueSymbolTable.h
 #include llvm/Support/MathExtras.h
@@ -86,8 +87,21 @@
   const std::vectorconst ParamAttrsList* Attrs = VE.getParamAttrs();
   if (Attrs.empty()) return;
   
+  Stream.EnterSubblock(bitc::PARAMATTR_BLOCK_ID, 3);
+
+  SmallVectoruint64_t, 64 Record;
+  for (unsigned i = 0, e = Attrs.size(); i != e; ++i) {
+const ParamAttrsList *A = Attrs[i];
+for (unsigned op = 0, e = A-size(); op != e; ++op) {
+  Record.push_back(A-getParamIndex(op));
+  Record.push_back(A-getParamAttrs(op));
+}
+
+Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);
+Record.clear();
+  }
   
-  
+  Stream.ExitBlock();
 }
 
 /// WriteTypeTable - Write out the type table for a module.



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


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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.26 - 1.27
---
Log message:

fix a bug encoding param attrs


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

 BitcodeWriter.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.26 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.27
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.26  Thu May  3 21:59:04 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 22:14:09 2007
@@ -94,7 +94,7 @@
 const ParamAttrsList *A = Attrs[i];
 for (unsigned op = 0, e = A-size(); op != e; ++op) {
   Record.push_back(A-getParamIndex(op));
-  Record.push_back(A-getParamAttrs(op));
+  Record.push_back(A-getParamAttrsAtIndex(op));
 }
 
 Stream.EmitRecord(bitc::PARAMATTR_CODE_ENTRY, Record);



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


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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.27 - 1.28
---
Log message:

encode and read param attrs along with function type.  WE can now roundtrip 
Olden/voronoi loslessly


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

 BitcodeWriter.cpp |4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.27 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.28
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.27  Thu May  3 22:14:09 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 22:41:34 2007
@@ -145,11 +145,11 @@
 
 case Type::FunctionTyID: {
   const FunctionType *FT = castFunctionType(T);
-  // FUNCTION: [isvararg, #pararms, paramty x N]
+  // FUNCTION: [isvararg, attrid, #pararms, paramty x N]
   Code = bitc::TYPE_CODE_FUNCTION;
   TypeVals.push_back(FT-isVarArg());
+  TypeVals.push_back(VE.getParamAttrID(FT-getParamAttrs()));
   TypeVals.push_back(VE.getTypeID(FT-getReturnType()));
-  // FIXME: PARAM ATTR ID!
   TypeVals.push_back(FT-getNumParams());
   for (unsigned i = 0, e = FT-getNumParams(); i != e; ++i)
 TypeVals.push_back(VE.getTypeID(FT-getParamType(i)));



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


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

2007-05-03 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.28 - 1.29
---
Log message:

fix encoding of invoke instructions.  kc++ now round trips


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

 BitcodeWriter.cpp |1 -
 1 files changed, 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.28 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.29
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.28  Thu May  3 22:41:34 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Thu May  3 22:52:24 2007
@@ -609,7 +609,6 @@
 // Emit type/value pairs for varargs params.
 if (FTy-isVarArg()) {
   unsigned NumVarargs = I.getNumOperands()-3-FTy-getNumParams();
-  Vals.push_back(NumVarargs);
   for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
i != e; ++i) {
 Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));



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


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

2007-05-01 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.18 - 1.19
---
Log message:

fix build with non-buggy compilers


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

 BitcodeWriter.cpp |   21 +++--
 1 files changed, 11 insertions(+), 10 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.18 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.19
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.18  Mon Apr 30 21:14:57 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Tue May  1 02:03:37 2007
@@ -571,7 +571,7 @@
 for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
   Vals.push_back(VE.getValueID(I.getOperand(i)));
 break;
-  case Instruction::Invoke:
+  case Instruction::Invoke: {
 Code = bitc::FUNC_CODE_INST_INVOKE;
 // FIXME: param attrs
 Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
@@ -596,6 +596,7 @@
   }
 }
 break;
+  }
   case Instruction::Unwind:
 Code = bitc::FUNC_CODE_INST_UNWIND;
 break;
@@ -658,18 +659,18 @@
 for (unsigned i = 0, e = FTy-getNumParams(); i != e; ++i)
   Vals.push_back(VE.getValueID(I.getOperand(i+1)));  // fixed param.
   
-  // Emit type/value pairs for varargs params.
-  if (FTy-isVarArg()) {
-unsigned NumVarargs = I.getNumOperands()-1-FTy-getNumParams();
-Vals.push_back(NumVarargs);
-for (unsigned i = I.getNumOperands()-NumVarargs, e = 
I.getNumOperands();
- i != e; ++i) {
-  Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));
-  Vals.push_back(VE.getValueID(I.getOperand(i)));
-}
+// Emit type/value pairs for varargs params.
+if (FTy-isVarArg()) {
+  unsigned NumVarargs = I.getNumOperands()-1-FTy-getNumParams();
+  Vals.push_back(NumVarargs);
+  for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
+   i != e; ++i) {
+Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));
+Vals.push_back(VE.getValueID(I.getOperand(i)));
   }
 }
 break;
+  }
 
   case Instruction::VAArg:
 Code = bitc::FUNC_CODE_INST_VAARG;



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


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

2007-05-01 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.19 - 1.20
---
Log message:

use the correct code for binop instrs


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

 BitcodeWriter.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.19 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.20
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.19  Tue May  1 02:03:37 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Tue May  1 23:26:36 2007
@@ -497,7 +497,7 @@
   Vals.push_back(VE.getValueID(I.getOperand(0)));
 } else {
   assert(isaBinaryOperator(I)  Unknown instruction!);
-  Code = bitc::CST_CODE_CE_BINOP;
+  Code = bitc::FUNC_CODE_INST_BINOP;
   Vals.push_back(GetEncodedBinaryOpcode(I.getOpcode()));
   Vals.push_back(VE.getTypeID(I.getType()));
   Vals.push_back(VE.getValueID(I.getOperand(0)));



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


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

2007-05-01 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.20 - 1.21
---
Log message:

add reader logic for terminator instrs.


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

 BitcodeWriter.cpp |2 --
 1 files changed, 2 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.20 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.21
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.20  Tue May  1 23:26:36 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Wed May  2 00:46:45 2007
@@ -507,7 +507,6 @@
 
   case Instruction::GetElementPtr:
 Code = bitc::FUNC_CODE_INST_GEP;
-Vals.push_back(I.getNumOperands());
 for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
   Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));
   Vals.push_back(VE.getValueID(I.getOperand(i)));
@@ -567,7 +566,6 @@
   case Instruction::Switch:
 Code = bitc::FUNC_CODE_INST_SWITCH;
 Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
-Vals.push_back(I.getNumOperands());
 for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
   Vals.push_back(VE.getValueID(I.getOperand(i)));
 break;



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


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

2007-04-30 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.16 - 1.17
---
Log message:

encode all of the instructions.


---
Diffs of the changes:  (+166 -3)

 BitcodeWriter.cpp |  169 +-
 1 files changed, 166 insertions(+), 3 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.16 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.17
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.16  Sun Apr 29 15:56:48 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Mon Apr 30 21:13:26 2007
@@ -485,13 +485,12 @@
 static void WriteInstruction(const Instruction I, ValueEnumerator VE, 
  BitstreamWriter Stream,
  SmallVectorunsigned, 64 Vals) {
-  return; // FIXME: REMOVE
   unsigned Code = 0;
   unsigned AbbrevToUse = 0;
   switch (I.getOpcode()) {
   default:
 if (Instruction::isCast(I.getOpcode())) {
-  Code = bitc::FUNC_CODE_INST_BINOP;
+  Code = bitc::FUNC_CODE_INST_CAST;
   Vals.push_back(GetEncodedCastOpcode(I.getOpcode()));
   Vals.push_back(VE.getTypeID(I.getType()));
   Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
@@ -505,15 +504,179 @@
   Vals.push_back(VE.getValueID(I.getOperand(1)));
 }
 break;
+
+  case Instruction::GetElementPtr:
+Code = bitc::FUNC_CODE_INST_GEP;
+Vals.push_back(I.getNumOperands());
+for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i) {
+  Vals.push_back(VE.getTypeID(I.getOperand(i)-getType()));
+  Vals.push_back(VE.getValueID(I.getOperand(i)));
+}
+break;
+  case Instruction::Select:
+Code = bitc::FUNC_CODE_INST_SELECT;
+Vals.push_back(VE.getTypeID(I.getType()));
+Vals.push_back(VE.getValueID(I.getOperand(0)));
+Vals.push_back(VE.getValueID(I.getOperand(1)));
+Vals.push_back(VE.getValueID(I.getOperand(2)));
+break;
+  case Instruction::ExtractElement:
+Code = bitc::FUNC_CODE_INST_EXTRACTELT;
+Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
+Vals.push_back(VE.getValueID(I.getOperand(0)));
+Vals.push_back(VE.getValueID(I.getOperand(1)));
+break;
+  case Instruction::InsertElement:
+Code = bitc::FUNC_CODE_INST_INSERTELT;
+Vals.push_back(VE.getTypeID(I.getType()));
+Vals.push_back(VE.getValueID(I.getOperand(0)));
+Vals.push_back(VE.getValueID(I.getOperand(1)));
+Vals.push_back(VE.getValueID(I.getOperand(2)));
+break;
+  case Instruction::ShuffleVector:
+Code = bitc::FUNC_CODE_INST_SHUFFLEVEC;
+Vals.push_back(VE.getTypeID(I.getType()));
+Vals.push_back(VE.getValueID(I.getOperand(0)));
+Vals.push_back(VE.getValueID(I.getOperand(1)));
+Vals.push_back(VE.getValueID(I.getOperand(2)));
+break;
+  case Instruction::ICmp:
+  case Instruction::FCmp:
+Code = bitc::FUNC_CODE_INST_CMP;
+Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
+Vals.push_back(VE.getValueID(I.getOperand(0)));
+Vals.push_back(VE.getValueID(I.getOperand(1)));
+Vals.push_back(castCmpInst(I).getPredicate());
+break;
+
+  case Instruction::Ret:
+Code = bitc::FUNC_CODE_INST_RET;
+if (I.getNumOperands()) {
+  Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
+  Vals.push_back(VE.getValueID(I.getOperand(0)));
+}
+break;
+  case Instruction::Br:
+Code = bitc::FUNC_CODE_INST_BR;
+Vals.push_back(VE.getValueID(I.getOperand(0)));
+if (castBranchInst(I).isConditional()) {
+  Vals.push_back(VE.getValueID(I.getOperand(1)));
+  Vals.push_back(VE.getValueID(I.getOperand(2)));
+}
+break;
+  case Instruction::Switch:
+Code = bitc::FUNC_CODE_INST_SWITCH;
+Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
+Vals.push_back(I.getNumOperands());
+for (unsigned i = 0, e = I.getNumOperands(); i != e; ++i)
+  Vals.push_back(VE.getValueID(I.getOperand(i)));
+break;
+  case Instruction::Invoke:
+Code = bitc::FUNC_CODE_INST_INVOKE;
+// FIXME: param attrs
+Vals.push_back(VE.getTypeID(I.getOperand(0)-getType()));
+Vals.push_back(VE.getValueID(I.getOperand(0)));  // callee
+Vals.push_back(VE.getValueID(I.getOperand(1)));  // normal
+Vals.push_back(VE.getValueID(I.getOperand(2)));  // unwind
 
-
+// Emit value #'s for the fixed parameters.
+const PointerType *PTy = castPointerType(I.getOperand(0)-getType());
+const FunctionType *FTy = castFunctionType(PTy-getElementType());
+for (unsigned i = 0, e = FTy-getNumParams(); i != e; ++i)
+  Vals.push_back(VE.getValueID(I.getOperand(i+3)));  // fixed param.
+
+// Emit type/value pairs for varargs params.
+if (FTy-isVarArg()) {
+  unsigned NumVarargs = I.getNumOperands()-3-FTy-getNumParams();
+  Vals.push_back(NumVarargs);
+  for (unsigned i = I.getNumOperands()-NumVarargs, e = I.getNumOperands();
+   i != e; ++i) {
+

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

2007-04-30 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.17 - 1.18
---
Log message:

write the symbol table for function bodies


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

 BitcodeWriter.cpp |   63 --
 1 files changed, 33 insertions(+), 30 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.17 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.18
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.17  Mon Apr 30 21:13:26 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Mon Apr 30 21:14:57 2007
@@ -683,6 +683,36 @@
   Vals.clear();
 }
 
+// Emit names for globals/functions etc.
+static void WriteValueSymbolTable(const ValueSymbolTable VST,
+  const ValueEnumerator VE,
+  BitstreamWriter Stream) {
+  if (VST.empty()) return;
+  Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
+  
+  // FIXME: Set up the abbrev, we know how many values there are!
+  // FIXME: We know if the type names can use 7-bit ascii.
+  SmallVectorunsigned, 64 NameVals;
+  
+  for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
+   SI != SE; ++SI) {
+unsigned AbbrevToUse = 0;
+
+// VST_ENTRY: [valueid, namelen, namechar x N]
+NameVals.push_back(VE.getValueID(SI-getValue()));
+
+NameVals.push_back(SI-getKeyLength());
+for (const char *P = SI-getKeyData(),
+ *E = SI-getKeyData()+SI-getKeyLength(); P != E; ++P)
+  NameVals.push_back((unsigned char)*P);
+
+// Emit the finished record.
+Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
+NameVals.clear();
+  }
+  Stream.ExitBlock();
+}
+
 /// WriteFunction - Emit a function body to the module stream.
 static void WriteFunction(const Function F, ValueEnumerator VE, 
   BitstreamWriter Stream) {
@@ -709,6 +739,9 @@
 for (BasicBlock::const_iterator I = BB-begin(), E = BB-end(); I != E; 
++I)
   WriteInstruction(*I, VE, Stream, Vals);
   
+  // Emit names for all the instructions etc.
+  WriteValueSymbolTable(F.getValueSymbolTable(), VE, Stream);
+
   VE.purgeFunction();
   Stream.ExitBlock();
 }
@@ -746,36 +779,6 @@
   Stream.ExitBlock();
 }
 
-// Emit names for globals/functions etc.
-static void WriteValueSymbolTable(const ValueSymbolTable VST,
-  const ValueEnumerator VE,
-  BitstreamWriter Stream) {
-  if (VST.empty()) return;
-  Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
-  
-  // FIXME: Set up the abbrev, we know how many values there are!
-  // FIXME: We know if the type names can use 7-bit ascii.
-  SmallVectorunsigned, 64 NameVals;
-  
-  for (ValueSymbolTable::const_iterator SI = VST.begin(), SE = VST.end();
-   SI != SE; ++SI) {
-unsigned AbbrevToUse = 0;
-
-// VST_ENTRY: [valueid, namelen, namechar x N]
-NameVals.push_back(VE.getValueID(SI-getValue()));
-
-NameVals.push_back(SI-getKeyLength());
-for (const char *P = SI-getKeyData(),
- *E = SI-getKeyData()+SI-getKeyLength(); P != E; ++P)
-  NameVals.push_back((unsigned char)*P);
-
-// Emit the finished record.
-Stream.EmitRecord(bitc::VST_CODE_ENTRY, NameVals, AbbrevToUse);
-NameVals.clear();
-  }
-  Stream.ExitBlock();
-}
-
 
 /// WriteModule - Emit the specified module to the bitstream.
 static void WriteModule(const Module *M, BitstreamWriter Stream) {



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


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

2007-04-29 Thread Anton Korobeynikov


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.15 - 1.16
---
Log message:

Implement visibility checking during linking. Also implement protected 
visibility support for bitcode.


---
Diffs of the changes:  (+3 -2)

 BitcodeWriter.cpp |5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.15 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.16
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.15  Sun Apr 29 00:49:09 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sun Apr 29 15:56:48 2007
@@ -187,8 +187,9 @@
 static unsigned getEncodedVisibility(const GlobalValue *GV) {
   switch (GV-getVisibility()) {
   default: assert(0  Invalid visibility!);
-  case GlobalValue::DefaultVisibility: return 0;
-  case GlobalValue::HiddenVisibility:  return 1;
+  case GlobalValue::DefaultVisibility:   return 0;
+  case GlobalValue::HiddenVisibility:return 1;
+  case GlobalValue::ProtectedVisibility: return 2;
   }
 }
 



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


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

2007-04-28 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.13 - 1.14
---
Log message:

moved Writer.cpp - BitcodeWriter.cpp to make it more unique in the tree.


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

 BitcodeWriter.cpp |2 +-
 1 files changed, 1 insertion(+), 1 deletion(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.13 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.14
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.13  Thu Apr 26 00:53:54 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sun Apr 29 00:31:57 2007
@@ -1,4 +1,4 @@
-//===--- Bitcode/Writer/Writer.cpp - Bitcode Writer 
---===//
+//===--- Bitcode/Writer/BitcodeWriter.cpp - Bitcode Writer 
===//
 //
 // The LLVM Compiler Infrastructure
 //



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


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

2007-04-28 Thread Chris Lattner


Changes in directory llvm/lib/Bitcode/Writer:

BitcodeWriter.cpp updated: 1.14 - 1.15
---
Log message:

Fix this to use the right block ID


---
Diffs of the changes:  (+1 -3)

 BitcodeWriter.cpp |4 +---
 1 files changed, 1 insertion(+), 3 deletions(-)


Index: llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
diff -u llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.14 
llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.15
--- llvm/lib/Bitcode/Writer/BitcodeWriter.cpp:1.14  Sun Apr 29 00:31:57 2007
+++ llvm/lib/Bitcode/Writer/BitcodeWriter.cpp   Sun Apr 29 00:49:09 2007
@@ -485,8 +485,6 @@
  BitstreamWriter Stream,
  SmallVectorunsigned, 64 Vals) {
   return; // FIXME: REMOVE
-  
-  
   unsigned Code = 0;
   unsigned AbbrevToUse = 0;
   switch (I.getOpcode()) {
@@ -524,7 +522,7 @@
 /// WriteFunction - Emit a function body to the module stream.
 static void WriteFunction(const Function F, ValueEnumerator VE, 
   BitstreamWriter Stream) {
-  Stream.EnterSubblock(bitc::TYPE_SYMTAB_BLOCK_ID, 3);
+  Stream.EnterSubblock(bitc::FUNCTION_BLOCK_ID, 3);
   VE.incorporateFunction(F);
 
   SmallVectorunsigned, 64 Vals;



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