| OLD | NEW |
| 1 //===--- Bitcode/NaCl/TestUtils/NaClBitcodeMungeUtils.cpp - Munge Bitcode -===// | 1 //===--- Bitcode/NaCl/TestUtils/NaClBitcodeMungeUtils.cpp - Munge Bitcode -===// |
| 2 // | 2 // |
| 3 // The LLVM Compiler Infrastructure | 3 // The LLVM Compiler Infrastructure |
| 4 // | 4 // |
| 5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
| 7 // | 7 // |
| 8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
| 9 // | 9 // |
| 10 // Munge bitcode records utility class NaClMungedBitcode. | 10 // Munge bitcode records utility class NaClMungedBitcode. |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 std::unique_ptr<NaClBitcodeAbbrevRecord> | 80 std::unique_ptr<NaClBitcodeAbbrevRecord> |
| 81 Rcd(new NaClBitcodeAbbrevRecord()); | 81 Rcd(new NaClBitcodeAbbrevRecord()); |
| 82 Rcd->read(Records, RecordsSize, RecordTerminator, Index); | 82 Rcd->read(Records, RecordsSize, RecordTerminator, Index); |
| 83 RecordList.push_back(std::move(Rcd)); | 83 RecordList.push_back(std::move(Rcd)); |
| 84 } | 84 } |
| 85 } | 85 } |
| 86 | 86 |
| 87 } // end of namespace llvm | 87 } // end of namespace llvm |
| 88 | 88 |
| 89 void NaClBitcodeAbbrevRecord::print(raw_ostream &Out) const { | 89 void NaClBitcodeAbbrevRecord::print(raw_ostream &Out) const { |
| 90 NaClBitcodeRecordData::Print(Out << format("%8u", Abbrev) << ": "); | 90 NaClBitcodeRecordData::Print(Out << Abbrev << ": "); |
| 91 } | 91 } |
| 92 | 92 |
| 93 void NaClBitcodeAbbrevRecord::read(const uint64_t Vals[], size_t ValsSize, | 93 void NaClBitcodeAbbrevRecord::read(const uint64_t Vals[], size_t ValsSize, |
| 94 uint64_t Terminator, size_t &Index) { | 94 uint64_t Terminator, size_t &Index) { |
| 95 Abbrev = readAsType<unsigned>(Vals, ValsSize, Terminator, Index); | 95 Abbrev = readAsType<unsigned>(Vals, ValsSize, Terminator, Index); |
| 96 Code = readAsType<unsigned>(Vals, ValsSize, Terminator, Index); | 96 Code = readAsType<unsigned>(Vals, ValsSize, Terminator, Index); |
| 97 Values.clear(); | 97 Values.clear(); |
| 98 while (Index < ValsSize) { | 98 while (Index < ValsSize) { |
| 99 uint64_t Value = Vals[Index++]; | 99 uint64_t Value = Vals[Index++]; |
| 100 if (Value == Terminator) | 100 if (Value == Terminator) |
| (...skipping 11 matching lines...) Expand all Loading... |
| 112 } | 112 } |
| 113 | 113 |
| 114 void NaClMungedBitcode::print(raw_ostream &Out) const { | 114 void NaClMungedBitcode::print(raw_ostream &Out) const { |
| 115 size_t Indent = 0; | 115 size_t Indent = 0; |
| 116 for (const NaClBitcodeAbbrevRecord &Record : *this) { | 116 for (const NaClBitcodeAbbrevRecord &Record : *this) { |
| 117 if (Indent && Record.Code == naclbitc::BLK_CODE_EXIT) | 117 if (Indent && Record.Code == naclbitc::BLK_CODE_EXIT) |
| 118 --Indent; | 118 --Indent; |
| 119 for (size_t i = 0; i < Indent; ++i) { | 119 for (size_t i = 0; i < Indent; ++i) { |
| 120 Out << " "; | 120 Out << " "; |
| 121 } | 121 } |
| 122 // Blank fill to make abbreviation indices right align, and then |
| 123 // print record. |
| 124 uint32_t Cutoff = 9999999; |
| 125 while (Record.Abbrev <= Cutoff && Cutoff) { |
| 126 Out << " "; |
| 127 Cutoff /= 10; |
| 128 } |
| 122 Out << Record << "\n"; | 129 Out << Record << "\n"; |
| 123 if (Record.Code == naclbitc::BLK_CODE_ENTER) | 130 if (Record.Code == naclbitc::BLK_CODE_ENTER) |
| 124 ++Indent; | 131 ++Indent; |
| 125 } | 132 } |
| 126 } | 133 } |
| 127 | 134 |
| 128 NaClMungedBitcode::~NaClMungedBitcode() { | 135 NaClMungedBitcode::~NaClMungedBitcode() { |
| 129 removeEdits(); | 136 removeEdits(); |
| 130 } | 137 } |
| 131 | 138 |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 case InAfterInsertions: | 304 case InAfterInsertions: |
| 298 if (InsertionsIter != InsertionsIterEnd) | 305 if (InsertionsIter != InsertionsIterEnd) |
| 299 return; | 306 return; |
| 300 Position = InBeforeInsertions; | 307 Position = InBeforeInsertions; |
| 301 ++Index; | 308 ++Index; |
| 302 placeAt(MungedBitcode->BeforeInsertionsMap, Index); | 309 placeAt(MungedBitcode->BeforeInsertionsMap, Index); |
| 303 break; | 310 break; |
| 304 } | 311 } |
| 305 } | 312 } |
| 306 } | 313 } |
| OLD | NEW |