LLVM
17.0.0git
lib
CodeGen
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
9
#include "
llvm/CodeGen/NonRelocatableStringpool.h
"
10
#include "
llvm/ADT/STLExtras.h
"
11
12
namespace
llvm
{
13
14
DwarfStringPoolEntryRef
NonRelocatableStringpool::getEntry
(
StringRef
S
) {
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
31
StringRef
NonRelocatableStringpool::internString
(
StringRef
S
) {
32
DwarfStringPoolEntry
Entry{
nullptr
, 0,
DwarfStringPoolEntry::NotIndexed
};
33
34
if
(Translator)
35
S
= Translator(
S
);
36
37
auto
InsertResult = Strings.
insert
({
S
, Entry});
38
return
InsertResult.first->getKey();
39
}
40
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
);
48
llvm::sort
(Result, [](
const
DwarfStringPoolEntryRef
A,
49
const
DwarfStringPoolEntryRef
B
) {
50
return
A.getIndex() <
B
.getIndex();
51
});
52
return
Result;
53
}
54
55
}
// namespace llvm
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition:
AddressRanges.h:18
STLExtras.h
llvm::DwarfStringPoolEntryRef
DwarfStringPoolEntryRef: Dwarf string pool entry reference.
Definition:
DwarfStringPoolEntry.h:44
llvm::DwarfStringPoolEntry::NotIndexed
static constexpr unsigned NotIndexed
Definition:
DwarfStringPoolEntry.h:21
E
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
NonRelocatableStringpool.h
llvm::StringMap::insert
bool insert(MapEntryTy *KeyValue)
insert - Insert the specified key/value pair into the map.
Definition:
StringMap.h:275
B
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
llvm::NonRelocatableStringpool::getEntriesForEmission
std::vector< DwarfStringPoolEntryRef > getEntriesForEmission() const
Return the list of strings to be emitted.
Definition:
NonRelocatableStringpool.cpp:42
llvm::NonRelocatableStringpool::internString
StringRef internString(StringRef S)
Get permanent storage for S (but do not necessarily emit S in the output section).
Definition:
NonRelocatableStringpool.cpp:31
llvm::NonRelocatableStringpool::getEntry
DwarfStringPoolEntryRef getEntry(StringRef S)
Definition:
NonRelocatableStringpool.cpp:14
llvm::sort
void sort(IteratorTy Start, IteratorTy End)
Definition:
STLExtras.h:1683
llvm::DwarfStringPoolEntry
Data for a string pool entry.
Definition:
DwarfStringPoolEntry.h:20
I
#define I(x, y, z)
Definition:
MD5.cpp:58
llvm::StringMapImpl::size
unsigned size() const
Definition:
StringMap.h:95
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition:
StringRef.h:50
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition:
README.txt:210
llvm::StringMapImpl::empty
bool empty() const
Definition:
StringMap.h:94
Generated on Sat Jan 28 2023 09:17:03 for LLVM by
1.8.17