[ARM] Add support for MVE pre and post inc loads and stores
[llvm-core.git] / tools / dsymutil / NonRelocatableStringpool.cpp
blob8cb1590cfb64394a4c20d79756705a9a49a15330
1 //===- NonRelocatableStringpool.cpp - A simple stringpool ----------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "NonRelocatableStringpool.h"
11 namespace llvm {
12 namespace dsymutil {
14 DwarfStringPoolEntryRef NonRelocatableStringpool::getEntry(StringRef S) {
15 if (S.empty() && !Strings.empty())
16 return EmptyString;
18 if (Translator)
19 S = Translator(S);
20 auto I = Strings.insert({S, DwarfStringPoolEntry()});
21 auto &Entry = I.first->second;
22 if (I.second || !Entry.isIndexed()) {
23 Entry.Index = NumEntries++;
24 Entry.Offset = CurrentEndOffset;
25 Entry.Symbol = nullptr;
26 CurrentEndOffset += S.size() + 1;
28 return DwarfStringPoolEntryRef(*I.first, true);
31 StringRef NonRelocatableStringpool::internString(StringRef S) {
32 DwarfStringPoolEntry Entry{nullptr, 0, DwarfStringPoolEntry::NotIndexed};
34 if (Translator)
35 S = Translator(S);
37 auto InsertResult = Strings.insert({S, Entry});
38 return InsertResult.first->getKey();
41 std::vector<DwarfStringPoolEntryRef>
42 NonRelocatableStringpool::getEntriesForEmission() const {
43 std::vector<DwarfStringPoolEntryRef> Result;
44 Result.reserve(Strings.size());
45 for (const auto &E : Strings)
46 if (E.getValue().isIndexed())
47 Result.emplace_back(E, true);
48 llvm::sort(Result, [](const DwarfStringPoolEntryRef A,
49 const DwarfStringPoolEntryRef B) {
50 return A.getIndex() < B.getIndex();
51 });
52 return Result;
55 } // namespace dsymutil
56 } // namespace llvm