Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(34)

Unified Diff: include/llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h

Issue 1113023005: Add abilities to generate bitcode buffers from munged bitcode. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Initial version of code. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: include/llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h
diff --git a/include/llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h b/include/llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h
index 6f8a05a8f29aa93f8dec5e1c796b8b8f2c8f148d..b1da3ea102608d4cd5a7d6db01353dc5b59b5a65 100644
--- a/include/llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h
+++ b/include/llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h
@@ -81,6 +81,7 @@
namespace llvm {
+class MemoryBuffer; // Buffer to read bitcode from
class NaClBitcodeAbbrevRecord; // bitcode record.
class NaClMungedBitcodeIter; // iterator over edited bitcode records.
@@ -99,6 +100,10 @@ void readNaClBitcodeRecordList(NaClBitcodeRecordList &RecordList,
size_t RecordsSize,
uint64_t RecordTerminator);
+/// \brief Read in the list of records from bitcode in a memory buffer.
+void readNaClBitcodeRecordList(NaClBitcodeRecordList &RecordList,
+ std::unique_ptr<MemoryBuffer> InputBuffer);
+
/// \brief An edited (i.e. munged) list of bitcode records. Edits are
/// always relative to the initial list of records.
class NaClMungedBitcode {
@@ -111,6 +116,9 @@ public:
/// \brief Iterator over edited records.
typedef NaClMungedBitcodeIter iterator;
+ /// \brief Read in initial list of records from bitcode in a memory buffer.
+ explicit NaClMungedBitcode(std::unique_ptr<MemoryBuffer> InputBuffer);
+
/// \brief Initialize the list of records to be edited.
explicit NaClMungedBitcode(std::unique_ptr<NaClBitcodeRecordList> BaseRecords)
: BaseRecords(std::move(BaseRecords)) {}
@@ -160,6 +168,16 @@ public:
/// \brief Print out the resulting edited list of records.
void print(raw_ostream &Out) const;
+ /// \brief Write out the edited list of bitcode records using
+ /// the given buffer.
+ ///
+ /// \param Buffer The buffer to write into.
+ /// \param AddHeader Add header block when true.
+ /// \param RecoverOnBadAbbrevId When true, try to recover and when
+ /// given a bad abbreviation index.
+ void write(SmallVectorImpl<char> &Buffer, bool AddHeader,
+ bool RecoverOnBadAbbrevId) const;
+
/// \brief The types of editing actions that can be applied.
enum EditAction {
AddBefore, // Insert new record before base record at index.
@@ -190,6 +208,11 @@ public:
/// set of base records.
void removeEdits();
+ /// Returns the unedited list of bitcode records.
+ const NaClBitcodeRecordList &getBaseRecords() const {
+ return *BaseRecords;
+ }
+
private:
typedef std::list<NaClBitcodeAbbrevRecord *> RecordListType;
typedef std::map<size_t, RecordListType *> InsertionsMapType;
@@ -241,7 +264,7 @@ public:
/// \param Code The selector code of the record.
/// \param Values The values associated with the selector code.
NaClBitcodeAbbrevRecord(unsigned Abbrev, unsigned Code,
- NaClRecordVector &Values)
+ const NaClRecordVector &Values)
: NaClBitcodeRecordData(Code, Values), Abbrev(Abbrev) {}
/// \brief Creates a copy of the given abbreviated bitcode record.

Powered by Google App Engine
This is Rietveld 408576698