You've already forked linux-packaging-mono
acceptance-tests
data
debian
docs
external
Newtonsoft.Json
api-doc-tools
api-snapshot
aspnetwebstack
bdwgc
binary-reference-assemblies
bockbuild
boringssl
cecil
cecil-legacy
corefx
corert
helix-binaries
ikdasm
ikvm
illinker-test-assets
linker
llvm-project
clang
clang-tools-extra
compiler-rt
eng
libcxx
libcxxabi
libunwind
lld
lldb
llvm
bindings
cmake
docs
examples
include
lib
projects
resources
runtimes
scripts
test
tools
bugpoint
bugpoint-passes
dsymutil
gold
llc
lli
llvm-ar
llvm-as
llvm-as-fuzzer
llvm-bcanalyzer
llvm-c-test
llvm-cat
llvm-cfi-verify
llvm-config
llvm-cov
llvm-cvtres
llvm-cxxdump
llvm-cxxfilt
llvm-demangle-fuzzer
llvm-diff
llvm-dis
llvm-dwarfdump
llvm-dwp
CMakeLists.txt
DWPError.cpp
DWPError.h
DWPStringPool.h
LLVMBuild.txt
llvm-dwp.cpp
llvm-extract
llvm-go
llvm-isel-fuzzer
llvm-jitlistener
llvm-link
llvm-lto
llvm-lto2
llvm-mc
llvm-mc-assemble-fuzzer
llvm-mc-disassemble-fuzzer
llvm-mcmarkup
llvm-modextract
llvm-mt
llvm-nm
llvm-objcopy
llvm-objdump
llvm-opt-fuzzer
llvm-opt-report
llvm-pdbutil
llvm-profdata
llvm-rc
llvm-readobj
llvm-rtdyld
llvm-shlib
llvm-size
llvm-special-case-list-fuzzer
llvm-split
llvm-stress
llvm-strings
llvm-symbolizer
llvm-xray
lto
msbuild
obj2yaml
opt
opt-viewer
sancov
sanstats
verify-uselistorder
xcode-toolchain
yaml2obj
CMakeLists.txt
LLVMBuild.txt
unittests
utils
.arcconfig
.clang-format
.clang-tidy
.gitattributes
.gitignore
CMakeLists.txt
CODE_OWNERS.TXT
CREDITS.TXT
LICENSE.TXT
LLVMBuild.txt
README.txt
RELEASE_TESTERS.TXT
configure
llvm.spec.in
version.txt.in
nuget
openmp
polly
Directory.Build.props
Directory.Build.targets
NuGet.config
azure-pipelines.yml
build.cmd
build.sh
dir.common.props
global.json
llvm.proj
mxe-Win64.cmake.in
nuget-buildtasks
nunit-lite
roslyn-binaries
rx
xunit-binaries
how-to-bump-roslyn-binaries.md
ikvm-native
llvm
m4
man
mcs
mono
msvc
netcore
po
runtime
samples
scripts
support
tools
COPYING.LIB
LICENSE
Makefile.am
Makefile.in
NEWS
README.md
acinclude.m4
aclocal.m4
autogen.sh
code_of_conduct.md
compile
config.guess
config.h.in
config.rpath
config.sub
configure.REMOVED.git-id
configure.ac.REMOVED.git-id
depcomp
install-sh
ltmain.sh.REMOVED.git-id
missing
mkinstalldirs
mono-uninstalled.pc.in
test-driver
winconfig.h
57 lines
1.5 KiB
C++
57 lines
1.5 KiB
C++
#ifndef TOOLS_LLVM_DWP_DWPSTRINGPOOL
|
|
#define TOOLS_LLVM_DWP_DWPSTRINGPOOL
|
|
|
|
#include "llvm/ADT/DenseMap.h"
|
|
#include "llvm/MC/MCSection.h"
|
|
#include "llvm/MC/MCStreamer.h"
|
|
#include <cassert>
|
|
|
|
namespace llvm {
|
|
class DWPStringPool {
|
|
|
|
struct CStrDenseMapInfo {
|
|
static inline const char *getEmptyKey() {
|
|
return reinterpret_cast<const char *>(~static_cast<uintptr_t>(0));
|
|
}
|
|
static inline const char *getTombstoneKey() {
|
|
return reinterpret_cast<const char *>(~static_cast<uintptr_t>(1));
|
|
}
|
|
static unsigned getHashValue(const char *Val) {
|
|
assert(Val != getEmptyKey() && "Cannot hash the empty key!");
|
|
assert(Val != getTombstoneKey() && "Cannot hash the tombstone key!");
|
|
return (unsigned)hash_value(StringRef(Val));
|
|
}
|
|
static bool isEqual(const char *LHS, const char *RHS) {
|
|
if (RHS == getEmptyKey())
|
|
return LHS == getEmptyKey();
|
|
if (RHS == getTombstoneKey())
|
|
return LHS == getTombstoneKey();
|
|
return strcmp(LHS, RHS) == 0;
|
|
}
|
|
};
|
|
|
|
MCStreamer &Out;
|
|
MCSection *Sec;
|
|
DenseMap<const char *, uint32_t, CStrDenseMapInfo> Pool;
|
|
uint32_t Offset = 0;
|
|
|
|
public:
|
|
DWPStringPool(MCStreamer &Out, MCSection *Sec) : Out(Out), Sec(Sec) {}
|
|
|
|
uint32_t getOffset(const char *Str, unsigned Length) {
|
|
assert(strlen(Str) + 1 == Length && "Ensure length hint is correct");
|
|
|
|
auto Pair = Pool.insert(std::make_pair(Str, Offset));
|
|
if (Pair.second) {
|
|
Out.SwitchSection(Sec);
|
|
Out.EmitBytes(StringRef(Str, Length));
|
|
Offset += Length;
|
|
}
|
|
|
|
return Pair.first->second;
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif
|