LLVM 17.0.0git
NonRelocatableStringpool.cpp
Go to the documentation of this file.
1//===-- NonRelocatableStringpool.cpp --------------------------------------===//
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//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/STLExtras.h"
11
12namespace llvm {
13
15 if (S.empty() && !Strings.empty())
16 return EmptyString;
17
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;
27 }
28 return DwarfStringPoolEntryRef(*I.first);
29}
30
33
34 if (Translator)
35 S = Translator(S);
36
37 auto InsertResult = Strings.insert({S, Entry});
38 return InsertResult.first->getKey();
39}
40
41std::vector<DwarfStringPoolEntryRef>
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);
48 llvm::sort(Result, [](const DwarfStringPoolEntryRef A,
50 return A.getIndex() < B.getIndex();
51 });
52 return Result;
53}
54
55} // namespace llvm
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define I(x, y, z)
Definition: MD5.cpp:58
This file contains some templates that are useful if you are working with the STL at all.
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
DwarfStringPoolEntryRef getEntry(StringRef S)
std::vector< DwarfStringPoolEntryRef > getEntriesForEmission() const
Return the list of strings to be emitted.
StringRef internString(StringRef S)
Get permanent storage for S (but do not necessarily emit S in the output section).
unsigned size() const
Definition: StringMap.h:95
bool empty() const
Definition: StringMap.h:94
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition: StringMap.h:286
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
constexpr bool empty() const
empty - Check if the string is empty.
Definition: StringRef.h:134
constexpr size_t size() const
size - Get the string size.
Definition: StringRef.h:137
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
void sort(IteratorTy Start, IteratorTy End)
Definition: STLExtras.h:1744
Data for a string pool entry.
static constexpr unsigned NotIndexed