#ifndef LLVM_OBJECT_OFFLOADBINARY_H
#define LLVM_OBJECT_OFFLOADBINARY_H
-#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Object/Binary.h"
#include "llvm/Support/Error.h"
/// offsets from the beginning of the file.
class OffloadBinary : public Binary {
public:
- using string_iterator = StringMap<StringRef>::const_iterator;
+ using string_iterator = MapVector<StringRef, StringRef>::const_iterator;
using string_iterator_range = iterator_range<string_iterator>;
/// The current version of the binary used for backwards compatibility.
ImageKind TheImageKind;
OffloadKind TheOffloadKind;
uint32_t Flags;
- StringMap<StringRef> StringData;
+ MapVector<StringRef, StringRef> StringData;
std::unique_ptr<MemoryBuffer> Image;
};
OffloadBinary(const OffloadBinary &Other) = delete;
/// Map from keys to offsets in the binary.
- StringMap<StringRef> StringData;
+ MapVector<StringRef, StringRef> StringData;
/// Raw pointer to the MemoryBufferRef for convenience.
const char *Buffer;
/// Location of the header within the binary.
// Create a null-terminated string table with all the used strings.
StringTableBuilder StrTab(StringTableBuilder::ELF);
for (auto &KeyAndValue : OffloadingData.StringData) {
- StrTab.add(KeyAndValue.getKey());
- StrTab.add(KeyAndValue.getValue());
+ StrTab.add(KeyAndValue.first);
+ StrTab.add(KeyAndValue.second);
}
StrTab.finalize();
OS << StringRef(reinterpret_cast<char *>(&TheEntry), sizeof(Entry));
for (auto &KeyAndValue : OffloadingData.StringData) {
uint64_t Offset = sizeof(Header) + sizeof(Entry) + StringEntrySize;
- StringEntry Map{Offset + StrTab.getOffset(KeyAndValue.getKey()),
- Offset + StrTab.getOffset(KeyAndValue.getValue())};
+ StringEntry Map{Offset + StrTab.getOffset(KeyAndValue.first),
+ Offset + StrTab.getOffset(KeyAndValue.second)};
OS << StringRef(reinterpret_cast<char *>(&Map), sizeof(StringEntry));
}
StrTab.write(OS);
if (Member.Flags)
Image.Flags = *Member.Flags;
- StringMap<StringRef> &StringData = Image.StringData;
- if (Member.StringEntries) {
- for (const auto &Entry : *Member.StringEntries) {
- StringData[Entry.Key] = Entry.Value;
- }
- }
+ if (Member.StringEntries)
+ for (const auto &Entry : *Member.StringEntries)
+ Image.StringData[Entry.Key] = Entry.Value;
SmallVector<char, 1024> Data;
raw_svector_ostream OS(Data);
Member.StringEntries = std::vector<OffloadYAML::Binary::StringEntry>();
for (const auto &Entry : OB.strings())
Member.StringEntries->emplace_back(OffloadYAML::Binary::StringEntry(
- {Saver.save(Entry.getKey()), Saver.save(Entry.getValue())}));
+ {Saver.save(Entry.first), Saver.save(Entry.second)}));
}
if (!OB.getImage().empty())
}
// Create the image.
- StringMap<StringRef> StringData;
+ MapVector<StringRef, StringRef> StringData;
for (auto &KeyAndValue : Strings)
StringData[KeyAndValue.first] = KeyAndValue.second;
std::unique_ptr<MemoryBuffer> ImageData = MemoryBuffer::getMemBuffer(