llvm.org GIT mirror llvm / ff294a4
add a char6 abbrev for bbnames and value names. This represents each character with 6 bits where possible. This shrinks kc++ from 3324164B to 3183584B. The old VST was: Block ID #14 (VALUE_SYMTAB): Total Size: 1.26713e+07b/1.58391e+06B/395978W Average Size: 5403.53b/675.442B/168.86W % of file: 47.6484 The new one is: Block ID #14 (VALUE_SYMTAB): Total Size: 1.15467e+07b/1.44334e+06B/360834W Average Size: 4923.96b/615.495B/153.874W % of file: 45.3368 This is 11% smaller than the VST in the bytecode format. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@36771 91177308-0d34-0410-b5e6-96231b3b80d8 Chris Lattner 12 years ago
1 changed file(s) with 30 addition(s) and 12 deletion(s). Raw diff Collapse all Expand all
3232 // VALUE_SYMTAB_BLOCK abbrev id's.
3333 VST_ENTRY_8_ABBREV = bitc::FIRST_APPLICATION_ABBREV,
3434 VST_ENTRY_7_ABBREV,
35 VST_BBENTRY_7_ABBREV
36
35 VST_ENTRY_6_ABBREV,
36 VST_BBENTRY_6_ABBREV
3737 };
3838
3939
711711 const ValueEnumerator &VE,
712712 BitstreamWriter &Stream) {
713713 if (VST.empty()) return;
714 Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 3);
714 Stream.EnterSubblock(bitc::VALUE_SYMTAB_BLOCK_ID, 4);
715715
716716 // FIXME: Set up the abbrev, we know how many values there are!
717717 // FIXME: We know if the type names can use 7-bit ascii.
724724
725725 // Figure out the encoding to use for the name.
726726 bool is7Bit = true;
727 for (unsigned i = 0, e = Name.getKeyLength(); i != e; ++i)
728 if ((unsigned char)Name.getKeyData()[i] & 128) {
727 bool isChar6 = true;
728 for (const char *C = Name.getKeyData(), *E = C+Name.getKeyLength();
729 C != E; ++C) {
730 if (isChar6)
731 isChar6 = BitCodeAbbrevOp::isChar6(*C);
732 if ((unsigned char)*C & 128) {
729733 is7Bit = false;
730 break;
734 break; // don't bother scanning the rest.
731735 }
732
736 }
733737
734738 unsigned AbbrevToUse = VST_ENTRY_8_ABBREV;
735739
738742 unsigned Code;
739743 if (isa(SI->getValue())) {
740744 Code = bitc::VST_CODE_BBENTRY;
741 if (is7Bit) AbbrevToUse = VST_BBENTRY_7_ABBREV;
745 if (isChar6)
746 AbbrevToUse = VST_BBENTRY_6_ABBREV;
742747 } else {
743748 Code = bitc::VST_CODE_ENTRY;
744 if (is7Bit) AbbrevToUse = VST_ENTRY_7_ABBREV;
749 if (isChar6)
750 AbbrevToUse = VST_ENTRY_6_ABBREV;
751 else if (is7Bit)
752 AbbrevToUse = VST_ENTRY_7_ABBREV;
745753 }
746754
747755 NameVals.push_back(VE.getValueID(SI->getValue()));
909917 Abbv) != VST_ENTRY_7_ABBREV)
910918 assert(0 && "Unexpected abbrev ordering!");
911919 }
912 { // 7-bit fixed width VST_BBENTRY strings.
920 { // 6-bit char6 VST_ENTRY strings.
921 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
922 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_ENTRY));
923 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
924 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
925 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
926 if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID,
927 Abbv) != VST_ENTRY_6_ABBREV)
928 assert(0 && "Unexpected abbrev ordering!");
929 }
930 { // 6-bit char6 VST_BBENTRY strings.
913931 BitCodeAbbrev *Abbv = new BitCodeAbbrev();
914932 Abbv->Add(BitCodeAbbrevOp(bitc::VST_CODE_BBENTRY));
915933 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8));
916934 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Array));
917 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 7));
935 Abbv->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Char6));
918936 if (Stream.EmitBlockInfoAbbrev(bitc::VALUE_SYMTAB_BLOCK_ID,
919 Abbv) != VST_BBENTRY_7_ABBREV)
937 Abbv) != VST_BBENTRY_6_ABBREV)
920938 assert(0 && "Unexpected abbrev ordering!");
921939 }
922940