summaryrefslogtreecommitdiffstats
path: root/contrib/llvm/include/llvm/Support
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2017-09-26 19:56:36 +0000
committerLuiz Souza <luiz@netgate.com>2018-02-21 15:12:19 -0300
commit1dcd2e8d24b295bc73e513acec2ed1514bb66be4 (patch)
tree4bd13a34c251e980e1a6b13584ca1f63b0dfe670 /contrib/llvm/include/llvm/Support
parentf45541ca2a56a1ba1202f94c080b04e96c1fa239 (diff)
downloadFreeBSD-src-1dcd2e8d24b295bc73e513acec2ed1514bb66be4.zip
FreeBSD-src-1dcd2e8d24b295bc73e513acec2ed1514bb66be4.tar.gz
Merge clang, llvm, lld, lldb, compiler-rt and libc++ 5.0.0 release.
MFC r309126 (by emaste): Correct lld llvm-tblgen dependency file name MFC r309169: Get rid of separate Subversion mergeinfo properties for llvm-dwarfdump and llvm-lto. The mergeinfo confuses Subversion enormously, and these directories will just use the mergeinfo for llvm itself. MFC r312765: Pull in r276136 from upstream llvm trunk (by Wei Mi): Use ValueOffsetPair to enhance value reuse during SCEV expansion. In D12090, the ExprValueMap was added to reuse existing value during SCEV expansion. However, const folding and sext/zext distribution can make the reuse still difficult. A simplified case is: suppose we know S1 expands to V1 in ExprValueMap, and S1 = S2 + C_a S3 = S2 + C_b where C_a and C_b are different SCEVConstants. Then we'd like to expand S3 as V1 - C_a + C_b instead of expanding S2 literally. It is helpful when S2 is a complex SCEV expr and S2 has no entry in ExprValueMap, which is usually caused by the fact that S3 is generated from S1 after const folding. In order to do that, we represent ExprValueMap as a mapping from SCEV to ValueOffsetPair. We will save both S1->{V1, 0} and S2->{V1, C_a} into the ExprValueMap when we create SCEV for V1. When S3 is expanded, it will first expand S2 to V1 - C_a because of S2->{V1, C_a} in the map, then expand S3 to V1 - C_a + C_b. Differential Revision: https://reviews.llvm.org/D21313 This should fix assertion failures when building OpenCV >= 3.1. PR: 215649 MFC r312831: Revert r312765 for now, since it causes assertions when building lang/spidermonkey24. Reported by: antoine PR: 215649 MFC r316511 (by jhb): Add an implementation of __ffssi2() derived from __ffsdi2(). Newer versions of GCC include an __ffssi2() symbol in libgcc and the compiler can emit calls to it in generated code. This is true for at least GCC 6.2 when compiling world for mips and mips64. Reviewed by: jmallett, dim Sponsored by: DARPA / AFRL Differential Revision: https://reviews.freebsd.org/D10086 MFC r318601 (by adrian): [libcompiler-rt] add bswapdi2/bswapsi2 This is required for mips gcc 6.3 userland to build/run. Reviewed by: emaste, dim Approved by: emaste Differential Revision: https://reviews.freebsd.org/D10838 MFC r318884 (by emaste): lldb: map TRAP_CAP to a trace trap In the absense of a more specific handler for TRAP_CAP (generated by ENOTCAPABLE or ECAPMODE while in capability mode) treat it as a trace trap. Example usage (testing the bug in PR219173): % proccontrol -m trapcap lldb usr.bin/hexdump/obj/hexdump -- -Cv -s 1 /bin/ls ... (lldb) run Process 12980 launching Process 12980 launched: '.../usr.bin/hexdump/obj/hexdump' (x86_64) Process 12980 stopped * thread #1, stop reason = trace frame #0: 0x0000004b80c65f1a libc.so.7`__sys_lseek + 10 ... In the future we should have LLDB control the trapcap procctl itself (as it does with ASLR), as well as report a specific stop reason. This change eliminates an assertion failure from LLDB for now. MFC r319796: Remove a few unneeded files from libllvm, libclang and liblldb. MFC r319885 (by emaste): lld: ELF: Fix ICF crash on absolute symbol relocations. If two sections contained relocations to absolute symbols with the same value we would crash when trying to access their sections. Add a check that both symbols point to sections before accessing their sections, and treat absolute symbols as equal if their values are equal. Obtained from: LLD commit r292578 MFC r319918: Revert r319796 for now, it can cause undefined references when linking in some circumstances. Reported by: Shawn Webb <shawn.webb@hardenedbsd.org> MFC r319957 (by emaste): lld: Add armelf emulation mode Obtained from: LLD r305375 MFC r321369: Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to 5.0.0 (trunk r308421). Upstream has branched for the 5.0.0 release, which should be in about a month. Please report bugs and regressions, so we can get them into the release. Please note that from 3.5.0 onwards, clang, llvm and lldb require C++11 support to build; see UPDATING for more information. MFC r321420: Add a few more object files to liblldb, which should solve errors when linking the lldb executable in some cases. In particular, when the -ffunction-sections -fdata-sections options are turned off, or ineffective. Reported by: Shawn Webb, Mark Millard MFC r321433: Cleanup stale Options.inc files from the previous libllvm build for clang 4.0.0. Otherwise, these can get included before the two newly generated ones (which are different) for clang 5.0.0. Reported by: Mark Millard MFC r321439 (by bdrewery): Move llvm Options.inc hack from r321433 for NO_CLEAN to lib/clang/libllvm. The files are only ever generated to .OBJDIR, not to WORLDTMP (as a sysroot) and are only ever included from a compilation. So using a beforebuild target here removes the file before the compilation tries to include it. MFC r321664: Pull in r308891 from upstream llvm trunk (by Benjamin Kramer): [CodeGenPrepare] Cut off FindAllMemoryUses if there are too many uses. This avoids excessive compile time. The case I'm looking at is Function.cpp from an old version of LLVM that still had the giant memcmp string matcher in it. Before r308322 this compiled in about 2 minutes, after it, clang takes infinite* time to compile it. With this patch we're at 5 min, which is still bad but this is a pathological case. The cut off at 20 uses was chosen by looking at other cut-offs in LLVM for user scanning. It's probably too high, but does the job and is very unlikely to regress anything. Fixes PR33900. * I'm impatient and aborted after 15 minutes, on the bug report it was killed after 2h. Pull in r308986 from upstream llvm trunk (by Simon Pilgrim): [X86][CGP] Reduce memcmp() expansion to 2 load pairs (PR33914) D35067/rL308322 attempted to support up to 4 load pairs for memcmp inlining which resulted in regressions for some optimized libc memcmp implementations (PR33914). Until we can match these more optimal cases, this patch reduces the memcmp expansion to a maximum of 2 load pairs (which matches what we do for -Os). This patch should be considered for the 5.0.0 release branch as well Differential Revision: https://reviews.llvm.org/D35830 These fix a hang (or extremely long compile time) when building older LLVM ports. Reported by: antoine PR: 219139 MFC r321719: Pull in r309503 from upstream clang trunk (by Richard Smith): PR33902: Invalidate line number cache when adding more text to existing buffer. This led to crashes as the line number cache would report a bogus line number for a line of code, and we'd try to find a nonexistent column within the line when printing diagnostics. This fixes an assertion when building the graphics/champlain port. Reported by: antoine, kwm PR: 219139 MFC r321723: Upgrade our copies of clang, llvm, lld and lldb to r309439 from the upstream release_50 branch. This is just after upstream's 5.0.0-rc1. MFC r322320: Upgrade our copies of clang, llvm and libc++ to r310316 from the upstream release_50 branch. MFC r322326 (by emaste): lldb: Make i386-*-freebsd expression work on JIT path * Enable i386 ABI creation for freebsd * Added an extra argument in ABISysV_i386::PrepareTrivialCall for mmap syscall * Unlike linux, the last argument of mmap is actually 64-bit(off_t). This requires us to push an additional word for the higher order bits. * Prior to this change, ktrace dump will show mmap failures due to invalid argument coming from the 6th mmap argument. Submitted by: Karnajit Wangkhem Differential Revision: https://reviews.llvm.org/D34776 MFC r322360 (by emaste): lldb: Report inferior signals as signals, not exceptions, on FreeBSD This is the FreeBSD equivalent of LLVM r238549. This serves 2 purposes: * LLDB should handle inferior process signals SIGSEGV/SIGILL/SIGBUS/ SIGFPE the way it is suppose to be handled. Prior to this fix these signals will neither create a coredump, nor exit from the debugger or work for signal handling scenario. * eInvalidCrashReason need not report "unknown crash reason" if we have a valid si_signo llvm.org/pr23699 Patch by Karnajit Wangkhem Differential Revision: https://reviews.llvm.org/D35223 Submitted by: Karnajit Wangkhem Obtained from: LLVM r310591 MFC r322474 (by emaste): lld: Add `-z muldefs` option. Obtained from: LLVM r310757 MFC r322740: Upgrade our copies of clang, llvm, lld and libc++ to r311219 from the upstream release_50 branch. MFC r322855: Upgrade our copies of clang, llvm, lldb and compiler-rt to r311606 from the upstream release_50 branch. As of this version, lib/msun's trig test should also work correctly again (see bug 220989 for more information). PR: 220989 MFC r323112: Upgrade our copies of clang, llvm, lldb and compiler-rt to r312293 from the upstream release_50 branch. This corresponds to 5.0.0 rc4. As of this version, the cad/stepcode port should now compile in a more reasonable time on i386 (see bug 221836 for more information). PR: 221836 MFC r323245: Upgrade our copies of clang, llvm, lld, lldb, compiler-rt and libc++ to 5.0.0 release (upstream r312559). Release notes for llvm, clang and lld will be available here soon: <http://releases.llvm.org/5.0.0/docs/ReleaseNotes.html> <http://releases.llvm.org/5.0.0/tools/clang/docs/ReleaseNotes.html> <http://releases.llvm.org/5.0.0/tools/lld/docs/ReleaseNotes.html> Relnotes: yes (cherry picked from commit 12cd91cf4c6b96a24427c0de5374916f2808d263)
Diffstat (limited to 'contrib/llvm/include/llvm/Support')
-rw-r--r--contrib/llvm/include/llvm/Support/AArch64TargetParser.def42
-rw-r--r--contrib/llvm/include/llvm/Support/AMDGPUCodeObjectMetadata.h422
-rw-r--r--contrib/llvm/include/llvm/Support/ARMAttributeParser.h140
-rw-r--r--contrib/llvm/include/llvm/Support/ARMBuildAttributes.h14
-rw-r--r--contrib/llvm/include/llvm/Support/ARMTargetParser.def46
-rw-r--r--contrib/llvm/include/llvm/Support/Allocator.h50
-rw-r--r--contrib/llvm/include/llvm/Support/ArrayRecycler.h3
-rw-r--r--contrib/llvm/include/llvm/Support/Atomic.h5
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryByteStream.h192
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryItemStream.h108
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryStream.h78
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryStreamArray.h358
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryStreamError.h48
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryStreamReader.h270
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryStreamRef.h229
-rw-r--r--contrib/llvm/include/llvm/Support/BinaryStreamWriter.h183
-rw-r--r--contrib/llvm/include/llvm/Support/BlockFrequency.h4
-rw-r--r--contrib/llvm/include/llvm/Support/BranchProbability.h12
-rw-r--r--contrib/llvm/include/llvm/Support/CBindingWrapping.h2
-rw-r--r--contrib/llvm/include/llvm/Support/COFF.h680
-rw-r--r--contrib/llvm/include/llvm/Support/CachePruning.h76
-rw-r--r--contrib/llvm/include/llvm/Support/Casting.h109
-rw-r--r--contrib/llvm/include/llvm/Support/Chrono.h95
-rw-r--r--contrib/llvm/include/llvm/Support/CommandLine.h78
-rw-r--r--contrib/llvm/include/llvm/Support/Compiler.h25
-rw-r--r--contrib/llvm/include/llvm/Support/Compression.h24
-rw-r--r--contrib/llvm/include/llvm/Support/ConvertUTF.h2
-rw-r--r--contrib/llvm/include/llvm/Support/DataExtractor.h63
-rw-r--r--contrib/llvm/include/llvm/Support/Debug.h28
-rw-r--r--contrib/llvm/include/llvm/Support/DebugCounter.h165
-rw-r--r--contrib/llvm/include/llvm/Support/Dwarf.def811
-rw-r--r--contrib/llvm/include/llvm/Support/Dwarf.h446
-rw-r--r--contrib/llvm/include/llvm/Support/DynamicLibrary.h30
-rw-r--r--contrib/llvm/include/llvm/Support/ELF.h1359
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def201
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/AMDGPU.def16
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def138
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/AVR.def40
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/BPF.def8
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def101
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/Lanai.def19
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def117
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def123
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def181
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/RISCV.def50
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def89
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def71
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/WebAssembly.def8
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/i386.def47
-rw-r--r--contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def45
-rw-r--r--contrib/llvm/include/llvm/Support/Endian.h253
-rw-r--r--contrib/llvm/include/llvm/Support/Errno.h12
-rw-r--r--contrib/llvm/include/llvm/Support/Error.h148
-rw-r--r--contrib/llvm/include/llvm/Support/ErrorHandling.h48
-rw-r--r--contrib/llvm/include/llvm/Support/ErrorOr.h18
-rw-r--r--contrib/llvm/include/llvm/Support/FileSystem.h329
-rw-r--r--contrib/llvm/include/llvm/Support/Format.h25
-rw-r--r--contrib/llvm/include/llvm/Support/FormatAdapters.h16
-rw-r--r--contrib/llvm/include/llvm/Support/FormatCommon.h20
-rw-r--r--contrib/llvm/include/llvm/Support/FormatProviders.h22
-rw-r--r--contrib/llvm/include/llvm/Support/FormatVariadic.h4
-rw-r--r--contrib/llvm/include/llvm/Support/GCOV.h89
-rw-r--r--contrib/llvm/include/llvm/Support/GenericDomTree.h671
-rw-r--r--contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h1111
-rw-r--r--contrib/llvm/include/llvm/Support/GraphWriter.h59
-rw-r--r--contrib/llvm/include/llvm/Support/Host.h22
-rw-r--r--contrib/llvm/include/llvm/Support/KnownBits.h200
-rw-r--r--contrib/llvm/include/llvm/Support/LEB128.h79
-rw-r--r--contrib/llvm/include/llvm/Support/LowLevelTypeImpl.h309
-rw-r--r--contrib/llvm/include/llvm/Support/MD5.h59
-rw-r--r--contrib/llvm/include/llvm/Support/MachO.def116
-rw-r--r--contrib/llvm/include/llvm/Support/MachO.h1936
-rw-r--r--contrib/llvm/include/llvm/Support/ManagedStatic.h20
-rw-r--r--contrib/llvm/include/llvm/Support/MathExtras.h141
-rw-r--r--contrib/llvm/include/llvm/Support/MemoryBuffer.h24
-rw-r--r--contrib/llvm/include/llvm/Support/Parallel.h249
-rw-r--r--contrib/llvm/include/llvm/Support/Path.h91
-rw-r--r--contrib/llvm/include/llvm/Support/PointerLikeTypeTraits.h14
-rw-r--r--contrib/llvm/include/llvm/Support/RWMutex.h25
-rw-r--r--contrib/llvm/include/llvm/Support/Recycler.h3
-rw-r--r--contrib/llvm/include/llvm/Support/Regex.h2
-rw-r--r--contrib/llvm/include/llvm/Support/ReverseIteration.h17
-rw-r--r--contrib/llvm/include/llvm/Support/SMLoc.h4
-rw-r--r--contrib/llvm/include/llvm/Support/ScopedPrinter.h7
-rw-r--r--contrib/llvm/include/llvm/Support/Solaris/sys/regset.h (renamed from contrib/llvm/include/llvm/Support/Solaris.h)20
-rw-r--r--contrib/llvm/include/llvm/Support/SourceMgr.h59
-rw-r--r--contrib/llvm/include/llvm/Support/StringPool.h24
-rw-r--r--contrib/llvm/include/llvm/Support/StringSaver.h2
-rw-r--r--contrib/llvm/include/llvm/Support/TargetParser.h11
-rw-r--r--contrib/llvm/include/llvm/Support/TargetRegistry.h166
-rw-r--r--contrib/llvm/include/llvm/Support/ThreadPool.h43
-rw-r--r--contrib/llvm/include/llvm/Support/Threading.h104
-rw-r--r--contrib/llvm/include/llvm/Support/Timer.h4
-rw-r--r--contrib/llvm/include/llvm/Support/TrailingObjects.h7
-rw-r--r--contrib/llvm/include/llvm/Support/UnicodeCharRanges.h7
-rw-r--r--contrib/llvm/include/llvm/Support/UniqueLock.h18
-rw-r--r--contrib/llvm/include/llvm/Support/Wasm.h87
-rw-r--r--contrib/llvm/include/llvm/Support/YAMLParser.h111
-rw-r--r--contrib/llvm/include/llvm/Support/YAMLTraits.h357
-rw-r--r--contrib/llvm/include/llvm/Support/raw_sha1_ostream.h4
-rw-r--r--contrib/llvm/include/llvm/Support/thread.h14
-rw-r--r--contrib/llvm/include/llvm/Support/type_traits.h29
102 files changed, 6294 insertions, 8367 deletions
diff --git a/contrib/llvm/include/llvm/Support/AArch64TargetParser.def b/contrib/llvm/include/llvm/Support/AArch64TargetParser.def
index c4416f0..09f9602 100644
--- a/contrib/llvm/include/llvm/Support/AArch64TargetParser.def
+++ b/contrib/llvm/include/llvm/Support/AArch64TargetParser.def
@@ -20,8 +20,7 @@ AARCH64_ARCH("invalid", AK_INVALID, nullptr, nullptr,
ARMBuildAttrs::CPUArch::v8_A, FK_NONE, AArch64::AEK_NONE)
AARCH64_ARCH("armv8-a", AK_ARMV8A, "8-A", "v8", ARMBuildAttrs::CPUArch::v8_A,
FK_CRYPTO_NEON_FP_ARMV8,
- (AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
- AArch64::AEK_SIMD | AArch64::AEK_LSE))
+ (AArch64::AEK_CRYPTO | AArch64::AEK_FP | AArch64::AEK_SIMD))
AARCH64_ARCH("armv8.1-a", AK_ARMV8_1A, "8.1-A", "v8.1a",
ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
(AArch64::AEK_CRC | AArch64::AEK_CRYPTO | AArch64::AEK_FP |
@@ -44,37 +43,46 @@ AARCH64_ARCH_EXT_NAME("crypto", AArch64::AEK_CRYPTO, "+crypto","-crypto")
AARCH64_ARCH_EXT_NAME("fp", AArch64::AEK_FP, "+fp-armv8", "-fp-armv8")
AARCH64_ARCH_EXT_NAME("simd", AArch64::AEK_SIMD, "+neon", "-neon")
AARCH64_ARCH_EXT_NAME("fp16", AArch64::AEK_FP16, "+fullfp16", "-fullfp16")
-AARCH64_ARCH_EXT_NAME("profile", AArch64::AEK_PROFILE, "+spe", "-spe")
-AARCH64_ARCH_EXT_NAME("ras", AArch64::AEK_RAS, "+ras", "-ras")
+AARCH64_ARCH_EXT_NAME("profile", AArch64::AEK_PROFILE, "+spe", "-spe")
+AARCH64_ARCH_EXT_NAME("ras", AArch64::AEK_RAS, "+ras", "-ras")
+AARCH64_ARCH_EXT_NAME("sve", AArch64::AEK_SVE, "+sve", "-sve")
#undef AARCH64_ARCH_EXT_NAME
#ifndef AARCH64_CPU_NAME
#define AARCH64_CPU_NAME(NAME, ID, DEFAULT_FPU, IS_DEFAULT, DEFAULT_EXT)
#endif
AARCH64_CPU_NAME("cortex-a35", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("cortex-a53", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, true,
- ( AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("cortex-a57", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("cortex-a72", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("cortex-a73", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("cyclone", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_NONE))
AARCH64_CPU_NAME("exynos-m1", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("exynos-m2", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("exynos-m3", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("falkor", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
AARCH64_CPU_NAME("kryo", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
-AARCH64_CPU_NAME("vulcan", AK_ARMV8_1A, FK_CRYPTO_NEON_FP_ARMV8, false,
- (AArch64::AEK_SIMD | AArch64::AEK_CRC | AArch64::AEK_CRYPTO))
+ (AArch64::AEK_CRC))
+AARCH64_CPU_NAME("thunderx2t99", AK_ARMV8_1A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_NONE))
+AARCH64_CPU_NAME("thunderx", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_CRC | AArch64::AEK_PROFILE))
+AARCH64_CPU_NAME("thunderxt88", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_CRC | AArch64::AEK_PROFILE))
+AARCH64_CPU_NAME("thunderxt81", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_CRC | AArch64::AEK_PROFILE))
+AARCH64_CPU_NAME("thunderxt83", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false,
+ (AArch64::AEK_CRC | AArch64::AEK_PROFILE))
// Invalid CPU
AARCH64_CPU_NAME("invalid", AK_INVALID, FK_INVALID, true, AArch64::AEK_INVALID)
#undef AARCH64_CPU_NAME
diff --git a/contrib/llvm/include/llvm/Support/AMDGPUCodeObjectMetadata.h b/contrib/llvm/include/llvm/Support/AMDGPUCodeObjectMetadata.h
new file mode 100644
index 0000000..d274c5e
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/AMDGPUCodeObjectMetadata.h
@@ -0,0 +1,422 @@
+//===--- AMDGPUCodeObjectMetadata.h -----------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+/// \file
+/// \brief AMDGPU Code Object Metadata definitions and in-memory
+/// representations.
+///
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H
+#define LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H
+
+#include <cstdint>
+#include <string>
+#include <system_error>
+#include <vector>
+
+namespace llvm {
+namespace AMDGPU {
+
+//===----------------------------------------------------------------------===//
+// Code Object Metadata.
+//===----------------------------------------------------------------------===//
+namespace CodeObject {
+
+/// \brief Code object metadata major version.
+constexpr uint32_t MetadataVersionMajor = 1;
+/// \brief Code object metadata minor version.
+constexpr uint32_t MetadataVersionMinor = 0;
+
+/// \brief Code object metadata beginning assembler directive.
+constexpr char MetadataAssemblerDirectiveBegin[] =
+ ".amdgpu_code_object_metadata";
+/// \brief Code object metadata ending assembler directive.
+constexpr char MetadataAssemblerDirectiveEnd[] =
+ ".end_amdgpu_code_object_metadata";
+
+/// \brief Access qualifiers.
+enum class AccessQualifier : uint8_t {
+ Default = 0,
+ ReadOnly = 1,
+ WriteOnly = 2,
+ ReadWrite = 3,
+ Unknown = 0xff
+};
+
+/// \brief Address space qualifiers.
+enum class AddressSpaceQualifier : uint8_t {
+ Private = 0,
+ Global = 1,
+ Constant = 2,
+ Local = 3,
+ Generic = 4,
+ Region = 5,
+ Unknown = 0xff
+};
+
+/// \brief Value kinds.
+enum class ValueKind : uint8_t {
+ ByValue = 0,
+ GlobalBuffer = 1,
+ DynamicSharedPointer = 2,
+ Sampler = 3,
+ Image = 4,
+ Pipe = 5,
+ Queue = 6,
+ HiddenGlobalOffsetX = 7,
+ HiddenGlobalOffsetY = 8,
+ HiddenGlobalOffsetZ = 9,
+ HiddenNone = 10,
+ HiddenPrintfBuffer = 11,
+ HiddenDefaultQueue = 12,
+ HiddenCompletionAction = 13,
+ Unknown = 0xff
+};
+
+/// \brief Value types.
+enum class ValueType : uint8_t {
+ Struct = 0,
+ I8 = 1,
+ U8 = 2,
+ I16 = 3,
+ U16 = 4,
+ F16 = 5,
+ I32 = 6,
+ U32 = 7,
+ F32 = 8,
+ I64 = 9,
+ U64 = 10,
+ F64 = 11,
+ Unknown = 0xff
+};
+
+//===----------------------------------------------------------------------===//
+// Kernel Metadata.
+//===----------------------------------------------------------------------===//
+namespace Kernel {
+
+//===----------------------------------------------------------------------===//
+// Kernel Attributes Metadata.
+//===----------------------------------------------------------------------===//
+namespace Attrs {
+
+namespace Key {
+/// \brief Key for Kernel::Attr::Metadata::mReqdWorkGroupSize.
+constexpr char ReqdWorkGroupSize[] = "ReqdWorkGroupSize";
+/// \brief Key for Kernel::Attr::Metadata::mWorkGroupSizeHint.
+constexpr char WorkGroupSizeHint[] = "WorkGroupSizeHint";
+/// \brief Key for Kernel::Attr::Metadata::mVecTypeHint.
+constexpr char VecTypeHint[] = "VecTypeHint";
+} // end namespace Key
+
+/// \brief In-memory representation of kernel attributes metadata.
+struct Metadata final {
+ /// \brief 'reqd_work_group_size' attribute. Optional.
+ std::vector<uint32_t> mReqdWorkGroupSize = std::vector<uint32_t>();
+ /// \brief 'work_group_size_hint' attribute. Optional.
+ std::vector<uint32_t> mWorkGroupSizeHint = std::vector<uint32_t>();
+ /// \brief 'vec_type_hint' attribute. Optional.
+ std::string mVecTypeHint = std::string();
+
+ /// \brief Default constructor.
+ Metadata() = default;
+
+ /// \returns True if kernel attributes metadata is empty, false otherwise.
+ bool empty() const {
+ return mReqdWorkGroupSize.empty() &&
+ mWorkGroupSizeHint.empty() &&
+ mVecTypeHint.empty();
+ }
+
+ /// \returns True if kernel attributes metadata is not empty, false otherwise.
+ bool notEmpty() const {
+ return !empty();
+ }
+};
+
+} // end namespace Attrs
+
+//===----------------------------------------------------------------------===//
+// Kernel Argument Metadata.
+//===----------------------------------------------------------------------===//
+namespace Arg {
+
+namespace Key {
+/// \brief Key for Kernel::Arg::Metadata::mSize.
+constexpr char Size[] = "Size";
+/// \brief Key for Kernel::Arg::Metadata::mAlign.
+constexpr char Align[] = "Align";
+/// \brief Key for Kernel::Arg::Metadata::mValueKind.
+constexpr char ValueKind[] = "ValueKind";
+/// \brief Key for Kernel::Arg::Metadata::mValueType.
+constexpr char ValueType[] = "ValueType";
+/// \brief Key for Kernel::Arg::Metadata::mPointeeAlign.
+constexpr char PointeeAlign[] = "PointeeAlign";
+/// \brief Key for Kernel::Arg::Metadata::mAccQual.
+constexpr char AccQual[] = "AccQual";
+/// \brief Key for Kernel::Arg::Metadata::mAddrSpaceQual.
+constexpr char AddrSpaceQual[] = "AddrSpaceQual";
+/// \brief Key for Kernel::Arg::Metadata::mIsConst.
+constexpr char IsConst[] = "IsConst";
+/// \brief Key for Kernel::Arg::Metadata::mIsPipe.
+constexpr char IsPipe[] = "IsPipe";
+/// \brief Key for Kernel::Arg::Metadata::mIsRestrict.
+constexpr char IsRestrict[] = "IsRestrict";
+/// \brief Key for Kernel::Arg::Metadata::mIsVolatile.
+constexpr char IsVolatile[] = "IsVolatile";
+/// \brief Key for Kernel::Arg::Metadata::mName.
+constexpr char Name[] = "Name";
+/// \brief Key for Kernel::Arg::Metadata::mTypeName.
+constexpr char TypeName[] = "TypeName";
+} // end namespace Key
+
+/// \brief In-memory representation of kernel argument metadata.
+struct Metadata final {
+ /// \brief Size in bytes. Required.
+ uint32_t mSize = 0;
+ /// \brief Alignment in bytes. Required.
+ uint32_t mAlign = 0;
+ /// \brief Value kind. Required.
+ ValueKind mValueKind = ValueKind::Unknown;
+ /// \brief Value type. Required.
+ ValueType mValueType = ValueType::Unknown;
+ /// \brief Pointee alignment in bytes. Optional.
+ uint32_t mPointeeAlign = 0;
+ /// \brief Access qualifier. Optional.
+ AccessQualifier mAccQual = AccessQualifier::Unknown;
+ /// \brief Address space qualifier. Optional.
+ AddressSpaceQualifier mAddrSpaceQual = AddressSpaceQualifier::Unknown;
+ /// \brief True if 'const' qualifier is specified. Optional.
+ bool mIsConst = false;
+ /// \brief True if 'pipe' qualifier is specified. Optional.
+ bool mIsPipe = false;
+ /// \brief True if 'restrict' qualifier is specified. Optional.
+ bool mIsRestrict = false;
+ /// \brief True if 'volatile' qualifier is specified. Optional.
+ bool mIsVolatile = false;
+ /// \brief Name. Optional.
+ std::string mName = std::string();
+ /// \brief Type name. Optional.
+ std::string mTypeName = std::string();
+
+ /// \brief Default constructor.
+ Metadata() = default;
+};
+
+} // end namespace Arg
+
+//===----------------------------------------------------------------------===//
+// Kernel Code Properties Metadata.
+//===----------------------------------------------------------------------===//
+namespace CodeProps {
+
+namespace Key {
+/// \brief Key for Kernel::CodeProps::Metadata::mKernargSegmentSize.
+constexpr char KernargSegmentSize[] = "KernargSegmentSize";
+/// \brief Key for Kernel::CodeProps::Metadata::mWorkgroupGroupSegmentSize.
+constexpr char WorkgroupGroupSegmentSize[] = "WorkgroupGroupSegmentSize";
+/// \brief Key for Kernel::CodeProps::Metadata::mWorkitemPrivateSegmentSize.
+constexpr char WorkitemPrivateSegmentSize[] = "WorkitemPrivateSegmentSize";
+/// \brief Key for Kernel::CodeProps::Metadata::mWavefrontNumSGPRs.
+constexpr char WavefrontNumSGPRs[] = "WavefrontNumSGPRs";
+/// \brief Key for Kernel::CodeProps::Metadata::mWorkitemNumVGPRs.
+constexpr char WorkitemNumVGPRs[] = "WorkitemNumVGPRs";
+/// \brief Key for Kernel::CodeProps::Metadata::mKernargSegmentAlign.
+constexpr char KernargSegmentAlign[] = "KernargSegmentAlign";
+/// \brief Key for Kernel::CodeProps::Metadata::mGroupSegmentAlign.
+constexpr char GroupSegmentAlign[] = "GroupSegmentAlign";
+/// \brief Key for Kernel::CodeProps::Metadata::mPrivateSegmentAlign.
+constexpr char PrivateSegmentAlign[] = "PrivateSegmentAlign";
+/// \brief Key for Kernel::CodeProps::Metadata::mWavefrontSize.
+constexpr char WavefrontSize[] = "WavefrontSize";
+} // end namespace Key
+
+/// \brief In-memory representation of kernel code properties metadata.
+struct Metadata final {
+ /// \brief Size in bytes of the kernarg segment memory. Kernarg segment memory
+ /// holds the values of the arguments to the kernel. Optional.
+ uint64_t mKernargSegmentSize = 0;
+ /// \brief Size in bytes of the group segment memory required by a workgroup.
+ /// This value does not include any dynamically allocated group segment memory
+ /// that may be added when the kernel is dispatched. Optional.
+ uint32_t mWorkgroupGroupSegmentSize = 0;
+ /// \brief Size in bytes of the private segment memory required by a workitem.
+ /// Private segment memory includes arg, spill and private segments. Optional.
+ uint32_t mWorkitemPrivateSegmentSize = 0;
+ /// \brief Total number of SGPRs used by a wavefront. Optional.
+ uint16_t mWavefrontNumSGPRs = 0;
+ /// \brief Total number of VGPRs used by a workitem. Optional.
+ uint16_t mWorkitemNumVGPRs = 0;
+ /// \brief Maximum byte alignment of variables used by the kernel in the
+ /// kernarg memory segment. Expressed as a power of two. Optional.
+ uint8_t mKernargSegmentAlign = 0;
+ /// \brief Maximum byte alignment of variables used by the kernel in the
+ /// group memory segment. Expressed as a power of two. Optional.
+ uint8_t mGroupSegmentAlign = 0;
+ /// \brief Maximum byte alignment of variables used by the kernel in the
+ /// private memory segment. Expressed as a power of two. Optional.
+ uint8_t mPrivateSegmentAlign = 0;
+ /// \brief Wavefront size. Expressed as a power of two. Optional.
+ uint8_t mWavefrontSize = 0;
+
+ /// \brief Default constructor.
+ Metadata() = default;
+
+ /// \returns True if kernel code properties metadata is empty, false
+ /// otherwise.
+ bool empty() const {
+ return !notEmpty();
+ }
+
+ /// \returns True if kernel code properties metadata is not empty, false
+ /// otherwise.
+ bool notEmpty() const {
+ return mKernargSegmentSize || mWorkgroupGroupSegmentSize ||
+ mWorkitemPrivateSegmentSize || mWavefrontNumSGPRs ||
+ mWorkitemNumVGPRs || mKernargSegmentAlign || mGroupSegmentAlign ||
+ mPrivateSegmentAlign || mWavefrontSize;
+ }
+};
+
+} // end namespace CodeProps
+
+//===----------------------------------------------------------------------===//
+// Kernel Debug Properties Metadata.
+//===----------------------------------------------------------------------===//
+namespace DebugProps {
+
+namespace Key {
+/// \brief Key for Kernel::DebugProps::Metadata::mDebuggerABIVersion.
+constexpr char DebuggerABIVersion[] = "DebuggerABIVersion";
+/// \brief Key for Kernel::DebugProps::Metadata::mReservedNumVGPRs.
+constexpr char ReservedNumVGPRs[] = "ReservedNumVGPRs";
+/// \brief Key for Kernel::DebugProps::Metadata::mReservedFirstVGPR.
+constexpr char ReservedFirstVGPR[] = "ReservedFirstVGPR";
+/// \brief Key for Kernel::DebugProps::Metadata::mPrivateSegmentBufferSGPR.
+constexpr char PrivateSegmentBufferSGPR[] = "PrivateSegmentBufferSGPR";
+/// \brief Key for
+/// Kernel::DebugProps::Metadata::mWavefrontPrivateSegmentOffsetSGPR.
+constexpr char WavefrontPrivateSegmentOffsetSGPR[] =
+ "WavefrontPrivateSegmentOffsetSGPR";
+} // end namespace Key
+
+/// \brief In-memory representation of kernel debug properties metadata.
+struct Metadata final {
+ /// \brief Debugger ABI version. Optional.
+ std::vector<uint32_t> mDebuggerABIVersion = std::vector<uint32_t>();
+ /// \brief Consecutive number of VGPRs reserved for debugger use. Must be 0 if
+ /// mDebuggerABIVersion is not set. Optional.
+ uint16_t mReservedNumVGPRs = 0;
+ /// \brief First fixed VGPR reserved. Must be uint16_t(-1) if
+ /// mDebuggerABIVersion is not set or mReservedFirstVGPR is 0. Optional.
+ uint16_t mReservedFirstVGPR = uint16_t(-1);
+ /// \brief Fixed SGPR of the first of 4 SGPRs used to hold the scratch V# used
+ /// for the entire kernel execution. Must be uint16_t(-1) if
+ /// mDebuggerABIVersion is not set or SGPR not used or not known. Optional.
+ uint16_t mPrivateSegmentBufferSGPR = uint16_t(-1);
+ /// \brief Fixed SGPR used to hold the wave scratch offset for the entire
+ /// kernel execution. Must be uint16_t(-1) if mDebuggerABIVersion is not set
+ /// or SGPR is not used or not known. Optional.
+ uint16_t mWavefrontPrivateSegmentOffsetSGPR = uint16_t(-1);
+
+ /// \brief Default constructor.
+ Metadata() = default;
+
+ /// \returns True if kernel debug properties metadata is empty, false
+ /// otherwise.
+ bool empty() const {
+ return !notEmpty();
+ }
+
+ /// \returns True if kernel debug properties metadata is not empty, false
+ /// otherwise.
+ bool notEmpty() const {
+ return !mDebuggerABIVersion.empty();
+ }
+};
+
+} // end namespace DebugProps
+
+namespace Key {
+/// \brief Key for Kernel::Metadata::mName.
+constexpr char Name[] = "Name";
+/// \brief Key for Kernel::Metadata::mLanguage.
+constexpr char Language[] = "Language";
+/// \brief Key for Kernel::Metadata::mLanguageVersion.
+constexpr char LanguageVersion[] = "LanguageVersion";
+/// \brief Key for Kernel::Metadata::mAttrs.
+constexpr char Attrs[] = "Attrs";
+/// \brief Key for Kernel::Metadata::mArgs.
+constexpr char Args[] = "Args";
+/// \brief Key for Kernel::Metadata::mCodeProps.
+constexpr char CodeProps[] = "CodeProps";
+/// \brief Key for Kernel::Metadata::mDebugProps.
+constexpr char DebugProps[] = "DebugProps";
+} // end namespace Key
+
+/// \brief In-memory representation of kernel metadata.
+struct Metadata final {
+ /// \brief Name. Required.
+ std::string mName = std::string();
+ /// \brief Language. Optional.
+ std::string mLanguage = std::string();
+ /// \brief Language version. Optional.
+ std::vector<uint32_t> mLanguageVersion = std::vector<uint32_t>();
+ /// \brief Attributes metadata. Optional.
+ Attrs::Metadata mAttrs = Attrs::Metadata();
+ /// \brief Arguments metadata. Optional.
+ std::vector<Arg::Metadata> mArgs = std::vector<Arg::Metadata>();
+ /// \brief Code properties metadata. Optional.
+ CodeProps::Metadata mCodeProps = CodeProps::Metadata();
+ /// \brief Debug properties metadata. Optional.
+ DebugProps::Metadata mDebugProps = DebugProps::Metadata();
+
+ /// \brief Default constructor.
+ Metadata() = default;
+};
+
+} // end namespace Kernel
+
+namespace Key {
+/// \brief Key for CodeObject::Metadata::mVersion.
+constexpr char Version[] = "Version";
+/// \brief Key for CodeObject::Metadata::mPrintf.
+constexpr char Printf[] = "Printf";
+/// \brief Key for CodeObject::Metadata::mKernels.
+constexpr char Kernels[] = "Kernels";
+} // end namespace Key
+
+/// \brief In-memory representation of code object metadata.
+struct Metadata final {
+ /// \brief Code object metadata version. Required.
+ std::vector<uint32_t> mVersion = std::vector<uint32_t>();
+ /// \brief Printf metadata. Optional.
+ std::vector<std::string> mPrintf = std::vector<std::string>();
+ /// \brief Kernels metadata. Optional.
+ std::vector<Kernel::Metadata> mKernels = std::vector<Kernel::Metadata>();
+
+ /// \brief Default constructor.
+ Metadata() = default;
+
+ /// \brief Converts \p YamlString to \p CodeObjectMetadata.
+ static std::error_code fromYamlString(std::string YamlString,
+ Metadata &CodeObjectMetadata);
+
+ /// \brief Converts \p CodeObjectMetadata to \p YamlString.
+ static std::error_code toYamlString(Metadata CodeObjectMetadata,
+ std::string &YamlString);
+};
+
+} // end namespace CodeObject
+} // end namespace AMDGPU
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_AMDGPUCODEOBJECTMETADATA_H
diff --git a/contrib/llvm/include/llvm/Support/ARMAttributeParser.h b/contrib/llvm/include/llvm/Support/ARMAttributeParser.h
new file mode 100644
index 0000000..919f397
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/ARMAttributeParser.h
@@ -0,0 +1,140 @@
+//===--- ARMAttributeParser.h - ARM Attribute Information Printer ---------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_ARMATTRIBUTEPARSER_H
+#define LLVM_SUPPORT_ARMATTRIBUTEPARSER_H
+
+#include "ARMBuildAttributes.h"
+#include "ScopedPrinter.h"
+
+#include <map>
+
+namespace llvm {
+class StringRef;
+
+class ARMAttributeParser {
+ ScopedPrinter *SW;
+
+ std::map<unsigned, unsigned> Attributes;
+
+ struct DisplayHandler {
+ ARMBuildAttrs::AttrType Attribute;
+ void (ARMAttributeParser::*Routine)(ARMBuildAttrs::AttrType,
+ const uint8_t *, uint32_t &);
+ };
+ static const DisplayHandler DisplayRoutines[];
+
+ uint64_t ParseInteger(const uint8_t *Data, uint32_t &Offset);
+ StringRef ParseString(const uint8_t *Data, uint32_t &Offset);
+
+ void IntegerAttribute(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void StringAttribute(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+
+ void PrintAttribute(unsigned Tag, unsigned Value, StringRef ValueDesc);
+
+ void CPU_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void CPU_arch_profile(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ARM_ISA_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void THUMB_ISA_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void FP_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void WMMX_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void Advanced_SIMD_arch(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void PCS_config(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_PCS_R9_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_PCS_RW_data(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_PCS_RO_data(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_PCS_GOT_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_PCS_wchar_t(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_rounding(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_denormal(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_exceptions(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_user_exceptions(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_number_model(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_align_needed(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_align_preserved(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_enum_size(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_HardFP_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_VFP_args(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_WMMX_args(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_optimization_goals(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_optimization_goals(ARMBuildAttrs::AttrType Tag,
+ const uint8_t *Data, uint32_t &Offset);
+ void compatibility(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void CPU_unaligned_access(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void FP_HP_extension(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void ABI_FP_16bit_format(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void MPextension_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void DIV_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void DSP_extension(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void T2EE_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void Virtualization_use(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+ void nodefaults(ARMBuildAttrs::AttrType Tag, const uint8_t *Data,
+ uint32_t &Offset);
+
+ void ParseAttributeList(const uint8_t *Data, uint32_t &Offset,
+ uint32_t Length);
+ void ParseIndexList(const uint8_t *Data, uint32_t &Offset,
+ SmallVectorImpl<uint8_t> &IndexList);
+ void ParseSubsection(const uint8_t *Data, uint32_t Length);
+public:
+ ARMAttributeParser(ScopedPrinter *SW) : SW(SW) {}
+
+ ARMAttributeParser() : SW(nullptr) { }
+
+ void Parse(ArrayRef<uint8_t> Section, bool isLittle);
+
+ bool hasAttribute(unsigned Tag) const {
+ return Attributes.count(Tag);
+ }
+
+ unsigned getAttributeValue(unsigned Tag) const {
+ return Attributes.find(Tag)->second;
+ }
+};
+
+}
+
+#endif
+
diff --git a/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h b/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h
index e254457..6c83e44 100644
--- a/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h
+++ b/contrib/llvm/include/llvm/Support/ARMBuildAttributes.h
@@ -176,14 +176,25 @@ enum {
WCharWidth2Bytes = 2, // sizeof(wchar_t) == 2
WCharWidth4Bytes = 4, // sizeof(wchar_t) == 4
+ // Tag_ABI_align_needed, (=24), uleb128
+ Align8Byte = 1,
+ Align4Byte = 2,
+ AlignReserved = 3,
+
+ // Tag_ABI_align_needed, (=25), uleb128
+ AlignNotPreserved = 0,
+ AlignPreserve8Byte = 1,
+ AlignPreserveAll = 2,
+
// Tag_ABI_FP_denormal, (=20), uleb128
PositiveZero = 0,
IEEEDenormals = 1,
PreserveFPSign = 2, // sign when flushed-to-zero is preserved
// Tag_ABI_FP_number_model, (=23), uleb128
+ AllowIEEENormal = 1,
AllowRTABI = 2, // numbers, infinities, and one quiet NaN (see [RTABI])
- AllowIEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
+ AllowIEEE754 = 3, // this code to use all the IEEE 754-defined FP encodings
// Tag_ABI_enum_size, (=26), uleb128
EnumProhibited = 0, // The user prohibited the use of enums when building
@@ -208,6 +219,7 @@ enum {
// Tag_FP_16bit_format, (=38), uleb128
FP16FormatIEEE = 1,
+ FP16VFP3 = 2,
// Tag_MPextension_use, (=42), uleb128
AllowMP = 1, // Allow use of MP extensions
diff --git a/contrib/llvm/include/llvm/Support/ARMTargetParser.def b/contrib/llvm/include/llvm/Support/ARMTargetParser.def
index 58cb638..65cb271 100644
--- a/contrib/llvm/include/llvm/Support/ARMTargetParser.def
+++ b/contrib/llvm/include/llvm/Support/ARMTargetParser.def
@@ -76,32 +76,35 @@ ARM_ARCH("armv6-m", AK_ARMV6M, "6-M", "v6m", ARMBuildAttrs::CPUArch::v6_M,
FK_NONE, ARM::AEK_NONE)
ARM_ARCH("armv7-a", AK_ARMV7A, "7-A", "v7", ARMBuildAttrs::CPUArch::v7,
FK_NEON, ARM::AEK_DSP)
+ARM_ARCH("armv7ve", AK_ARMV7VE, "7VE", "v7ve", ARMBuildAttrs::CPUArch::v7,
+ FK_NEON, (ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT |
+ ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP))
ARM_ARCH("armv7-r", AK_ARMV7R, "7-R", "v7r", ARMBuildAttrs::CPUArch::v7,
- FK_NONE, (ARM::AEK_HWDIV | ARM::AEK_DSP))
+ FK_NONE, (ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP))
ARM_ARCH("armv7-m", AK_ARMV7M, "7-M", "v7m", ARMBuildAttrs::CPUArch::v7,
- FK_NONE, ARM::AEK_HWDIV)
+ FK_NONE, ARM::AEK_HWDIVTHUMB)
ARM_ARCH("armv7e-m", AK_ARMV7EM, "7E-M", "v7em", ARMBuildAttrs::CPUArch::v7E_M,
- FK_NONE, (ARM::AEK_HWDIV | ARM::AEK_DSP))
+ FK_NONE, (ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP))
ARM_ARCH("armv8-a", AK_ARMV8A, "8-A", "v8", ARMBuildAttrs::CPUArch::v8_A,
FK_CRYPTO_NEON_FP_ARMV8,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV | ARM::AEK_DSP | ARM::AEK_CRC))
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC))
ARM_ARCH("armv8.1-a", AK_ARMV8_1A, "8.1-A", "v8.1a",
ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV | ARM::AEK_DSP | ARM::AEK_CRC))
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC))
ARM_ARCH("armv8.2-a", AK_ARMV8_2A, "8.2-A", "v8.2a",
ARMBuildAttrs::CPUArch::v8_A, FK_CRYPTO_NEON_FP_ARMV8,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS))
+ ARM::AEK_HWDIVTHUMB | ARM::AEK_DSP | ARM::AEK_CRC | ARM::AEK_RAS))
ARM_ARCH("armv8-r", AK_ARMV8R, "8-R", "v8r", ARMBuildAttrs::CPUArch::v8_R,
FK_NEON_FP_ARMV8,
- (ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | ARM::AEK_HWDIV |
+ (ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB |
ARM::AEK_DSP | ARM::AEK_CRC))
ARM_ARCH("armv8-m.base", AK_ARMV8MBaseline, "8-M.Baseline", "v8m.base",
- ARMBuildAttrs::CPUArch::v8_M_Base, FK_NONE, ARM::AEK_HWDIV)
+ ARMBuildAttrs::CPUArch::v8_M_Base, FK_NONE, ARM::AEK_HWDIVTHUMB)
ARM_ARCH("armv8-m.main", AK_ARMV8MMainline, "8-M.Mainline", "v8m.main",
- ARMBuildAttrs::CPUArch::v8_M_Main, FK_FPV5_D16, ARM::AEK_HWDIV)
+ ARMBuildAttrs::CPUArch::v8_M_Main, FK_FPV5_D16, ARM::AEK_HWDIVTHUMB)
// Non-standard Arch names.
ARM_ARCH("iwmmxt", AK_IWMMXT, "iwmmxt", "", ARMBuildAttrs::CPUArch::v5TE,
FK_NONE, ARM::AEK_NONE)
@@ -125,7 +128,7 @@ ARM_ARCH_EXT_NAME("crc", ARM::AEK_CRC, "+crc", "-crc")
ARM_ARCH_EXT_NAME("crypto", ARM::AEK_CRYPTO, "+crypto","-crypto")
ARM_ARCH_EXT_NAME("dsp", ARM::AEK_DSP, "+dsp", "-dsp")
ARM_ARCH_EXT_NAME("fp", ARM::AEK_FP, nullptr, nullptr)
-ARM_ARCH_EXT_NAME("idiv", (ARM::AEK_HWDIVARM | ARM::AEK_HWDIV), nullptr, nullptr)
+ARM_ARCH_EXT_NAME("idiv", (ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB), nullptr, nullptr)
ARM_ARCH_EXT_NAME("mp", ARM::AEK_MP, nullptr, nullptr)
ARM_ARCH_EXT_NAME("simd", ARM::AEK_SIMD, nullptr, nullptr)
ARM_ARCH_EXT_NAME("sec", ARM::AEK_SEC, nullptr, nullptr)
@@ -144,9 +147,9 @@ ARM_ARCH_EXT_NAME("xscale", ARM::AEK_XSCALE, nullptr, nullptr)
#endif
ARM_HW_DIV_NAME("invalid", ARM::AEK_INVALID)
ARM_HW_DIV_NAME("none", ARM::AEK_NONE)
-ARM_HW_DIV_NAME("thumb", ARM::AEK_HWDIV)
+ARM_HW_DIV_NAME("thumb", ARM::AEK_HWDIVTHUMB)
ARM_HW_DIV_NAME("arm", ARM::AEK_HWDIVARM)
-ARM_HW_DIV_NAME("arm,thumb", (ARM::AEK_HWDIVARM | ARM::AEK_HWDIV))
+ARM_HW_DIV_NAME("arm,thumb", (ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB))
#undef ARM_HW_DIV_NAME
#ifndef ARM_CPU_NAME
@@ -202,20 +205,20 @@ ARM_CPU_NAME("cortex-a5", AK_ARMV7A, FK_NEON_VFPV4, false,
(ARM::AEK_SEC | ARM::AEK_MP))
ARM_CPU_NAME("cortex-a7", AK_ARMV7A, FK_NEON_VFPV4, false,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV))
-ARM_CPU_NAME("cortex-a8", AK_ARMV7A, FK_NEON, true, ARM::AEK_SEC)
+ ARM::AEK_HWDIVTHUMB))
+ARM_CPU_NAME("cortex-a8", AK_ARMV7A, FK_NEON, false, ARM::AEK_SEC)
ARM_CPU_NAME("cortex-a9", AK_ARMV7A, FK_NEON_FP16, false, (ARM::AEK_SEC | ARM::AEK_MP))
ARM_CPU_NAME("cortex-a12", AK_ARMV7A, FK_NEON_VFPV4, false,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV))
+ ARM::AEK_HWDIVTHUMB))
ARM_CPU_NAME("cortex-a15", AK_ARMV7A, FK_NEON_VFPV4, false,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV))
+ ARM::AEK_HWDIVTHUMB))
ARM_CPU_NAME("cortex-a17", AK_ARMV7A, FK_NEON_VFPV4, false,
(ARM::AEK_SEC | ARM::AEK_MP | ARM::AEK_VIRT | ARM::AEK_HWDIVARM |
- ARM::AEK_HWDIV))
+ ARM::AEK_HWDIVTHUMB))
ARM_CPU_NAME("krait", AK_ARMV7A, FK_NEON_VFPV4, false,
- (ARM::AEK_HWDIVARM | ARM::AEK_HWDIV))
+ (ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB))
ARM_CPU_NAME("cortex-r4", AK_ARMV7R, FK_NONE, true, ARM::AEK_NONE)
ARM_CPU_NAME("cortex-r4f", AK_ARMV7R, FK_VFPV3_D16, false, ARM::AEK_NONE)
ARM_CPU_NAME("cortex-r5", AK_ARMV7R, FK_VFPV3_D16, false,
@@ -229,9 +232,11 @@ ARM_CPU_NAME("sc300", AK_ARMV7M, FK_NONE, false, ARM::AEK_NONE)
ARM_CPU_NAME("cortex-m3", AK_ARMV7M, FK_NONE, true, ARM::AEK_NONE)
ARM_CPU_NAME("cortex-m4", AK_ARMV7EM, FK_FPV4_SP_D16, true, ARM::AEK_NONE)
ARM_CPU_NAME("cortex-m7", AK_ARMV7EM, FK_FPV5_D16, false, ARM::AEK_NONE)
+ARM_CPU_NAME("cortex-m23", AK_ARMV8MBaseline, FK_NONE, false, ARM::AEK_NONE)
+ARM_CPU_NAME("cortex-m33", AK_ARMV8MMainline, FK_FPV5_SP_D16, false, ARM::AEK_DSP)
ARM_CPU_NAME("cortex-a32", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("cortex-a35", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
-ARM_CPU_NAME("cortex-a53", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, true, ARM::AEK_CRC)
+ARM_CPU_NAME("cortex-a53", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("cortex-a57", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("cortex-a72", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("cortex-a73", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
@@ -239,11 +244,12 @@ ARM_CPU_NAME("cyclone", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("exynos-m1", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("exynos-m2", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
ARM_CPU_NAME("exynos-m3", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
+ARM_CPU_NAME("kryo", AK_ARMV8A, FK_CRYPTO_NEON_FP_ARMV8, false, ARM::AEK_CRC)
// Non-standard Arch names.
ARM_CPU_NAME("iwmmxt", AK_IWMMXT, FK_NONE, true, ARM::AEK_NONE)
ARM_CPU_NAME("xscale", AK_XSCALE, FK_NONE, true, ARM::AEK_NONE)
ARM_CPU_NAME("swift", AK_ARMV7S, FK_NEON_VFPV4, true,
- (ARM::AEK_HWDIVARM | ARM::AEK_HWDIV))
+ (ARM::AEK_HWDIVARM | ARM::AEK_HWDIVTHUMB))
// Invalid CPU
ARM_CPU_NAME("invalid", AK_INVALID, FK_INVALID, true, ARM::AEK_INVALID)
#undef ARM_CPU_NAME
diff --git a/contrib/llvm/include/llvm/Support/Allocator.h b/contrib/llvm/include/llvm/Support/Allocator.h
index c71759a..a5e662f 100644
--- a/contrib/llvm/include/llvm/Support/Allocator.h
+++ b/contrib/llvm/include/llvm/Support/Allocator.h
@@ -1,4 +1,4 @@
-//===--- Allocator.h - Simple memory allocation abstraction -----*- C++ -*-===//
+//===- Allocator.h - Simple memory allocation abstraction -------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -144,19 +144,18 @@ public:
"that objects larger than a slab go into their own memory "
"allocation.");
- BumpPtrAllocatorImpl()
- : CurPtr(nullptr), End(nullptr), BytesAllocated(0), Allocator() {}
+ BumpPtrAllocatorImpl() = default;
+
template <typename T>
BumpPtrAllocatorImpl(T &&Allocator)
- : CurPtr(nullptr), End(nullptr), BytesAllocated(0),
- Allocator(std::forward<T &&>(Allocator)) {}
+ : Allocator(std::forward<T &&>(Allocator)) {}
// Manually implement a move constructor as we must clear the old allocator's
// slabs as a matter of correctness.
BumpPtrAllocatorImpl(BumpPtrAllocatorImpl &&Old)
: CurPtr(Old.CurPtr), End(Old.End), Slabs(std::move(Old.Slabs)),
CustomSizedSlabs(std::move(Old.CustomSizedSlabs)),
- BytesAllocated(Old.BytesAllocated),
+ BytesAllocated(Old.BytesAllocated), RedZoneSize(Old.RedZoneSize),
Allocator(std::move(Old.Allocator)) {
Old.CurPtr = Old.End = nullptr;
Old.BytesAllocated = 0;
@@ -176,6 +175,7 @@ public:
CurPtr = RHS.CurPtr;
End = RHS.End;
BytesAllocated = RHS.BytesAllocated;
+ RedZoneSize = RHS.RedZoneSize;
Slabs = std::move(RHS.Slabs);
CustomSizedSlabs = std::move(RHS.CustomSizedSlabs);
Allocator = std::move(RHS.Allocator);
@@ -218,10 +218,16 @@ public:
size_t Adjustment = alignmentAdjustment(CurPtr, Alignment);
assert(Adjustment + Size >= Size && "Adjustment + Size must not overflow");
+ size_t SizeToAllocate = Size;
+#if LLVM_ADDRESS_SANITIZER_BUILD
+ // Add trailing bytes as a "red zone" under ASan.
+ SizeToAllocate += RedZoneSize;
+#endif
+
// Check if we have enough space.
- if (Adjustment + Size <= size_t(End - CurPtr)) {
+ if (Adjustment + SizeToAllocate <= size_t(End - CurPtr)) {
char *AlignedPtr = CurPtr + Adjustment;
- CurPtr = AlignedPtr + Size;
+ CurPtr = AlignedPtr + SizeToAllocate;
// Update the allocation point of this memory block in MemorySanitizer.
// Without this, MemorySanitizer messages for values originated from here
// will point to the allocation of the entire slab.
@@ -232,7 +238,7 @@ public:
}
// If Size is really big, allocate a separate slab for it.
- size_t PaddedSize = Size + Alignment - 1;
+ size_t PaddedSize = SizeToAllocate + Alignment - 1;
if (PaddedSize > SizeThreshold) {
void *NewSlab = Allocator.Allocate(PaddedSize, 0);
// We own the new slab and don't want anyone reading anyting other than
@@ -251,10 +257,10 @@ public:
// Otherwise, start a new slab and try again.
StartNewSlab();
uintptr_t AlignedAddr = alignAddr(CurPtr, Alignment);
- assert(AlignedAddr + Size <= (uintptr_t)End &&
+ assert(AlignedAddr + SizeToAllocate <= (uintptr_t)End &&
"Unable to allocate memory!");
char *AlignedPtr = (char*)AlignedAddr;
- CurPtr = AlignedPtr + Size;
+ CurPtr = AlignedPtr + SizeToAllocate;
__msan_allocated_memory(AlignedPtr, Size);
__asan_unpoison_memory_region(AlignedPtr, Size);
return AlignedPtr;
@@ -283,6 +289,10 @@ public:
size_t getBytesAllocated() const { return BytesAllocated; }
+ void setRedZoneSize(size_t NewSize) {
+ RedZoneSize = NewSize;
+ }
+
void PrintStats() const {
detail::printBumpPtrAllocatorStats(Slabs.size(), BytesAllocated,
getTotalMemory());
@@ -292,10 +302,10 @@ private:
/// \brief The current pointer into the current slab.
///
/// This points to the next free byte in the slab.
- char *CurPtr;
+ char *CurPtr = nullptr;
/// \brief The end of the current slab.
- char *End;
+ char *End = nullptr;
/// \brief The slabs allocated so far.
SmallVector<void *, 4> Slabs;
@@ -306,7 +316,11 @@ private:
/// \brief How many bytes we've allocated.
///
/// Used so that we can compute how much space was wasted.
- size_t BytesAllocated;
+ size_t BytesAllocated = 0;
+
+ /// \brief The number of bytes to put between allocations when running under
+ /// a sanitizer.
+ size_t RedZoneSize = 1;
/// \brief The allocator instance we use to get slabs of memory.
AllocatorT Allocator;
@@ -357,7 +371,7 @@ private:
};
/// \brief The standard BumpPtrAllocator which just uses the default template
-/// paramaters.
+/// parameters.
typedef BumpPtrAllocatorImpl<> BumpPtrAllocator;
/// \brief A BumpPtrAllocator that allows only elements of a specific type to be
@@ -369,7 +383,11 @@ template <typename T> class SpecificBumpPtrAllocator {
BumpPtrAllocator Allocator;
public:
- SpecificBumpPtrAllocator() = default;
+ SpecificBumpPtrAllocator() {
+ // Because SpecificBumpPtrAllocator walks the memory to call destructors,
+ // it can't have red zones between allocations.
+ Allocator.setRedZoneSize(0);
+ }
SpecificBumpPtrAllocator(SpecificBumpPtrAllocator &&Old)
: Allocator(std::move(Old.Allocator)) {}
~SpecificBumpPtrAllocator() { DestroyAll(); }
diff --git a/contrib/llvm/include/llvm/Support/ArrayRecycler.h b/contrib/llvm/include/llvm/Support/ArrayRecycler.h
index 4698f12..68696be 100644
--- a/contrib/llvm/include/llvm/Support/ArrayRecycler.h
+++ b/contrib/llvm/include/llvm/Support/ArrayRecycler.h
@@ -47,7 +47,9 @@ template <class T, size_t Align = alignof(T)> class ArrayRecycler {
FreeList *Entry = Bucket[Idx];
if (!Entry)
return nullptr;
+ __asan_unpoison_memory_region(Entry, Capacity::get(Idx).getSize());
Bucket[Idx] = Entry->Next;
+ __msan_allocated_memory(Entry, Capacity::get(Idx).getSize());
return reinterpret_cast<T*>(Entry);
}
@@ -59,6 +61,7 @@ template <class T, size_t Align = alignof(T)> class ArrayRecycler {
Bucket.resize(size_t(Idx) + 1);
Entry->Next = Bucket[Idx];
Bucket[Idx] = Entry;
+ __asan_poison_memory_region(Ptr, Capacity::get(Idx).getSize());
}
public:
diff --git a/contrib/llvm/include/llvm/Support/Atomic.h b/contrib/llvm/include/llvm/Support/Atomic.h
index d03714b..552313f 100644
--- a/contrib/llvm/include/llvm/Support/Atomic.h
+++ b/contrib/llvm/include/llvm/Support/Atomic.h
@@ -20,6 +20,11 @@
#include "llvm/Support/DataTypes.h"
+// Windows will at times define MemoryFence.
+#ifdef MemoryFence
+#undef MemoryFence
+#endif
+
namespace llvm {
namespace sys {
void MemoryFence();
diff --git a/contrib/llvm/include/llvm/Support/BinaryByteStream.h b/contrib/llvm/include/llvm/Support/BinaryByteStream.h
new file mode 100644
index 0000000..694be28
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryByteStream.h
@@ -0,0 +1,192 @@
+//===- BinaryByteStream.h ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//===----------------------------------------------------------------------===//
+// A BinaryStream which stores data in a single continguous memory buffer.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYBYTESTREAM_H
+#define LLVM_SUPPORT_BINARYBYTESTREAM_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/BinaryStream.h"
+#include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/FileOutputBuffer.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include <algorithm>
+#include <cstdint>
+#include <cstring>
+#include <memory>
+
+namespace llvm {
+
+/// \brief An implementation of BinaryStream which holds its entire data set
+/// in a single contiguous buffer. BinaryByteStream guarantees that no read
+/// operation will ever incur a copy. Note that BinaryByteStream does not
+/// own the underlying buffer.
+class BinaryByteStream : public BinaryStream {
+public:
+ BinaryByteStream() = default;
+ BinaryByteStream(ArrayRef<uint8_t> Data, llvm::support::endianness Endian)
+ : Endian(Endian), Data(Data) {}
+ BinaryByteStream(StringRef Data, llvm::support::endianness Endian)
+ : Endian(Endian), Data(Data.bytes_begin(), Data.bytes_end()) {}
+
+ llvm::support::endianness getEndian() const override { return Endian; }
+
+ Error readBytes(uint32_t Offset, uint32_t Size,
+ ArrayRef<uint8_t> &Buffer) override {
+ if (auto EC = checkOffset(Offset, Size))
+ return EC;
+ Buffer = Data.slice(Offset, Size);
+ return Error::success();
+ }
+
+ Error readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) override {
+ if (auto EC = checkOffset(Offset, 1))
+ return EC;
+ Buffer = Data.slice(Offset);
+ return Error::success();
+ }
+
+ uint32_t getLength() override { return Data.size(); }
+
+ ArrayRef<uint8_t> data() const { return Data; }
+
+ StringRef str() const {
+ const char *CharData = reinterpret_cast<const char *>(Data.data());
+ return StringRef(CharData, Data.size());
+ }
+
+protected:
+ llvm::support::endianness Endian;
+ ArrayRef<uint8_t> Data;
+};
+
+/// \brief An implementation of BinaryStream whose data is backed by an llvm
+/// MemoryBuffer object. MemoryBufferByteStream owns the MemoryBuffer in
+/// question. As with BinaryByteStream, reading from a MemoryBufferByteStream
+/// will never cause a copy.
+class MemoryBufferByteStream : public BinaryByteStream {
+public:
+ MemoryBufferByteStream(std::unique_ptr<MemoryBuffer> Buffer,
+ llvm::support::endianness Endian)
+ : BinaryByteStream(Buffer->getBuffer(), Endian),
+ MemBuffer(std::move(Buffer)) {}
+
+ std::unique_ptr<MemoryBuffer> MemBuffer;
+};
+
+/// \brief An implementation of BinaryStream which holds its entire data set
+/// in a single contiguous buffer. As with BinaryByteStream, the mutable
+/// version also guarantees that no read operation will ever incur a copy,
+/// and similarly it does not own the underlying buffer.
+class MutableBinaryByteStream : public WritableBinaryStream {
+public:
+ MutableBinaryByteStream() = default;
+ MutableBinaryByteStream(MutableArrayRef<uint8_t> Data,
+ llvm::support::endianness Endian)
+ : Data(Data), ImmutableStream(Data, Endian) {}
+
+ llvm::support::endianness getEndian() const override {
+ return ImmutableStream.getEndian();
+ }
+
+ Error readBytes(uint32_t Offset, uint32_t Size,
+ ArrayRef<uint8_t> &Buffer) override {
+ return ImmutableStream.readBytes(Offset, Size, Buffer);
+ }
+
+ Error readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) override {
+ return ImmutableStream.readLongestContiguousChunk(Offset, Buffer);
+ }
+
+ uint32_t getLength() override { return ImmutableStream.getLength(); }
+
+ Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Buffer) override {
+ if (Buffer.empty())
+ return Error::success();
+
+ if (auto EC = checkOffset(Offset, Buffer.size()))
+ return EC;
+
+ uint8_t *DataPtr = const_cast<uint8_t *>(Data.data());
+ ::memcpy(DataPtr + Offset, Buffer.data(), Buffer.size());
+ return Error::success();
+ }
+
+ Error commit() override { return Error::success(); }
+
+ MutableArrayRef<uint8_t> data() const { return Data; }
+
+private:
+ MutableArrayRef<uint8_t> Data;
+ BinaryByteStream ImmutableStream;
+};
+
+/// \brief An implementation of WritableBinaryStream backed by an llvm
+/// FileOutputBuffer.
+class FileBufferByteStream : public WritableBinaryStream {
+private:
+ class StreamImpl : public MutableBinaryByteStream {
+ public:
+ StreamImpl(std::unique_ptr<FileOutputBuffer> Buffer,
+ llvm::support::endianness Endian)
+ : MutableBinaryByteStream(
+ MutableArrayRef<uint8_t>(Buffer->getBufferStart(),
+ Buffer->getBufferEnd()),
+ Endian),
+ FileBuffer(std::move(Buffer)) {}
+
+ Error commit() override {
+ if (FileBuffer->commit())
+ return make_error<BinaryStreamError>(
+ stream_error_code::filesystem_error);
+ return Error::success();
+ }
+
+ private:
+ std::unique_ptr<FileOutputBuffer> FileBuffer;
+ };
+
+public:
+ FileBufferByteStream(std::unique_ptr<FileOutputBuffer> Buffer,
+ llvm::support::endianness Endian)
+ : Impl(std::move(Buffer), Endian) {}
+
+ llvm::support::endianness getEndian() const override {
+ return Impl.getEndian();
+ }
+
+ Error readBytes(uint32_t Offset, uint32_t Size,
+ ArrayRef<uint8_t> &Buffer) override {
+ return Impl.readBytes(Offset, Size, Buffer);
+ }
+
+ Error readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) override {
+ return Impl.readLongestContiguousChunk(Offset, Buffer);
+ }
+
+ uint32_t getLength() override { return Impl.getLength(); }
+
+ Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) override {
+ return Impl.writeBytes(Offset, Data);
+ }
+
+ Error commit() override { return Impl.commit(); }
+
+private:
+ StreamImpl Impl;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_BYTESTREAM_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryItemStream.h b/contrib/llvm/include/llvm/Support/BinaryItemStream.h
new file mode 100644
index 0000000..fe7e6ca
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryItemStream.h
@@ -0,0 +1,108 @@
+//===- BinaryItemStream.h ---------------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYITEMSTREAM_H
+#define LLVM_SUPPORT_BINARYITEMSTREAM_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/BinaryStream.h"
+#include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/Error.h"
+#include <cstddef>
+#include <cstdint>
+
+namespace llvm {
+
+template <typename T> struct BinaryItemTraits {
+ static size_t length(const T &Item) = delete;
+ static ArrayRef<uint8_t> bytes(const T &Item) = delete;
+};
+
+/// BinaryItemStream represents a sequence of objects stored in some kind of
+/// external container but for which it is useful to view as a stream of
+/// contiguous bytes. An example of this might be if you have a collection of
+/// records and you serialize each one into a buffer, and store these serialized
+/// records in a container. The pointers themselves are not laid out
+/// contiguously in memory, but we may wish to read from or write to these
+/// records as if they were.
+template <typename T, typename Traits = BinaryItemTraits<T>>
+class BinaryItemStream : public BinaryStream {
+public:
+ explicit BinaryItemStream(llvm::support::endianness Endian)
+ : Endian(Endian) {}
+
+ llvm::support::endianness getEndian() const override { return Endian; }
+
+ Error readBytes(uint32_t Offset, uint32_t Size,
+ ArrayRef<uint8_t> &Buffer) override {
+ auto ExpectedIndex = translateOffsetIndex(Offset);
+ if (!ExpectedIndex)
+ return ExpectedIndex.takeError();
+ const auto &Item = Items[*ExpectedIndex];
+ if (auto EC = checkOffset(Offset, Size))
+ return EC;
+ if (Size > Traits::length(Item))
+ return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
+ Buffer = Traits::bytes(Item).take_front(Size);
+ return Error::success();
+ }
+
+ Error readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) override {
+ auto ExpectedIndex = translateOffsetIndex(Offset);
+ if (!ExpectedIndex)
+ return ExpectedIndex.takeError();
+ Buffer = Traits::bytes(Items[*ExpectedIndex]);
+ return Error::success();
+ }
+
+ void setItems(ArrayRef<T> ItemArray) {
+ Items = ItemArray;
+ computeItemOffsets();
+ }
+
+ uint32_t getLength() override {
+ return ItemEndOffsets.empty() ? 0 : ItemEndOffsets.back();
+ }
+
+private:
+ void computeItemOffsets() {
+ ItemEndOffsets.clear();
+ ItemEndOffsets.reserve(Items.size());
+ uint32_t CurrentOffset = 0;
+ for (const auto &Item : Items) {
+ uint32_t Len = Traits::length(Item);
+ assert(Len > 0 && "no empty items");
+ CurrentOffset += Len;
+ ItemEndOffsets.push_back(CurrentOffset);
+ }
+ }
+
+ Expected<uint32_t> translateOffsetIndex(uint32_t Offset) {
+ // Make sure the offset is somewhere in our items array.
+ if (Offset >= getLength())
+ return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
+ ++Offset;
+ auto Iter =
+ std::lower_bound(ItemEndOffsets.begin(), ItemEndOffsets.end(), Offset);
+ size_t Idx = std::distance(ItemEndOffsets.begin(), Iter);
+ assert(Idx < Items.size() && "binary search for offset failed");
+ return Idx;
+ }
+
+ llvm::support::endianness Endian;
+ ArrayRef<T> Items;
+
+ // Sorted vector of offsets to accelerate lookup.
+ std::vector<uint32_t> ItemEndOffsets;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYITEMSTREAM_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryStream.h b/contrib/llvm/include/llvm/Support/BinaryStream.h
new file mode 100644
index 0000000..a227117
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryStream.h
@@ -0,0 +1,78 @@
+//===- BinaryStream.h - Base interface for a stream of data -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYSTREAM_H
+#define LLVM_SUPPORT_BINARYSTREAM_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include <cstdint>
+
+namespace llvm {
+
+/// \brief An interface for accessing data in a stream-like format, but which
+/// discourages copying. Instead of specifying a buffer in which to copy
+/// data on a read, the API returns an ArrayRef to data owned by the stream's
+/// implementation. Since implementations may not necessarily store data in a
+/// single contiguous buffer (or even in memory at all), in such cases a it may
+/// be necessary for an implementation to cache such a buffer so that it can
+/// return it.
+class BinaryStream {
+public:
+ virtual ~BinaryStream() = default;
+
+ virtual llvm::support::endianness getEndian() const = 0;
+
+ /// \brief Given an offset into the stream and a number of bytes, attempt to
+ /// read the bytes and set the output ArrayRef to point to data owned by the
+ /// stream.
+ virtual Error readBytes(uint32_t Offset, uint32_t Size,
+ ArrayRef<uint8_t> &Buffer) = 0;
+
+ /// \brief Given an offset into the stream, read as much as possible without
+ /// copying any data.
+ virtual Error readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) = 0;
+
+ /// \brief Return the number of bytes of data in this stream.
+ virtual uint32_t getLength() = 0;
+
+protected:
+ Error checkOffset(uint32_t Offset, uint32_t DataSize) {
+ if (Offset > getLength())
+ return make_error<BinaryStreamError>(stream_error_code::invalid_offset);
+ if (getLength() < DataSize + Offset)
+ return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
+ return Error::success();
+ }
+};
+
+/// \brief A BinaryStream which can be read from as well as written to. Note
+/// that writing to a BinaryStream always necessitates copying from the input
+/// buffer to the stream's backing store. Streams are assumed to be buffered
+/// so that to be portable it is necessary to call commit() on the stream when
+/// all data has been written.
+class WritableBinaryStream : public BinaryStream {
+public:
+ ~WritableBinaryStream() override = default;
+
+ /// \brief Attempt to write the given bytes into the stream at the desired
+ /// offset. This will always necessitate a copy. Cannot shrink or grow the
+ /// stream, only writes into existing allocated space.
+ virtual Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) = 0;
+
+ /// \brief For buffered streams, commits changes to the backing store.
+ virtual Error commit() = 0;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYSTREAM_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryStreamArray.h b/contrib/llvm/include/llvm/Support/BinaryStreamArray.h
new file mode 100644
index 0000000..3f5562b
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryStreamArray.h
@@ -0,0 +1,358 @@
+//===- BinaryStreamArray.h - Array backed by an arbitrary stream *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYSTREAMARRAY_H
+#define LLVM_SUPPORT_BINARYSTREAMARRAY_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Error.h"
+#include <cassert>
+#include <cstdint>
+
+/// Lightweight arrays that are backed by an arbitrary BinaryStream. This file
+/// provides two different array implementations.
+///
+/// VarStreamArray - Arrays of variable length records. The user specifies
+/// an Extractor type that can extract a record from a given offset and
+/// return the number of bytes consumed by the record.
+///
+/// FixedStreamArray - Arrays of fixed length records. This is similar in
+/// spirit to ArrayRef<T>, but since it is backed by a BinaryStream, the
+/// elements of the array need not be laid out in contiguous memory.
+namespace llvm {
+
+/// VarStreamArrayExtractor is intended to be specialized to provide customized
+/// extraction logic. On input it receives a BinaryStreamRef pointing to the
+/// beginning of the next record, but where the length of the record is not yet
+/// known. Upon completion, it should return an appropriate Error instance if
+/// a record could not be extracted, or if one could be extracted it should
+/// return success and set Len to the number of bytes this record occupied in
+/// the underlying stream, and it should fill out the fields of the value type
+/// Item appropriately to represent the current record.
+///
+/// You can specialize this template for your own custom value types to avoid
+/// having to specify a second template argument to VarStreamArray (documented
+/// below).
+template <typename T> struct VarStreamArrayExtractor {
+ // Method intentionally deleted. You must provide an explicit specialization
+ // with the following method implemented.
+ Error operator()(BinaryStreamRef Stream, uint32_t &Len,
+ T &Item) const = delete;
+};
+
+/// VarStreamArray represents an array of variable length records backed by a
+/// stream. This could be a contiguous sequence of bytes in memory, it could
+/// be a file on disk, or it could be a PDB stream where bytes are stored as
+/// discontiguous blocks in a file. Usually it is desirable to treat arrays
+/// as contiguous blocks of memory, but doing so with large PDB files, for
+/// example, could mean allocating huge amounts of memory just to allow
+/// re-ordering of stream data to be contiguous before iterating over it. By
+/// abstracting this out, we need not duplicate this memory, and we can
+/// iterate over arrays in arbitrarily formatted streams. Elements are parsed
+/// lazily on iteration, so there is no upfront cost associated with building
+/// or copying a VarStreamArray, no matter how large it may be.
+///
+/// You create a VarStreamArray by specifying a ValueType and an Extractor type.
+/// If you do not specify an Extractor type, you are expected to specialize
+/// VarStreamArrayExtractor<T> for your ValueType.
+///
+/// By default an Extractor is default constructed in the class, but in some
+/// cases you might find it useful for an Extractor to maintain state across
+/// extractions. In this case you can provide your own Extractor through a
+/// secondary constructor. The following examples show various ways of
+/// creating a VarStreamArray.
+///
+/// // Will use VarStreamArrayExtractor<MyType> as the extractor.
+/// VarStreamArray<MyType> MyTypeArray;
+///
+/// // Will use a default-constructed MyExtractor as the extractor.
+/// VarStreamArray<MyType, MyExtractor> MyTypeArray2;
+///
+/// // Will use the specific instance of MyExtractor provided.
+/// // MyExtractor need not be default-constructible in this case.
+/// MyExtractor E(SomeContext);
+/// VarStreamArray<MyType, MyExtractor> MyTypeArray3(E);
+///
+
+template <typename ValueType, typename Extractor> class VarStreamArrayIterator;
+
+template <typename ValueType,
+ typename Extractor = VarStreamArrayExtractor<ValueType>>
+class VarStreamArray {
+ friend class VarStreamArrayIterator<ValueType, Extractor>;
+
+public:
+ typedef VarStreamArrayIterator<ValueType, Extractor> Iterator;
+
+ VarStreamArray() = default;
+
+ explicit VarStreamArray(const Extractor &E) : E(E) {}
+
+ explicit VarStreamArray(BinaryStreamRef Stream) : Stream(Stream) {}
+
+ VarStreamArray(BinaryStreamRef Stream, const Extractor &E)
+ : Stream(Stream), E(E) {}
+
+ Iterator begin(bool *HadError = nullptr) const {
+ return Iterator(*this, E, HadError);
+ }
+
+ bool valid() const { return Stream.valid(); }
+
+ Iterator end() const { return Iterator(E); }
+
+ bool empty() const { return Stream.getLength() == 0; }
+
+ /// \brief given an offset into the array's underlying stream, return an
+ /// iterator to the record at that offset. This is considered unsafe
+ /// since the behavior is undefined if \p Offset does not refer to the
+ /// beginning of a valid record.
+ Iterator at(uint32_t Offset) const {
+ return Iterator(*this, E, Offset, nullptr);
+ }
+
+ const Extractor &getExtractor() const { return E; }
+ Extractor &getExtractor() { return E; }
+
+ BinaryStreamRef getUnderlyingStream() const { return Stream; }
+ void setUnderlyingStream(BinaryStreamRef S) { Stream = S; }
+
+private:
+ BinaryStreamRef Stream;
+ Extractor E;
+};
+
+template <typename ValueType, typename Extractor>
+class VarStreamArrayIterator
+ : public iterator_facade_base<VarStreamArrayIterator<ValueType, Extractor>,
+ std::forward_iterator_tag, ValueType> {
+ typedef VarStreamArrayIterator<ValueType, Extractor> IterType;
+ typedef VarStreamArray<ValueType, Extractor> ArrayType;
+
+public:
+ VarStreamArrayIterator(const ArrayType &Array, const Extractor &E,
+ bool *HadError)
+ : VarStreamArrayIterator(Array, E, 0, HadError) {}
+
+ VarStreamArrayIterator(const ArrayType &Array, const Extractor &E,
+ uint32_t Offset, bool *HadError)
+ : IterRef(Array.Stream.drop_front(Offset)), Extract(E),
+ Array(&Array), AbsOffset(Offset), HadError(HadError) {
+ if (IterRef.getLength() == 0)
+ moveToEnd();
+ else {
+ auto EC = Extract(IterRef, ThisLen, ThisValue);
+ if (EC) {
+ consumeError(std::move(EC));
+ markError();
+ }
+ }
+ }
+
+ VarStreamArrayIterator() = default;
+ explicit VarStreamArrayIterator(const Extractor &E) : Extract(E) {}
+ ~VarStreamArrayIterator() = default;
+
+ bool operator==(const IterType &R) const {
+ if (Array && R.Array) {
+ // Both have a valid array, make sure they're same.
+ assert(Array == R.Array);
+ return IterRef == R.IterRef;
+ }
+
+ // Both iterators are at the end.
+ if (!Array && !R.Array)
+ return true;
+
+ // One is not at the end and one is.
+ return false;
+ }
+
+ const ValueType &operator*() const {
+ assert(Array && !HasError);
+ return ThisValue;
+ }
+
+ ValueType &operator*() {
+ assert(Array && !HasError);
+ return ThisValue;
+ }
+
+ IterType &operator+=(unsigned N) {
+ for (unsigned I = 0; I < N; ++I) {
+ // We are done with the current record, discard it so that we are
+ // positioned at the next record.
+ AbsOffset += ThisLen;
+ IterRef = IterRef.drop_front(ThisLen);
+ if (IterRef.getLength() == 0) {
+ // There is nothing after the current record, we must make this an end
+ // iterator.
+ moveToEnd();
+ } else {
+ // There is some data after the current record.
+ auto EC = Extract(IterRef, ThisLen, ThisValue);
+ if (EC) {
+ consumeError(std::move(EC));
+ markError();
+ } else if (ThisLen == 0) {
+ // An empty record? Make this an end iterator.
+ moveToEnd();
+ }
+ }
+ }
+ return *this;
+ }
+
+ uint32_t offset() const { return AbsOffset; }
+ uint32_t getRecordLength() const { return ThisLen; }
+
+private:
+ void moveToEnd() {
+ Array = nullptr;
+ ThisLen = 0;
+ }
+ void markError() {
+ moveToEnd();
+ HasError = true;
+ if (HadError != nullptr)
+ *HadError = true;
+ }
+
+ ValueType ThisValue;
+ BinaryStreamRef IterRef;
+ Extractor Extract;
+ const ArrayType *Array{nullptr};
+ uint32_t ThisLen{0};
+ uint32_t AbsOffset{0};
+ bool HasError{false};
+ bool *HadError{nullptr};
+};
+
+template <typename T> class FixedStreamArrayIterator;
+
+/// FixedStreamArray is similar to VarStreamArray, except with each record
+/// having a fixed-length. As with VarStreamArray, there is no upfront
+/// cost associated with building or copying a FixedStreamArray, as the
+/// memory for each element is not read from the backing stream until that
+/// element is iterated.
+template <typename T> class FixedStreamArray {
+ friend class FixedStreamArrayIterator<T>;
+
+public:
+ typedef FixedStreamArrayIterator<T> Iterator;
+
+ FixedStreamArray() = default;
+ explicit FixedStreamArray(BinaryStreamRef Stream) : Stream(Stream) {
+ assert(Stream.getLength() % sizeof(T) == 0);
+ }
+
+ bool operator==(const FixedStreamArray<T> &Other) const {
+ return Stream == Other.Stream;
+ }
+
+ bool operator!=(const FixedStreamArray<T> &Other) const {
+ return !(*this == Other);
+ }
+
+ FixedStreamArray &operator=(const FixedStreamArray &) = default;
+
+ const T &operator[](uint32_t Index) const {
+ assert(Index < size());
+ uint32_t Off = Index * sizeof(T);
+ ArrayRef<uint8_t> Data;
+ if (auto EC = Stream.readBytes(Off, sizeof(T), Data)) {
+ assert(false && "Unexpected failure reading from stream");
+ // This should never happen since we asserted that the stream length was
+ // an exact multiple of the element size.
+ consumeError(std::move(EC));
+ }
+ assert(llvm::alignmentAdjustment(Data.data(), alignof(T)) == 0);
+ return *reinterpret_cast<const T *>(Data.data());
+ }
+
+ uint32_t size() const { return Stream.getLength() / sizeof(T); }
+
+ bool empty() const { return size() == 0; }
+
+ FixedStreamArrayIterator<T> begin() const {
+ return FixedStreamArrayIterator<T>(*this, 0);
+ }
+
+ FixedStreamArrayIterator<T> end() const {
+ return FixedStreamArrayIterator<T>(*this, size());
+ }
+
+ const T &front() const { return *begin(); }
+ const T &back() const {
+ FixedStreamArrayIterator<T> I = end();
+ return *(--I);
+ }
+
+ BinaryStreamRef getUnderlyingStream() const { return Stream; }
+
+private:
+ BinaryStreamRef Stream;
+};
+
+template <typename T>
+class FixedStreamArrayIterator
+ : public iterator_facade_base<FixedStreamArrayIterator<T>,
+ std::random_access_iterator_tag, const T> {
+
+public:
+ FixedStreamArrayIterator(const FixedStreamArray<T> &Array, uint32_t Index)
+ : Array(Array), Index(Index) {}
+
+ FixedStreamArrayIterator<T> &
+ operator=(const FixedStreamArrayIterator<T> &Other) {
+ Array = Other.Array;
+ Index = Other.Index;
+ return *this;
+ }
+
+ const T &operator*() const { return Array[Index]; }
+ const T &operator*() { return Array[Index]; }
+
+ bool operator==(const FixedStreamArrayIterator<T> &R) const {
+ assert(Array == R.Array);
+ return (Index == R.Index) && (Array == R.Array);
+ }
+
+ FixedStreamArrayIterator<T> &operator+=(std::ptrdiff_t N) {
+ Index += N;
+ return *this;
+ }
+
+ FixedStreamArrayIterator<T> &operator-=(std::ptrdiff_t N) {
+ assert(std::ptrdiff_t(Index) >= N);
+ Index -= N;
+ return *this;
+ }
+
+ std::ptrdiff_t operator-(const FixedStreamArrayIterator<T> &R) const {
+ assert(Array == R.Array);
+ assert(Index >= R.Index);
+ return Index - R.Index;
+ }
+
+ bool operator<(const FixedStreamArrayIterator<T> &RHS) const {
+ assert(Array == RHS.Array);
+ return Index < RHS.Index;
+ }
+
+private:
+ FixedStreamArray<T> Array;
+ uint32_t Index;
+};
+
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYSTREAMARRAY_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryStreamError.h b/contrib/llvm/include/llvm/Support/BinaryStreamError.h
new file mode 100644
index 0000000..7d9699d
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryStreamError.h
@@ -0,0 +1,48 @@
+//===- BinaryStreamError.h - Error extensions for Binary Streams *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYSTREAMERROR_H
+#define LLVM_SUPPORT_BINARYSTREAMERROR_H
+
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+#include <string>
+
+namespace llvm {
+enum class stream_error_code {
+ unspecified,
+ stream_too_short,
+ invalid_array_size,
+ invalid_offset,
+ filesystem_error
+};
+
+/// Base class for errors originating when parsing raw PDB files
+class BinaryStreamError : public ErrorInfo<BinaryStreamError> {
+public:
+ static char ID;
+ explicit BinaryStreamError(stream_error_code C);
+ explicit BinaryStreamError(StringRef Context);
+ BinaryStreamError(stream_error_code C, StringRef Context);
+
+ void log(raw_ostream &OS) const override;
+ std::error_code convertToErrorCode() const override;
+
+ StringRef getErrorMessage() const;
+
+ stream_error_code getErrorCode() const { return Code; }
+
+private:
+ std::string ErrMsg;
+ stream_error_code Code;
+};
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYSTREAMERROR_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryStreamReader.h b/contrib/llvm/include/llvm/Support/BinaryStreamReader.h
new file mode 100644
index 0000000..ae5ebb2
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryStreamReader.h
@@ -0,0 +1,270 @@
+//===- BinaryStreamReader.h - Reads objects from a binary stream *- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYSTREAMREADER_H
+#define LLVM_SUPPORT_BINARYSTREAMREADER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Support/BinaryStreamArray.h"
+#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/ConvertUTF.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include "llvm/Support/type_traits.h"
+
+#include <string>
+#include <type_traits>
+
+namespace llvm {
+
+/// \brief Provides read only access to a subclass of `BinaryStream`. Provides
+/// bounds checking and helpers for writing certain common data types such as
+/// null-terminated strings, integers in various flavors of endianness, etc.
+/// Can be subclassed to provide reading of custom datatypes, although no
+/// are overridable.
+class BinaryStreamReader {
+public:
+ BinaryStreamReader() = default;
+ explicit BinaryStreamReader(BinaryStreamRef Ref);
+ explicit BinaryStreamReader(BinaryStream &Stream);
+ explicit BinaryStreamReader(ArrayRef<uint8_t> Data,
+ llvm::support::endianness Endian);
+ explicit BinaryStreamReader(StringRef Data, llvm::support::endianness Endian);
+
+ BinaryStreamReader(const BinaryStreamReader &Other)
+ : Stream(Other.Stream), Offset(Other.Offset) {}
+
+ BinaryStreamReader &operator=(const BinaryStreamReader &Other) {
+ Stream = Other.Stream;
+ Offset = Other.Offset;
+ return *this;
+ }
+
+ virtual ~BinaryStreamReader() {}
+
+ /// Read as much as possible from the underlying string at the current offset
+ /// without invoking a copy, and set \p Buffer to the resulting data slice.
+ /// Updates the stream's offset to point after the newly read data.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readLongestContiguousChunk(ArrayRef<uint8_t> &Buffer);
+
+ /// Read \p Size bytes from the underlying stream at the current offset and
+ /// and set \p Buffer to the resulting data slice. Whether a copy occurs
+ /// depends on the implementation of the underlying stream. Updates the
+ /// stream's offset to point after the newly read data.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readBytes(ArrayRef<uint8_t> &Buffer, uint32_t Size);
+
+ /// Read an integer of the specified endianness into \p Dest and update the
+ /// stream's offset. The data is always copied from the stream's underlying
+ /// buffer into \p Dest. Updates the stream's offset to point after the newly
+ /// read data.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ template <typename T> Error readInteger(T &Dest) {
+ static_assert(std::is_integral<T>::value,
+ "Cannot call readInteger with non-integral value!");
+
+ ArrayRef<uint8_t> Bytes;
+ if (auto EC = readBytes(Bytes, sizeof(T)))
+ return EC;
+
+ Dest = llvm::support::endian::read<T, llvm::support::unaligned>(
+ Bytes.data(), Stream.getEndian());
+ return Error::success();
+ }
+
+ /// Similar to readInteger.
+ template <typename T> Error readEnum(T &Dest) {
+ static_assert(std::is_enum<T>::value,
+ "Cannot call readEnum with non-enum value!");
+ typename std::underlying_type<T>::type N;
+ if (auto EC = readInteger(N))
+ return EC;
+ Dest = static_cast<T>(N);
+ return Error::success();
+ }
+
+ /// Read a null terminated string from \p Dest. Whether a copy occurs depends
+ /// on the implementation of the underlying stream. Updates the stream's
+ /// offset to point after the newly read data.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readCString(StringRef &Dest);
+
+ /// Similar to readCString, however read a null-terminated UTF16 string
+ /// instead.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readWideString(ArrayRef<UTF16> &Dest);
+
+ /// Read a \p Length byte string into \p Dest. Whether a copy occurs depends
+ /// on the implementation of the underlying stream. Updates the stream's
+ /// offset to point after the newly read data.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readFixedString(StringRef &Dest, uint32_t Length);
+
+ /// Read the entire remainder of the underlying stream into \p Ref. This is
+ /// equivalent to calling getUnderlyingStream().slice(Offset). Updates the
+ /// stream's offset to point to the end of the stream. Never causes a copy.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readStreamRef(BinaryStreamRef &Ref);
+
+ /// Read \p Length bytes from the underlying stream into \p Ref. This is
+ /// equivalent to calling getUnderlyingStream().slice(Offset, Length).
+ /// Updates the stream's offset to point after the newly read object. Never
+ /// causes a copy.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readStreamRef(BinaryStreamRef &Ref, uint32_t Length);
+
+ /// Read \p Length bytes from the underlying stream into \p Stream. This is
+ /// equivalent to calling getUnderlyingStream().slice(Offset, Length).
+ /// Updates the stream's offset to point after the newly read object. Never
+ /// causes a copy.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ Error readSubstream(BinarySubstreamRef &Stream, uint32_t Size);
+
+ /// Get a pointer to an object of type T from the underlying stream, as if by
+ /// memcpy, and store the result into \p Dest. It is up to the caller to
+ /// ensure that objects of type T can be safely treated in this manner.
+ /// Updates the stream's offset to point after the newly read object. Whether
+ /// a copy occurs depends upon the implementation of the underlying
+ /// stream.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ template <typename T> Error readObject(const T *&Dest) {
+ ArrayRef<uint8_t> Buffer;
+ if (auto EC = readBytes(Buffer, sizeof(T)))
+ return EC;
+ Dest = reinterpret_cast<const T *>(Buffer.data());
+ return Error::success();
+ }
+
+ /// Get a reference to a \p NumElements element array of objects of type T
+ /// from the underlying stream as if by memcpy, and store the resulting array
+ /// slice into \p array. It is up to the caller to ensure that objects of
+ /// type T can be safely treated in this manner. Updates the stream's offset
+ /// to point after the newly read object. Whether a copy occurs depends upon
+ /// the implementation of the underlying stream.
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ template <typename T>
+ Error readArray(ArrayRef<T> &Array, uint32_t NumElements) {
+ ArrayRef<uint8_t> Bytes;
+ if (NumElements == 0) {
+ Array = ArrayRef<T>();
+ return Error::success();
+ }
+
+ if (NumElements > UINT32_MAX / sizeof(T))
+ return make_error<BinaryStreamError>(
+ stream_error_code::invalid_array_size);
+
+ if (auto EC = readBytes(Bytes, NumElements * sizeof(T)))
+ return EC;
+
+ assert(alignmentAdjustment(Bytes.data(), alignof(T)) == 0 &&
+ "Reading at invalid alignment!");
+
+ Array = ArrayRef<T>(reinterpret_cast<const T *>(Bytes.data()), NumElements);
+ return Error::success();
+ }
+
+ /// Read a VarStreamArray of size \p Size bytes and store the result into
+ /// \p Array. Updates the stream's offset to point after the newly read
+ /// array. Never causes a copy (although iterating the elements of the
+ /// VarStreamArray may, depending upon the implementation of the underlying
+ /// stream).
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ template <typename T, typename U>
+ Error readArray(VarStreamArray<T, U> &Array, uint32_t Size) {
+ BinaryStreamRef S;
+ if (auto EC = readStreamRef(S, Size))
+ return EC;
+ Array.setUnderlyingStream(S);
+ return Error::success();
+ }
+
+ /// Read a FixedStreamArray of \p NumItems elements and store the result into
+ /// \p Array. Updates the stream's offset to point after the newly read
+ /// array. Never causes a copy (although iterating the elements of the
+ /// FixedStreamArray may, depending upon the implementation of the underlying
+ /// stream).
+ ///
+ /// \returns a success error code if the data was successfully read, otherwise
+ /// returns an appropriate error code.
+ template <typename T>
+ Error readArray(FixedStreamArray<T> &Array, uint32_t NumItems) {
+ if (NumItems == 0) {
+ Array = FixedStreamArray<T>();
+ return Error::success();
+ }
+
+ if (NumItems > UINT32_MAX / sizeof(T))
+ return make_error<BinaryStreamError>(
+ stream_error_code::invalid_array_size);
+
+ BinaryStreamRef View;
+ if (auto EC = readStreamRef(View, NumItems * sizeof(T)))
+ return EC;
+
+ Array = FixedStreamArray<T>(View);
+ return Error::success();
+ }
+
+ bool empty() const { return bytesRemaining() == 0; }
+ void setOffset(uint32_t Off) { Offset = Off; }
+ uint32_t getOffset() const { return Offset; }
+ uint32_t getLength() const { return Stream.getLength(); }
+ uint32_t bytesRemaining() const { return getLength() - getOffset(); }
+
+ /// Advance the stream's offset by \p Amount bytes.
+ ///
+ /// \returns a success error code if at least \p Amount bytes remain in the
+ /// stream, otherwise returns an appropriate error code.
+ Error skip(uint32_t Amount);
+
+ /// Examine the next byte of the underlying stream without advancing the
+ /// stream's offset. If the stream is empty the behavior is undefined.
+ ///
+ /// \returns the next byte in the stream.
+ uint8_t peek() const;
+
+ Error padToAlignment(uint32_t Align);
+
+ std::pair<BinaryStreamReader, BinaryStreamReader>
+ split(uint32_t Offset) const;
+
+private:
+ BinaryStreamRef Stream;
+ uint32_t Offset = 0;
+};
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYSTREAMREADER_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryStreamRef.h b/contrib/llvm/include/llvm/Support/BinaryStreamRef.h
new file mode 100644
index 0000000..6d5135c
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryStreamRef.h
@@ -0,0 +1,229 @@
+//===- BinaryStreamRef.h - A copyable reference to a stream -----*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYSTREAMREF_H
+#define LLVM_SUPPORT_BINARYSTREAMREF_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/BinaryStream.h"
+#include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/Error.h"
+#include <algorithm>
+#include <cstdint>
+#include <memory>
+
+namespace llvm {
+
+/// Common stuff for mutable and immutable StreamRefs.
+template <class RefType, class StreamType> class BinaryStreamRefBase {
+protected:
+ BinaryStreamRefBase() = default;
+ BinaryStreamRefBase(std::shared_ptr<StreamType> SharedImpl, uint32_t Offset,
+ uint32_t Length)
+ : SharedImpl(SharedImpl), BorrowedImpl(SharedImpl.get()),
+ ViewOffset(Offset), Length(Length) {}
+ BinaryStreamRefBase(StreamType &BorrowedImpl, uint32_t Offset,
+ uint32_t Length)
+ : BorrowedImpl(&BorrowedImpl), ViewOffset(Offset), Length(Length) {}
+ BinaryStreamRefBase(const BinaryStreamRefBase &Other) {
+ SharedImpl = Other.SharedImpl;
+ BorrowedImpl = Other.BorrowedImpl;
+ ViewOffset = Other.ViewOffset;
+ Length = Other.Length;
+ }
+
+public:
+ llvm::support::endianness getEndian() const {
+ return BorrowedImpl->getEndian();
+ }
+
+ uint32_t getLength() const { return Length; }
+
+ /// Return a new BinaryStreamRef with the first \p N elements removed.
+ RefType drop_front(uint32_t N) const {
+ if (!BorrowedImpl)
+ return RefType();
+
+ N = std::min(N, Length);
+ RefType Result(static_cast<const RefType &>(*this));
+ Result.ViewOffset += N;
+ Result.Length -= N;
+ return Result;
+ }
+
+ /// Return a new BinaryStreamRef with the first \p N elements removed.
+ RefType drop_back(uint32_t N) const {
+ if (!BorrowedImpl)
+ return RefType();
+
+ N = std::min(N, Length);
+ RefType Result(static_cast<const RefType &>(*this));
+ Result.Length -= N;
+ return Result;
+ }
+
+ /// Return a new BinaryStreamRef with only the first \p N elements remaining.
+ RefType keep_front(uint32_t N) const {
+ assert(N <= getLength());
+ return drop_back(getLength() - N);
+ }
+
+ /// Return a new BinaryStreamRef with only the last \p N elements remaining.
+ RefType keep_back(uint32_t N) const {
+ assert(N <= getLength());
+ return drop_front(getLength() - N);
+ }
+
+ /// Return a new BinaryStreamRef with the first and last \p N elements
+ /// removed.
+ RefType drop_symmetric(uint32_t N) const {
+ return drop_front(N).drop_back(N);
+ }
+
+ /// Return a new BinaryStreamRef with the first \p Offset elements removed,
+ /// and retaining exactly \p Len elements.
+ RefType slice(uint32_t Offset, uint32_t Len) const {
+ return drop_front(Offset).keep_front(Len);
+ }
+
+ bool valid() const { return BorrowedImpl != nullptr; }
+
+ bool operator==(const RefType &Other) const {
+ if (BorrowedImpl != Other.BorrowedImpl)
+ return false;
+ if (ViewOffset != Other.ViewOffset)
+ return false;
+ if (Length != Other.Length)
+ return false;
+ return true;
+ }
+
+protected:
+ Error checkOffset(uint32_t Offset, uint32_t DataSize) const {
+ if (Offset > getLength())
+ return make_error<BinaryStreamError>(stream_error_code::invalid_offset);
+ if (getLength() < DataSize + Offset)
+ return make_error<BinaryStreamError>(stream_error_code::stream_too_short);
+ return Error::success();
+ }
+
+ std::shared_ptr<StreamType> SharedImpl;
+ StreamType *BorrowedImpl = nullptr;
+ uint32_t ViewOffset = 0;
+ uint32_t Length = 0;
+};
+
+/// \brief BinaryStreamRef is to BinaryStream what ArrayRef is to an Array. It
+/// provides copy-semantics and read only access to a "window" of the underlying
+/// BinaryStream. Note that BinaryStreamRef is *not* a BinaryStream. That is to
+/// say, it does not inherit and override the methods of BinaryStream. In
+/// general, you should not pass around pointers or references to BinaryStreams
+/// and use inheritance to achieve polymorphism. Instead, you should pass
+/// around BinaryStreamRefs by value and achieve polymorphism that way.
+class BinaryStreamRef
+ : public BinaryStreamRefBase<BinaryStreamRef, BinaryStream> {
+ friend BinaryStreamRefBase<BinaryStreamRef, BinaryStream>;
+ friend class WritableBinaryStreamRef;
+ BinaryStreamRef(std::shared_ptr<BinaryStream> Impl, uint32_t ViewOffset,
+ uint32_t Length)
+ : BinaryStreamRefBase(Impl, ViewOffset, Length) {}
+
+public:
+ BinaryStreamRef() = default;
+ BinaryStreamRef(BinaryStream &Stream);
+ BinaryStreamRef(BinaryStream &Stream, uint32_t Offset, uint32_t Length);
+ explicit BinaryStreamRef(ArrayRef<uint8_t> Data,
+ llvm::support::endianness Endian);
+ explicit BinaryStreamRef(StringRef Data, llvm::support::endianness Endian);
+
+ BinaryStreamRef(const BinaryStreamRef &Other);
+
+ // Use BinaryStreamRef.slice() instead.
+ BinaryStreamRef(BinaryStreamRef &S, uint32_t Offset,
+ uint32_t Length) = delete;
+
+ /// Given an Offset into this StreamRef and a Size, return a reference to a
+ /// buffer owned by the stream.
+ ///
+ /// \returns a success error code if the entire range of data is within the
+ /// bounds of this BinaryStreamRef's view and the implementation could read
+ /// the data, and an appropriate error code otherwise.
+ Error readBytes(uint32_t Offset, uint32_t Size,
+ ArrayRef<uint8_t> &Buffer) const;
+
+ /// Given an Offset into this BinaryStreamRef, return a reference to the
+ /// largest buffer the stream could support without necessitating a copy.
+ ///
+ /// \returns a success error code if implementation could read the data,
+ /// and an appropriate error code otherwise.
+ Error readLongestContiguousChunk(uint32_t Offset,
+ ArrayRef<uint8_t> &Buffer) const;
+};
+
+struct BinarySubstreamRef {
+ uint32_t Offset; // Offset in the parent stream
+ BinaryStreamRef StreamData; // Stream Data
+
+ BinarySubstreamRef slice(uint32_t Off, uint32_t Size) const {
+ BinaryStreamRef SubSub = StreamData.slice(Off, Size);
+ return {Off + Offset, SubSub};
+ }
+ BinarySubstreamRef drop_front(uint32_t N) const {
+ return slice(N, size() - N);
+ }
+ BinarySubstreamRef keep_front(uint32_t N) const { return slice(0, N); }
+
+ std::pair<BinarySubstreamRef, BinarySubstreamRef>
+ split(uint32_t Offset) const {
+ return std::make_pair(keep_front(Offset), drop_front(Offset));
+ }
+
+ uint32_t size() const { return StreamData.getLength(); }
+ bool empty() const { return size() == 0; }
+};
+
+class WritableBinaryStreamRef
+ : public BinaryStreamRefBase<WritableBinaryStreamRef,
+ WritableBinaryStream> {
+ friend BinaryStreamRefBase<WritableBinaryStreamRef, WritableBinaryStream>;
+ WritableBinaryStreamRef(std::shared_ptr<WritableBinaryStream> Impl,
+ uint32_t ViewOffset, uint32_t Length)
+ : BinaryStreamRefBase(Impl, ViewOffset, Length) {}
+
+public:
+ WritableBinaryStreamRef() = default;
+ WritableBinaryStreamRef(WritableBinaryStream &Stream);
+ WritableBinaryStreamRef(WritableBinaryStream &Stream, uint32_t Offset,
+ uint32_t Length);
+ explicit WritableBinaryStreamRef(MutableArrayRef<uint8_t> Data,
+ llvm::support::endianness Endian);
+ WritableBinaryStreamRef(const WritableBinaryStreamRef &Other);
+
+ // Use WritableBinaryStreamRef.slice() instead.
+ WritableBinaryStreamRef(WritableBinaryStreamRef &S, uint32_t Offset,
+ uint32_t Length) = delete;
+
+ /// Given an Offset into this WritableBinaryStreamRef and some input data,
+ /// writes the data to the underlying stream.
+ ///
+ /// \returns a success error code if the data could fit within the underlying
+ /// stream at the specified location and the implementation could write the
+ /// data, and an appropriate error code otherwise.
+ Error writeBytes(uint32_t Offset, ArrayRef<uint8_t> Data) const;
+
+ /// Conver this WritableBinaryStreamRef to a read-only BinaryStreamRef.
+ operator BinaryStreamRef() const;
+
+ /// \brief For buffered streams, commits changes to the backing store.
+ Error commit();
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYSTREAMREF_H
diff --git a/contrib/llvm/include/llvm/Support/BinaryStreamWriter.h b/contrib/llvm/include/llvm/Support/BinaryStreamWriter.h
new file mode 100644
index 0000000..a4495a1
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/BinaryStreamWriter.h
@@ -0,0 +1,183 @@
+//===- BinaryStreamWriter.h - Writes objects to a BinaryStream ---*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_BINARYSTREAMWRITER_H
+#define LLVM_SUPPORT_BINARYSTREAMWRITER_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/BinaryStreamArray.h"
+#include "llvm/Support/BinaryStreamError.h"
+#include "llvm/Support/BinaryStreamRef.h"
+#include "llvm/Support/Endian.h"
+#include "llvm/Support/Error.h"
+#include <cstdint>
+#include <type_traits>
+#include <utility>
+
+namespace llvm {
+
+/// \brief Provides write only access to a subclass of `WritableBinaryStream`.
+/// Provides bounds checking and helpers for writing certain common data types
+/// such as null-terminated strings, integers in various flavors of endianness,
+/// etc. Can be subclassed to provide reading and writing of custom datatypes,
+/// although no methods are overridable.
+class BinaryStreamWriter {
+public:
+ BinaryStreamWriter() = default;
+ explicit BinaryStreamWriter(WritableBinaryStreamRef Ref);
+ explicit BinaryStreamWriter(WritableBinaryStream &Stream);
+ explicit BinaryStreamWriter(MutableArrayRef<uint8_t> Data,
+ llvm::support::endianness Endian);
+
+ BinaryStreamWriter(const BinaryStreamWriter &Other)
+ : Stream(Other.Stream), Offset(Other.Offset) {}
+
+ BinaryStreamWriter &operator=(const BinaryStreamWriter &Other) {
+ Stream = Other.Stream;
+ Offset = Other.Offset;
+ return *this;
+ }
+
+ virtual ~BinaryStreamWriter() {}
+
+ /// Write the bytes specified in \p Buffer to the underlying stream.
+ /// On success, updates the offset so that subsequent writes will occur
+ /// at the next unwritten position.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ Error writeBytes(ArrayRef<uint8_t> Buffer);
+
+ /// Write the the integer \p Value to the underlying stream in the
+ /// specified endianness. On success, updates the offset so that
+ /// subsequent writes occur at the next unwritten position.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ template <typename T> Error writeInteger(T Value) {
+ static_assert(std::is_integral<T>::value,
+ "Cannot call writeInteger with non-integral value!");
+ uint8_t Buffer[sizeof(T)];
+ llvm::support::endian::write<T, llvm::support::unaligned>(
+ Buffer, Value, Stream.getEndian());
+ return writeBytes(Buffer);
+ }
+
+ /// Similar to writeInteger
+ template <typename T> Error writeEnum(T Num) {
+ static_assert(std::is_enum<T>::value,
+ "Cannot call writeEnum with non-Enum type");
+
+ using U = typename std::underlying_type<T>::type;
+ return writeInteger<U>(static_cast<U>(Num));
+ }
+
+ /// Write the the string \p Str to the underlying stream followed by a null
+ /// terminator. On success, updates the offset so that subsequent writes
+ /// occur at the next unwritten position. \p Str need not be null terminated
+ /// on input.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ Error writeCString(StringRef Str);
+
+ /// Write the the string \p Str to the underlying stream without a null
+ /// terminator. On success, updates the offset so that subsequent writes
+ /// occur at the next unwritten position.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ Error writeFixedString(StringRef Str);
+
+ /// Efficiently reads all data from \p Ref, and writes it to this stream.
+ /// This operation will not invoke any copies of the source data, regardless
+ /// of the source stream's implementation.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ Error writeStreamRef(BinaryStreamRef Ref);
+
+ /// Efficiently reads \p Size bytes from \p Ref, and writes it to this stream.
+ /// This operation will not invoke any copies of the source data, regardless
+ /// of the source stream's implementation.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ Error writeStreamRef(BinaryStreamRef Ref, uint32_t Size);
+
+ /// Writes the object \p Obj to the underlying stream, as if by using memcpy.
+ /// It is up to the caller to ensure that type of \p Obj can be safely copied
+ /// in this fashion, as no checks are made to ensure that this is safe.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ template <typename T> Error writeObject(const T &Obj) {
+ static_assert(!std::is_pointer<T>::value,
+ "writeObject should not be used with pointers, to write "
+ "the pointed-to value dereference the pointer before calling "
+ "writeObject");
+ return writeBytes(
+ ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(&Obj), sizeof(T)));
+ }
+
+ /// Writes an array of objects of type T to the underlying stream, as if by
+ /// using memcpy. It is up to the caller to ensure that type of \p Obj can
+ /// be safely copied in this fashion, as no checks are made to ensure that
+ /// this is safe.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ template <typename T> Error writeArray(ArrayRef<T> Array) {
+ if (Array.empty())
+ return Error::success();
+ if (Array.size() > UINT32_MAX / sizeof(T))
+ return make_error<BinaryStreamError>(
+ stream_error_code::invalid_array_size);
+
+ return writeBytes(
+ ArrayRef<uint8_t>(reinterpret_cast<const uint8_t *>(Array.data()),
+ Array.size() * sizeof(T)));
+ }
+
+ /// Writes all data from the array \p Array to the underlying stream.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ template <typename T, typename U>
+ Error writeArray(VarStreamArray<T, U> Array) {
+ return writeStreamRef(Array.getUnderlyingStream());
+ }
+
+ /// Writes all elements from the array \p Array to the underlying stream.
+ ///
+ /// \returns a success error code if the data was successfully written,
+ /// otherwise returns an appropriate error code.
+ template <typename T> Error writeArray(FixedStreamArray<T> Array) {
+ return writeStreamRef(Array.getUnderlyingStream());
+ }
+
+ /// Splits the Writer into two Writers at a given offset.
+ std::pair<BinaryStreamWriter, BinaryStreamWriter> split(uint32_t Off) const;
+
+ void setOffset(uint32_t Off) { Offset = Off; }
+ uint32_t getOffset() const { return Offset; }
+ uint32_t getLength() const { return Stream.getLength(); }
+ uint32_t bytesRemaining() const { return getLength() - getOffset(); }
+ Error padToAlignment(uint32_t Align);
+
+protected:
+ WritableBinaryStreamRef Stream;
+ uint32_t Offset = 0;
+};
+
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_BINARYSTREAMWRITER_H
diff --git a/contrib/llvm/include/llvm/Support/BlockFrequency.h b/contrib/llvm/include/llvm/Support/BlockFrequency.h
index 1b45cc5..2e75cbd 100644
--- a/contrib/llvm/include/llvm/Support/BlockFrequency.h
+++ b/contrib/llvm/include/llvm/Support/BlockFrequency.h
@@ -71,6 +71,10 @@ public:
bool operator>=(BlockFrequency RHS) const {
return Frequency >= RHS.Frequency;
}
+
+ bool operator==(BlockFrequency RHS) const {
+ return Frequency == RHS.Frequency;
+ }
};
}
diff --git a/contrib/llvm/include/llvm/Support/BranchProbability.h b/contrib/llvm/include/llvm/Support/BranchProbability.h
index e8eb50d..b403d7f 100644
--- a/contrib/llvm/include/llvm/Support/BranchProbability.h
+++ b/contrib/llvm/include/llvm/Support/BranchProbability.h
@@ -112,6 +112,13 @@ public:
return *this;
}
+ BranchProbability &operator*=(uint32_t RHS) {
+ assert(N != UnknownN &&
+ "Unknown probability cannot participate in arithmetics.");
+ N = (uint64_t(N) * RHS > D) ? D : N * RHS;
+ return *this;
+ }
+
BranchProbability &operator/=(uint32_t RHS) {
assert(N != UnknownN &&
"Unknown probability cannot participate in arithmetics.");
@@ -135,6 +142,11 @@ public:
return Prob *= RHS;
}
+ BranchProbability operator*(uint32_t RHS) const {
+ BranchProbability Prob(*this);
+ return Prob *= RHS;
+ }
+
BranchProbability operator/(uint32_t RHS) const {
BranchProbability Prob(*this);
return Prob /= RHS;
diff --git a/contrib/llvm/include/llvm/Support/CBindingWrapping.h b/contrib/llvm/include/llvm/Support/CBindingWrapping.h
index d4633aa..f60f99d 100644
--- a/contrib/llvm/include/llvm/Support/CBindingWrapping.h
+++ b/contrib/llvm/include/llvm/Support/CBindingWrapping.h
@@ -14,8 +14,8 @@
#ifndef LLVM_SUPPORT_CBINDINGWRAPPING_H
#define LLVM_SUPPORT_CBINDINGWRAPPING_H
-#include "llvm/Support/Casting.h"
#include "llvm-c/Types.h"
+#include "llvm/Support/Casting.h"
#define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \
inline ty *unwrap(ref P) { \
diff --git a/contrib/llvm/include/llvm/Support/COFF.h b/contrib/llvm/include/llvm/Support/COFF.h
deleted file mode 100644
index 1922330..0000000
--- a/contrib/llvm/include/llvm/Support/COFF.h
+++ /dev/null
@@ -1,680 +0,0 @@
-//===-- llvm/Support/COFF.h -------------------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file contains an definitions used in Windows COFF Files.
-//
-// Structures and enums defined within this file where created using
-// information from Microsoft's publicly available PE/COFF format document:
-//
-// Microsoft Portable Executable and Common Object File Format Specification
-// Revision 8.1 - February 15, 2008
-//
-// As of 5/2/2010, hosted by Microsoft at:
-// http://www.microsoft.com/whdc/system/platform/firmware/pecoff.mspx
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_COFF_H
-#define LLVM_SUPPORT_COFF_H
-
-#include "llvm/Support/DataTypes.h"
-#include <cassert>
-#include <cstring>
-
-namespace llvm {
-namespace COFF {
-
- // The maximum number of sections that a COFF object can have (inclusive).
- const int32_t MaxNumberOfSections16 = 65279;
-
- // The PE signature bytes that follows the DOS stub header.
- static const char PEMagic[] = { 'P', 'E', '\0', '\0' };
-
- static const char BigObjMagic[] = {
- '\xc7', '\xa1', '\xba', '\xd1', '\xee', '\xba', '\xa9', '\x4b',
- '\xaf', '\x20', '\xfa', '\xf6', '\x6a', '\xa4', '\xdc', '\xb8',
- };
-
- static const char ClGlObjMagic[] = {
- '\x38', '\xfe', '\xb3', '\x0c', '\xa5', '\xd9', '\xab', '\x4d',
- '\xac', '\x9b', '\xd6', '\xb6', '\x22', '\x26', '\x53', '\xc2',
- };
-
- // Sizes in bytes of various things in the COFF format.
- enum {
- Header16Size = 20,
- Header32Size = 56,
- NameSize = 8,
- Symbol16Size = 18,
- Symbol32Size = 20,
- SectionSize = 40,
- RelocationSize = 10
- };
-
- struct header {
- uint16_t Machine;
- int32_t NumberOfSections;
- uint32_t TimeDateStamp;
- uint32_t PointerToSymbolTable;
- uint32_t NumberOfSymbols;
- uint16_t SizeOfOptionalHeader;
- uint16_t Characteristics;
- };
-
- struct BigObjHeader {
- enum : uint16_t { MinBigObjectVersion = 2 };
-
- uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0).
- uint16_t Sig2; ///< Must be 0xFFFF.
- uint16_t Version;
- uint16_t Machine;
- uint32_t TimeDateStamp;
- uint8_t UUID[16];
- uint32_t unused1;
- uint32_t unused2;
- uint32_t unused3;
- uint32_t unused4;
- uint32_t NumberOfSections;
- uint32_t PointerToSymbolTable;
- uint32_t NumberOfSymbols;
- };
-
- enum MachineTypes {
- MT_Invalid = 0xffff,
-
- IMAGE_FILE_MACHINE_UNKNOWN = 0x0,
- IMAGE_FILE_MACHINE_AM33 = 0x13,
- IMAGE_FILE_MACHINE_AMD64 = 0x8664,
- IMAGE_FILE_MACHINE_ARM = 0x1C0,
- IMAGE_FILE_MACHINE_ARMNT = 0x1C4,
- IMAGE_FILE_MACHINE_ARM64 = 0xAA64,
- IMAGE_FILE_MACHINE_EBC = 0xEBC,
- IMAGE_FILE_MACHINE_I386 = 0x14C,
- IMAGE_FILE_MACHINE_IA64 = 0x200,
- IMAGE_FILE_MACHINE_M32R = 0x9041,
- IMAGE_FILE_MACHINE_MIPS16 = 0x266,
- IMAGE_FILE_MACHINE_MIPSFPU = 0x366,
- IMAGE_FILE_MACHINE_MIPSFPU16 = 0x466,
- IMAGE_FILE_MACHINE_POWERPC = 0x1F0,
- IMAGE_FILE_MACHINE_POWERPCFP = 0x1F1,
- IMAGE_FILE_MACHINE_R4000 = 0x166,
- IMAGE_FILE_MACHINE_SH3 = 0x1A2,
- IMAGE_FILE_MACHINE_SH3DSP = 0x1A3,
- IMAGE_FILE_MACHINE_SH4 = 0x1A6,
- IMAGE_FILE_MACHINE_SH5 = 0x1A8,
- IMAGE_FILE_MACHINE_THUMB = 0x1C2,
- IMAGE_FILE_MACHINE_WCEMIPSV2 = 0x169
- };
-
- enum Characteristics {
- C_Invalid = 0,
-
- /// The file does not contain base relocations and must be loaded at its
- /// preferred base. If this cannot be done, the loader will error.
- IMAGE_FILE_RELOCS_STRIPPED = 0x0001,
- /// The file is valid and can be run.
- IMAGE_FILE_EXECUTABLE_IMAGE = 0x0002,
- /// COFF line numbers have been stripped. This is deprecated and should be
- /// 0.
- IMAGE_FILE_LINE_NUMS_STRIPPED = 0x0004,
- /// COFF symbol table entries for local symbols have been removed. This is
- /// deprecated and should be 0.
- IMAGE_FILE_LOCAL_SYMS_STRIPPED = 0x0008,
- /// Aggressively trim working set. This is deprecated and must be 0.
- IMAGE_FILE_AGGRESSIVE_WS_TRIM = 0x0010,
- /// Image can handle > 2GiB addresses.
- IMAGE_FILE_LARGE_ADDRESS_AWARE = 0x0020,
- /// Little endian: the LSB precedes the MSB in memory. This is deprecated
- /// and should be 0.
- IMAGE_FILE_BYTES_REVERSED_LO = 0x0080,
- /// Machine is based on a 32bit word architecture.
- IMAGE_FILE_32BIT_MACHINE = 0x0100,
- /// Debugging info has been removed.
- IMAGE_FILE_DEBUG_STRIPPED = 0x0200,
- /// If the image is on removable media, fully load it and copy it to swap.
- IMAGE_FILE_REMOVABLE_RUN_FROM_SWAP = 0x0400,
- /// If the image is on network media, fully load it and copy it to swap.
- IMAGE_FILE_NET_RUN_FROM_SWAP = 0x0800,
- /// The image file is a system file, not a user program.
- IMAGE_FILE_SYSTEM = 0x1000,
- /// The image file is a DLL.
- IMAGE_FILE_DLL = 0x2000,
- /// This file should only be run on a uniprocessor machine.
- IMAGE_FILE_UP_SYSTEM_ONLY = 0x4000,
- /// Big endian: the MSB precedes the LSB in memory. This is deprecated
- /// and should be 0.
- IMAGE_FILE_BYTES_REVERSED_HI = 0x8000
- };
-
- struct symbol {
- char Name[NameSize];
- uint32_t Value;
- int32_t SectionNumber;
- uint16_t Type;
- uint8_t StorageClass;
- uint8_t NumberOfAuxSymbols;
- };
-
- enum SymbolSectionNumber : int32_t {
- IMAGE_SYM_DEBUG = -2,
- IMAGE_SYM_ABSOLUTE = -1,
- IMAGE_SYM_UNDEFINED = 0
- };
-
- /// Storage class tells where and what the symbol represents
- enum SymbolStorageClass {
- SSC_Invalid = 0xff,
-
- IMAGE_SYM_CLASS_END_OF_FUNCTION = -1, ///< Physical end of function
- IMAGE_SYM_CLASS_NULL = 0, ///< No symbol
- IMAGE_SYM_CLASS_AUTOMATIC = 1, ///< Stack variable
- IMAGE_SYM_CLASS_EXTERNAL = 2, ///< External symbol
- IMAGE_SYM_CLASS_STATIC = 3, ///< Static
- IMAGE_SYM_CLASS_REGISTER = 4, ///< Register variable
- IMAGE_SYM_CLASS_EXTERNAL_DEF = 5, ///< External definition
- IMAGE_SYM_CLASS_LABEL = 6, ///< Label
- IMAGE_SYM_CLASS_UNDEFINED_LABEL = 7, ///< Undefined label
- IMAGE_SYM_CLASS_MEMBER_OF_STRUCT = 8, ///< Member of structure
- IMAGE_SYM_CLASS_ARGUMENT = 9, ///< Function argument
- IMAGE_SYM_CLASS_STRUCT_TAG = 10, ///< Structure tag
- IMAGE_SYM_CLASS_MEMBER_OF_UNION = 11, ///< Member of union
- IMAGE_SYM_CLASS_UNION_TAG = 12, ///< Union tag
- IMAGE_SYM_CLASS_TYPE_DEFINITION = 13, ///< Type definition
- IMAGE_SYM_CLASS_UNDEFINED_STATIC = 14, ///< Undefined static
- IMAGE_SYM_CLASS_ENUM_TAG = 15, ///< Enumeration tag
- IMAGE_SYM_CLASS_MEMBER_OF_ENUM = 16, ///< Member of enumeration
- IMAGE_SYM_CLASS_REGISTER_PARAM = 17, ///< Register parameter
- IMAGE_SYM_CLASS_BIT_FIELD = 18, ///< Bit field
- /// ".bb" or ".eb" - beginning or end of block
- IMAGE_SYM_CLASS_BLOCK = 100,
- /// ".bf" or ".ef" - beginning or end of function
- IMAGE_SYM_CLASS_FUNCTION = 101,
- IMAGE_SYM_CLASS_END_OF_STRUCT = 102, ///< End of structure
- IMAGE_SYM_CLASS_FILE = 103, ///< File name
- /// Line number, reformatted as symbol
- IMAGE_SYM_CLASS_SECTION = 104,
- IMAGE_SYM_CLASS_WEAK_EXTERNAL = 105, ///< Duplicate tag
- /// External symbol in dmert public lib
- IMAGE_SYM_CLASS_CLR_TOKEN = 107
- };
-
- enum SymbolBaseType {
- IMAGE_SYM_TYPE_NULL = 0, ///< No type information or unknown base type.
- IMAGE_SYM_TYPE_VOID = 1, ///< Used with void pointers and functions.
- IMAGE_SYM_TYPE_CHAR = 2, ///< A character (signed byte).
- IMAGE_SYM_TYPE_SHORT = 3, ///< A 2-byte signed integer.
- IMAGE_SYM_TYPE_INT = 4, ///< A natural integer type on the target.
- IMAGE_SYM_TYPE_LONG = 5, ///< A 4-byte signed integer.
- IMAGE_SYM_TYPE_FLOAT = 6, ///< A 4-byte floating-point number.
- IMAGE_SYM_TYPE_DOUBLE = 7, ///< An 8-byte floating-point number.
- IMAGE_SYM_TYPE_STRUCT = 8, ///< A structure.
- IMAGE_SYM_TYPE_UNION = 9, ///< An union.
- IMAGE_SYM_TYPE_ENUM = 10, ///< An enumerated type.
- IMAGE_SYM_TYPE_MOE = 11, ///< A member of enumeration (a specific value).
- IMAGE_SYM_TYPE_BYTE = 12, ///< A byte; unsigned 1-byte integer.
- IMAGE_SYM_TYPE_WORD = 13, ///< A word; unsigned 2-byte integer.
- IMAGE_SYM_TYPE_UINT = 14, ///< An unsigned integer of natural size.
- IMAGE_SYM_TYPE_DWORD = 15 ///< An unsigned 4-byte integer.
- };
-
- enum SymbolComplexType {
- IMAGE_SYM_DTYPE_NULL = 0, ///< No complex type; simple scalar variable.
- IMAGE_SYM_DTYPE_POINTER = 1, ///< A pointer to base type.
- IMAGE_SYM_DTYPE_FUNCTION = 2, ///< A function that returns a base type.
- IMAGE_SYM_DTYPE_ARRAY = 3, ///< An array of base type.
-
- /// Type is formed as (base + (derived << SCT_COMPLEX_TYPE_SHIFT))
- SCT_COMPLEX_TYPE_SHIFT = 4
- };
-
- enum AuxSymbolType {
- IMAGE_AUX_SYMBOL_TYPE_TOKEN_DEF = 1
- };
-
- struct section {
- char Name[NameSize];
- uint32_t VirtualSize;
- uint32_t VirtualAddress;
- uint32_t SizeOfRawData;
- uint32_t PointerToRawData;
- uint32_t PointerToRelocations;
- uint32_t PointerToLineNumbers;
- uint16_t NumberOfRelocations;
- uint16_t NumberOfLineNumbers;
- uint32_t Characteristics;
- };
-
- enum SectionCharacteristics : uint32_t {
- SC_Invalid = 0xffffffff,
-
- IMAGE_SCN_TYPE_NOLOAD = 0x00000002,
- IMAGE_SCN_TYPE_NO_PAD = 0x00000008,
- IMAGE_SCN_CNT_CODE = 0x00000020,
- IMAGE_SCN_CNT_INITIALIZED_DATA = 0x00000040,
- IMAGE_SCN_CNT_UNINITIALIZED_DATA = 0x00000080,
- IMAGE_SCN_LNK_OTHER = 0x00000100,
- IMAGE_SCN_LNK_INFO = 0x00000200,
- IMAGE_SCN_LNK_REMOVE = 0x00000800,
- IMAGE_SCN_LNK_COMDAT = 0x00001000,
- IMAGE_SCN_GPREL = 0x00008000,
- IMAGE_SCN_MEM_PURGEABLE = 0x00020000,
- IMAGE_SCN_MEM_16BIT = 0x00020000,
- IMAGE_SCN_MEM_LOCKED = 0x00040000,
- IMAGE_SCN_MEM_PRELOAD = 0x00080000,
- IMAGE_SCN_ALIGN_1BYTES = 0x00100000,
- IMAGE_SCN_ALIGN_2BYTES = 0x00200000,
- IMAGE_SCN_ALIGN_4BYTES = 0x00300000,
- IMAGE_SCN_ALIGN_8BYTES = 0x00400000,
- IMAGE_SCN_ALIGN_16BYTES = 0x00500000,
- IMAGE_SCN_ALIGN_32BYTES = 0x00600000,
- IMAGE_SCN_ALIGN_64BYTES = 0x00700000,
- IMAGE_SCN_ALIGN_128BYTES = 0x00800000,
- IMAGE_SCN_ALIGN_256BYTES = 0x00900000,
- IMAGE_SCN_ALIGN_512BYTES = 0x00A00000,
- IMAGE_SCN_ALIGN_1024BYTES = 0x00B00000,
- IMAGE_SCN_ALIGN_2048BYTES = 0x00C00000,
- IMAGE_SCN_ALIGN_4096BYTES = 0x00D00000,
- IMAGE_SCN_ALIGN_8192BYTES = 0x00E00000,
- IMAGE_SCN_LNK_NRELOC_OVFL = 0x01000000,
- IMAGE_SCN_MEM_DISCARDABLE = 0x02000000,
- IMAGE_SCN_MEM_NOT_CACHED = 0x04000000,
- IMAGE_SCN_MEM_NOT_PAGED = 0x08000000,
- IMAGE_SCN_MEM_SHARED = 0x10000000,
- IMAGE_SCN_MEM_EXECUTE = 0x20000000,
- IMAGE_SCN_MEM_READ = 0x40000000,
- IMAGE_SCN_MEM_WRITE = 0x80000000
- };
-
- struct relocation {
- uint32_t VirtualAddress;
- uint32_t SymbolTableIndex;
- uint16_t Type;
- };
-
- enum RelocationTypeI386 {
- IMAGE_REL_I386_ABSOLUTE = 0x0000,
- IMAGE_REL_I386_DIR16 = 0x0001,
- IMAGE_REL_I386_REL16 = 0x0002,
- IMAGE_REL_I386_DIR32 = 0x0006,
- IMAGE_REL_I386_DIR32NB = 0x0007,
- IMAGE_REL_I386_SEG12 = 0x0009,
- IMAGE_REL_I386_SECTION = 0x000A,
- IMAGE_REL_I386_SECREL = 0x000B,
- IMAGE_REL_I386_TOKEN = 0x000C,
- IMAGE_REL_I386_SECREL7 = 0x000D,
- IMAGE_REL_I386_REL32 = 0x0014
- };
-
- enum RelocationTypeAMD64 {
- IMAGE_REL_AMD64_ABSOLUTE = 0x0000,
- IMAGE_REL_AMD64_ADDR64 = 0x0001,
- IMAGE_REL_AMD64_ADDR32 = 0x0002,
- IMAGE_REL_AMD64_ADDR32NB = 0x0003,
- IMAGE_REL_AMD64_REL32 = 0x0004,
- IMAGE_REL_AMD64_REL32_1 = 0x0005,
- IMAGE_REL_AMD64_REL32_2 = 0x0006,
- IMAGE_REL_AMD64_REL32_3 = 0x0007,
- IMAGE_REL_AMD64_REL32_4 = 0x0008,
- IMAGE_REL_AMD64_REL32_5 = 0x0009,
- IMAGE_REL_AMD64_SECTION = 0x000A,
- IMAGE_REL_AMD64_SECREL = 0x000B,
- IMAGE_REL_AMD64_SECREL7 = 0x000C,
- IMAGE_REL_AMD64_TOKEN = 0x000D,
- IMAGE_REL_AMD64_SREL32 = 0x000E,
- IMAGE_REL_AMD64_PAIR = 0x000F,
- IMAGE_REL_AMD64_SSPAN32 = 0x0010
- };
-
- enum RelocationTypesARM {
- IMAGE_REL_ARM_ABSOLUTE = 0x0000,
- IMAGE_REL_ARM_ADDR32 = 0x0001,
- IMAGE_REL_ARM_ADDR32NB = 0x0002,
- IMAGE_REL_ARM_BRANCH24 = 0x0003,
- IMAGE_REL_ARM_BRANCH11 = 0x0004,
- IMAGE_REL_ARM_TOKEN = 0x0005,
- IMAGE_REL_ARM_BLX24 = 0x0008,
- IMAGE_REL_ARM_BLX11 = 0x0009,
- IMAGE_REL_ARM_SECTION = 0x000E,
- IMAGE_REL_ARM_SECREL = 0x000F,
- IMAGE_REL_ARM_MOV32A = 0x0010,
- IMAGE_REL_ARM_MOV32T = 0x0011,
- IMAGE_REL_ARM_BRANCH20T = 0x0012,
- IMAGE_REL_ARM_BRANCH24T = 0x0014,
- IMAGE_REL_ARM_BLX23T = 0x0015
- };
-
- enum COMDATType {
- IMAGE_COMDAT_SELECT_NODUPLICATES = 1,
- IMAGE_COMDAT_SELECT_ANY,
- IMAGE_COMDAT_SELECT_SAME_SIZE,
- IMAGE_COMDAT_SELECT_EXACT_MATCH,
- IMAGE_COMDAT_SELECT_ASSOCIATIVE,
- IMAGE_COMDAT_SELECT_LARGEST,
- IMAGE_COMDAT_SELECT_NEWEST
- };
-
- // Auxiliary Symbol Formats
- struct AuxiliaryFunctionDefinition {
- uint32_t TagIndex;
- uint32_t TotalSize;
- uint32_t PointerToLinenumber;
- uint32_t PointerToNextFunction;
- char unused[2];
- };
-
- struct AuxiliarybfAndefSymbol {
- uint8_t unused1[4];
- uint16_t Linenumber;
- uint8_t unused2[6];
- uint32_t PointerToNextFunction;
- uint8_t unused3[2];
- };
-
- struct AuxiliaryWeakExternal {
- uint32_t TagIndex;
- uint32_t Characteristics;
- uint8_t unused[10];
- };
-
- enum WeakExternalCharacteristics {
- IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY = 1,
- IMAGE_WEAK_EXTERN_SEARCH_LIBRARY = 2,
- IMAGE_WEAK_EXTERN_SEARCH_ALIAS = 3
- };
-
- struct AuxiliarySectionDefinition {
- uint32_t Length;
- uint16_t NumberOfRelocations;
- uint16_t NumberOfLinenumbers;
- uint32_t CheckSum;
- uint32_t Number;
- uint8_t Selection;
- char unused;
- };
-
- struct AuxiliaryCLRToken {
- uint8_t AuxType;
- uint8_t unused1;
- uint32_t SymbolTableIndex;
- char unused2[12];
- };
-
- union Auxiliary {
- AuxiliaryFunctionDefinition FunctionDefinition;
- AuxiliarybfAndefSymbol bfAndefSymbol;
- AuxiliaryWeakExternal WeakExternal;
- AuxiliarySectionDefinition SectionDefinition;
- };
-
- /// @brief The Import Directory Table.
- ///
- /// There is a single array of these and one entry per imported DLL.
- struct ImportDirectoryTableEntry {
- uint32_t ImportLookupTableRVA;
- uint32_t TimeDateStamp;
- uint32_t ForwarderChain;
- uint32_t NameRVA;
- uint32_t ImportAddressTableRVA;
- };
-
- /// @brief The PE32 Import Lookup Table.
- ///
- /// There is an array of these for each imported DLL. It represents either
- /// the ordinal to import from the target DLL, or a name to lookup and import
- /// from the target DLL.
- ///
- /// This also happens to be the same format used by the Import Address Table
- /// when it is initially written out to the image.
- struct ImportLookupTableEntry32 {
- uint32_t data;
-
- /// @brief Is this entry specified by ordinal, or name?
- bool isOrdinal() const { return data & 0x80000000; }
-
- /// @brief Get the ordinal value of this entry. isOrdinal must be true.
- uint16_t getOrdinal() const {
- assert(isOrdinal() && "ILT entry is not an ordinal!");
- return data & 0xFFFF;
- }
-
- /// @brief Set the ordinal value and set isOrdinal to true.
- void setOrdinal(uint16_t o) {
- data = o;
- data |= 0x80000000;
- }
-
- /// @brief Get the Hint/Name entry RVA. isOrdinal must be false.
- uint32_t getHintNameRVA() const {
- assert(!isOrdinal() && "ILT entry is not a Hint/Name RVA!");
- return data;
- }
-
- /// @brief Set the Hint/Name entry RVA and set isOrdinal to false.
- void setHintNameRVA(uint32_t rva) { data = rva; }
- };
-
- /// @brief The DOS compatible header at the front of all PEs.
- struct DOSHeader {
- uint16_t Magic;
- uint16_t UsedBytesInTheLastPage;
- uint16_t FileSizeInPages;
- uint16_t NumberOfRelocationItems;
- uint16_t HeaderSizeInParagraphs;
- uint16_t MinimumExtraParagraphs;
- uint16_t MaximumExtraParagraphs;
- uint16_t InitialRelativeSS;
- uint16_t InitialSP;
- uint16_t Checksum;
- uint16_t InitialIP;
- uint16_t InitialRelativeCS;
- uint16_t AddressOfRelocationTable;
- uint16_t OverlayNumber;
- uint16_t Reserved[4];
- uint16_t OEMid;
- uint16_t OEMinfo;
- uint16_t Reserved2[10];
- uint32_t AddressOfNewExeHeader;
- };
-
- struct PE32Header {
- enum {
- PE32 = 0x10b,
- PE32_PLUS = 0x20b
- };
-
- uint16_t Magic;
- uint8_t MajorLinkerVersion;
- uint8_t MinorLinkerVersion;
- uint32_t SizeOfCode;
- uint32_t SizeOfInitializedData;
- uint32_t SizeOfUninitializedData;
- uint32_t AddressOfEntryPoint; // RVA
- uint32_t BaseOfCode; // RVA
- uint32_t BaseOfData; // RVA
- uint32_t ImageBase;
- uint32_t SectionAlignment;
- uint32_t FileAlignment;
- uint16_t MajorOperatingSystemVersion;
- uint16_t MinorOperatingSystemVersion;
- uint16_t MajorImageVersion;
- uint16_t MinorImageVersion;
- uint16_t MajorSubsystemVersion;
- uint16_t MinorSubsystemVersion;
- uint32_t Win32VersionValue;
- uint32_t SizeOfImage;
- uint32_t SizeOfHeaders;
- uint32_t CheckSum;
- uint16_t Subsystem;
- // FIXME: This should be DllCharacteristics to match the COFF spec.
- uint16_t DLLCharacteristics;
- uint32_t SizeOfStackReserve;
- uint32_t SizeOfStackCommit;
- uint32_t SizeOfHeapReserve;
- uint32_t SizeOfHeapCommit;
- uint32_t LoaderFlags;
- // FIXME: This should be NumberOfRvaAndSizes to match the COFF spec.
- uint32_t NumberOfRvaAndSize;
- };
-
- struct DataDirectory {
- uint32_t RelativeVirtualAddress;
- uint32_t Size;
- };
-
- enum DataDirectoryIndex {
- EXPORT_TABLE = 0,
- IMPORT_TABLE,
- RESOURCE_TABLE,
- EXCEPTION_TABLE,
- CERTIFICATE_TABLE,
- BASE_RELOCATION_TABLE,
- DEBUG_DIRECTORY,
- ARCHITECTURE,
- GLOBAL_PTR,
- TLS_TABLE,
- LOAD_CONFIG_TABLE,
- BOUND_IMPORT,
- IAT,
- DELAY_IMPORT_DESCRIPTOR,
- CLR_RUNTIME_HEADER,
-
- NUM_DATA_DIRECTORIES
- };
-
- enum WindowsSubsystem {
- IMAGE_SUBSYSTEM_UNKNOWN = 0, ///< An unknown subsystem.
- IMAGE_SUBSYSTEM_NATIVE = 1, ///< Device drivers and native Windows processes
- IMAGE_SUBSYSTEM_WINDOWS_GUI = 2, ///< The Windows GUI subsystem.
- IMAGE_SUBSYSTEM_WINDOWS_CUI = 3, ///< The Windows character subsystem.
- IMAGE_SUBSYSTEM_OS2_CUI = 5, ///< The OS/2 character subsytem.
- IMAGE_SUBSYSTEM_POSIX_CUI = 7, ///< The POSIX character subsystem.
- IMAGE_SUBSYSTEM_NATIVE_WINDOWS = 8, ///< Native Windows 9x driver.
- IMAGE_SUBSYSTEM_WINDOWS_CE_GUI = 9, ///< Windows CE.
- IMAGE_SUBSYSTEM_EFI_APPLICATION = 10, ///< An EFI application.
- IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER = 11, ///< An EFI driver with boot
- /// services.
- IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER = 12, ///< An EFI driver with run-time
- /// services.
- IMAGE_SUBSYSTEM_EFI_ROM = 13, ///< An EFI ROM image.
- IMAGE_SUBSYSTEM_XBOX = 14, ///< XBOX.
- IMAGE_SUBSYSTEM_WINDOWS_BOOT_APPLICATION = 16 ///< A BCD application.
- };
-
- enum DLLCharacteristics {
- /// ASLR with 64 bit address space.
- IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA = 0x0020,
- /// DLL can be relocated at load time.
- IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE = 0x0040,
- /// Code integrity checks are enforced.
- IMAGE_DLL_CHARACTERISTICS_FORCE_INTEGRITY = 0x0080,
- ///< Image is NX compatible.
- IMAGE_DLL_CHARACTERISTICS_NX_COMPAT = 0x0100,
- /// Isolation aware, but do not isolate the image.
- IMAGE_DLL_CHARACTERISTICS_NO_ISOLATION = 0x0200,
- /// Does not use structured exception handling (SEH). No SEH handler may be
- /// called in this image.
- IMAGE_DLL_CHARACTERISTICS_NO_SEH = 0x0400,
- /// Do not bind the image.
- IMAGE_DLL_CHARACTERISTICS_NO_BIND = 0x0800,
- ///< Image should execute in an AppContainer.
- IMAGE_DLL_CHARACTERISTICS_APPCONTAINER = 0x1000,
- ///< A WDM driver.
- IMAGE_DLL_CHARACTERISTICS_WDM_DRIVER = 0x2000,
- ///< Image supports Control Flow Guard.
- IMAGE_DLL_CHARACTERISTICS_GUARD_CF = 0x4000,
- /// Terminal Server aware.
- IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE = 0x8000
- };
-
- enum DebugType {
- IMAGE_DEBUG_TYPE_UNKNOWN = 0,
- IMAGE_DEBUG_TYPE_COFF = 1,
- IMAGE_DEBUG_TYPE_CODEVIEW = 2,
- IMAGE_DEBUG_TYPE_FPO = 3,
- IMAGE_DEBUG_TYPE_MISC = 4,
- IMAGE_DEBUG_TYPE_EXCEPTION = 5,
- IMAGE_DEBUG_TYPE_FIXUP = 6,
- IMAGE_DEBUG_TYPE_OMAP_TO_SRC = 7,
- IMAGE_DEBUG_TYPE_OMAP_FROM_SRC = 8,
- IMAGE_DEBUG_TYPE_BORLAND = 9,
- IMAGE_DEBUG_TYPE_RESERVED10 = 10,
- IMAGE_DEBUG_TYPE_CLSID = 11,
- IMAGE_DEBUG_TYPE_VC_FEATURE = 12,
- IMAGE_DEBUG_TYPE_POGO = 13,
- IMAGE_DEBUG_TYPE_ILTCG = 14,
- IMAGE_DEBUG_TYPE_MPX = 15,
- IMAGE_DEBUG_TYPE_REPRO = 16,
- };
-
- enum BaseRelocationType {
- IMAGE_REL_BASED_ABSOLUTE = 0,
- IMAGE_REL_BASED_HIGH = 1,
- IMAGE_REL_BASED_LOW = 2,
- IMAGE_REL_BASED_HIGHLOW = 3,
- IMAGE_REL_BASED_HIGHADJ = 4,
- IMAGE_REL_BASED_MIPS_JMPADDR = 5,
- IMAGE_REL_BASED_ARM_MOV32A = 5,
- IMAGE_REL_BASED_ARM_MOV32T = 7,
- IMAGE_REL_BASED_MIPS_JMPADDR16 = 9,
- IMAGE_REL_BASED_DIR64 = 10
- };
-
- enum ImportType {
- IMPORT_CODE = 0,
- IMPORT_DATA = 1,
- IMPORT_CONST = 2
- };
-
- enum ImportNameType {
- /// Import is by ordinal. This indicates that the value in the Ordinal/Hint
- /// field of the import header is the import's ordinal. If this constant is
- /// not specified, then the Ordinal/Hint field should always be interpreted
- /// as the import's hint.
- IMPORT_ORDINAL = 0,
- /// The import name is identical to the public symbol name
- IMPORT_NAME = 1,
- /// The import name is the public symbol name, but skipping the leading ?,
- /// @, or optionally _.
- IMPORT_NAME_NOPREFIX = 2,
- /// The import name is the public symbol name, but skipping the leading ?,
- /// @, or optionally _, and truncating at the first @.
- IMPORT_NAME_UNDECORATE = 3
- };
-
- struct ImportHeader {
- uint16_t Sig1; ///< Must be IMAGE_FILE_MACHINE_UNKNOWN (0).
- uint16_t Sig2; ///< Must be 0xFFFF.
- uint16_t Version;
- uint16_t Machine;
- uint32_t TimeDateStamp;
- uint32_t SizeOfData;
- uint16_t OrdinalHint;
- uint16_t TypeInfo;
-
- ImportType getType() const {
- return static_cast<ImportType>(TypeInfo & 0x3);
- }
-
- ImportNameType getNameType() const {
- return static_cast<ImportNameType>((TypeInfo & 0x1C) >> 2);
- }
- };
-
- enum CodeViewIdentifiers {
- DEBUG_SECTION_MAGIC = 0x4,
- };
-
- inline bool isReservedSectionNumber(int32_t SectionNumber) {
- return SectionNumber <= 0;
- }
-
-} // End namespace COFF.
-} // End namespace llvm.
-
-#endif
diff --git a/contrib/llvm/include/llvm/Support/CachePruning.h b/contrib/llvm/include/llvm/Support/CachePruning.h
index 954fd8a..46e3435 100644
--- a/contrib/llvm/include/llvm/Support/CachePruning.h
+++ b/contrib/llvm/include/llvm/Support/CachePruning.h
@@ -20,51 +20,49 @@
namespace llvm {
-/// Handle pruning a directory provided a path and some options to control what
-/// to prune.
-class CachePruning {
-public:
- /// Prepare to prune \p Path.
- CachePruning(StringRef Path) : Path(Path) {}
+template <typename T> class Expected;
- /// Define the pruning interval. This is intended to be used to avoid scanning
- /// the directory too often. It does not impact the decision of which file to
- /// prune. A value of 0 forces the scan to occurs.
- CachePruning &setPruningInterval(std::chrono::seconds PruningInterval) {
- Interval = PruningInterval;
- return *this;
- }
+/// Policy for the pruneCache() function. A default constructed
+/// CachePruningPolicy provides a reasonable default policy.
+struct CachePruningPolicy {
+ /// The pruning interval. This is intended to be used to avoid scanning the
+ /// directory too often. It does not impact the decision of which file to
+ /// prune. A value of 0 forces the scan to occur.
+ std::chrono::seconds Interval = std::chrono::seconds(1200);
- /// Define the expiration for a file. When a file hasn't been accessed for
- /// \p ExpireAfter seconds, it is removed from the cache. A value of 0 disable
- /// the expiration-based pruning.
- CachePruning &setEntryExpiration(std::chrono::seconds ExpireAfter) {
- Expiration = ExpireAfter;
- return *this;
- }
+ /// The expiration for a file. When a file hasn't been accessed for Expiration
+ /// seconds, it is removed from the cache. A value of 0 disables the
+ /// expiration-based pruning.
+ std::chrono::seconds Expiration = std::chrono::hours(7 * 24); // 1w
- /// Define the maximum size for the cache directory, in terms of percentage of
- /// the available space on the the disk. Set to 100 to indicate no limit, 50
- /// to indicate that the cache size will not be left over half the
- /// available disk space. A value over 100 will be reduced to 100. A value of
- /// 0 disable the size-based pruning.
- CachePruning &setMaxSize(unsigned Percentage) {
- PercentageOfAvailableSpace = std::min(100u, Percentage);
- return *this;
- }
+ /// The maximum size for the cache directory, in terms of percentage of the
+ /// available space on the the disk. Set to 100 to indicate no limit, 50 to
+ /// indicate that the cache size will not be left over half the available disk
+ /// space. A value over 100 will be reduced to 100. A value of 0 disables the
+ /// percentage size-based pruning.
+ unsigned MaxSizePercentageOfAvailableSpace = 75;
- /// Peform pruning using the supplied options, returns true if pruning
- /// occured, i.e. if PruningInterval was expired.
- bool prune();
-
-private:
- // Options that matches the setters above.
- std::string Path;
- std::chrono::seconds Expiration = std::chrono::seconds::zero();
- std::chrono::seconds Interval = std::chrono::seconds::zero();
- unsigned PercentageOfAvailableSpace = 0;
+ /// The maximum size for the cache directory in bytes. A value over the amount
+ /// of available space on the disk will be reduced to the amount of available
+ /// space. A value of 0 disables the absolute size-based pruning.
+ uint64_t MaxSizeBytes = 0;
};
+/// Parse the given string as a cache pruning policy. Defaults are taken from a
+/// default constructed CachePruningPolicy object.
+/// For example: "prune_interval=30s:prune_after=24h:cache_size=50%"
+/// which means a pruning interval of 30 seconds, expiration time of 24 hours
+/// and maximum cache size of 50% of available disk space.
+Expected<CachePruningPolicy> parseCachePruningPolicy(StringRef PolicyStr);
+
+/// Peform pruning using the supplied policy, returns true if pruning
+/// occured, i.e. if Policy.Interval was expired.
+///
+/// As a safeguard against data loss if the user specifies the wrong directory
+/// as their cache directory, this function will ignore files not matching the
+/// pattern "llvmcache-*".
+bool pruneCache(StringRef Path, CachePruningPolicy Policy);
+
} // namespace llvm
#endif
diff --git a/contrib/llvm/include/llvm/Support/Casting.h b/contrib/llvm/include/llvm/Support/Casting.h
index a73047b..baa2a81 100644
--- a/contrib/llvm/include/llvm/Support/Casting.h
+++ b/contrib/llvm/include/llvm/Support/Casting.h
@@ -1,4 +1,4 @@
-//===-- llvm/Support/Casting.h - Allow flexible, checked, casts -*- C++ -*-===//
+//===- llvm/Support/Casting.h - Allow flexible, checked, casts --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -18,6 +18,8 @@
#include "llvm/Support/Compiler.h"
#include "llvm/Support/type_traits.h"
#include <cassert>
+#include <memory>
+#include <type_traits>
namespace llvm {
@@ -30,18 +32,19 @@ namespace llvm {
// template selection process... the default implementation is a noop.
//
template<typename From> struct simplify_type {
- typedef From SimpleType; // The real type this represents...
+ using SimpleType = From; // The real type this represents...
// An accessor to get the real value...
static SimpleType &getSimplifiedValue(From &Val) { return Val; }
};
template<typename From> struct simplify_type<const From> {
- typedef typename simplify_type<From>::SimpleType NonConstSimpleType;
- typedef typename add_const_past_pointer<NonConstSimpleType>::type
- SimpleType;
- typedef typename add_lvalue_reference_if_not_pointer<SimpleType>::type
- RetType;
+ using NonConstSimpleType = typename simplify_type<From>::SimpleType;
+ using SimpleType =
+ typename add_const_past_pointer<NonConstSimpleType>::type;
+ using RetType =
+ typename add_lvalue_reference_if_not_pointer<SimpleType>::type;
+
static RetType getSimplifiedValue(const From& Val) {
return simplify_type<From>::getSimplifiedValue(const_cast<From&>(Val));
}
@@ -76,6 +79,14 @@ template <typename To, typename From> struct isa_impl_cl<To, const From> {
}
};
+template <typename To, typename From>
+struct isa_impl_cl<To, const std::unique_ptr<From>> {
+ static inline bool doit(const std::unique_ptr<From> &Val) {
+ assert(Val && "isa<> used on a null pointer");
+ return isa_impl_cl<To, From>::doit(*Val);
+ }
+};
+
template <typename To, typename From> struct isa_impl_cl<To, From*> {
static inline bool doit(const From *Val) {
assert(Val && "isa<> used on a null pointer");
@@ -139,47 +150,55 @@ template <class X, class Y> LLVM_NODISCARD inline bool isa(const Y &Val) {
template<class To, class From> struct cast_retty;
-
// Calculate what type the 'cast' function should return, based on a requested
// type of To and a source type of From.
template<class To, class From> struct cast_retty_impl {
- typedef To& ret_type; // Normal case, return Ty&
+ using ret_type = To &; // Normal case, return Ty&
};
template<class To, class From> struct cast_retty_impl<To, const From> {
- typedef const To &ret_type; // Normal case, return Ty&
+ using ret_type = const To &; // Normal case, return Ty&
};
template<class To, class From> struct cast_retty_impl<To, From*> {
- typedef To* ret_type; // Pointer arg case, return Ty*
+ using ret_type = To *; // Pointer arg case, return Ty*
};
template<class To, class From> struct cast_retty_impl<To, const From*> {
- typedef const To* ret_type; // Constant pointer arg case, return const Ty*
+ using ret_type = const To *; // Constant pointer arg case, return const Ty*
};
template<class To, class From> struct cast_retty_impl<To, const From*const> {
- typedef const To* ret_type; // Constant pointer arg case, return const Ty*
+ using ret_type = const To *; // Constant pointer arg case, return const Ty*
};
+template <class To, class From>
+struct cast_retty_impl<To, std::unique_ptr<From>> {
+private:
+ using PointerType = typename cast_retty_impl<To, From *>::ret_type;
+ using ResultType = typename std::remove_pointer<PointerType>::type;
+
+public:
+ using ret_type = std::unique_ptr<ResultType>;
+};
template<class To, class From, class SimpleFrom>
struct cast_retty_wrap {
// When the simplified type and the from type are not the same, use the type
// simplifier to reduce the type, then reuse cast_retty_impl to get the
// resultant type.
- typedef typename cast_retty<To, SimpleFrom>::ret_type ret_type;
+ using ret_type = typename cast_retty<To, SimpleFrom>::ret_type;
};
template<class To, class FromTy>
struct cast_retty_wrap<To, FromTy, FromTy> {
// When the simplified type is equal to the from type, use it directly.
- typedef typename cast_retty_impl<To,FromTy>::ret_type ret_type;
+ using ret_type = typename cast_retty_impl<To,FromTy>::ret_type;
};
template<class To, class From>
struct cast_retty {
- typedef typename cast_retty_wrap<To, From,
- typename simplify_type<From>::SimpleType>::ret_type ret_type;
+ using ret_type = typename cast_retty_wrap<
+ To, From, typename simplify_type<From>::SimpleType>::ret_type;
};
// Ensure the non-simple values are converted using the simplify_type template
@@ -238,6 +257,16 @@ inline typename cast_retty<X, Y *>::ret_type cast(Y *Val) {
typename simplify_type<Y*>::SimpleType>::doit(Val);
}
+template <class X, class Y>
+inline typename cast_retty<X, std::unique_ptr<Y>>::ret_type
+cast(std::unique_ptr<Y> &&Val) {
+ assert(isa<X>(Val.get()) && "cast<Ty>() argument of incompatible type!");
+ using ret_type = typename cast_retty<X, std::unique_ptr<Y>>::ret_type;
+ return ret_type(
+ cast_convert_val<X, Y *, typename simplify_type<Y *>::SimpleType>::doit(
+ Val.release()));
+}
+
// cast_or_null<X> - Functionally identical to cast, except that a null value is
// accepted.
//
@@ -271,6 +300,13 @@ cast_or_null(Y *Val) {
return cast<X>(Val);
}
+template <class X, class Y>
+inline typename cast_retty<X, std::unique_ptr<Y>>::ret_type
+cast_or_null(std::unique_ptr<Y> &&Val) {
+ if (!Val)
+ return nullptr;
+ return cast<X>(std::move(Val));
+}
// dyn_cast<X> - Return the argument parameter cast to the specified type. This
// casting operator returns null if the argument is of the wrong type, so it can
@@ -323,6 +359,41 @@ dyn_cast_or_null(Y *Val) {
return (Val && isa<X>(Val)) ? cast<X>(Val) : nullptr;
}
-} // End llvm namespace
+// unique_dyn_cast<X> - Given a unique_ptr<Y>, try to return a unique_ptr<X>,
+// taking ownership of the input pointer iff isa<X>(Val) is true. If the
+// cast is successful, From refers to nullptr on exit and the casted value
+// is returned. If the cast is unsuccessful, the function returns nullptr
+// and From is unchanged.
+template <class X, class Y>
+LLVM_NODISCARD inline auto unique_dyn_cast(std::unique_ptr<Y> &Val)
+ -> decltype(cast<X>(Val)) {
+ if (!isa<X>(Val))
+ return nullptr;
+ return cast<X>(std::move(Val));
+}
+
+template <class X, class Y>
+LLVM_NODISCARD inline auto unique_dyn_cast(std::unique_ptr<Y> &&Val)
+ -> decltype(cast<X>(Val)) {
+ return unique_dyn_cast<X, Y>(Val);
+}
+
+// dyn_cast_or_null<X> - Functionally identical to unique_dyn_cast, except that
+// a null value is accepted.
+template <class X, class Y>
+LLVM_NODISCARD inline auto unique_dyn_cast_or_null(std::unique_ptr<Y> &Val)
+ -> decltype(cast<X>(Val)) {
+ if (!Val)
+ return nullptr;
+ return unique_dyn_cast<X, Y>(Val);
+}
+
+template <class X, class Y>
+LLVM_NODISCARD inline auto unique_dyn_cast_or_null(std::unique_ptr<Y> &&Val)
+ -> decltype(cast<X>(Val)) {
+ return unique_dyn_cast_or_null<X, Y>(Val);
+}
+
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_CASTING_H
diff --git a/contrib/llvm/include/llvm/Support/Chrono.h b/contrib/llvm/include/llvm/Support/Chrono.h
index 203439c..6118ed0 100644
--- a/contrib/llvm/include/llvm/Support/Chrono.h
+++ b/contrib/llvm/include/llvm/Support/Chrono.h
@@ -11,6 +11,7 @@
#define LLVM_SUPPORT_CHRONO_H
#include "llvm/Support/Compiler.h"
+#include "llvm/Support/FormatProviders.h"
#include <chrono>
#include <ctime>
@@ -50,6 +51,100 @@ toTimePoint(std::time_t T) {
raw_ostream &operator<<(raw_ostream &OS, sys::TimePoint<> TP);
+/// Implementation of format_provider<T> for duration types.
+///
+/// The options string of a duration type has the grammar:
+///
+/// duration_options ::= [unit][show_unit [number_options]]
+/// unit ::= `h`|`m`|`s`|`ms|`us`|`ns`
+/// show_unit ::= `+` | `-`
+/// number_options ::= options string for a integral or floating point type
+///
+/// Examples
+/// =================================
+/// | options | Input | Output |
+/// =================================
+/// | "" | 1s | 1 s |
+/// | "ms" | 1s | 1000 ms |
+/// | "ms-" | 1s | 1000 |
+/// | "ms-n" | 1s | 1,000 |
+/// | "" | 1.0s | 1.00 s |
+/// =================================
+///
+/// If the unit of the duration type is not one of the units specified above,
+/// it is still possible to format it, provided you explicitly request a
+/// display unit or you request that the unit is not displayed.
+
+namespace detail {
+template <typename Period> struct unit { static const char value[]; };
+template <typename Period> const char unit<Period>::value[] = "";
+
+template <> struct unit<std::ratio<3600>> { static const char value[]; };
+template <> struct unit<std::ratio<60>> { static const char value[]; };
+template <> struct unit<std::ratio<1>> { static const char value[]; };
+template <> struct unit<std::milli> { static const char value[]; };
+template <> struct unit<std::micro> { static const char value[]; };
+template <> struct unit<std::nano> { static const char value[]; };
+} // namespace detail
+
+template <typename Rep, typename Period>
+struct format_provider<std::chrono::duration<Rep, Period>> {
+private:
+ typedef std::chrono::duration<Rep, Period> Dur;
+ typedef typename std::conditional<
+ std::chrono::treat_as_floating_point<Rep>::value, double, intmax_t>::type
+ InternalRep;
+
+ template <typename AsPeriod> static InternalRep getAs(const Dur &D) {
+ using namespace std::chrono;
+ return duration_cast<duration<InternalRep, AsPeriod>>(D).count();
+ }
+
+ static std::pair<InternalRep, StringRef> consumeUnit(StringRef &Style,
+ const Dur &D) {
+ using namespace std::chrono;
+ if (Style.consume_front("ns"))
+ return {getAs<std::nano>(D), "ns"};
+ if (Style.consume_front("us"))
+ return {getAs<std::micro>(D), "us"};
+ if (Style.consume_front("ms"))
+ return {getAs<std::milli>(D), "ms"};
+ if (Style.consume_front("s"))
+ return {getAs<std::ratio<1>>(D), "s"};
+ if (Style.consume_front("m"))
+ return {getAs<std::ratio<60>>(D), "m"};
+ if (Style.consume_front("h"))
+ return {getAs<std::ratio<3600>>(D), "h"};
+ return {D.count(), detail::unit<Period>::value};
+ }
+
+ static bool consumeShowUnit(StringRef &Style) {
+ if (Style.empty())
+ return true;
+ if (Style.consume_front("-"))
+ return false;
+ if (Style.consume_front("+"))
+ return true;
+ assert(0 && "Unrecognised duration format");
+ return true;
+ }
+
+public:
+ static void format(const Dur &D, llvm::raw_ostream &Stream, StringRef Style) {
+ InternalRep count;
+ StringRef unit;
+ std::tie(count, unit) = consumeUnit(Style, D);
+ bool show_unit = consumeShowUnit(Style);
+
+ format_provider<InternalRep>::format(count, Stream, Style);
+
+ if (show_unit) {
+ assert(!unit.empty());
+ Stream << " " << unit;
+ }
+ }
+};
+
} // namespace llvm
#endif // LLVM_SUPPORT_CHRONO_H
diff --git a/contrib/llvm/include/llvm/Support/CommandLine.h b/contrib/llvm/include/llvm/Support/CommandLine.h
index 8d4ac81..71d2f02 100644
--- a/contrib/llvm/include/llvm/Support/CommandLine.h
+++ b/contrib/llvm/include/llvm/Support/CommandLine.h
@@ -21,18 +21,19 @@
#define LLVM_SUPPORT_COMMANDLINE_H
#include "llvm/ADT/ArrayRef.h"
-#include "llvm/ADT/iterator_range.h"
+#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ManagedStatic.h"
#include <cassert>
#include <climits>
#include <cstddef>
+#include <functional>
#include <initializer_list>
#include <string>
#include <type_traits>
@@ -41,6 +42,7 @@
namespace llvm {
class StringSaver;
+class raw_ostream;
/// cl Namespace - This namespace contains all of the command line option
/// processing machinery. It is intentionally a short name to make qualified
@@ -50,9 +52,12 @@ namespace cl {
//===----------------------------------------------------------------------===//
// ParseCommandLineOptions - Command line option processing entry point.
//
+// Returns true on success. Otherwise, this will print the error message to
+// stderr and exit if \p Errs is not set (nullptr by default), or print the
+// error message to \p Errs and return false if \p Errs is provided.
bool ParseCommandLineOptions(int argc, const char *const *argv,
StringRef Overview = "",
- bool IgnoreErrors = false);
+ raw_ostream *Errs = nullptr);
//===----------------------------------------------------------------------===//
// ParseEnvironmentOptions - Environment variable option processing alternate
@@ -239,7 +244,7 @@ class Option {
// Out of line virtual function to provide home for the class.
virtual void anchor();
- int NumOccurrences; // The number of times specified
+ int NumOccurrences = 0; // The number of times specified
// Occurrences, HiddenFlag, and Formatting are all enum types but to avoid
// problems with signed enums in bitfields.
unsigned Occurrences : 3; // enum NumOccurrencesFlag
@@ -249,8 +254,8 @@ class Option {
unsigned HiddenFlag : 2; // enum OptionHidden
unsigned Formatting : 2; // enum FormattingFlags
unsigned Misc : 3;
- unsigned Position; // Position of last occurrence of the option
- unsigned AdditionalVals; // Greater than 0 for multi-valued option.
+ unsigned Position = 0; // Position of last occurrence of the option
+ unsigned AdditionalVals = 0; // Greater than 0 for multi-valued option.
public:
StringRef ArgStr; // The argument string itself (ex: "help", "o")
@@ -258,7 +263,7 @@ public:
StringRef ValueStr; // String describing what the value of this option is
OptionCategory *Category; // The Category this option belongs to
SmallPtrSet<SubCommand *, 4> Subs; // The subcommands this option belongs to.
- bool FullyInitialized; // Has addArguemnt been called?
+ bool FullyInitialized = false; // Has addArguemnt been called?
inline enum NumOccurrencesFlag getNumOccurrencesFlag() const {
return (enum NumOccurrencesFlag)Occurrences;
@@ -313,10 +318,8 @@ public:
protected:
explicit Option(enum NumOccurrencesFlag OccurrencesFlag,
enum OptionHidden Hidden)
- : NumOccurrences(0), Occurrences(OccurrencesFlag), Value(0),
- HiddenFlag(Hidden), Formatting(NormalFormatting), Misc(0), Position(0),
- AdditionalVals(0), Category(&GeneralCategory), FullyInitialized(false) {
- }
+ : Occurrences(OccurrencesFlag), Value(0), HiddenFlag(Hidden),
+ Formatting(NormalFormatting), Misc(0), Category(&GeneralCategory) {}
inline void setNumAdditionalVals(unsigned n) { AdditionalVals = n; }
@@ -343,6 +346,9 @@ public:
virtual void printOptionValue(size_t GlobalWidth, bool Force) const = 0;
+ static void printHelpStr(StringRef HelpStr, size_t Indent,
+ size_t FirstLineIndentedBy);
+
virtual void getExtraOptionNames(SmallVectorImpl<StringRef> &) {}
// addOccurrence - Wrapper around handleOccurrence that enforces Flags.
@@ -441,8 +447,8 @@ struct GenericOptionValue {
protected:
GenericOptionValue() = default;
GenericOptionValue(const GenericOptionValue&) = default;
- ~GenericOptionValue() = default;
GenericOptionValue &operator=(const GenericOptionValue &) = default;
+ ~GenericOptionValue() = default;
private:
virtual void anchor();
@@ -455,7 +461,7 @@ template <class DataType> struct OptionValue;
template <class DataType, bool isClass>
struct OptionValueBase : public GenericOptionValue {
// Temporary storage for argument passing.
- typedef OptionValue<DataType> WrapperType;
+ using WrapperType = OptionValue<DataType>;
bool hasValue() const { return false; }
@@ -481,8 +487,8 @@ template <class DataType> class OptionValueCopy : public GenericOptionValue {
protected:
OptionValueCopy(const OptionValueCopy&) = default;
+ OptionValueCopy &operator=(const OptionValueCopy &) = default;
~OptionValueCopy() = default;
- OptionValueCopy &operator=(const OptionValueCopy&) = default;
public:
OptionValueCopy() = default;
@@ -513,13 +519,13 @@ public:
// Non-class option values.
template <class DataType>
struct OptionValueBase<DataType, false> : OptionValueCopy<DataType> {
- typedef DataType WrapperType;
+ using WrapperType = DataType;
protected:
OptionValueBase() = default;
OptionValueBase(const OptionValueBase&) = default;
+ OptionValueBase &operator=(const OptionValueBase &) = default;
~OptionValueBase() = default;
- OptionValueBase &operator=(const OptionValueBase&) = default;
};
// Top-level option class.
@@ -542,7 +548,7 @@ enum boolOrDefault { BOU_UNSET, BOU_TRUE, BOU_FALSE };
template <>
struct OptionValue<cl::boolOrDefault> final
: OptionValueCopy<cl::boolOrDefault> {
- typedef cl::boolOrDefault WrapperType;
+ using WrapperType = cl::boolOrDefault;
OptionValue() = default;
@@ -559,7 +565,7 @@ private:
template <>
struct OptionValue<std::string> final : OptionValueCopy<std::string> {
- typedef StringRef WrapperType;
+ using WrapperType = StringRef;
OptionValue() = default;
@@ -730,13 +736,15 @@ protected:
public:
OptionInfo(StringRef name, DataType v, StringRef helpStr)
: GenericOptionInfo(name, helpStr), V(v) {}
+
OptionValue<DataType> V;
};
SmallVector<OptionInfo, 8> Values;
public:
parser(Option &O) : generic_parser_base(O) {}
- typedef DataType parser_data_type;
+
+ using parser_data_type = DataType;
// Implement virtual functions needed by generic_parser_base
unsigned getNumOptions() const override { return unsigned(Values.size()); }
@@ -831,10 +839,10 @@ protected:
//
template <class DataType> class basic_parser : public basic_parser_impl {
public:
- basic_parser(Option &O) : basic_parser_impl(O) {}
+ using parser_data_type = DataType;
+ using OptVal = OptionValue<DataType>;
- typedef DataType parser_data_type;
- typedef OptionValue<DataType> OptVal;
+ basic_parser(Option &O) : basic_parser_impl(O) {}
protected:
~basic_parser() = default;
@@ -1286,6 +1294,7 @@ class opt : public Option,
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
+
void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}
@@ -1294,6 +1303,7 @@ class opt : public Option,
size_t getOptionWidth() const override {
return Parser.getOptionWidth(*this);
}
+
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}
@@ -1378,16 +1388,18 @@ template <class DataType> class list_storage<DataType, bool> {
std::vector<DataType> Storage;
public:
- typedef typename std::vector<DataType>::iterator iterator;
+ using iterator = typename std::vector<DataType>::iterator;
iterator begin() { return Storage.begin(); }
iterator end() { return Storage.end(); }
- typedef typename std::vector<DataType>::const_iterator const_iterator;
+ using const_iterator = typename std::vector<DataType>::const_iterator;
+
const_iterator begin() const { return Storage.begin(); }
const_iterator end() const { return Storage.end(); }
- typedef typename std::vector<DataType>::size_type size_type;
+ using size_type = typename std::vector<DataType>::size_type;
+
size_type size() const { return Storage.size(); }
bool empty() const { return Storage.empty(); }
@@ -1395,8 +1407,9 @@ public:
void push_back(const DataType &value) { Storage.push_back(value); }
void push_back(DataType &&value) { Storage.push_back(value); }
- typedef typename std::vector<DataType>::reference reference;
- typedef typename std::vector<DataType>::const_reference const_reference;
+ using reference = typename std::vector<DataType>::reference;
+ using const_reference = typename std::vector<DataType>::const_reference;
+
reference operator[](size_type pos) { return Storage[pos]; }
const_reference operator[](size_type pos) const { return Storage[pos]; }
@@ -1447,6 +1460,7 @@ class list : public Option, public list_storage<DataType, StorageClass> {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
+
void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}
@@ -1467,6 +1481,7 @@ class list : public Option, public list_storage<DataType, StorageClass> {
size_t getOptionWidth() const override {
return Parser.getOptionWidth(*this);
}
+
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}
@@ -1586,6 +1601,7 @@ class bits : public Option, public bits_storage<DataType, Storage> {
enum ValueExpected getValueExpectedFlagDefault() const override {
return Parser.getValueExpectedFlagDefault();
}
+
void getExtraOptionNames(SmallVectorImpl<StringRef> &OptionNames) override {
return Parser.getExtraOptionNames(OptionNames);
}
@@ -1606,6 +1622,7 @@ class bits : public Option, public bits_storage<DataType, Storage> {
size_t getOptionWidth() const override {
return Parser.getOptionWidth(*this);
}
+
void printOptionInfo(size_t GlobalWidth) const override {
Parser.printOptionInfo(*this, GlobalWidth);
}
@@ -1818,9 +1835,9 @@ void TokenizeWindowsCommandLine(StringRef Source, StringSaver &Saver,
/// \brief String tokenization function type. Should be compatible with either
/// Windows or Unix command line tokenizers.
-typedef void (*TokenizerCallback)(StringRef Source, StringSaver &Saver,
- SmallVectorImpl<const char *> &NewArgv,
- bool MarkEOLs);
+using TokenizerCallback = void (*)(StringRef Source, StringSaver &Saver,
+ SmallVectorImpl<const char *> &NewArgv,
+ bool MarkEOLs);
/// \brief Expand response files on a command line recursively using the given
/// StringSaver and tokenization strategy. Argv should contain the command line
@@ -1874,6 +1891,7 @@ void ResetAllOptionOccurrences();
void ResetCommandLineParser();
} // end namespace cl
+
} // end namespace llvm
#endif // LLVM_SUPPORT_COMMANDLINE_H
diff --git a/contrib/llvm/include/llvm/Support/Compiler.h b/contrib/llvm/include/llvm/Support/Compiler.h
index 55148a4..b19e372 100644
--- a/contrib/llvm/include/llvm/Support/Compiler.h
+++ b/contrib/llvm/include/llvm/Support/Compiler.h
@@ -111,12 +111,6 @@
#define LLVM_PREFETCH(addr, rw, locality)
#endif
-#if __has_attribute(sentinel) || LLVM_GNUC_PREREQ(3, 0, 0)
-#define LLVM_END_WITH_NULL __attribute__((sentinel))
-#else
-#define LLVM_END_WITH_NULL
-#endif
-
#if __has_attribute(used) || LLVM_GNUC_PREREQ(3, 1, 0)
#define LLVM_ATTRIBUTE_USED __attribute__((__used__))
#else
@@ -233,6 +227,8 @@
/// LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
#if __cplusplus > 201402L && __has_cpp_attribute(fallthrough)
#define LLVM_FALLTHROUGH [[fallthrough]]
+#elif __has_cpp_attribute(gnu::fallthrough)
+#define LLVM_FALLTHROUGH [[gnu::fallthrough]]
#elif !__cplusplus
// Workaround for llvm.org/PR23435, since clang 3.6 and below emit a spurious
// error when __has_cpp_attribute is given a scoped attribute in C mode.
@@ -343,7 +339,7 @@
/// int k;
/// long long l;
/// };
-/// LLVM_PACKED_END
+/// LLVM_PACKED_END
#ifdef _MSC_VER
# define LLVM_PACKED(d) __pragma(pack(push, 1)) d __pragma(pack(pop))
# define LLVM_PACKED_START __pragma(pack(push, 1))
@@ -445,6 +441,9 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
/// \brief Mark debug helper function definitions like dump() that should not be
/// stripped from debug builds.
+/// Note that you should also surround dump() functions with
+/// `#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)` so they do always
+/// get stripped in release builds.
// FIXME: Move this to a private config.h as it's not usable in public headers.
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
#define LLVM_DUMP_METHOD LLVM_ATTRIBUTE_NOINLINE LLVM_ATTRIBUTE_USED
@@ -461,7 +460,7 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
#define LLVM_PRETTY_FUNCTION __FUNCSIG__
#elif defined(__GNUC__) || defined(__clang__)
#define LLVM_PRETTY_FUNCTION __PRETTY_FUNCTION__
-#else
+#else
#define LLVM_PRETTY_FUNCTION __func__
#endif
@@ -494,4 +493,14 @@ void AnnotateIgnoreWritesEnd(const char *file, int line);
#define LLVM_THREAD_LOCAL
#endif
+/// \macro LLVM_ENABLE_EXCEPTIONS
+/// \brief Whether LLVM is built with exception support.
+#if __has_feature(cxx_exceptions)
+#define LLVM_ENABLE_EXCEPTIONS 1
+#elif defined(__GNUC__) && defined(__EXCEPTIONS)
+#define LLVM_ENABLE_EXCEPTIONS 1
+#elif defined(_MSC_VER) && defined(_CPPUNWIND)
+#define LLVM_ENABLE_EXCEPTIONS 1
+#endif
+
#endif
diff --git a/contrib/llvm/include/llvm/Support/Compression.h b/contrib/llvm/include/llvm/Support/Compression.h
index 5bf7031..2d191ab 100644
--- a/contrib/llvm/include/llvm/Support/Compression.h
+++ b/contrib/llvm/include/llvm/Support/Compression.h
@@ -18,6 +18,7 @@
namespace llvm {
template <typename T> class SmallVectorImpl;
+class Error;
class StringRef;
namespace zlib {
@@ -29,26 +30,17 @@ enum CompressionLevel {
BestSizeCompression
};
-enum Status {
- StatusOK,
- StatusUnsupported, // zlib is unavailable
- StatusOutOfMemory, // there was not enough memory
- StatusBufferTooShort, // there was not enough room in the output buffer
- StatusInvalidArg, // invalid input parameter
- StatusInvalidData // data was corrupted or incomplete
-};
-
bool isAvailable();
-Status compress(StringRef InputBuffer, SmallVectorImpl<char> &CompressedBuffer,
- CompressionLevel Level = DefaultCompression);
+Error compress(StringRef InputBuffer, SmallVectorImpl<char> &CompressedBuffer,
+ CompressionLevel Level = DefaultCompression);
-Status uncompress(StringRef InputBuffer, char *UncompressedBuffer,
- size_t &UncompressedSize);
+Error uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+ size_t &UncompressedSize);
-Status uncompress(StringRef InputBuffer,
- SmallVectorImpl<char> &UncompressedBuffer,
- size_t UncompressedSize);
+Error uncompress(StringRef InputBuffer,
+ SmallVectorImpl<char> &UncompressedBuffer,
+ size_t UncompressedSize);
uint32_t crc32(StringRef Buffer);
diff --git a/contrib/llvm/include/llvm/Support/ConvertUTF.h b/contrib/llvm/include/llvm/Support/ConvertUTF.h
index f714c0e..bd439f3 100644
--- a/contrib/llvm/include/llvm/Support/ConvertUTF.h
+++ b/contrib/llvm/include/llvm/Support/ConvertUTF.h
@@ -90,8 +90,8 @@
#ifndef LLVM_SUPPORT_CONVERTUTF_H
#define LLVM_SUPPORT_CONVERTUTF_H
-#include <string>
#include <cstddef>
+#include <string>
// Wrap everything in namespace llvm so that programs can link with llvm and
// their own version of the unicode libraries.
diff --git a/contrib/llvm/include/llvm/Support/DataExtractor.h b/contrib/llvm/include/llvm/Support/DataExtractor.h
index 2d1180c..3144788 100644
--- a/contrib/llvm/include/llvm/Support/DataExtractor.h
+++ b/contrib/llvm/include/llvm/Support/DataExtractor.h
@@ -14,6 +14,30 @@
#include "llvm/Support/DataTypes.h"
namespace llvm {
+
+/// An auxiliary type to facilitate extraction of 3-byte entities.
+struct Uint24 {
+ uint8_t Bytes[3];
+ Uint24(uint8_t U) {
+ Bytes[0] = Bytes[1] = Bytes[2] = U;
+ }
+ Uint24(uint8_t U0, uint8_t U1, uint8_t U2) {
+ Bytes[0] = U0; Bytes[1] = U1; Bytes[2] = U2;
+ }
+ uint32_t getAsUint32(bool IsLittleEndian) const {
+ int LoIx = IsLittleEndian ? 0 : 2;
+ return Bytes[LoIx] + (Bytes[1] << 8) + (Bytes[2-LoIx] << 16);
+ }
+};
+
+using uint24_t = Uint24;
+static_assert(sizeof(uint24_t) == 3, "sizeof(uint24_t) != 3");
+
+/// Needed by swapByteOrder().
+inline uint24_t getSwappedBytes(uint24_t C) {
+ return uint24_t(C.Bytes[2], C.Bytes[1], C.Bytes[0]);
+}
+
class DataExtractor {
StringRef Data;
uint8_t IsLittleEndian;
@@ -58,6 +82,28 @@ public:
/// NULL will be returned.
const char *getCStr(uint32_t *offset_ptr) const;
+ /// Extract a C string from \a *OffsetPtr.
+ ///
+ /// Returns a StringRef for the C String from the data at the offset
+ /// pointed to by \a OffsetPtr. A variable length NULL terminated C
+ /// string will be extracted and the \a OffsetPtr will be
+ /// updated with the offset of the byte that follows the NULL
+ /// terminator byte.
+ ///
+ /// \param[in,out] OffsetPtr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the appropriate number of bytes if the value is extracted
+ /// correctly. If the offset is out of bounds or there are not
+ /// enough bytes to extract this value, the offset will be left
+ /// unmodified.
+ ///
+ /// \return
+ /// A StringRef for the C string value in the data. If the offset
+ /// pointed to by \a OffsetPtr is out of bounds, or if the
+ /// offset plus the length of the C string is out of bounds,
+ /// a default-initialized StringRef will be returned.
+ StringRef getCStrRef(uint32_t *OffsetPtr) const;
+
/// Extract an unsigned integer of size \a byte_size from \a
/// *offset_ptr.
///
@@ -214,6 +260,23 @@ public:
/// NULL otherise.
uint16_t *getU16(uint32_t *offset_ptr, uint16_t *dst, uint32_t count) const;
+ /// Extract a 24-bit unsigned value from \a *offset_ptr and return it
+ /// in a uint32_t.
+ ///
+ /// Extract 3 bytes from the binary data at the offset pointed to by
+ /// \a offset_ptr, construct a uint32_t from them and update the offset
+ /// on success.
+ ///
+ /// @param[in,out] offset_ptr
+ /// A pointer to an offset within the data that will be advanced
+ /// by the 3 bytes if the value is extracted correctly. If the offset
+ /// is out of bounds or there are not enough bytes to extract this value,
+ /// the offset will be left unmodified.
+ ///
+ /// @return
+ /// The extracted 24-bit value represented in a uint32_t.
+ uint32_t getU24(uint32_t *offset_ptr) const;
+
/// Extract a uint32_t value from \a *offset_ptr.
///
/// Extract a single uint32_t from the binary data at the offset
diff --git a/contrib/llvm/include/llvm/Support/Debug.h b/contrib/llvm/include/llvm/Support/Debug.h
index 3465c40..48e9e1b 100644
--- a/contrib/llvm/include/llvm/Support/Debug.h
+++ b/contrib/llvm/include/llvm/Support/Debug.h
@@ -33,11 +33,6 @@ namespace llvm {
class raw_ostream;
#ifndef NDEBUG
-/// DebugFlag - This boolean is set to true if the '-debug' command line option
-/// is specified. This should probably not be referenced directly, instead, use
-/// the DEBUG macro below.
-///
-extern bool DebugFlag;
/// isCurrentDebugType - Return true if the specified string is the debug type
/// specified on the command line, or if none was specified on the command line
@@ -77,6 +72,29 @@ void setCurrentDebugTypes(const char **Types, unsigned Count);
#define DEBUG_WITH_TYPE(TYPE, X) do { } while (false)
#endif
+/// This boolean is set to true if the '-debug' command line option
+/// is specified. This should probably not be referenced directly, instead, use
+/// the DEBUG macro below.
+///
+extern bool DebugFlag;
+
+/// \name Verification flags.
+///
+/// These flags turns on/off that are expensive and are turned off by default,
+/// unless macro EXPENSIVE_CHECKS is defined. The flags allow selectively
+/// turning the checks on without need to recompile.
+/// \{
+
+/// Enables verification of dominator trees.
+///
+extern bool VerifyDomInfo;
+
+/// Enables verification of loop info.
+///
+extern bool VerifyLoopInfo;
+
+///\}
+
/// EnableDebugBuffering - This defaults to false. If true, the debug
/// stream will install signal handlers to dump any buffered debug
/// output. It allows clients to selectively allow the debug stream
diff --git a/contrib/llvm/include/llvm/Support/DebugCounter.h b/contrib/llvm/include/llvm/Support/DebugCounter.h
new file mode 100644
index 0000000..a533fea
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/DebugCounter.h
@@ -0,0 +1,165 @@
+//===- llvm/Support/DebugCounter.h - Debug counter support ------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+/// \file
+/// \brief This file provides an implementation of debug counters. Debug
+/// counters are a tool that let you narrow down a miscompilation to a specific
+/// thing happening.
+///
+/// To give a use case: Imagine you have a file, very large, and you
+/// are trying to understand the minimal transformation that breaks it. Bugpoint
+/// and bisection is often helpful here in narrowing it down to a specific pass,
+/// but it's still a very large file, and a very complicated pass to try to
+/// debug. That is where debug counting steps in. You can instrument the pass
+/// with a debug counter before it does a certain thing, and depending on the
+/// counts, it will either execute that thing or not. The debug counter itself
+/// consists of a skip and a count. Skip is the number of times shouldExecute
+/// needs to be called before it returns true. Count is the number of times to
+/// return true once Skip is 0. So a skip=47, count=2 ,would skip the first 47
+/// executions by returning false from shouldExecute, then execute twice, and
+/// then return false again.
+/// Note that a counter set to a negative number will always execute.
+/// For a concrete example, during predicateinfo creation, the renaming pass
+/// replaces each use with a renamed use.
+////
+/// If I use DEBUG_COUNTER to create a counter called "predicateinfo", and
+/// variable name RenameCounter, and then instrument this renaming with a debug
+/// counter, like so:
+///
+/// if (!DebugCounter::shouldExecute(RenameCounter)
+/// <continue or return or whatever not executing looks like>
+///
+/// Now I can, from the command line, make it rename or not rename certain uses
+/// by setting the skip and count.
+/// So for example
+/// bin/opt -debug-counter=predicateinfo-skip=47,predicateinfo-count=1
+/// will skip renaming the first 47 uses, then rename one, then skip the rest.
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_DEBUGCOUNTER_H
+#define LLVM_SUPPORT_DEBUGCOUNTER_H
+
+#include "llvm/ADT/DenseMap.h"
+#include "llvm/ADT/UniqueVector.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/Debug.h"
+#include "llvm/Support/raw_ostream.h"
+#include <string>
+
+namespace llvm {
+
+class DebugCounter {
+public:
+ /// \brief Returns a reference to the singleton instance.
+ static DebugCounter &instance();
+
+ // Used by the command line option parser to push a new value it parsed.
+ void push_back(const std::string &);
+
+ // Register a counter with the specified name.
+ //
+ // FIXME: Currently, counter registration is required to happen before command
+ // line option parsing. The main reason to register counters is to produce a
+ // nice list of them on the command line, but i'm not sure this is worth it.
+ static unsigned registerCounter(StringRef Name, StringRef Desc) {
+ return instance().addCounter(Name, Desc);
+ }
+ inline static bool shouldExecute(unsigned CounterName) {
+// Compile to nothing when debugging is off
+#ifdef NDEBUG
+ return true;
+#else
+ auto &Us = instance();
+ auto Result = Us.Counters.find(CounterName);
+ if (Result != Us.Counters.end()) {
+ auto &CounterPair = Result->second;
+ // We only execute while the skip (first) is zero and the count (second)
+ // is non-zero.
+ // Negative counters always execute.
+ if (CounterPair.first < 0)
+ return true;
+ if (CounterPair.first != 0) {
+ --CounterPair.first;
+ return false;
+ }
+ if (CounterPair.second < 0)
+ return true;
+ if (CounterPair.second != 0) {
+ --CounterPair.second;
+ return true;
+ }
+ return false;
+ }
+ // Didn't find the counter, should we warn?
+ return true;
+#endif // NDEBUG
+ }
+
+ // Return true if a given counter had values set (either programatically or on
+ // the command line). This will return true even if those values are
+ // currently in a state where the counter will always execute.
+ static bool isCounterSet(unsigned ID) {
+ return instance().Counters.count(ID);
+ }
+
+ // Return the skip and count for a counter. This only works for set counters.
+ static std::pair<int, int> getCounterValue(unsigned ID) {
+ auto &Us = instance();
+ auto Result = Us.Counters.find(ID);
+ assert(Result != Us.Counters.end() && "Asking about a non-set counter");
+ return Result->second;
+ }
+
+ // Set a registered counter to a given value.
+ static void setCounterValue(unsigned ID, const std::pair<int, int> &Val) {
+ auto &Us = instance();
+ Us.Counters[ID] = Val;
+ }
+
+ // Dump or print the current counter set into llvm::dbgs().
+ LLVM_DUMP_METHOD void dump() const;
+
+ void print(raw_ostream &OS) const;
+
+ // Get the counter ID for a given named counter, or return 0 if none is found.
+ unsigned getCounterId(const std::string &Name) const {
+ return RegisteredCounters.idFor(Name);
+ }
+
+ // Return the number of registered counters.
+ unsigned int getNumCounters() const { return RegisteredCounters.size(); }
+
+ // Return the name and description of the counter with the given ID.
+ std::pair<std::string, std::string> getCounterInfo(unsigned ID) const {
+ return std::make_pair(RegisteredCounters[ID], CounterDesc.lookup(ID));
+ }
+
+ // Iterate through the registered counters
+ typedef UniqueVector<std::string> CounterVector;
+ CounterVector::const_iterator begin() const {
+ return RegisteredCounters.begin();
+ }
+ CounterVector::const_iterator end() const { return RegisteredCounters.end(); }
+
+private:
+ unsigned addCounter(const std::string &Name, const std::string &Desc) {
+ unsigned Result = RegisteredCounters.insert(Name);
+ CounterDesc[Result] = Desc;
+ return Result;
+ }
+ DenseMap<unsigned, std::pair<long, long>> Counters;
+ DenseMap<unsigned, std::string> CounterDesc;
+ CounterVector RegisteredCounters;
+};
+
+#define DEBUG_COUNTER(VARNAME, COUNTERNAME, DESC) \
+ static const unsigned VARNAME = \
+ DebugCounter::registerCounter(COUNTERNAME, DESC);
+
+} // namespace llvm
+#endif
diff --git a/contrib/llvm/include/llvm/Support/Dwarf.def b/contrib/llvm/include/llvm/Support/Dwarf.def
deleted file mode 100644
index 841fc7d..0000000
--- a/contrib/llvm/include/llvm/Support/Dwarf.def
+++ /dev/null
@@ -1,811 +0,0 @@
-//===- llvm/Support/Dwarf.def - Dwarf definitions ---------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// Macros for running through Dwarf enumerators.
-//
-//===----------------------------------------------------------------------===//
-
-// TODO: Add other DW-based macros.
-#if !(defined HANDLE_DW_TAG || defined HANDLE_DW_AT || \
- defined HANDLE_DW_FORM || defined HANDLE_DW_OP || \
- defined HANDLE_DW_LANG || defined HANDLE_DW_ATE || \
- defined HANDLE_DW_VIRTUALITY || defined HANDLE_DW_DEFAULTED || \
- defined HANDLE_DW_CC || defined HANDLE_DW_LNS || \
- defined HANDLE_DW_LNE || defined HANDLE_DW_LNCT || \
- defined HANDLE_DW_MACRO || defined HANDLE_DW_RLE || \
- defined HANDLE_DW_CFA || defined HANDLE_DW_APPLE_PROPERTY)
-#error "Missing macro definition of HANDLE_DW*"
-#endif
-
-#ifndef HANDLE_DW_TAG
-#define HANDLE_DW_TAG(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_AT
-#define HANDLE_DW_AT(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_FORM
-#define HANDLE_DW_FORM(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_OP
-#define HANDLE_DW_OP(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_LANG
-#define HANDLE_DW_LANG(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_ATE
-#define HANDLE_DW_ATE(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_VIRTUALITY
-#define HANDLE_DW_VIRTUALITY(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_DEFAULTED
-#define HANDLE_DW_DEFAULTED(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_CC
-#define HANDLE_DW_CC(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_LNS
-#define HANDLE_DW_LNS(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_LNE
-#define HANDLE_DW_LNE(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_LNCT
-#define HANDLE_DW_LNCT(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_MACRO
-#define HANDLE_DW_MACRO(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_RLE
-#define HANDLE_DW_RLE(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_CFA
-#define HANDLE_DW_CFA(ID, NAME)
-#endif
-
-#ifndef HANDLE_DW_APPLE_PROPERTY
-#define HANDLE_DW_APPLE_PROPERTY(ID, NAME)
-#endif
-
-HANDLE_DW_TAG(0x0000, null)
-HANDLE_DW_TAG(0x0001, array_type)
-HANDLE_DW_TAG(0x0002, class_type)
-HANDLE_DW_TAG(0x0003, entry_point)
-HANDLE_DW_TAG(0x0004, enumeration_type)
-HANDLE_DW_TAG(0x0005, formal_parameter)
-HANDLE_DW_TAG(0x0008, imported_declaration)
-HANDLE_DW_TAG(0x000a, label)
-HANDLE_DW_TAG(0x000b, lexical_block)
-HANDLE_DW_TAG(0x000d, member)
-HANDLE_DW_TAG(0x000f, pointer_type)
-HANDLE_DW_TAG(0x0010, reference_type)
-HANDLE_DW_TAG(0x0011, compile_unit)
-HANDLE_DW_TAG(0x0012, string_type)
-HANDLE_DW_TAG(0x0013, structure_type)
-HANDLE_DW_TAG(0x0015, subroutine_type)
-HANDLE_DW_TAG(0x0016, typedef)
-HANDLE_DW_TAG(0x0017, union_type)
-HANDLE_DW_TAG(0x0018, unspecified_parameters)
-HANDLE_DW_TAG(0x0019, variant)
-HANDLE_DW_TAG(0x001a, common_block)
-HANDLE_DW_TAG(0x001b, common_inclusion)
-HANDLE_DW_TAG(0x001c, inheritance)
-HANDLE_DW_TAG(0x001d, inlined_subroutine)
-HANDLE_DW_TAG(0x001e, module)
-HANDLE_DW_TAG(0x001f, ptr_to_member_type)
-HANDLE_DW_TAG(0x0020, set_type)
-HANDLE_DW_TAG(0x0021, subrange_type)
-HANDLE_DW_TAG(0x0022, with_stmt)
-HANDLE_DW_TAG(0x0023, access_declaration)
-HANDLE_DW_TAG(0x0024, base_type)
-HANDLE_DW_TAG(0x0025, catch_block)
-HANDLE_DW_TAG(0x0026, const_type)
-HANDLE_DW_TAG(0x0027, constant)
-HANDLE_DW_TAG(0x0028, enumerator)
-HANDLE_DW_TAG(0x0029, file_type)
-HANDLE_DW_TAG(0x002a, friend)
-HANDLE_DW_TAG(0x002b, namelist)
-HANDLE_DW_TAG(0x002c, namelist_item)
-HANDLE_DW_TAG(0x002d, packed_type)
-HANDLE_DW_TAG(0x002e, subprogram)
-HANDLE_DW_TAG(0x002f, template_type_parameter)
-HANDLE_DW_TAG(0x0030, template_value_parameter)
-HANDLE_DW_TAG(0x0031, thrown_type)
-HANDLE_DW_TAG(0x0032, try_block)
-HANDLE_DW_TAG(0x0033, variant_part)
-HANDLE_DW_TAG(0x0034, variable)
-HANDLE_DW_TAG(0x0035, volatile_type)
-HANDLE_DW_TAG(0x0036, dwarf_procedure)
-HANDLE_DW_TAG(0x0037, restrict_type)
-HANDLE_DW_TAG(0x0038, interface_type)
-HANDLE_DW_TAG(0x0039, namespace)
-HANDLE_DW_TAG(0x003a, imported_module)
-HANDLE_DW_TAG(0x003b, unspecified_type)
-HANDLE_DW_TAG(0x003c, partial_unit)
-HANDLE_DW_TAG(0x003d, imported_unit)
-HANDLE_DW_TAG(0x003f, condition)
-HANDLE_DW_TAG(0x0040, shared_type)
-HANDLE_DW_TAG(0x0041, type_unit)
-HANDLE_DW_TAG(0x0042, rvalue_reference_type)
-HANDLE_DW_TAG(0x0043, template_alias)
-
-// New in DWARF v5.
-HANDLE_DW_TAG(0x0044, coarray_type)
-HANDLE_DW_TAG(0x0045, generic_subrange)
-HANDLE_DW_TAG(0x0046, dynamic_type)
-HANDLE_DW_TAG(0x0047, atomic_type)
-HANDLE_DW_TAG(0x0048, call_site)
-HANDLE_DW_TAG(0x0049, call_site_parameter)
-HANDLE_DW_TAG(0x004a, skeleton_unit)
-HANDLE_DW_TAG(0x004b, immutable_type)
-
-// User-defined tags.
-HANDLE_DW_TAG(0x4081, MIPS_loop)
-HANDLE_DW_TAG(0x4101, format_label)
-HANDLE_DW_TAG(0x4102, function_template)
-HANDLE_DW_TAG(0x4103, class_template)
-HANDLE_DW_TAG(0x4106, GNU_template_template_param)
-HANDLE_DW_TAG(0x4107, GNU_template_parameter_pack)
-HANDLE_DW_TAG(0x4108, GNU_formal_parameter_pack)
-HANDLE_DW_TAG(0x4200, APPLE_property)
-HANDLE_DW_TAG(0xb000, BORLAND_property)
-HANDLE_DW_TAG(0xb001, BORLAND_Delphi_string)
-HANDLE_DW_TAG(0xb002, BORLAND_Delphi_dynamic_array)
-HANDLE_DW_TAG(0xb003, BORLAND_Delphi_set)
-HANDLE_DW_TAG(0xb004, BORLAND_Delphi_variant)
-
-// Attributes.
-HANDLE_DW_AT(0x01, sibling)
-HANDLE_DW_AT(0x02, location)
-HANDLE_DW_AT(0x03, name)
-HANDLE_DW_AT(0x09, ordering)
-HANDLE_DW_AT(0x0b, byte_size)
-HANDLE_DW_AT(0x0c, bit_offset)
-HANDLE_DW_AT(0x0d, bit_size)
-HANDLE_DW_AT(0x10, stmt_list)
-HANDLE_DW_AT(0x11, low_pc)
-HANDLE_DW_AT(0x12, high_pc)
-HANDLE_DW_AT(0x13, language)
-HANDLE_DW_AT(0x15, discr)
-HANDLE_DW_AT(0x16, discr_value)
-HANDLE_DW_AT(0x17, visibility)
-HANDLE_DW_AT(0x18, import)
-HANDLE_DW_AT(0x19, string_length)
-HANDLE_DW_AT(0x1a, common_reference)
-HANDLE_DW_AT(0x1b, comp_dir)
-HANDLE_DW_AT(0x1c, const_value)
-HANDLE_DW_AT(0x1d, containing_type)
-HANDLE_DW_AT(0x1e, default_value)
-HANDLE_DW_AT(0x20, inline)
-HANDLE_DW_AT(0x21, is_optional)
-HANDLE_DW_AT(0x22, lower_bound)
-HANDLE_DW_AT(0x25, producer)
-HANDLE_DW_AT(0x27, prototyped)
-HANDLE_DW_AT(0x2a, return_addr)
-HANDLE_DW_AT(0x2c, start_scope)
-HANDLE_DW_AT(0x2e, bit_stride)
-HANDLE_DW_AT(0x2f, upper_bound)
-HANDLE_DW_AT(0x31, abstract_origin)
-HANDLE_DW_AT(0x32, accessibility)
-HANDLE_DW_AT(0x33, address_class)
-HANDLE_DW_AT(0x34, artificial)
-HANDLE_DW_AT(0x35, base_types)
-HANDLE_DW_AT(0x36, calling_convention)
-HANDLE_DW_AT(0x37, count)
-HANDLE_DW_AT(0x38, data_member_location)
-HANDLE_DW_AT(0x39, decl_column)
-HANDLE_DW_AT(0x3a, decl_file)
-HANDLE_DW_AT(0x3b, decl_line)
-HANDLE_DW_AT(0x3c, declaration)
-HANDLE_DW_AT(0x3d, discr_list)
-HANDLE_DW_AT(0x3e, encoding)
-HANDLE_DW_AT(0x3f, external)
-HANDLE_DW_AT(0x40, frame_base)
-HANDLE_DW_AT(0x41, friend)
-HANDLE_DW_AT(0x42, identifier_case)
-HANDLE_DW_AT(0x43, macro_info)
-HANDLE_DW_AT(0x44, namelist_item)
-HANDLE_DW_AT(0x45, priority)
-HANDLE_DW_AT(0x46, segment)
-HANDLE_DW_AT(0x47, specification)
-HANDLE_DW_AT(0x48, static_link)
-HANDLE_DW_AT(0x49, type)
-HANDLE_DW_AT(0x4a, use_location)
-HANDLE_DW_AT(0x4b, variable_parameter)
-HANDLE_DW_AT(0x4c, virtuality)
-HANDLE_DW_AT(0x4d, vtable_elem_location)
-HANDLE_DW_AT(0x4e, allocated)
-HANDLE_DW_AT(0x4f, associated)
-HANDLE_DW_AT(0x50, data_location)
-HANDLE_DW_AT(0x51, byte_stride)
-HANDLE_DW_AT(0x52, entry_pc)
-HANDLE_DW_AT(0x53, use_UTF8)
-HANDLE_DW_AT(0x54, extension)
-HANDLE_DW_AT(0x55, ranges)
-HANDLE_DW_AT(0x56, trampoline)
-HANDLE_DW_AT(0x57, call_column)
-HANDLE_DW_AT(0x58, call_file)
-HANDLE_DW_AT(0x59, call_line)
-HANDLE_DW_AT(0x5a, description)
-HANDLE_DW_AT(0x5b, binary_scale)
-HANDLE_DW_AT(0x5c, decimal_scale)
-HANDLE_DW_AT(0x5d, small)
-HANDLE_DW_AT(0x5e, decimal_sign)
-HANDLE_DW_AT(0x5f, digit_count)
-HANDLE_DW_AT(0x60, picture_string)
-HANDLE_DW_AT(0x61, mutable)
-HANDLE_DW_AT(0x62, threads_scaled)
-HANDLE_DW_AT(0x63, explicit)
-HANDLE_DW_AT(0x64, object_pointer)
-HANDLE_DW_AT(0x65, endianity)
-HANDLE_DW_AT(0x66, elemental)
-HANDLE_DW_AT(0x67, pure)
-HANDLE_DW_AT(0x68, recursive)
-HANDLE_DW_AT(0x69, signature)
-HANDLE_DW_AT(0x6a, main_subprogram)
-HANDLE_DW_AT(0x6b, data_bit_offset)
-HANDLE_DW_AT(0x6c, const_expr)
-HANDLE_DW_AT(0x6d, enum_class)
-HANDLE_DW_AT(0x6e, linkage_name)
-
-// New in DWARF 5:
-HANDLE_DW_AT(0x6f, string_length_bit_size)
-HANDLE_DW_AT(0x70, string_length_byte_size)
-HANDLE_DW_AT(0x71, rank)
-HANDLE_DW_AT(0x72, str_offsets_base)
-HANDLE_DW_AT(0x73, addr_base)
-HANDLE_DW_AT(0x74, rnglists_base)
-HANDLE_DW_AT(0x75, dwo_id) ///< Retracted from DWARF 5.
-HANDLE_DW_AT(0x76, dwo_name)
-HANDLE_DW_AT(0x77, reference)
-HANDLE_DW_AT(0x78, rvalue_reference)
-HANDLE_DW_AT(0x79, macros)
-HANDLE_DW_AT(0x7a, call_all_calls)
-HANDLE_DW_AT(0x7b, call_all_source_calls)
-HANDLE_DW_AT(0x7c, call_all_tail_calls)
-HANDLE_DW_AT(0x7d, call_return_pc)
-HANDLE_DW_AT(0x7e, call_value)
-HANDLE_DW_AT(0x7f, call_origin)
-HANDLE_DW_AT(0x80, call_parameter)
-HANDLE_DW_AT(0x81, call_pc)
-HANDLE_DW_AT(0x82, call_tail_call)
-HANDLE_DW_AT(0x83, call_target)
-HANDLE_DW_AT(0x84, call_target_clobbered)
-HANDLE_DW_AT(0x85, call_data_location)
-HANDLE_DW_AT(0x86, call_data_value)
-HANDLE_DW_AT(0x87, noreturn)
-HANDLE_DW_AT(0x88, alignment)
-HANDLE_DW_AT(0x89, export_symbols)
-HANDLE_DW_AT(0x8a, deleted)
-HANDLE_DW_AT(0x8b, defaulted)
-HANDLE_DW_AT(0x8c, loclists_base)
-
-HANDLE_DW_AT(0x2002, MIPS_loop_begin)
-HANDLE_DW_AT(0x2003, MIPS_tail_loop_begin)
-HANDLE_DW_AT(0x2004, MIPS_epilog_begin)
-HANDLE_DW_AT(0x2005, MIPS_loop_unroll_factor)
-HANDLE_DW_AT(0x2006, MIPS_software_pipeline_depth)
-HANDLE_DW_AT(0x2007, MIPS_linkage_name)
-HANDLE_DW_AT(0x2008, MIPS_stride)
-HANDLE_DW_AT(0x2009, MIPS_abstract_name)
-HANDLE_DW_AT(0x200a, MIPS_clone_origin)
-HANDLE_DW_AT(0x200b, MIPS_has_inlines)
-HANDLE_DW_AT(0x200c, MIPS_stride_byte)
-HANDLE_DW_AT(0x200d, MIPS_stride_elem)
-HANDLE_DW_AT(0x200e, MIPS_ptr_dopetype)
-HANDLE_DW_AT(0x200f, MIPS_allocatable_dopetype)
-HANDLE_DW_AT(0x2010, MIPS_assumed_shape_dopetype)
-
-// This one appears to have only been implemented by Open64 for
-// fortran and may conflict with other extensions.
-HANDLE_DW_AT(0x2011, MIPS_assumed_size)
-
-// GNU extensions
-HANDLE_DW_AT(0x2101, sf_names)
-HANDLE_DW_AT(0x2102, src_info)
-HANDLE_DW_AT(0x2103, mac_info)
-HANDLE_DW_AT(0x2104, src_coords)
-HANDLE_DW_AT(0x2105, body_begin)
-HANDLE_DW_AT(0x2106, body_end)
-HANDLE_DW_AT(0x2107, GNU_vector)
-HANDLE_DW_AT(0x2110, GNU_template_name)
-
-HANDLE_DW_AT(0x210f, GNU_odr_signature)
-HANDLE_DW_AT(0x2119, GNU_macros)
-
-// Extensions for Fission proposal.
-HANDLE_DW_AT(0x2130, GNU_dwo_name)
-HANDLE_DW_AT(0x2131, GNU_dwo_id)
-HANDLE_DW_AT(0x2132, GNU_ranges_base)
-HANDLE_DW_AT(0x2133, GNU_addr_base)
-HANDLE_DW_AT(0x2134, GNU_pubnames)
-HANDLE_DW_AT(0x2135, GNU_pubtypes)
-HANDLE_DW_AT(0x2136, GNU_discriminator)
-
-// Borland extensions.
-HANDLE_DW_AT(0x3b11, BORLAND_property_read)
-HANDLE_DW_AT(0x3b12, BORLAND_property_write)
-HANDLE_DW_AT(0x3b13, BORLAND_property_implements)
-HANDLE_DW_AT(0x3b14, BORLAND_property_index)
-HANDLE_DW_AT(0x3b15, BORLAND_property_default)
-HANDLE_DW_AT(0x3b20, BORLAND_Delphi_unit)
-HANDLE_DW_AT(0x3b21, BORLAND_Delphi_class)
-HANDLE_DW_AT(0x3b22, BORLAND_Delphi_record)
-HANDLE_DW_AT(0x3b23, BORLAND_Delphi_metaclass)
-HANDLE_DW_AT(0x3b24, BORLAND_Delphi_constructor)
-HANDLE_DW_AT(0x3b25, BORLAND_Delphi_destructor)
-HANDLE_DW_AT(0x3b26, BORLAND_Delphi_anonymous_method)
-HANDLE_DW_AT(0x3b27, BORLAND_Delphi_interface)
-HANDLE_DW_AT(0x3b28, BORLAND_Delphi_ABI)
-HANDLE_DW_AT(0x3b29, BORLAND_Delphi_return)
-HANDLE_DW_AT(0x3b30, BORLAND_Delphi_frameptr)
-HANDLE_DW_AT(0x3b31, BORLAND_closure)
-
-// LLVM project extensions.
-HANDLE_DW_AT(0x3e00, LLVM_include_path)
-HANDLE_DW_AT(0x3e01, LLVM_config_macros)
-HANDLE_DW_AT(0x3e02, LLVM_isysroot)
-
-// Apple extensions.
-HANDLE_DW_AT(0x3fe1, APPLE_optimized)
-HANDLE_DW_AT(0x3fe2, APPLE_flags)
-HANDLE_DW_AT(0x3fe3, APPLE_isa)
-HANDLE_DW_AT(0x3fe4, APPLE_block)
-HANDLE_DW_AT(0x3fe5, APPLE_major_runtime_vers)
-HANDLE_DW_AT(0x3fe6, APPLE_runtime_class)
-HANDLE_DW_AT(0x3fe7, APPLE_omit_frame_ptr)
-HANDLE_DW_AT(0x3fe8, APPLE_property_name)
-HANDLE_DW_AT(0x3fe9, APPLE_property_getter)
-HANDLE_DW_AT(0x3fea, APPLE_property_setter)
-HANDLE_DW_AT(0x3feb, APPLE_property_attribute)
-HANDLE_DW_AT(0x3fec, APPLE_objc_complete_type)
-HANDLE_DW_AT(0x3fed, APPLE_property)
-
-// Attribute form encodings.
-HANDLE_DW_FORM(0x01, addr)
-HANDLE_DW_FORM(0x03, block2)
-HANDLE_DW_FORM(0x04, block4)
-HANDLE_DW_FORM(0x05, data2)
-HANDLE_DW_FORM(0x06, data4)
-HANDLE_DW_FORM(0x07, data8)
-HANDLE_DW_FORM(0x08, string)
-HANDLE_DW_FORM(0x09, block)
-HANDLE_DW_FORM(0x0a, block1)
-HANDLE_DW_FORM(0x0b, data1)
-HANDLE_DW_FORM(0x0c, flag)
-HANDLE_DW_FORM(0x0d, sdata)
-HANDLE_DW_FORM(0x0e, strp)
-HANDLE_DW_FORM(0x0f, udata)
-HANDLE_DW_FORM(0x10, ref_addr)
-HANDLE_DW_FORM(0x11, ref1)
-HANDLE_DW_FORM(0x12, ref2)
-HANDLE_DW_FORM(0x13, ref4)
-HANDLE_DW_FORM(0x14, ref8)
-HANDLE_DW_FORM(0x15, ref_udata)
-HANDLE_DW_FORM(0x16, indirect)
-HANDLE_DW_FORM(0x17, sec_offset)
-HANDLE_DW_FORM(0x18, exprloc)
-HANDLE_DW_FORM(0x19, flag_present)
-
-// New in DWARF v5.
-HANDLE_DW_FORM(0x1a, strx)
-HANDLE_DW_FORM(0x1b, addrx)
-HANDLE_DW_FORM(0x1c, ref_sup)
-HANDLE_DW_FORM(0x1d, strp_sup)
-HANDLE_DW_FORM(0x1e, data16)
-HANDLE_DW_FORM(0x1f, line_strp)
-HANDLE_DW_FORM(0x20, ref_sig8)
-HANDLE_DW_FORM(0x21, implicit_const)
-HANDLE_DW_FORM(0x22, loclistx)
-HANDLE_DW_FORM(0x23, rnglistx)
-
-// Extensions for Fission proposal
-HANDLE_DW_FORM(0x1f01, GNU_addr_index)
-HANDLE_DW_FORM(0x1f02, GNU_str_index)
-
-// Alternate debug sections proposal (output of "dwz" tool).
-HANDLE_DW_FORM(0x1f20, GNU_ref_alt)
-HANDLE_DW_FORM(0x1f21, GNU_strp_alt)
-
-// DWARF Expression operators.
-HANDLE_DW_OP(0x03, addr)
-HANDLE_DW_OP(0x06, deref)
-HANDLE_DW_OP(0x08, const1u)
-HANDLE_DW_OP(0x09, const1s)
-HANDLE_DW_OP(0x0a, const2u)
-HANDLE_DW_OP(0x0b, const2s)
-HANDLE_DW_OP(0x0c, const4u)
-HANDLE_DW_OP(0x0d, const4s)
-HANDLE_DW_OP(0x0e, const8u)
-HANDLE_DW_OP(0x0f, const8s)
-HANDLE_DW_OP(0x10, constu)
-HANDLE_DW_OP(0x11, consts)
-HANDLE_DW_OP(0x12, dup)
-HANDLE_DW_OP(0x13, drop)
-HANDLE_DW_OP(0x14, over)
-HANDLE_DW_OP(0x15, pick)
-HANDLE_DW_OP(0x16, swap)
-HANDLE_DW_OP(0x17, rot)
-HANDLE_DW_OP(0x18, xderef)
-HANDLE_DW_OP(0x19, abs)
-HANDLE_DW_OP(0x1a, and)
-HANDLE_DW_OP(0x1b, div)
-HANDLE_DW_OP(0x1c, minus)
-HANDLE_DW_OP(0x1d, mod)
-HANDLE_DW_OP(0x1e, mul)
-HANDLE_DW_OP(0x1f, neg)
-HANDLE_DW_OP(0x20, not)
-HANDLE_DW_OP(0x21, or)
-HANDLE_DW_OP(0x22, plus)
-HANDLE_DW_OP(0x23, plus_uconst)
-HANDLE_DW_OP(0x24, shl)
-HANDLE_DW_OP(0x25, shr)
-HANDLE_DW_OP(0x26, shra)
-HANDLE_DW_OP(0x27, xor)
-HANDLE_DW_OP(0x2f, skip)
-HANDLE_DW_OP(0x28, bra)
-HANDLE_DW_OP(0x29, eq)
-HANDLE_DW_OP(0x2a, ge)
-HANDLE_DW_OP(0x2b, gt)
-HANDLE_DW_OP(0x2c, le)
-HANDLE_DW_OP(0x2d, lt)
-HANDLE_DW_OP(0x2e, ne)
-HANDLE_DW_OP(0x30, lit0)
-HANDLE_DW_OP(0x31, lit1)
-HANDLE_DW_OP(0x32, lit2)
-HANDLE_DW_OP(0x33, lit3)
-HANDLE_DW_OP(0x34, lit4)
-HANDLE_DW_OP(0x35, lit5)
-HANDLE_DW_OP(0x36, lit6)
-HANDLE_DW_OP(0x37, lit7)
-HANDLE_DW_OP(0x38, lit8)
-HANDLE_DW_OP(0x39, lit9)
-HANDLE_DW_OP(0x3a, lit10)
-HANDLE_DW_OP(0x3b, lit11)
-HANDLE_DW_OP(0x3c, lit12)
-HANDLE_DW_OP(0x3d, lit13)
-HANDLE_DW_OP(0x3e, lit14)
-HANDLE_DW_OP(0x3f, lit15)
-HANDLE_DW_OP(0x40, lit16)
-HANDLE_DW_OP(0x41, lit17)
-HANDLE_DW_OP(0x42, lit18)
-HANDLE_DW_OP(0x43, lit19)
-HANDLE_DW_OP(0x44, lit20)
-HANDLE_DW_OP(0x45, lit21)
-HANDLE_DW_OP(0x46, lit22)
-HANDLE_DW_OP(0x47, lit23)
-HANDLE_DW_OP(0x48, lit24)
-HANDLE_DW_OP(0x49, lit25)
-HANDLE_DW_OP(0x4a, lit26)
-HANDLE_DW_OP(0x4b, lit27)
-HANDLE_DW_OP(0x4c, lit28)
-HANDLE_DW_OP(0x4d, lit29)
-HANDLE_DW_OP(0x4e, lit30)
-HANDLE_DW_OP(0x4f, lit31)
-HANDLE_DW_OP(0x50, reg0)
-HANDLE_DW_OP(0x51, reg1)
-HANDLE_DW_OP(0x52, reg2)
-HANDLE_DW_OP(0x53, reg3)
-HANDLE_DW_OP(0x54, reg4)
-HANDLE_DW_OP(0x55, reg5)
-HANDLE_DW_OP(0x56, reg6)
-HANDLE_DW_OP(0x57, reg7)
-HANDLE_DW_OP(0x58, reg8)
-HANDLE_DW_OP(0x59, reg9)
-HANDLE_DW_OP(0x5a, reg10)
-HANDLE_DW_OP(0x5b, reg11)
-HANDLE_DW_OP(0x5c, reg12)
-HANDLE_DW_OP(0x5d, reg13)
-HANDLE_DW_OP(0x5e, reg14)
-HANDLE_DW_OP(0x5f, reg15)
-HANDLE_DW_OP(0x60, reg16)
-HANDLE_DW_OP(0x61, reg17)
-HANDLE_DW_OP(0x62, reg18)
-HANDLE_DW_OP(0x63, reg19)
-HANDLE_DW_OP(0x64, reg20)
-HANDLE_DW_OP(0x65, reg21)
-HANDLE_DW_OP(0x66, reg22)
-HANDLE_DW_OP(0x67, reg23)
-HANDLE_DW_OP(0x68, reg24)
-HANDLE_DW_OP(0x69, reg25)
-HANDLE_DW_OP(0x6a, reg26)
-HANDLE_DW_OP(0x6b, reg27)
-HANDLE_DW_OP(0x6c, reg28)
-HANDLE_DW_OP(0x6d, reg29)
-HANDLE_DW_OP(0x6e, reg30)
-HANDLE_DW_OP(0x6f, reg31)
-HANDLE_DW_OP(0x70, breg0)
-HANDLE_DW_OP(0x71, breg1)
-HANDLE_DW_OP(0x72, breg2)
-HANDLE_DW_OP(0x73, breg3)
-HANDLE_DW_OP(0x74, breg4)
-HANDLE_DW_OP(0x75, breg5)
-HANDLE_DW_OP(0x76, breg6)
-HANDLE_DW_OP(0x77, breg7)
-HANDLE_DW_OP(0x78, breg8)
-HANDLE_DW_OP(0x79, breg9)
-HANDLE_DW_OP(0x7a, breg10)
-HANDLE_DW_OP(0x7b, breg11)
-HANDLE_DW_OP(0x7c, breg12)
-HANDLE_DW_OP(0x7d, breg13)
-HANDLE_DW_OP(0x7e, breg14)
-HANDLE_DW_OP(0x7f, breg15)
-HANDLE_DW_OP(0x80, breg16)
-HANDLE_DW_OP(0x81, breg17)
-HANDLE_DW_OP(0x82, breg18)
-HANDLE_DW_OP(0x83, breg19)
-HANDLE_DW_OP(0x84, breg20)
-HANDLE_DW_OP(0x85, breg21)
-HANDLE_DW_OP(0x86, breg22)
-HANDLE_DW_OP(0x87, breg23)
-HANDLE_DW_OP(0x88, breg24)
-HANDLE_DW_OP(0x89, breg25)
-HANDLE_DW_OP(0x8a, breg26)
-HANDLE_DW_OP(0x8b, breg27)
-HANDLE_DW_OP(0x8c, breg28)
-HANDLE_DW_OP(0x8d, breg29)
-HANDLE_DW_OP(0x8e, breg30)
-HANDLE_DW_OP(0x8f, breg31)
-HANDLE_DW_OP(0x90, regx)
-HANDLE_DW_OP(0x91, fbreg)
-HANDLE_DW_OP(0x92, bregx)
-HANDLE_DW_OP(0x93, piece)
-HANDLE_DW_OP(0x94, deref_size)
-HANDLE_DW_OP(0x95, xderef_size)
-HANDLE_DW_OP(0x96, nop)
-HANDLE_DW_OP(0x97, push_object_address)
-HANDLE_DW_OP(0x98, call2)
-HANDLE_DW_OP(0x99, call4)
-HANDLE_DW_OP(0x9a, call_ref)
-HANDLE_DW_OP(0x9b, form_tls_address)
-HANDLE_DW_OP(0x9c, call_frame_cfa)
-HANDLE_DW_OP(0x9d, bit_piece)
-HANDLE_DW_OP(0x9e, implicit_value)
-HANDLE_DW_OP(0x9f, stack_value)
-HANDLE_DW_OP(0xa0, implicit_pointer)
-HANDLE_DW_OP(0xa1, addrx)
-HANDLE_DW_OP(0xa2, constx)
-HANDLE_DW_OP(0xa3, entry_value)
-HANDLE_DW_OP(0xa4, const_type)
-HANDLE_DW_OP(0xa5, regval_type)
-HANDLE_DW_OP(0xa6, deref_type)
-HANDLE_DW_OP(0xa7, xderef_type)
-HANDLE_DW_OP(0xa8, convert)
-HANDLE_DW_OP(0xa9, reinterpret)
-
-// Vendor extensions.
-// Extensions for GNU-style thread-local storage.
-HANDLE_DW_OP(0xe0, GNU_push_tls_address)
-
-// Extensions for Fission proposal.
-HANDLE_DW_OP(0xfb, GNU_addr_index)
-HANDLE_DW_OP(0xfc, GNU_const_index)
-
-// DWARF languages.
-HANDLE_DW_LANG(0x0001, C89)
-HANDLE_DW_LANG(0x0002, C)
-HANDLE_DW_LANG(0x0003, Ada83)
-HANDLE_DW_LANG(0x0004, C_plus_plus)
-HANDLE_DW_LANG(0x0005, Cobol74)
-HANDLE_DW_LANG(0x0006, Cobol85)
-HANDLE_DW_LANG(0x0007, Fortran77)
-HANDLE_DW_LANG(0x0008, Fortran90)
-HANDLE_DW_LANG(0x0009, Pascal83)
-HANDLE_DW_LANG(0x000a, Modula2)
-HANDLE_DW_LANG(0x000b, Java)
-HANDLE_DW_LANG(0x000c, C99)
-HANDLE_DW_LANG(0x000d, Ada95)
-HANDLE_DW_LANG(0x000e, Fortran95)
-HANDLE_DW_LANG(0x000f, PLI)
-HANDLE_DW_LANG(0x0010, ObjC)
-HANDLE_DW_LANG(0x0011, ObjC_plus_plus)
-HANDLE_DW_LANG(0x0012, UPC)
-HANDLE_DW_LANG(0x0013, D)
-
-// New in DWARF 5:
-HANDLE_DW_LANG(0x0014, Python)
-HANDLE_DW_LANG(0x0015, OpenCL)
-HANDLE_DW_LANG(0x0016, Go)
-HANDLE_DW_LANG(0x0017, Modula3)
-HANDLE_DW_LANG(0x0018, Haskell)
-HANDLE_DW_LANG(0x0019, C_plus_plus_03)
-HANDLE_DW_LANG(0x001a, C_plus_plus_11)
-HANDLE_DW_LANG(0x001b, OCaml)
-HANDLE_DW_LANG(0x001c, Rust)
-HANDLE_DW_LANG(0x001d, C11)
-HANDLE_DW_LANG(0x001e, Swift)
-HANDLE_DW_LANG(0x001f, Julia)
-HANDLE_DW_LANG(0x0020, Dylan)
-HANDLE_DW_LANG(0x0021, C_plus_plus_14)
-HANDLE_DW_LANG(0x0022, Fortran03)
-HANDLE_DW_LANG(0x0023, Fortran08)
-HANDLE_DW_LANG(0x0024, RenderScript)
-
-// Vendor extensions.
-HANDLE_DW_LANG(0x8001, Mips_Assembler)
-HANDLE_DW_LANG(0x8e57, GOOGLE_RenderScript)
-HANDLE_DW_LANG(0xb000, BORLAND_Delphi)
-
-// DWARF attribute type encodings.
-HANDLE_DW_ATE(0x01, address)
-HANDLE_DW_ATE(0x02, boolean)
-HANDLE_DW_ATE(0x03, complex_float)
-HANDLE_DW_ATE(0x04, float)
-HANDLE_DW_ATE(0x05, signed)
-HANDLE_DW_ATE(0x06, signed_char)
-HANDLE_DW_ATE(0x07, unsigned)
-HANDLE_DW_ATE(0x08, unsigned_char)
-HANDLE_DW_ATE(0x09, imaginary_float)
-HANDLE_DW_ATE(0x0a, packed_decimal)
-HANDLE_DW_ATE(0x0b, numeric_string)
-HANDLE_DW_ATE(0x0c, edited)
-HANDLE_DW_ATE(0x0d, signed_fixed)
-HANDLE_DW_ATE(0x0e, unsigned_fixed)
-HANDLE_DW_ATE(0x0f, decimal_float)
-HANDLE_DW_ATE(0x10, UTF)
-HANDLE_DW_ATE(0x11, UCS)
-HANDLE_DW_ATE(0x12, ASCII)
-
-// DWARF virtuality codes.
-HANDLE_DW_VIRTUALITY(0x00, none)
-HANDLE_DW_VIRTUALITY(0x01, virtual)
-HANDLE_DW_VIRTUALITY(0x02, pure_virtual)
-
-// DWARF v5 Defaulted Member Encodings.
-HANDLE_DW_DEFAULTED(0x00, no)
-HANDLE_DW_DEFAULTED(0x01, in_class)
-HANDLE_DW_DEFAULTED(0x02, out_of_class)
-
-// DWARF calling convention codes.
-HANDLE_DW_CC(0x01, normal)
-HANDLE_DW_CC(0x02, program)
-HANDLE_DW_CC(0x03, nocall)
-HANDLE_DW_CC(0x04, pass_by_reference)
-HANDLE_DW_CC(0x05, pass_by_value)
-HANDLE_DW_CC(0x41, GNU_borland_fastcall_i386)
-HANDLE_DW_CC(0xb0, BORLAND_safecall)
-HANDLE_DW_CC(0xb1, BORLAND_stdcall)
-HANDLE_DW_CC(0xb2, BORLAND_pascal)
-HANDLE_DW_CC(0xb3, BORLAND_msfastcall)
-HANDLE_DW_CC(0xb4, BORLAND_msreturn)
-HANDLE_DW_CC(0xb5, BORLAND_thiscall)
-HANDLE_DW_CC(0xb6, BORLAND_fastcall)
-HANDLE_DW_CC(0xc0, LLVM_vectorcall)
-
-// Line Number Extended Opcode Encodings
-HANDLE_DW_LNE(0x01, end_sequence)
-HANDLE_DW_LNE(0x02, set_address)
-HANDLE_DW_LNE(0x03, define_file)
-HANDLE_DW_LNE(0x04, set_discriminator)
-
-// Line Number Standard Opcode Encodings.
-HANDLE_DW_LNS(0x00, extended_op)
-HANDLE_DW_LNS(0x01, copy)
-HANDLE_DW_LNS(0x02, advance_pc)
-HANDLE_DW_LNS(0x03, advance_line)
-HANDLE_DW_LNS(0x04, set_file)
-HANDLE_DW_LNS(0x05, set_column)
-HANDLE_DW_LNS(0x06, negate_stmt)
-HANDLE_DW_LNS(0x07, set_basic_block)
-HANDLE_DW_LNS(0x08, const_add_pc)
-HANDLE_DW_LNS(0x09, fixed_advance_pc)
-HANDLE_DW_LNS(0x0a, set_prologue_end)
-HANDLE_DW_LNS(0x0b, set_epilogue_begin)
-HANDLE_DW_LNS(0x0c, set_isa)
-
-// DWARF v5 Line number header entry format.
-HANDLE_DW_LNCT(0x01, path)
-HANDLE_DW_LNCT(0x02, directory_index)
-HANDLE_DW_LNCT(0x03, timestamp)
-HANDLE_DW_LNCT(0x04, size)
-HANDLE_DW_LNCT(0x05, MD5)
-
-HANDLE_DW_MACRO(0x01, define)
-HANDLE_DW_MACRO(0x02, undef)
-HANDLE_DW_MACRO(0x03, start_file)
-HANDLE_DW_MACRO(0x04, end_file)
-HANDLE_DW_MACRO(0x05, define_strp)
-HANDLE_DW_MACRO(0x06, undef_strp)
-HANDLE_DW_MACRO(0x07, import)
-HANDLE_DW_MACRO(0x08, define_sup)
-HANDLE_DW_MACRO(0x09, undef_sup)
-HANDLE_DW_MACRO(0x0a, import_sup)
-HANDLE_DW_MACRO(0x0b, define_strx)
-HANDLE_DW_MACRO(0x0c, undef_strx)
-
-// Range list entry encoding values.
-HANDLE_DW_RLE(0x00, end_of_list)
-HANDLE_DW_RLE(0x01, base_addressx)
-HANDLE_DW_RLE(0x02, startx_endx)
-HANDLE_DW_RLE(0x03, startx_length)
-HANDLE_DW_RLE(0x04, offset_pair)
-HANDLE_DW_RLE(0x05, base_address)
-HANDLE_DW_RLE(0x06, start_end)
-HANDLE_DW_RLE(0x07, start_length)
-
-// Call frame instruction encodings.
-HANDLE_DW_CFA(0x00, nop)
-HANDLE_DW_CFA(0x40, advance_loc)
-HANDLE_DW_CFA(0x80, offset)
-HANDLE_DW_CFA(0xc0, restore)
-HANDLE_DW_CFA(0x01, set_loc)
-HANDLE_DW_CFA(0x02, advance_loc1)
-HANDLE_DW_CFA(0x03, advance_loc2)
-HANDLE_DW_CFA(0x04, advance_loc4)
-HANDLE_DW_CFA(0x05, offset_extended)
-HANDLE_DW_CFA(0x06, restore_extended)
-HANDLE_DW_CFA(0x07, undefined)
-HANDLE_DW_CFA(0x08, same_value)
-HANDLE_DW_CFA(0x09, register)
-HANDLE_DW_CFA(0x0a, remember_state)
-HANDLE_DW_CFA(0x0b, restore_state)
-HANDLE_DW_CFA(0x0c, def_cfa)
-HANDLE_DW_CFA(0x0d, def_cfa_register)
-HANDLE_DW_CFA(0x0e, def_cfa_offset)
-HANDLE_DW_CFA(0x0f, def_cfa_expression)
-HANDLE_DW_CFA(0x10, expression)
-HANDLE_DW_CFA(0x11, offset_extended_sf)
-HANDLE_DW_CFA(0x12, def_cfa_sf)
-HANDLE_DW_CFA(0x13, def_cfa_offset_sf)
-HANDLE_DW_CFA(0x14, val_offset)
-HANDLE_DW_CFA(0x15, val_offset_sf)
-HANDLE_DW_CFA(0x16, val_expression)
-HANDLE_DW_CFA(0x1d, MIPS_advance_loc8)
-HANDLE_DW_CFA(0x2d, GNU_window_save)
-HANDLE_DW_CFA(0x2e, GNU_args_size)
-
-// Apple Objective-C Property Attributes.
-// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
-HANDLE_DW_APPLE_PROPERTY(0x01, readonly)
-HANDLE_DW_APPLE_PROPERTY(0x02, getter)
-HANDLE_DW_APPLE_PROPERTY(0x04, assign)
-HANDLE_DW_APPLE_PROPERTY(0x08, readwrite)
-HANDLE_DW_APPLE_PROPERTY(0x10, retain)
-HANDLE_DW_APPLE_PROPERTY(0x20, copy)
-HANDLE_DW_APPLE_PROPERTY(0x40, nonatomic)
-HANDLE_DW_APPLE_PROPERTY(0x80, setter)
-HANDLE_DW_APPLE_PROPERTY(0x100, atomic)
-HANDLE_DW_APPLE_PROPERTY(0x200, weak)
-HANDLE_DW_APPLE_PROPERTY(0x400, strong)
-HANDLE_DW_APPLE_PROPERTY(0x800, unsafe_unretained)
-HANDLE_DW_APPLE_PROPERTY(0x1000, nullability)
-HANDLE_DW_APPLE_PROPERTY(0x2000, null_resettable)
-HANDLE_DW_APPLE_PROPERTY(0x4000, class)
-
-
-#undef HANDLE_DW_TAG
-#undef HANDLE_DW_AT
-#undef HANDLE_DW_FORM
-#undef HANDLE_DW_OP
-#undef HANDLE_DW_LANG
-#undef HANDLE_DW_ATE
-#undef HANDLE_DW_VIRTUALITY
-#undef HANDLE_DW_DEFAULTED
-#undef HANDLE_DW_CC
-#undef HANDLE_DW_LNS
-#undef HANDLE_DW_LNE
-#undef HANDLE_DW_LNCT
-#undef HANDLE_DW_MACRO
-#undef HANDLE_DW_RLE
-#undef HANDLE_DW_CFA
-#undef HANDLE_DW_APPLE_PROPERTY
diff --git a/contrib/llvm/include/llvm/Support/Dwarf.h b/contrib/llvm/include/llvm/Support/Dwarf.h
deleted file mode 100644
index 8336b9d..0000000
--- a/contrib/llvm/include/llvm/Support/Dwarf.h
+++ /dev/null
@@ -1,446 +0,0 @@
-//===-- llvm/Support/Dwarf.h ---Dwarf Constants------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// \file
-// \brief This file contains constants used for implementing Dwarf
-// debug support.
-//
-// For details on the Dwarf specfication see the latest DWARF Debugging
-// Information Format standard document on http://www.dwarfstd.org. This
-// file often includes support for non-released standard features.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_DWARF_H
-#define LLVM_SUPPORT_DWARF_H
-
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
-
-namespace llvm {
-class StringRef;
-
-namespace dwarf {
-
-//===----------------------------------------------------------------------===//
-// Dwarf constants as gleaned from the DWARF Debugging Information Format V.4
-// reference manual http://www.dwarfstd.org/.
-//
-
-// Do not mix the following two enumerations sets. DW_TAG_invalid changes the
-// enumeration base type.
-
-enum LLVMConstants : uint32_t {
- // LLVM mock tags (see also llvm/Support/Dwarf.def).
- DW_TAG_invalid = ~0U, // Tag for invalid results.
- DW_VIRTUALITY_invalid = ~0U, // Virtuality for invalid results.
- DW_MACINFO_invalid = ~0U, // Macinfo type for invalid results.
-
- // Other constants.
- DWARF_VERSION = 4, // Default dwarf version we output.
- DW_PUBTYPES_VERSION = 2, // Section version number for .debug_pubtypes.
- DW_PUBNAMES_VERSION = 2, // Section version number for .debug_pubnames.
- DW_ARANGES_VERSION = 2 // Section version number for .debug_aranges.
-};
-
-// Special ID values that distinguish a CIE from a FDE in DWARF CFI.
-// Not inside an enum because a 64-bit value is needed.
-const uint32_t DW_CIE_ID = UINT32_MAX;
-const uint64_t DW64_CIE_ID = UINT64_MAX;
-
-enum Tag : uint16_t {
-#define HANDLE_DW_TAG(ID, NAME) DW_TAG_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_TAG_lo_user = 0x4080,
- DW_TAG_hi_user = 0xffff,
- DW_TAG_user_base = 0x1000 // Recommended base for user tags.
-};
-
-inline bool isType(Tag T) {
- switch (T) {
- case DW_TAG_array_type:
- case DW_TAG_class_type:
- case DW_TAG_interface_type:
- case DW_TAG_enumeration_type:
- case DW_TAG_pointer_type:
- case DW_TAG_reference_type:
- case DW_TAG_rvalue_reference_type:
- case DW_TAG_string_type:
- case DW_TAG_structure_type:
- case DW_TAG_subroutine_type:
- case DW_TAG_union_type:
- case DW_TAG_ptr_to_member_type:
- case DW_TAG_set_type:
- case DW_TAG_subrange_type:
- case DW_TAG_base_type:
- case DW_TAG_const_type:
- case DW_TAG_file_type:
- case DW_TAG_packed_type:
- case DW_TAG_volatile_type:
- case DW_TAG_typedef:
- return true;
- default:
- return false;
- }
-}
-
-/// Attributes.
-enum Attribute : uint16_t {
-#define HANDLE_DW_AT(ID, NAME) DW_AT_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_AT_lo_user = 0x2000,
- DW_AT_hi_user = 0x3fff,
-};
-
-enum Form : uint16_t {
-#define HANDLE_DW_FORM(ID, NAME) DW_FORM_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_FORM_lo_user = 0x1f00, ///< Not specified by DWARF.
-};
-
-enum LocationAtom {
-#define HANDLE_DW_OP(ID, NAME) DW_OP_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_OP_lo_user = 0xe0,
- DW_OP_hi_user = 0xff,
- DW_OP_LLVM_fragment = 0x1000 ///< Only used in LLVM metadata.
-};
-
-enum TypeKind {
-#define HANDLE_DW_ATE(ID, NAME) DW_ATE_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_ATE_lo_user = 0x80,
- DW_ATE_hi_user = 0xff
-};
-
-enum DecimalSignEncoding {
- // Decimal sign attribute values
- DW_DS_unsigned = 0x01,
- DW_DS_leading_overpunch = 0x02,
- DW_DS_trailing_overpunch = 0x03,
- DW_DS_leading_separate = 0x04,
- DW_DS_trailing_separate = 0x05
-};
-
-enum EndianityEncoding {
- // Endianity attribute values
- DW_END_default = 0x00,
- DW_END_big = 0x01,
- DW_END_little = 0x02,
- DW_END_lo_user = 0x40,
- DW_END_hi_user = 0xff
-};
-
-enum AccessAttribute {
- // Accessibility codes
- DW_ACCESS_public = 0x01,
- DW_ACCESS_protected = 0x02,
- DW_ACCESS_private = 0x03
-};
-
-enum VisibilityAttribute {
- // Visibility codes
- DW_VIS_local = 0x01,
- DW_VIS_exported = 0x02,
- DW_VIS_qualified = 0x03
-};
-
-enum VirtualityAttribute {
-#define HANDLE_DW_VIRTUALITY(ID, NAME) DW_VIRTUALITY_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_VIRTUALITY_max = 0x02
-};
-
-enum DefaultedMemberAttribute {
-#define HANDLE_DW_DEFAULTED(ID, NAME) DW_DEFAULTED_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_DEFAULTED_max = 0x02
-};
-
-enum SourceLanguage {
-#define HANDLE_DW_LANG(ID, NAME) DW_LANG_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_LANG_lo_user = 0x8000,
- DW_LANG_hi_user = 0xffff
-};
-
-enum CaseSensitivity {
- // Identifier case codes
- DW_ID_case_sensitive = 0x00,
- DW_ID_up_case = 0x01,
- DW_ID_down_case = 0x02,
- DW_ID_case_insensitive = 0x03
-};
-
-enum CallingConvention {
- // Calling convention codes
-#define HANDLE_DW_CC(ID, NAME) DW_CC_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_CC_lo_user = 0x40,
- DW_CC_hi_user = 0xff
-};
-
-enum InlineAttribute {
- // Inline codes
- DW_INL_not_inlined = 0x00,
- DW_INL_inlined = 0x01,
- DW_INL_declared_not_inlined = 0x02,
- DW_INL_declared_inlined = 0x03
-};
-
-enum ArrayDimensionOrdering {
- // Array ordering
- DW_ORD_row_major = 0x00,
- DW_ORD_col_major = 0x01
-};
-
-enum DiscriminantList {
- // Discriminant descriptor values
- DW_DSC_label = 0x00,
- DW_DSC_range = 0x01
-};
-
-/// Line Number Standard Opcode Encodings.
-enum LineNumberOps : uint8_t {
-#define HANDLE_DW_LNS(ID, NAME) DW_LNS_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
-};
-
-/// Line Number Extended Opcode Encodings.
-enum LineNumberExtendedOps {
-#define HANDLE_DW_LNE(ID, NAME) DW_LNE_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_LNE_lo_user = 0x80,
- DW_LNE_hi_user = 0xff
-};
-
-enum LinerNumberEntryFormat {
-#define HANDLE_DW_LNCT(ID, NAME) DW_DEFAULTED_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_LNCT_lo_user = 0x2000,
- DW_LNCT_hi_user = 0x3fff,
-};
-
-enum MacinfoRecordType {
- // Macinfo Type Encodings
- DW_MACINFO_define = 0x01,
- DW_MACINFO_undef = 0x02,
- DW_MACINFO_start_file = 0x03,
- DW_MACINFO_end_file = 0x04,
- DW_MACINFO_vendor_ext = 0xff
-};
-
-/// DWARF v5 macro information entry type encodings.
-enum MacroEntryType {
-#define HANDLE_DW_MACRO(ID, NAME) DW_MACRO_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_MACRO_lo_user = 0xe0,
- DW_MACRO_hi_user = 0xff
-};
-
-/// DWARF v5 range list entry encoding values.
-enum RangeListEntries {
-#define HANDLE_DW_RLE(ID, NAME) DW_RLE_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
-};
-
-
-/// Call frame instruction encodings.
-enum CallFrameInfo {
-#define HANDLE_DW_CFA(ID, NAME) DW_CFA_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
- DW_CFA_extended = 0x00,
-
- DW_CFA_lo_user = 0x1c,
- DW_CFA_hi_user = 0x3f
-};
-
-enum Constants {
- // Children flag
- DW_CHILDREN_no = 0x00,
- DW_CHILDREN_yes = 0x01,
-
- DW_EH_PE_absptr = 0x00,
- DW_EH_PE_omit = 0xff,
- DW_EH_PE_uleb128 = 0x01,
- DW_EH_PE_udata2 = 0x02,
- DW_EH_PE_udata4 = 0x03,
- DW_EH_PE_udata8 = 0x04,
- DW_EH_PE_sleb128 = 0x09,
- DW_EH_PE_sdata2 = 0x0A,
- DW_EH_PE_sdata4 = 0x0B,
- DW_EH_PE_sdata8 = 0x0C,
- DW_EH_PE_signed = 0x08,
- DW_EH_PE_pcrel = 0x10,
- DW_EH_PE_textrel = 0x20,
- DW_EH_PE_datarel = 0x30,
- DW_EH_PE_funcrel = 0x40,
- DW_EH_PE_aligned = 0x50,
- DW_EH_PE_indirect = 0x80
-};
-
-/// Constants for location lists in DWARF v5.
-enum LocationListEntry : unsigned char {
- DW_LLE_end_of_list = 0x00,
- DW_LLE_base_addressx = 0x01,
- DW_LLE_startx_endx = 0x02,
- DW_LLE_startx_length = 0x03,
- DW_LLE_offset_pair = 0x04,
- DW_LLE_default_location = 0x05,
- DW_LLE_base_address = 0x06,
- DW_LLE_start_end = 0x07,
- DW_LLE_start_length = 0x08
-};
-
-/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
-/// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
-enum ApplePropertyAttributes {
-#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
-#include "llvm/Support/Dwarf.def"
-};
-
-// Constants for the DWARF5 Accelerator Table Proposal
-enum AcceleratorTable {
- // Data layout descriptors.
- DW_ATOM_null = 0u, // Marker as the end of a list of atoms.
- DW_ATOM_die_offset = 1u, // DIE offset in the debug_info section.
- DW_ATOM_cu_offset = 2u, // Offset of the compile unit header that contains the
- // item in question.
- DW_ATOM_die_tag = 3u, // A tag entry.
- DW_ATOM_type_flags = 4u, // Set of flags for a type.
-
- // DW_ATOM_type_flags values.
-
- // Always set for C++, only set for ObjC if this is the @implementation for a
- // class.
- DW_FLAG_type_implementation = 2u,
-
- // Hash functions.
-
- // Daniel J. Bernstein hash.
- DW_hash_function_djb = 0u
-};
-
-// Constants for the GNU pubnames/pubtypes extensions supporting gdb index.
-enum GDBIndexEntryKind {
- GIEK_NONE,
- GIEK_TYPE,
- GIEK_VARIABLE,
- GIEK_FUNCTION,
- GIEK_OTHER,
- GIEK_UNUSED5,
- GIEK_UNUSED6,
- GIEK_UNUSED7
-};
-
-enum GDBIndexEntryLinkage {
- GIEL_EXTERNAL,
- GIEL_STATIC
-};
-
-/// \defgroup DwarfConstantsDumping Dwarf constants dumping functions
-///
-/// All these functions map their argument's value back to the
-/// corresponding enumerator name or return nullptr if the value isn't
-/// known.
-///
-/// @{
-StringRef TagString(unsigned Tag);
-StringRef ChildrenString(unsigned Children);
-StringRef AttributeString(unsigned Attribute);
-StringRef FormEncodingString(unsigned Encoding);
-StringRef OperationEncodingString(unsigned Encoding);
-StringRef AttributeEncodingString(unsigned Encoding);
-StringRef DecimalSignString(unsigned Sign);
-StringRef EndianityString(unsigned Endian);
-StringRef AccessibilityString(unsigned Access);
-StringRef VisibilityString(unsigned Visibility);
-StringRef VirtualityString(unsigned Virtuality);
-StringRef LanguageString(unsigned Language);
-StringRef CaseString(unsigned Case);
-StringRef ConventionString(unsigned Convention);
-StringRef InlineCodeString(unsigned Code);
-StringRef ArrayOrderString(unsigned Order);
-StringRef DiscriminantString(unsigned Discriminant);
-StringRef LNStandardString(unsigned Standard);
-StringRef LNExtendedString(unsigned Encoding);
-StringRef MacinfoString(unsigned Encoding);
-StringRef CallFrameString(unsigned Encoding);
-StringRef ApplePropertyString(unsigned);
-StringRef AtomTypeString(unsigned Atom);
-StringRef GDBIndexEntryKindString(GDBIndexEntryKind Kind);
-StringRef GDBIndexEntryLinkageString(GDBIndexEntryLinkage Linkage);
-/// @}
-
-/// \defgroup DwarfConstantsParsing Dwarf constants parsing functions
-///
-/// These functions map their strings back to the corresponding enumeration
-/// value or return 0 if there is none, except for these exceptions:
-///
-/// \li \a getTag() returns \a DW_TAG_invalid on invalid input.
-/// \li \a getVirtuality() returns \a DW_VIRTUALITY_invalid on invalid input.
-/// \li \a getMacinfo() returns \a DW_MACINFO_invalid on invalid input.
-///
-/// @{
-unsigned getTag(StringRef TagString);
-unsigned getOperationEncoding(StringRef OperationEncodingString);
-unsigned getVirtuality(StringRef VirtualityString);
-unsigned getLanguage(StringRef LanguageString);
-unsigned getCallingConvention(StringRef LanguageString);
-unsigned getAttributeEncoding(StringRef EncodingString);
-unsigned getMacinfo(StringRef MacinfoString);
-/// @}
-
-/// \brief Returns the symbolic string representing Val when used as a value
-/// for attribute Attr.
-StringRef AttributeValueString(uint16_t Attr, unsigned Val);
-
-/// \brief Decsribes an entry of the various gnu_pub* debug sections.
-///
-/// The gnu_pub* kind looks like:
-///
-/// 0-3 reserved
-/// 4-6 symbol kind
-/// 7 0 == global, 1 == static
-///
-/// A gdb_index descriptor includes the above kind, shifted 24 bits up with the
-/// offset of the cu within the debug_info section stored in those 24 bits.
-struct PubIndexEntryDescriptor {
- GDBIndexEntryKind Kind;
- GDBIndexEntryLinkage Linkage;
- PubIndexEntryDescriptor(GDBIndexEntryKind Kind, GDBIndexEntryLinkage Linkage)
- : Kind(Kind), Linkage(Linkage) {}
- /* implicit */ PubIndexEntryDescriptor(GDBIndexEntryKind Kind)
- : Kind(Kind), Linkage(GIEL_EXTERNAL) {}
- explicit PubIndexEntryDescriptor(uint8_t Value)
- : Kind(static_cast<GDBIndexEntryKind>((Value & KIND_MASK) >>
- KIND_OFFSET)),
- Linkage(static_cast<GDBIndexEntryLinkage>((Value & LINKAGE_MASK) >>
- LINKAGE_OFFSET)) {}
- uint8_t toBits() const {
- return Kind << KIND_OFFSET | Linkage << LINKAGE_OFFSET;
- }
-
-private:
- enum {
- KIND_OFFSET = 4,
- KIND_MASK = 7 << KIND_OFFSET,
- LINKAGE_OFFSET = 7,
- LINKAGE_MASK = 1 << LINKAGE_OFFSET
- };
-};
-
-/// Constants that define the DWARF format as 32 or 64 bit.
-enum DwarfFormat { DWARF32, DWARF64 };
-
-} // End of namespace dwarf
-
-} // End of namespace llvm
-
-#endif
diff --git a/contrib/llvm/include/llvm/Support/DynamicLibrary.h b/contrib/llvm/include/llvm/Support/DynamicLibrary.h
index a7d2221..469d5df 100644
--- a/contrib/llvm/include/llvm/Support/DynamicLibrary.h
+++ b/contrib/llvm/include/llvm/Support/DynamicLibrary.h
@@ -58,7 +58,7 @@ namespace sys {
void *getAddressOfSymbol(const char *symbolName);
/// This function permanently loads the dynamic library at the given path.
- /// The library will only be unloaded when the program terminates.
+ /// The library will only be unloaded when llvm_shutdown() is called.
/// This returns a valid DynamicLibrary instance on success and an invalid
/// instance on failure (see isValid()). \p *errMsg will only be modified
/// if the library fails to load.
@@ -68,6 +68,16 @@ namespace sys {
static DynamicLibrary getPermanentLibrary(const char *filename,
std::string *errMsg = nullptr);
+ /// Registers an externally loaded library. The library will be unloaded
+ /// when the program terminates.
+ ///
+ /// It is safe to call this function multiple times for the same library,
+ /// though ownership is only taken if there was no error.
+ ///
+ /// \returns An empty \p DynamicLibrary if the library was already loaded.
+ static DynamicLibrary addPermanentLibrary(void *handle,
+ std::string *errMsg = nullptr);
+
/// This function permanently loads the dynamic library at the given path.
/// Use this instead of getPermanentLibrary() when you won't need to get
/// symbols from the library itself.
@@ -78,6 +88,22 @@ namespace sys {
return !getPermanentLibrary(Filename, ErrMsg).isValid();
}
+ enum SearchOrdering {
+ /// SO_Linker - Search as a call to dlsym(dlopen(NULL)) would when
+ /// DynamicLibrary::getPermanentLibrary(NULL) has been called or
+ /// search the list of explcitly loaded symbols if not.
+ SO_Linker,
+ /// SO_LoadedFirst - Search all loaded libraries, then as SO_Linker would.
+ SO_LoadedFirst,
+ /// SO_LoadedLast - Search as SO_Linker would, then loaded libraries.
+ /// Only useful to search if libraries with RTLD_LOCAL have been added.
+ SO_LoadedLast,
+ /// SO_LoadOrder - Or this in to search libraries in the ordered loaded.
+ /// The default bahaviour is to search loaded libraries in reverse.
+ SO_LoadOrder = 4
+ };
+ static SearchOrdering SearchOrder; // = SO_Linker
+
/// This function will search through all previously loaded dynamic
/// libraries for the symbol \p symbolName. If it is found, the address of
/// that symbol is returned. If not, null is returned. Note that this will
@@ -97,6 +123,8 @@ namespace sys {
/// libraries.
/// @brief Add searchable symbol/value pair.
static void AddSymbol(StringRef symbolName, void *symbolValue);
+
+ class HandleSet;
};
} // End sys namespace
diff --git a/contrib/llvm/include/llvm/Support/ELF.h b/contrib/llvm/include/llvm/Support/ELF.h
deleted file mode 100644
index 3ea4da8..0000000
--- a/contrib/llvm/include/llvm/Support/ELF.h
+++ /dev/null
@@ -1,1359 +0,0 @@
-//===-- llvm/Support/ELF.h - ELF constants and data structures --*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This header contains common, non-processor-specific data structures and
-// constants for the ELF file format.
-//
-// The details of the ELF32 bits in this file are largely based on the Tool
-// Interface Standard (TIS) Executable and Linking Format (ELF) Specification
-// Version 1.2, May 1995. The ELF64 stuff is based on ELF-64 Object File Format
-// Version 1.5, Draft 2, May 1998 as well as OpenBSD header files.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_ELF_H
-#define LLVM_SUPPORT_ELF_H
-
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
-#include <cstring>
-
-namespace llvm {
-
-namespace ELF {
-
-typedef uint32_t Elf32_Addr; // Program address
-typedef uint32_t Elf32_Off; // File offset
-typedef uint16_t Elf32_Half;
-typedef uint32_t Elf32_Word;
-typedef int32_t Elf32_Sword;
-
-typedef uint64_t Elf64_Addr;
-typedef uint64_t Elf64_Off;
-typedef uint16_t Elf64_Half;
-typedef uint32_t Elf64_Word;
-typedef int32_t Elf64_Sword;
-typedef uint64_t Elf64_Xword;
-typedef int64_t Elf64_Sxword;
-
-// Object file magic string.
-static const char ElfMagic[] = {0x7f, 'E', 'L', 'F', '\0'};
-
-// e_ident size and indices.
-enum {
- EI_MAG0 = 0, // File identification index.
- EI_MAG1 = 1, // File identification index.
- EI_MAG2 = 2, // File identification index.
- EI_MAG3 = 3, // File identification index.
- EI_CLASS = 4, // File class.
- EI_DATA = 5, // Data encoding.
- EI_VERSION = 6, // File version.
- EI_OSABI = 7, // OS/ABI identification.
- EI_ABIVERSION = 8, // ABI version.
- EI_PAD = 9, // Start of padding bytes.
- EI_NIDENT = 16 // Number of bytes in e_ident.
-};
-
-struct Elf32_Ehdr {
- unsigned char e_ident[EI_NIDENT]; // ELF Identification bytes
- Elf32_Half e_type; // Type of file (see ET_* below)
- Elf32_Half e_machine; // Required architecture for this file (see EM_*)
- Elf32_Word e_version; // Must be equal to 1
- Elf32_Addr e_entry; // Address to jump to in order to start program
- Elf32_Off e_phoff; // Program header table's file offset, in bytes
- Elf32_Off e_shoff; // Section header table's file offset, in bytes
- Elf32_Word e_flags; // Processor-specific flags
- Elf32_Half e_ehsize; // Size of ELF header, in bytes
- Elf32_Half e_phentsize; // Size of an entry in the program header table
- Elf32_Half e_phnum; // Number of entries in the program header table
- Elf32_Half e_shentsize; // Size of an entry in the section header table
- Elf32_Half e_shnum; // Number of entries in the section header table
- Elf32_Half e_shstrndx; // Sect hdr table index of sect name string table
- bool checkMagic() const {
- return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
- }
- unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
- unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
-};
-
-// 64-bit ELF header. Fields are the same as for ELF32, but with different
-// types (see above).
-struct Elf64_Ehdr {
- unsigned char e_ident[EI_NIDENT];
- Elf64_Half e_type;
- Elf64_Half e_machine;
- Elf64_Word e_version;
- Elf64_Addr e_entry;
- Elf64_Off e_phoff;
- Elf64_Off e_shoff;
- Elf64_Word e_flags;
- Elf64_Half e_ehsize;
- Elf64_Half e_phentsize;
- Elf64_Half e_phnum;
- Elf64_Half e_shentsize;
- Elf64_Half e_shnum;
- Elf64_Half e_shstrndx;
- bool checkMagic() const {
- return (memcmp(e_ident, ElfMagic, strlen(ElfMagic))) == 0;
- }
- unsigned char getFileClass() const { return e_ident[EI_CLASS]; }
- unsigned char getDataEncoding() const { return e_ident[EI_DATA]; }
-};
-
-// File types
-enum {
- ET_NONE = 0, // No file type
- ET_REL = 1, // Relocatable file
- ET_EXEC = 2, // Executable file
- ET_DYN = 3, // Shared object file
- ET_CORE = 4, // Core file
- ET_LOPROC = 0xff00, // Beginning of processor-specific codes
- ET_HIPROC = 0xffff // Processor-specific
-};
-
-// Versioning
-enum { EV_NONE = 0, EV_CURRENT = 1 };
-
-// Machine architectures
-// See current registered ELF machine architectures at:
-// http://www.uxsglobal.com/developers/gabi/latest/ch4.eheader.html
-enum {
- EM_NONE = 0, // No machine
- EM_M32 = 1, // AT&T WE 32100
- EM_SPARC = 2, // SPARC
- EM_386 = 3, // Intel 386
- EM_68K = 4, // Motorola 68000
- EM_88K = 5, // Motorola 88000
- EM_IAMCU = 6, // Intel MCU
- EM_860 = 7, // Intel 80860
- EM_MIPS = 8, // MIPS R3000
- EM_S370 = 9, // IBM System/370
- EM_MIPS_RS3_LE = 10, // MIPS RS3000 Little-endian
- EM_PARISC = 15, // Hewlett-Packard PA-RISC
- EM_VPP500 = 17, // Fujitsu VPP500
- EM_SPARC32PLUS = 18, // Enhanced instruction set SPARC
- EM_960 = 19, // Intel 80960
- EM_PPC = 20, // PowerPC
- EM_PPC64 = 21, // PowerPC64
- EM_S390 = 22, // IBM System/390
- EM_SPU = 23, // IBM SPU/SPC
- EM_V800 = 36, // NEC V800
- EM_FR20 = 37, // Fujitsu FR20
- EM_RH32 = 38, // TRW RH-32
- EM_RCE = 39, // Motorola RCE
- EM_ARM = 40, // ARM
- EM_ALPHA = 41, // DEC Alpha
- EM_SH = 42, // Hitachi SH
- EM_SPARCV9 = 43, // SPARC V9
- EM_TRICORE = 44, // Siemens TriCore
- EM_ARC = 45, // Argonaut RISC Core
- EM_H8_300 = 46, // Hitachi H8/300
- EM_H8_300H = 47, // Hitachi H8/300H
- EM_H8S = 48, // Hitachi H8S
- EM_H8_500 = 49, // Hitachi H8/500
- EM_IA_64 = 50, // Intel IA-64 processor architecture
- EM_MIPS_X = 51, // Stanford MIPS-X
- EM_COLDFIRE = 52, // Motorola ColdFire
- EM_68HC12 = 53, // Motorola M68HC12
- EM_MMA = 54, // Fujitsu MMA Multimedia Accelerator
- EM_PCP = 55, // Siemens PCP
- EM_NCPU = 56, // Sony nCPU embedded RISC processor
- EM_NDR1 = 57, // Denso NDR1 microprocessor
- EM_STARCORE = 58, // Motorola Star*Core processor
- EM_ME16 = 59, // Toyota ME16 processor
- EM_ST100 = 60, // STMicroelectronics ST100 processor
- EM_TINYJ = 61, // Advanced Logic Corp. TinyJ embedded processor family
- EM_X86_64 = 62, // AMD x86-64 architecture
- EM_PDSP = 63, // Sony DSP Processor
- EM_PDP10 = 64, // Digital Equipment Corp. PDP-10
- EM_PDP11 = 65, // Digital Equipment Corp. PDP-11
- EM_FX66 = 66, // Siemens FX66 microcontroller
- EM_ST9PLUS = 67, // STMicroelectronics ST9+ 8/16 bit microcontroller
- EM_ST7 = 68, // STMicroelectronics ST7 8-bit microcontroller
- EM_68HC16 = 69, // Motorola MC68HC16 Microcontroller
- EM_68HC11 = 70, // Motorola MC68HC11 Microcontroller
- EM_68HC08 = 71, // Motorola MC68HC08 Microcontroller
- EM_68HC05 = 72, // Motorola MC68HC05 Microcontroller
- EM_SVX = 73, // Silicon Graphics SVx
- EM_ST19 = 74, // STMicroelectronics ST19 8-bit microcontroller
- EM_VAX = 75, // Digital VAX
- EM_CRIS = 76, // Axis Communications 32-bit embedded processor
- EM_JAVELIN = 77, // Infineon Technologies 32-bit embedded processor
- EM_FIREPATH = 78, // Element 14 64-bit DSP Processor
- EM_ZSP = 79, // LSI Logic 16-bit DSP Processor
- EM_MMIX = 80, // Donald Knuth's educational 64-bit processor
- EM_HUANY = 81, // Harvard University machine-independent object files
- EM_PRISM = 82, // SiTera Prism
- EM_AVR = 83, // Atmel AVR 8-bit microcontroller
- EM_FR30 = 84, // Fujitsu FR30
- EM_D10V = 85, // Mitsubishi D10V
- EM_D30V = 86, // Mitsubishi D30V
- EM_V850 = 87, // NEC v850
- EM_M32R = 88, // Mitsubishi M32R
- EM_MN10300 = 89, // Matsushita MN10300
- EM_MN10200 = 90, // Matsushita MN10200
- EM_PJ = 91, // picoJava
- EM_OPENRISC = 92, // OpenRISC 32-bit embedded processor
- EM_ARC_COMPACT = 93, // ARC International ARCompact processor (old
- // spelling/synonym: EM_ARC_A5)
- EM_XTENSA = 94, // Tensilica Xtensa Architecture
- EM_VIDEOCORE = 95, // Alphamosaic VideoCore processor
- EM_TMM_GPP = 96, // Thompson Multimedia General Purpose Processor
- EM_NS32K = 97, // National Semiconductor 32000 series
- EM_TPC = 98, // Tenor Network TPC processor
- EM_SNP1K = 99, // Trebia SNP 1000 processor
- EM_ST200 = 100, // STMicroelectronics (www.st.com) ST200
- EM_IP2K = 101, // Ubicom IP2xxx microcontroller family
- EM_MAX = 102, // MAX Processor
- EM_CR = 103, // National Semiconductor CompactRISC microprocessor
- EM_F2MC16 = 104, // Fujitsu F2MC16
- EM_MSP430 = 105, // Texas Instruments embedded microcontroller msp430
- EM_BLACKFIN = 106, // Analog Devices Blackfin (DSP) processor
- EM_SE_C33 = 107, // S1C33 Family of Seiko Epson processors
- EM_SEP = 108, // Sharp embedded microprocessor
- EM_ARCA = 109, // Arca RISC Microprocessor
- EM_UNICORE = 110, // Microprocessor series from PKU-Unity Ltd. and MPRC
- // of Peking University
- EM_EXCESS = 111, // eXcess: 16/32/64-bit configurable embedded CPU
- EM_DXP = 112, // Icera Semiconductor Inc. Deep Execution Processor
- EM_ALTERA_NIOS2 = 113, // Altera Nios II soft-core processor
- EM_CRX = 114, // National Semiconductor CompactRISC CRX
- EM_XGATE = 115, // Motorola XGATE embedded processor
- EM_C166 = 116, // Infineon C16x/XC16x processor
- EM_M16C = 117, // Renesas M16C series microprocessors
- EM_DSPIC30F = 118, // Microchip Technology dsPIC30F Digital Signal
- // Controller
- EM_CE = 119, // Freescale Communication Engine RISC core
- EM_M32C = 120, // Renesas M32C series microprocessors
- EM_TSK3000 = 131, // Altium TSK3000 core
- EM_RS08 = 132, // Freescale RS08 embedded processor
- EM_SHARC = 133, // Analog Devices SHARC family of 32-bit DSP
- // processors
- EM_ECOG2 = 134, // Cyan Technology eCOG2 microprocessor
- EM_SCORE7 = 135, // Sunplus S+core7 RISC processor
- EM_DSP24 = 136, // New Japan Radio (NJR) 24-bit DSP Processor
- EM_VIDEOCORE3 = 137, // Broadcom VideoCore III processor
- EM_LATTICEMICO32 = 138, // RISC processor for Lattice FPGA architecture
- EM_SE_C17 = 139, // Seiko Epson C17 family
- EM_TI_C6000 = 140, // The Texas Instruments TMS320C6000 DSP family
- EM_TI_C2000 = 141, // The Texas Instruments TMS320C2000 DSP family
- EM_TI_C5500 = 142, // The Texas Instruments TMS320C55x DSP family
- EM_MMDSP_PLUS = 160, // STMicroelectronics 64bit VLIW Data Signal Processor
- EM_CYPRESS_M8C = 161, // Cypress M8C microprocessor
- EM_R32C = 162, // Renesas R32C series microprocessors
- EM_TRIMEDIA = 163, // NXP Semiconductors TriMedia architecture family
- EM_HEXAGON = 164, // Qualcomm Hexagon processor
- EM_8051 = 165, // Intel 8051 and variants
- EM_STXP7X = 166, // STMicroelectronics STxP7x family of configurable
- // and extensible RISC processors
- EM_NDS32 = 167, // Andes Technology compact code size embedded RISC
- // processor family
- EM_ECOG1 = 168, // Cyan Technology eCOG1X family
- EM_ECOG1X = 168, // Cyan Technology eCOG1X family
- EM_MAXQ30 = 169, // Dallas Semiconductor MAXQ30 Core Micro-controllers
- EM_XIMO16 = 170, // New Japan Radio (NJR) 16-bit DSP Processor
- EM_MANIK = 171, // M2000 Reconfigurable RISC Microprocessor
- EM_CRAYNV2 = 172, // Cray Inc. NV2 vector architecture
- EM_RX = 173, // Renesas RX family
- EM_METAG = 174, // Imagination Technologies META processor
- // architecture
- EM_MCST_ELBRUS = 175, // MCST Elbrus general purpose hardware architecture
- EM_ECOG16 = 176, // Cyan Technology eCOG16 family
- EM_CR16 = 177, // National Semiconductor CompactRISC CR16 16-bit
- // microprocessor
- EM_ETPU = 178, // Freescale Extended Time Processing Unit
- EM_SLE9X = 179, // Infineon Technologies SLE9X core
- EM_L10M = 180, // Intel L10M
- EM_K10M = 181, // Intel K10M
- EM_AARCH64 = 183, // ARM AArch64
- EM_AVR32 = 185, // Atmel Corporation 32-bit microprocessor family
- EM_STM8 = 186, // STMicroeletronics STM8 8-bit microcontroller
- EM_TILE64 = 187, // Tilera TILE64 multicore architecture family
- EM_TILEPRO = 188, // Tilera TILEPro multicore architecture family
- EM_CUDA = 190, // NVIDIA CUDA architecture
- EM_TILEGX = 191, // Tilera TILE-Gx multicore architecture family
- EM_CLOUDSHIELD = 192, // CloudShield architecture family
- EM_COREA_1ST = 193, // KIPO-KAIST Core-A 1st generation processor family
- EM_COREA_2ND = 194, // KIPO-KAIST Core-A 2nd generation processor family
- EM_ARC_COMPACT2 = 195, // Synopsys ARCompact V2
- EM_OPEN8 = 196, // Open8 8-bit RISC soft processor core
- EM_RL78 = 197, // Renesas RL78 family
- EM_VIDEOCORE5 = 198, // Broadcom VideoCore V processor
- EM_78KOR = 199, // Renesas 78KOR family
- EM_56800EX = 200, // Freescale 56800EX Digital Signal Controller (DSC)
- EM_BA1 = 201, // Beyond BA1 CPU architecture
- EM_BA2 = 202, // Beyond BA2 CPU architecture
- EM_XCORE = 203, // XMOS xCORE processor family
- EM_MCHP_PIC = 204, // Microchip 8-bit PIC(r) family
- EM_INTEL205 = 205, // Reserved by Intel
- EM_INTEL206 = 206, // Reserved by Intel
- EM_INTEL207 = 207, // Reserved by Intel
- EM_INTEL208 = 208, // Reserved by Intel
- EM_INTEL209 = 209, // Reserved by Intel
- EM_KM32 = 210, // KM211 KM32 32-bit processor
- EM_KMX32 = 211, // KM211 KMX32 32-bit processor
- EM_KMX16 = 212, // KM211 KMX16 16-bit processor
- EM_KMX8 = 213, // KM211 KMX8 8-bit processor
- EM_KVARC = 214, // KM211 KVARC processor
- EM_CDP = 215, // Paneve CDP architecture family
- EM_COGE = 216, // Cognitive Smart Memory Processor
- EM_COOL = 217, // iCelero CoolEngine
- EM_NORC = 218, // Nanoradio Optimized RISC
- EM_CSR_KALIMBA = 219, // CSR Kalimba architecture family
- EM_AMDGPU = 224, // AMD GPU architecture
- EM_RISCV = 243, // RISC-V
- EM_LANAI = 244, // Lanai 32-bit processor
- EM_BPF = 247, // Linux kernel bpf virtual machine
-
- // A request has been made to the maintainer of the official registry for
- // such numbers for an official value for WebAssembly. As soon as one is
- // allocated, this enum will be updated to use it.
- EM_WEBASSEMBLY = 0x4157, // WebAssembly architecture
-};
-
-// Object file classes.
-enum {
- ELFCLASSNONE = 0,
- ELFCLASS32 = 1, // 32-bit object file
- ELFCLASS64 = 2 // 64-bit object file
-};
-
-// Object file byte orderings.
-enum {
- ELFDATANONE = 0, // Invalid data encoding.
- ELFDATA2LSB = 1, // Little-endian object file
- ELFDATA2MSB = 2 // Big-endian object file
-};
-
-// OS ABI identification.
-enum {
- ELFOSABI_NONE = 0, // UNIX System V ABI
- ELFOSABI_HPUX = 1, // HP-UX operating system
- ELFOSABI_NETBSD = 2, // NetBSD
- ELFOSABI_GNU = 3, // GNU/Linux
- ELFOSABI_LINUX = 3, // Historical alias for ELFOSABI_GNU.
- ELFOSABI_HURD = 4, // GNU/Hurd
- ELFOSABI_SOLARIS = 6, // Solaris
- ELFOSABI_AIX = 7, // AIX
- ELFOSABI_IRIX = 8, // IRIX
- ELFOSABI_FREEBSD = 9, // FreeBSD
- ELFOSABI_TRU64 = 10, // TRU64 UNIX
- ELFOSABI_MODESTO = 11, // Novell Modesto
- ELFOSABI_OPENBSD = 12, // OpenBSD
- ELFOSABI_OPENVMS = 13, // OpenVMS
- ELFOSABI_NSK = 14, // Hewlett-Packard Non-Stop Kernel
- ELFOSABI_AROS = 15, // AROS
- ELFOSABI_FENIXOS = 16, // FenixOS
- ELFOSABI_CLOUDABI = 17, // Nuxi CloudABI
- ELFOSABI_C6000_ELFABI = 64, // Bare-metal TMS320C6000
- ELFOSABI_AMDGPU_HSA = 64, // AMD HSA runtime
- ELFOSABI_C6000_LINUX = 65, // Linux TMS320C6000
- ELFOSABI_ARM = 97, // ARM
- ELFOSABI_STANDALONE = 255 // Standalone (embedded) application
-};
-
-#define ELF_RELOC(name, value) name = value,
-
-// X86_64 relocations.
-enum {
-#include "ELFRelocs/x86_64.def"
-};
-
-// i386 relocations.
-enum {
-#include "ELFRelocs/i386.def"
-};
-
-// ELF Relocation types for PPC32
-enum {
-#include "ELFRelocs/PowerPC.def"
-};
-
-// Specific e_flags for PPC64
-enum {
- // e_flags bits specifying ABI:
- // 1 for original ABI using function descriptors,
- // 2 for revised ABI without function descriptors,
- // 0 for unspecified or not using any features affected by the differences.
- EF_PPC64_ABI = 3
-};
-
-// Special values for the st_other field in the symbol table entry for PPC64.
-enum {
- STO_PPC64_LOCAL_BIT = 5,
- STO_PPC64_LOCAL_MASK = (7 << STO_PPC64_LOCAL_BIT)
-};
-static inline int64_t decodePPC64LocalEntryOffset(unsigned Other) {
- unsigned Val = (Other & STO_PPC64_LOCAL_MASK) >> STO_PPC64_LOCAL_BIT;
- return ((1 << Val) >> 2) << 2;
-}
-static inline unsigned encodePPC64LocalEntryOffset(int64_t Offset) {
- unsigned Val =
- (Offset >= 4 * 4 ? (Offset >= 8 * 4 ? (Offset >= 16 * 4 ? 6 : 5) : 4)
- : (Offset >= 2 * 4 ? 3 : (Offset >= 1 * 4 ? 2 : 0)));
- return Val << STO_PPC64_LOCAL_BIT;
-}
-
-// ELF Relocation types for PPC64
-enum {
-#include "ELFRelocs/PowerPC64.def"
-};
-
-// ELF Relocation types for AArch64
-enum {
-#include "ELFRelocs/AArch64.def"
-};
-
-// ARM Specific e_flags
-enum : unsigned {
- EF_ARM_SOFT_FLOAT = 0x00000200U,
- EF_ARM_VFP_FLOAT = 0x00000400U,
- EF_ARM_EABI_UNKNOWN = 0x00000000U,
- EF_ARM_EABI_VER1 = 0x01000000U,
- EF_ARM_EABI_VER2 = 0x02000000U,
- EF_ARM_EABI_VER3 = 0x03000000U,
- EF_ARM_EABI_VER4 = 0x04000000U,
- EF_ARM_EABI_VER5 = 0x05000000U,
- EF_ARM_EABIMASK = 0xFF000000U
-};
-
-// ELF Relocation types for ARM
-enum {
-#include "ELFRelocs/ARM.def"
-};
-
-// AVR specific e_flags
-enum : unsigned {
- EF_AVR_ARCH_AVR1 = 1,
- EF_AVR_ARCH_AVR2 = 2,
- EF_AVR_ARCH_AVR25 = 25,
- EF_AVR_ARCH_AVR3 = 3,
- EF_AVR_ARCH_AVR31 = 31,
- EF_AVR_ARCH_AVR35 = 35,
- EF_AVR_ARCH_AVR4 = 4,
- EF_AVR_ARCH_AVR5 = 5,
- EF_AVR_ARCH_AVR51 = 51,
- EF_AVR_ARCH_AVR6 = 6,
- EF_AVR_ARCH_AVRTINY = 100,
- EF_AVR_ARCH_XMEGA1 = 101,
- EF_AVR_ARCH_XMEGA2 = 102,
- EF_AVR_ARCH_XMEGA3 = 103,
- EF_AVR_ARCH_XMEGA4 = 104,
- EF_AVR_ARCH_XMEGA5 = 105,
- EF_AVR_ARCH_XMEGA6 = 106,
- EF_AVR_ARCH_XMEGA7 = 107
-};
-
-// ELF Relocation types for AVR
-enum {
-#include "ELFRelocs/AVR.def"
-};
-
-// Mips Specific e_flags
-enum : unsigned {
- EF_MIPS_NOREORDER = 0x00000001, // Don't reorder instructions
- EF_MIPS_PIC = 0x00000002, // Position independent code
- EF_MIPS_CPIC = 0x00000004, // Call object with Position independent code
- EF_MIPS_ABI2 = 0x00000020, // File uses N32 ABI
- EF_MIPS_32BITMODE = 0x00000100, // Code compiled for a 64-bit machine
- // in 32-bit mode
- EF_MIPS_FP64 = 0x00000200, // Code compiled for a 32-bit machine
- // but uses 64-bit FP registers
- EF_MIPS_NAN2008 = 0x00000400, // Uses IEE 754-2008 NaN encoding
-
- // ABI flags
- EF_MIPS_ABI_O32 = 0x00001000, // This file follows the first MIPS 32 bit ABI
- EF_MIPS_ABI_O64 = 0x00002000, // O32 ABI extended for 64-bit architecture.
- EF_MIPS_ABI_EABI32 = 0x00003000, // EABI in 32 bit mode.
- EF_MIPS_ABI_EABI64 = 0x00004000, // EABI in 64 bit mode.
- EF_MIPS_ABI = 0x0000f000, // Mask for selecting EF_MIPS_ABI_ variant.
-
- // MIPS machine variant
- EF_MIPS_MACH_NONE = 0x00000000, // A standard MIPS implementation.
- EF_MIPS_MACH_3900 = 0x00810000, // Toshiba R3900
- EF_MIPS_MACH_4010 = 0x00820000, // LSI R4010
- EF_MIPS_MACH_4100 = 0x00830000, // NEC VR4100
- EF_MIPS_MACH_4650 = 0x00850000, // MIPS R4650
- EF_MIPS_MACH_4120 = 0x00870000, // NEC VR4120
- EF_MIPS_MACH_4111 = 0x00880000, // NEC VR4111/VR4181
- EF_MIPS_MACH_SB1 = 0x008a0000, // Broadcom SB-1
- EF_MIPS_MACH_OCTEON = 0x008b0000, // Cavium Networks Octeon
- EF_MIPS_MACH_XLR = 0x008c0000, // RMI Xlr
- EF_MIPS_MACH_OCTEON2 = 0x008d0000, // Cavium Networks Octeon2
- EF_MIPS_MACH_OCTEON3 = 0x008e0000, // Cavium Networks Octeon3
- EF_MIPS_MACH_5400 = 0x00910000, // NEC VR5400
- EF_MIPS_MACH_5900 = 0x00920000, // MIPS R5900
- EF_MIPS_MACH_5500 = 0x00980000, // NEC VR5500
- EF_MIPS_MACH_9000 = 0x00990000, // Unknown
- EF_MIPS_MACH_LS2E = 0x00a00000, // ST Microelectronics Loongson 2E
- EF_MIPS_MACH_LS2F = 0x00a10000, // ST Microelectronics Loongson 2F
- EF_MIPS_MACH_LS3A = 0x00a20000, // Loongson 3A
- EF_MIPS_MACH = 0x00ff0000, // EF_MIPS_MACH_xxx selection mask
-
- // ARCH_ASE
- EF_MIPS_MICROMIPS = 0x02000000, // microMIPS
- EF_MIPS_ARCH_ASE_M16 = 0x04000000, // Has Mips-16 ISA extensions
- EF_MIPS_ARCH_ASE_MDMX = 0x08000000, // Has MDMX multimedia extensions
- EF_MIPS_ARCH_ASE = 0x0f000000, // Mask for EF_MIPS_ARCH_ASE_xxx flags
-
- // ARCH
- EF_MIPS_ARCH_1 = 0x00000000, // MIPS1 instruction set
- EF_MIPS_ARCH_2 = 0x10000000, // MIPS2 instruction set
- EF_MIPS_ARCH_3 = 0x20000000, // MIPS3 instruction set
- EF_MIPS_ARCH_4 = 0x30000000, // MIPS4 instruction set
- EF_MIPS_ARCH_5 = 0x40000000, // MIPS5 instruction set
- EF_MIPS_ARCH_32 = 0x50000000, // MIPS32 instruction set per linux not elf.h
- EF_MIPS_ARCH_64 = 0x60000000, // MIPS64 instruction set per linux not elf.h
- EF_MIPS_ARCH_32R2 = 0x70000000, // mips32r2, mips32r3, mips32r5
- EF_MIPS_ARCH_64R2 = 0x80000000, // mips64r2, mips64r3, mips64r5
- EF_MIPS_ARCH_32R6 = 0x90000000, // mips32r6
- EF_MIPS_ARCH_64R6 = 0xa0000000, // mips64r6
- EF_MIPS_ARCH = 0xf0000000 // Mask for applying EF_MIPS_ARCH_ variant
-};
-
-// ELF Relocation types for Mips
-enum {
-#include "ELFRelocs/Mips.def"
-};
-
-// Special values for the st_other field in the symbol table entry for MIPS.
-enum {
- STO_MIPS_OPTIONAL = 0x04, // Symbol whose definition is optional
- STO_MIPS_PLT = 0x08, // PLT entry related dynamic table record
- STO_MIPS_PIC = 0x20, // PIC func in an object mixes PIC/non-PIC
- STO_MIPS_MICROMIPS = 0x80, // MIPS Specific ISA for MicroMips
- STO_MIPS_MIPS16 = 0xf0 // MIPS Specific ISA for Mips16
-};
-
-// .MIPS.options section descriptor kinds
-enum {
- ODK_NULL = 0, // Undefined
- ODK_REGINFO = 1, // Register usage information
- ODK_EXCEPTIONS = 2, // Exception processing options
- ODK_PAD = 3, // Section padding options
- ODK_HWPATCH = 4, // Hardware patches applied
- ODK_FILL = 5, // Linker fill value
- ODK_TAGS = 6, // Space for tool identification
- ODK_HWAND = 7, // Hardware AND patches applied
- ODK_HWOR = 8, // Hardware OR patches applied
- ODK_GP_GROUP = 9, // GP group to use for text/data sections
- ODK_IDENT = 10, // ID information
- ODK_PAGESIZE = 11 // Page size information
-};
-
-// Hexagon-specific e_flags
-enum {
- // Object processor version flags, bits[11:0]
- EF_HEXAGON_MACH_V2 = 0x00000001, // Hexagon V2
- EF_HEXAGON_MACH_V3 = 0x00000002, // Hexagon V3
- EF_HEXAGON_MACH_V4 = 0x00000003, // Hexagon V4
- EF_HEXAGON_MACH_V5 = 0x00000004, // Hexagon V5
- EF_HEXAGON_MACH_V55 = 0x00000005, // Hexagon V55
- EF_HEXAGON_MACH_V60 = 0x00000060, // Hexagon V60
-
- // Highest ISA version flags
- EF_HEXAGON_ISA_MACH = 0x00000000, // Same as specified in bits[11:0]
- // of e_flags
- EF_HEXAGON_ISA_V2 = 0x00000010, // Hexagon V2 ISA
- EF_HEXAGON_ISA_V3 = 0x00000020, // Hexagon V3 ISA
- EF_HEXAGON_ISA_V4 = 0x00000030, // Hexagon V4 ISA
- EF_HEXAGON_ISA_V5 = 0x00000040, // Hexagon V5 ISA
- EF_HEXAGON_ISA_V55 = 0x00000050, // Hexagon V55 ISA
- EF_HEXAGON_ISA_V60 = 0x00000060, // Hexagon V60 ISA
-};
-
-// Hexagon-specific section indexes for common small data
-enum {
- SHN_HEXAGON_SCOMMON = 0xff00, // Other access sizes
- SHN_HEXAGON_SCOMMON_1 = 0xff01, // Byte-sized access
- SHN_HEXAGON_SCOMMON_2 = 0xff02, // Half-word-sized access
- SHN_HEXAGON_SCOMMON_4 = 0xff03, // Word-sized access
- SHN_HEXAGON_SCOMMON_8 = 0xff04 // Double-word-size access
-};
-
-// ELF Relocation types for Hexagon
-enum {
-#include "ELFRelocs/Hexagon.def"
-};
-
-// ELF Relocation type for Lanai.
-enum {
-#include "ELFRelocs/Lanai.def"
-};
-
-// ELF Relocation types for RISC-V
-enum {
-#include "ELFRelocs/RISCV.def"
-};
-
-// ELF Relocation types for S390/zSeries
-enum {
-#include "ELFRelocs/SystemZ.def"
-};
-
-// ELF Relocation type for Sparc.
-enum {
-#include "ELFRelocs/Sparc.def"
-};
-
-// ELF Relocation types for WebAssembly
-enum {
-#include "ELFRelocs/WebAssembly.def"
-};
-
-// ELF Relocation types for AMDGPU
-enum {
-#include "ELFRelocs/AMDGPU.def"
-};
-
-// ELF Relocation types for BPF
-enum {
-#include "ELFRelocs/BPF.def"
-};
-
-#undef ELF_RELOC
-
-// Section header.
-struct Elf32_Shdr {
- Elf32_Word sh_name; // Section name (index into string table)
- Elf32_Word sh_type; // Section type (SHT_*)
- Elf32_Word sh_flags; // Section flags (SHF_*)
- Elf32_Addr sh_addr; // Address where section is to be loaded
- Elf32_Off sh_offset; // File offset of section data, in bytes
- Elf32_Word sh_size; // Size of section, in bytes
- Elf32_Word sh_link; // Section type-specific header table index link
- Elf32_Word sh_info; // Section type-specific extra information
- Elf32_Word sh_addralign; // Section address alignment
- Elf32_Word sh_entsize; // Size of records contained within the section
-};
-
-// Section header for ELF64 - same fields as ELF32, different types.
-struct Elf64_Shdr {
- Elf64_Word sh_name;
- Elf64_Word sh_type;
- Elf64_Xword sh_flags;
- Elf64_Addr sh_addr;
- Elf64_Off sh_offset;
- Elf64_Xword sh_size;
- Elf64_Word sh_link;
- Elf64_Word sh_info;
- Elf64_Xword sh_addralign;
- Elf64_Xword sh_entsize;
-};
-
-// Special section indices.
-enum {
- SHN_UNDEF = 0, // Undefined, missing, irrelevant, or meaningless
- SHN_LORESERVE = 0xff00, // Lowest reserved index
- SHN_LOPROC = 0xff00, // Lowest processor-specific index
- SHN_HIPROC = 0xff1f, // Highest processor-specific index
- SHN_LOOS = 0xff20, // Lowest operating system-specific index
- SHN_HIOS = 0xff3f, // Highest operating system-specific index
- SHN_ABS = 0xfff1, // Symbol has absolute value; does not need relocation
- SHN_COMMON = 0xfff2, // FORTRAN COMMON or C external global variables
- SHN_XINDEX = 0xffff, // Mark that the index is >= SHN_LORESERVE
- SHN_HIRESERVE = 0xffff // Highest reserved index
-};
-
-// Section types.
-enum : unsigned {
- SHT_NULL = 0, // No associated section (inactive entry).
- SHT_PROGBITS = 1, // Program-defined contents.
- SHT_SYMTAB = 2, // Symbol table.
- SHT_STRTAB = 3, // String table.
- SHT_RELA = 4, // Relocation entries; explicit addends.
- SHT_HASH = 5, // Symbol hash table.
- SHT_DYNAMIC = 6, // Information for dynamic linking.
- SHT_NOTE = 7, // Information about the file.
- SHT_NOBITS = 8, // Data occupies no space in the file.
- SHT_REL = 9, // Relocation entries; no explicit addends.
- SHT_SHLIB = 10, // Reserved.
- SHT_DYNSYM = 11, // Symbol table.
- SHT_INIT_ARRAY = 14, // Pointers to initialization functions.
- SHT_FINI_ARRAY = 15, // Pointers to termination functions.
- SHT_PREINIT_ARRAY = 16, // Pointers to pre-init functions.
- SHT_GROUP = 17, // Section group.
- SHT_SYMTAB_SHNDX = 18, // Indices for SHN_XINDEX entries.
- SHT_LOOS = 0x60000000, // Lowest operating system-specific type.
- SHT_GNU_ATTRIBUTES = 0x6ffffff5, // Object attributes.
- SHT_GNU_HASH = 0x6ffffff6, // GNU-style hash table.
- SHT_GNU_verdef = 0x6ffffffd, // GNU version definitions.
- SHT_GNU_verneed = 0x6ffffffe, // GNU version references.
- SHT_GNU_versym = 0x6fffffff, // GNU symbol versions table.
- SHT_HIOS = 0x6fffffff, // Highest operating system-specific type.
- SHT_LOPROC = 0x70000000, // Lowest processor arch-specific type.
- // Fixme: All this is duplicated in MCSectionELF. Why??
- // Exception Index table
- SHT_ARM_EXIDX = 0x70000001U,
- // BPABI DLL dynamic linking pre-emption map
- SHT_ARM_PREEMPTMAP = 0x70000002U,
- // Object file compatibility attributes
- SHT_ARM_ATTRIBUTES = 0x70000003U,
- SHT_ARM_DEBUGOVERLAY = 0x70000004U,
- SHT_ARM_OVERLAYSECTION = 0x70000005U,
- SHT_HEX_ORDERED = 0x70000000, // Link editor is to sort the entries in
- // this section based on their sizes
- SHT_X86_64_UNWIND = 0x70000001, // Unwind information
-
- SHT_MIPS_REGINFO = 0x70000006, // Register usage information
- SHT_MIPS_OPTIONS = 0x7000000d, // General options
- SHT_MIPS_ABIFLAGS = 0x7000002a, // ABI information.
-
- SHT_HIPROC = 0x7fffffff, // Highest processor arch-specific type.
- SHT_LOUSER = 0x80000000, // Lowest type reserved for applications.
- SHT_HIUSER = 0xffffffff // Highest type reserved for applications.
-};
-
-// Section flags.
-enum : unsigned {
- // Section data should be writable during execution.
- SHF_WRITE = 0x1,
-
- // Section occupies memory during program execution.
- SHF_ALLOC = 0x2,
-
- // Section contains executable machine instructions.
- SHF_EXECINSTR = 0x4,
-
- // The data in this section may be merged.
- SHF_MERGE = 0x10,
-
- // The data in this section is null-terminated strings.
- SHF_STRINGS = 0x20,
-
- // A field in this section holds a section header table index.
- SHF_INFO_LINK = 0x40U,
-
- // Adds special ordering requirements for link editors.
- SHF_LINK_ORDER = 0x80U,
-
- // This section requires special OS-specific processing to avoid incorrect
- // behavior.
- SHF_OS_NONCONFORMING = 0x100U,
-
- // This section is a member of a section group.
- SHF_GROUP = 0x200U,
-
- // This section holds Thread-Local Storage.
- SHF_TLS = 0x400U,
-
- // Identifies a section containing compressed data.
- SHF_COMPRESSED = 0x800U,
-
- // This section is excluded from the final executable or shared library.
- SHF_EXCLUDE = 0x80000000U,
-
- // Start of target-specific flags.
-
- /// XCORE_SHF_CP_SECTION - All sections with the "c" flag are grouped
- /// together by the linker to form the constant pool and the cp register is
- /// set to the start of the constant pool by the boot code.
- XCORE_SHF_CP_SECTION = 0x800U,
-
- /// XCORE_SHF_DP_SECTION - All sections with the "d" flag are grouped
- /// together by the linker to form the data section and the dp register is
- /// set to the start of the section by the boot code.
- XCORE_SHF_DP_SECTION = 0x1000U,
-
- SHF_MASKOS = 0x0ff00000,
-
- // Bits indicating processor-specific flags.
- SHF_MASKPROC = 0xf0000000,
-
- // If an object file section does not have this flag set, then it may not hold
- // more than 2GB and can be freely referred to in objects using smaller code
- // models. Otherwise, only objects using larger code models can refer to them.
- // For example, a medium code model object can refer to data in a section that
- // sets this flag besides being able to refer to data in a section that does
- // not set it; likewise, a small code model object can refer only to code in a
- // section that does not set this flag.
- SHF_X86_64_LARGE = 0x10000000,
-
- // All sections with the GPREL flag are grouped into a global data area
- // for faster accesses
- SHF_HEX_GPREL = 0x10000000,
-
- // Section contains text/data which may be replicated in other sections.
- // Linker must retain only one copy.
- SHF_MIPS_NODUPES = 0x01000000,
-
- // Linker must generate implicit hidden weak names.
- SHF_MIPS_NAMES = 0x02000000,
-
- // Section data local to process.
- SHF_MIPS_LOCAL = 0x04000000,
-
- // Do not strip this section.
- SHF_MIPS_NOSTRIP = 0x08000000,
-
- // Section must be part of global data area.
- SHF_MIPS_GPREL = 0x10000000,
-
- // This section should be merged.
- SHF_MIPS_MERGE = 0x20000000,
-
- // Address size to be inferred from section entry size.
- SHF_MIPS_ADDR = 0x40000000,
-
- // Section data is string data by default.
- SHF_MIPS_STRING = 0x80000000,
-
- // Make code section unreadable when in execute-only mode
- SHF_ARM_PURECODE = 0x20000000,
-
- SHF_AMDGPU_HSA_GLOBAL = 0x00100000,
- SHF_AMDGPU_HSA_READONLY = 0x00200000,
- SHF_AMDGPU_HSA_CODE = 0x00400000,
- SHF_AMDGPU_HSA_AGENT = 0x00800000
-};
-
-// Section Group Flags
-enum : unsigned {
- GRP_COMDAT = 0x1,
- GRP_MASKOS = 0x0ff00000,
- GRP_MASKPROC = 0xf0000000
-};
-
-// Symbol table entries for ELF32.
-struct Elf32_Sym {
- Elf32_Word st_name; // Symbol name (index into string table)
- Elf32_Addr st_value; // Value or address associated with the symbol
- Elf32_Word st_size; // Size of the symbol
- unsigned char st_info; // Symbol's type and binding attributes
- unsigned char st_other; // Must be zero; reserved
- Elf32_Half st_shndx; // Which section (header table index) it's defined in
-
- // These accessors and mutators correspond to the ELF32_ST_BIND,
- // ELF32_ST_TYPE, and ELF32_ST_INFO macros defined in the ELF specification:
- unsigned char getBinding() const { return st_info >> 4; }
- unsigned char getType() const { return st_info & 0x0f; }
- void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
- void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
- void setBindingAndType(unsigned char b, unsigned char t) {
- st_info = (b << 4) + (t & 0x0f);
- }
-};
-
-// Symbol table entries for ELF64.
-struct Elf64_Sym {
- Elf64_Word st_name; // Symbol name (index into string table)
- unsigned char st_info; // Symbol's type and binding attributes
- unsigned char st_other; // Must be zero; reserved
- Elf64_Half st_shndx; // Which section (header tbl index) it's defined in
- Elf64_Addr st_value; // Value or address associated with the symbol
- Elf64_Xword st_size; // Size of the symbol
-
- // These accessors and mutators are identical to those defined for ELF32
- // symbol table entries.
- unsigned char getBinding() const { return st_info >> 4; }
- unsigned char getType() const { return st_info & 0x0f; }
- void setBinding(unsigned char b) { setBindingAndType(b, getType()); }
- void setType(unsigned char t) { setBindingAndType(getBinding(), t); }
- void setBindingAndType(unsigned char b, unsigned char t) {
- st_info = (b << 4) + (t & 0x0f);
- }
-};
-
-// The size (in bytes) of symbol table entries.
-enum {
- SYMENTRY_SIZE32 = 16, // 32-bit symbol entry size
- SYMENTRY_SIZE64 = 24 // 64-bit symbol entry size.
-};
-
-// Symbol bindings.
-enum {
- STB_LOCAL = 0, // Local symbol, not visible outside obj file containing def
- STB_GLOBAL = 1, // Global symbol, visible to all object files being combined
- STB_WEAK = 2, // Weak symbol, like global but lower-precedence
- STB_GNU_UNIQUE = 10,
- STB_LOOS = 10, // Lowest operating system-specific binding type
- STB_HIOS = 12, // Highest operating system-specific binding type
- STB_LOPROC = 13, // Lowest processor-specific binding type
- STB_HIPROC = 15 // Highest processor-specific binding type
-};
-
-// Symbol types.
-enum {
- STT_NOTYPE = 0, // Symbol's type is not specified
- STT_OBJECT = 1, // Symbol is a data object (variable, array, etc.)
- STT_FUNC = 2, // Symbol is executable code (function, etc.)
- STT_SECTION = 3, // Symbol refers to a section
- STT_FILE = 4, // Local, absolute symbol that refers to a file
- STT_COMMON = 5, // An uninitialized common block
- STT_TLS = 6, // Thread local data object
- STT_GNU_IFUNC = 10, // GNU indirect function
- STT_LOOS = 10, // Lowest operating system-specific symbol type
- STT_HIOS = 12, // Highest operating system-specific symbol type
- STT_LOPROC = 13, // Lowest processor-specific symbol type
- STT_HIPROC = 15, // Highest processor-specific symbol type
-
- // AMDGPU symbol types
- STT_AMDGPU_HSA_KERNEL = 10,
- STT_AMDGPU_HSA_INDIRECT_FUNCTION = 11,
- STT_AMDGPU_HSA_METADATA = 12
-};
-
-enum {
- STV_DEFAULT = 0, // Visibility is specified by binding type
- STV_INTERNAL = 1, // Defined by processor supplements
- STV_HIDDEN = 2, // Not visible to other components
- STV_PROTECTED = 3 // Visible in other components but not preemptable
-};
-
-// Symbol number.
-enum { STN_UNDEF = 0 };
-
-// Special relocation symbols used in the MIPS64 ELF relocation entries
-enum {
- RSS_UNDEF = 0, // None
- RSS_GP = 1, // Value of gp
- RSS_GP0 = 2, // Value of gp used to create object being relocated
- RSS_LOC = 3 // Address of location being relocated
-};
-
-// Relocation entry, without explicit addend.
-struct Elf32_Rel {
- Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
- Elf32_Word r_info; // Symbol table index and type of relocation to apply
-
- // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
- // and ELF32_R_INFO macros defined in the ELF specification:
- Elf32_Word getSymbol() const { return (r_info >> 8); }
- unsigned char getType() const { return (unsigned char)(r_info & 0x0ff); }
- void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
- void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
- void setSymbolAndType(Elf32_Word s, unsigned char t) {
- r_info = (s << 8) + t;
- }
-};
-
-// Relocation entry with explicit addend.
-struct Elf32_Rela {
- Elf32_Addr r_offset; // Location (file byte offset, or program virtual addr)
- Elf32_Word r_info; // Symbol table index and type of relocation to apply
- Elf32_Sword r_addend; // Compute value for relocatable field by adding this
-
- // These accessors and mutators correspond to the ELF32_R_SYM, ELF32_R_TYPE,
- // and ELF32_R_INFO macros defined in the ELF specification:
- Elf32_Word getSymbol() const { return (r_info >> 8); }
- unsigned char getType() const { return (unsigned char)(r_info & 0x0ff); }
- void setSymbol(Elf32_Word s) { setSymbolAndType(s, getType()); }
- void setType(unsigned char t) { setSymbolAndType(getSymbol(), t); }
- void setSymbolAndType(Elf32_Word s, unsigned char t) {
- r_info = (s << 8) + t;
- }
-};
-
-// Relocation entry, without explicit addend.
-struct Elf64_Rel {
- Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr).
- Elf64_Xword r_info; // Symbol table index and type of relocation to apply.
-
- // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
- // and ELF64_R_INFO macros defined in the ELF specification:
- Elf64_Word getSymbol() const { return (r_info >> 32); }
- Elf64_Word getType() const { return (Elf64_Word)(r_info & 0xffffffffL); }
- void setSymbol(Elf64_Word s) { setSymbolAndType(s, getType()); }
- void setType(Elf64_Word t) { setSymbolAndType(getSymbol(), t); }
- void setSymbolAndType(Elf64_Word s, Elf64_Word t) {
- r_info = ((Elf64_Xword)s << 32) + (t & 0xffffffffL);
- }
-};
-
-// Relocation entry with explicit addend.
-struct Elf64_Rela {
- Elf64_Addr r_offset; // Location (file byte offset, or program virtual addr).
- Elf64_Xword r_info; // Symbol table index and type of relocation to apply.
- Elf64_Sxword r_addend; // Compute value for relocatable field by adding this.
-
- // These accessors and mutators correspond to the ELF64_R_SYM, ELF64_R_TYPE,
- // and ELF64_R_INFO macros defined in the ELF specification:
- Elf64_Word getSymbol() const { return (r_info >> 32); }
- Elf64_Word getType() const { return (Elf64_Word)(r_info & 0xffffffffL); }
- void setSymbol(Elf64_Word s) { setSymbolAndType(s, getType()); }
- void setType(Elf64_Word t) { setSymbolAndType(getSymbol(), t); }
- void setSymbolAndType(Elf64_Word s, Elf64_Word t) {
- r_info = ((Elf64_Xword)s << 32) + (t & 0xffffffffL);
- }
-};
-
-// Program header for ELF32.
-struct Elf32_Phdr {
- Elf32_Word p_type; // Type of segment
- Elf32_Off p_offset; // File offset where segment is located, in bytes
- Elf32_Addr p_vaddr; // Virtual address of beginning of segment
- Elf32_Addr p_paddr; // Physical address of beginning of segment (OS-specific)
- Elf32_Word p_filesz; // Num. of bytes in file image of segment (may be zero)
- Elf32_Word p_memsz; // Num. of bytes in mem image of segment (may be zero)
- Elf32_Word p_flags; // Segment flags
- Elf32_Word p_align; // Segment alignment constraint
-};
-
-// Program header for ELF64.
-struct Elf64_Phdr {
- Elf64_Word p_type; // Type of segment
- Elf64_Word p_flags; // Segment flags
- Elf64_Off p_offset; // File offset where segment is located, in bytes
- Elf64_Addr p_vaddr; // Virtual address of beginning of segment
- Elf64_Addr p_paddr; // Physical addr of beginning of segment (OS-specific)
- Elf64_Xword p_filesz; // Num. of bytes in file image of segment (may be zero)
- Elf64_Xword p_memsz; // Num. of bytes in mem image of segment (may be zero)
- Elf64_Xword p_align; // Segment alignment constraint
-};
-
-// Segment types.
-enum {
- PT_NULL = 0, // Unused segment.
- PT_LOAD = 1, // Loadable segment.
- PT_DYNAMIC = 2, // Dynamic linking information.
- PT_INTERP = 3, // Interpreter pathname.
- PT_NOTE = 4, // Auxiliary information.
- PT_SHLIB = 5, // Reserved.
- PT_PHDR = 6, // The program header table itself.
- PT_TLS = 7, // The thread-local storage template.
- PT_LOOS = 0x60000000, // Lowest operating system-specific pt entry type.
- PT_HIOS = 0x6fffffff, // Highest operating system-specific pt entry type.
- PT_LOPROC = 0x70000000, // Lowest processor-specific program hdr entry type.
- PT_HIPROC = 0x7fffffff, // Highest processor-specific program hdr entry type.
-
- // x86-64 program header types.
- // These all contain stack unwind tables.
- PT_GNU_EH_FRAME = 0x6474e550,
- PT_SUNW_EH_FRAME = 0x6474e550,
- PT_SUNW_UNWIND = 0x6464e550,
-
- PT_GNU_STACK = 0x6474e551, // Indicates stack executability.
- PT_GNU_RELRO = 0x6474e552, // Read-only after relocation.
-
- PT_OPENBSD_RANDOMIZE = 0x65a3dbe6, // Fill with random data.
- PT_OPENBSD_WXNEEDED = 0x65a3dbe7, // Program does W^X violations.
- PT_OPENBSD_BOOTDATA = 0x65a41be6, // Section for boot arguments.
-
- // ARM program header types.
- PT_ARM_ARCHEXT = 0x70000000, // Platform architecture compatibility info
- // These all contain stack unwind tables.
- PT_ARM_EXIDX = 0x70000001,
- PT_ARM_UNWIND = 0x70000001,
-
- // MIPS program header types.
- PT_MIPS_REGINFO = 0x70000000, // Register usage information.
- PT_MIPS_RTPROC = 0x70000001, // Runtime procedure table.
- PT_MIPS_OPTIONS = 0x70000002, // Options segment.
- PT_MIPS_ABIFLAGS = 0x70000003, // Abiflags segment.
-
- // AMDGPU program header types.
- PT_AMDGPU_HSA_LOAD_GLOBAL_PROGRAM = 0x60000000,
- PT_AMDGPU_HSA_LOAD_GLOBAL_AGENT = 0x60000001,
- PT_AMDGPU_HSA_LOAD_READONLY_AGENT = 0x60000002,
- PT_AMDGPU_HSA_LOAD_CODE_AGENT = 0x60000003,
-
- // WebAssembly program header types.
- PT_WEBASSEMBLY_FUNCTIONS = PT_LOPROC + 0, // Function definitions.
-};
-
-// Segment flag bits.
-enum : unsigned {
- PF_X = 1, // Execute
- PF_W = 2, // Write
- PF_R = 4, // Read
- PF_MASKOS = 0x0ff00000, // Bits for operating system-specific semantics.
- PF_MASKPROC = 0xf0000000 // Bits for processor-specific semantics.
-};
-
-// Dynamic table entry for ELF32.
-struct Elf32_Dyn {
- Elf32_Sword d_tag; // Type of dynamic table entry.
- union {
- Elf32_Word d_val; // Integer value of entry.
- Elf32_Addr d_ptr; // Pointer value of entry.
- } d_un;
-};
-
-// Dynamic table entry for ELF64.
-struct Elf64_Dyn {
- Elf64_Sxword d_tag; // Type of dynamic table entry.
- union {
- Elf64_Xword d_val; // Integer value of entry.
- Elf64_Addr d_ptr; // Pointer value of entry.
- } d_un;
-};
-
-// Dynamic table entry tags.
-enum {
- DT_NULL = 0, // Marks end of dynamic array.
- DT_NEEDED = 1, // String table offset of needed library.
- DT_PLTRELSZ = 2, // Size of relocation entries in PLT.
- DT_PLTGOT = 3, // Address associated with linkage table.
- DT_HASH = 4, // Address of symbolic hash table.
- DT_STRTAB = 5, // Address of dynamic string table.
- DT_SYMTAB = 6, // Address of dynamic symbol table.
- DT_RELA = 7, // Address of relocation table (Rela entries).
- DT_RELASZ = 8, // Size of Rela relocation table.
- DT_RELAENT = 9, // Size of a Rela relocation entry.
- DT_STRSZ = 10, // Total size of the string table.
- DT_SYMENT = 11, // Size of a symbol table entry.
- DT_INIT = 12, // Address of initialization function.
- DT_FINI = 13, // Address of termination function.
- DT_SONAME = 14, // String table offset of a shared objects name.
- DT_RPATH = 15, // String table offset of library search path.
- DT_SYMBOLIC = 16, // Changes symbol resolution algorithm.
- DT_REL = 17, // Address of relocation table (Rel entries).
- DT_RELSZ = 18, // Size of Rel relocation table.
- DT_RELENT = 19, // Size of a Rel relocation entry.
- DT_PLTREL = 20, // Type of relocation entry used for linking.
- DT_DEBUG = 21, // Reserved for debugger.
- DT_TEXTREL = 22, // Relocations exist for non-writable segments.
- DT_JMPREL = 23, // Address of relocations associated with PLT.
- DT_BIND_NOW = 24, // Process all relocations before execution.
- DT_INIT_ARRAY = 25, // Pointer to array of initialization functions.
- DT_FINI_ARRAY = 26, // Pointer to array of termination functions.
- DT_INIT_ARRAYSZ = 27, // Size of DT_INIT_ARRAY.
- DT_FINI_ARRAYSZ = 28, // Size of DT_FINI_ARRAY.
- DT_RUNPATH = 29, // String table offset of lib search path.
- DT_FLAGS = 30, // Flags.
- DT_ENCODING = 32, // Values from here to DT_LOOS follow the rules
- // for the interpretation of the d_un union.
-
- DT_PREINIT_ARRAY = 32, // Pointer to array of preinit functions.
- DT_PREINIT_ARRAYSZ = 33, // Size of the DT_PREINIT_ARRAY array.
-
- DT_LOOS = 0x60000000, // Start of environment specific tags.
- DT_HIOS = 0x6FFFFFFF, // End of environment specific tags.
- DT_LOPROC = 0x70000000, // Start of processor specific tags.
- DT_HIPROC = 0x7FFFFFFF, // End of processor specific tags.
-
- DT_GNU_HASH = 0x6FFFFEF5, // Reference to the GNU hash table.
- DT_TLSDESC_PLT =
- 0x6FFFFEF6, // Location of PLT entry for TLS descriptor resolver calls.
- DT_TLSDESC_GOT = 0x6FFFFEF7, // Location of GOT entry used by TLS descriptor
- // resolver PLT entry.
- DT_RELACOUNT = 0x6FFFFFF9, // ELF32_Rela count.
- DT_RELCOUNT = 0x6FFFFFFA, // ELF32_Rel count.
-
- DT_FLAGS_1 = 0X6FFFFFFB, // Flags_1.
- DT_VERSYM = 0x6FFFFFF0, // The address of .gnu.version section.
- DT_VERDEF = 0X6FFFFFFC, // The address of the version definition table.
- DT_VERDEFNUM = 0X6FFFFFFD, // The number of entries in DT_VERDEF.
- DT_VERNEED = 0X6FFFFFFE, // The address of the version Dependency table.
- DT_VERNEEDNUM = 0X6FFFFFFF, // The number of entries in DT_VERNEED.
-
- // Hexagon specific dynamic table entries
- DT_HEXAGON_SYMSZ = 0x70000000,
- DT_HEXAGON_VER = 0x70000001,
- DT_HEXAGON_PLT = 0x70000002,
-
- // Mips specific dynamic table entry tags.
- DT_MIPS_RLD_VERSION = 0x70000001, // 32 bit version number for runtime
- // linker interface.
- DT_MIPS_TIME_STAMP = 0x70000002, // Time stamp.
- DT_MIPS_ICHECKSUM = 0x70000003, // Checksum of external strings
- // and common sizes.
- DT_MIPS_IVERSION = 0x70000004, // Index of version string
- // in string table.
- DT_MIPS_FLAGS = 0x70000005, // 32 bits of flags.
- DT_MIPS_BASE_ADDRESS = 0x70000006, // Base address of the segment.
- DT_MIPS_MSYM = 0x70000007, // Address of .msym section.
- DT_MIPS_CONFLICT = 0x70000008, // Address of .conflict section.
- DT_MIPS_LIBLIST = 0x70000009, // Address of .liblist section.
- DT_MIPS_LOCAL_GOTNO = 0x7000000a, // Number of local global offset
- // table entries.
- DT_MIPS_CONFLICTNO = 0x7000000b, // Number of entries
- // in the .conflict section.
- DT_MIPS_LIBLISTNO = 0x70000010, // Number of entries
- // in the .liblist section.
- DT_MIPS_SYMTABNO = 0x70000011, // Number of entries
- // in the .dynsym section.
- DT_MIPS_UNREFEXTNO = 0x70000012, // Index of first external dynamic symbol
- // not referenced locally.
- DT_MIPS_GOTSYM = 0x70000013, // Index of first dynamic symbol
- // in global offset table.
- DT_MIPS_HIPAGENO = 0x70000014, // Number of page table entries
- // in global offset table.
- DT_MIPS_RLD_MAP = 0x70000016, // Address of run time loader map,
- // used for debugging.
- DT_MIPS_DELTA_CLASS = 0x70000017, // Delta C++ class definition.
- DT_MIPS_DELTA_CLASS_NO = 0x70000018, // Number of entries
- // in DT_MIPS_DELTA_CLASS.
- DT_MIPS_DELTA_INSTANCE = 0x70000019, // Delta C++ class instances.
- DT_MIPS_DELTA_INSTANCE_NO = 0x7000001A, // Number of entries
- // in DT_MIPS_DELTA_INSTANCE.
- DT_MIPS_DELTA_RELOC = 0x7000001B, // Delta relocations.
- DT_MIPS_DELTA_RELOC_NO = 0x7000001C, // Number of entries
- // in DT_MIPS_DELTA_RELOC.
- DT_MIPS_DELTA_SYM = 0x7000001D, // Delta symbols that Delta
- // relocations refer to.
- DT_MIPS_DELTA_SYM_NO = 0x7000001E, // Number of entries
- // in DT_MIPS_DELTA_SYM.
- DT_MIPS_DELTA_CLASSSYM = 0x70000020, // Delta symbols that hold
- // class declarations.
- DT_MIPS_DELTA_CLASSSYM_NO = 0x70000021, // Number of entries
- // in DT_MIPS_DELTA_CLASSSYM.
- DT_MIPS_CXX_FLAGS = 0x70000022, // Flags indicating information
- // about C++ flavor.
- DT_MIPS_PIXIE_INIT = 0x70000023, // Pixie information.
- DT_MIPS_SYMBOL_LIB = 0x70000024, // Address of .MIPS.symlib
- DT_MIPS_LOCALPAGE_GOTIDX = 0x70000025, // The GOT index of the first PTE
- // for a segment
- DT_MIPS_LOCAL_GOTIDX = 0x70000026, // The GOT index of the first PTE
- // for a local symbol
- DT_MIPS_HIDDEN_GOTIDX = 0x70000027, // The GOT index of the first PTE
- // for a hidden symbol
- DT_MIPS_PROTECTED_GOTIDX = 0x70000028, // The GOT index of the first PTE
- // for a protected symbol
- DT_MIPS_OPTIONS = 0x70000029, // Address of `.MIPS.options'.
- DT_MIPS_INTERFACE = 0x7000002A, // Address of `.interface'.
- DT_MIPS_DYNSTR_ALIGN = 0x7000002B, // Unknown.
- DT_MIPS_INTERFACE_SIZE = 0x7000002C, // Size of the .interface section.
- DT_MIPS_RLD_TEXT_RESOLVE_ADDR = 0x7000002D, // Size of rld_text_resolve
- // function stored in the GOT.
- DT_MIPS_PERF_SUFFIX = 0x7000002E, // Default suffix of DSO to be added
- // by rld on dlopen() calls.
- DT_MIPS_COMPACT_SIZE = 0x7000002F, // Size of compact relocation
- // section (O32).
- DT_MIPS_GP_VALUE = 0x70000030, // GP value for auxiliary GOTs.
- DT_MIPS_AUX_DYNAMIC = 0x70000031, // Address of auxiliary .dynamic.
- DT_MIPS_PLTGOT = 0x70000032, // Address of the base of the PLTGOT.
- DT_MIPS_RWPLT = 0x70000034, // Points to the base
- // of a writable PLT.
- DT_MIPS_RLD_MAP_REL = 0x70000035, // Relative offset of run time loader
- // map, used for debugging.
-
- // Sun machine-independent extensions.
- DT_AUXILIARY = 0x7FFFFFFD, // Shared object to load before self
- DT_FILTER = 0x7FFFFFFF // Shared object to get values from
-};
-
-// DT_FLAGS values.
-enum {
- DF_ORIGIN = 0x01, // The object may reference $ORIGIN.
- DF_SYMBOLIC = 0x02, // Search the shared lib before searching the exe.
- DF_TEXTREL = 0x04, // Relocations may modify a non-writable segment.
- DF_BIND_NOW = 0x08, // Process all relocations on load.
- DF_STATIC_TLS = 0x10 // Reject attempts to load dynamically.
-};
-
-// State flags selectable in the `d_un.d_val' element of the DT_FLAGS_1 entry.
-enum {
- DF_1_NOW = 0x00000001, // Set RTLD_NOW for this object.
- DF_1_GLOBAL = 0x00000002, // Set RTLD_GLOBAL for this object.
- DF_1_GROUP = 0x00000004, // Set RTLD_GROUP for this object.
- DF_1_NODELETE = 0x00000008, // Set RTLD_NODELETE for this object.
- DF_1_LOADFLTR = 0x00000010, // Trigger filtee loading at runtime.
- DF_1_INITFIRST = 0x00000020, // Set RTLD_INITFIRST for this object.
- DF_1_NOOPEN = 0x00000040, // Set RTLD_NOOPEN for this object.
- DF_1_ORIGIN = 0x00000080, // $ORIGIN must be handled.
- DF_1_DIRECT = 0x00000100, // Direct binding enabled.
- DF_1_TRANS = 0x00000200,
- DF_1_INTERPOSE = 0x00000400, // Object is used to interpose.
- DF_1_NODEFLIB = 0x00000800, // Ignore default lib search path.
- DF_1_NODUMP = 0x00001000, // Object can't be dldump'ed.
- DF_1_CONFALT = 0x00002000, // Configuration alternative created.
- DF_1_ENDFILTEE = 0x00004000, // Filtee terminates filters search.
- DF_1_DISPRELDNE = 0x00008000, // Disp reloc applied at build time.
- DF_1_DISPRELPND = 0x00010000, // Disp reloc applied at run-time.
- DF_1_NODIRECT = 0x00020000, // Object has no-direct binding.
- DF_1_IGNMULDEF = 0x00040000,
- DF_1_NOKSYMS = 0x00080000,
- DF_1_NOHDR = 0x00100000,
- DF_1_EDITED = 0x00200000, // Object is modified after built.
- DF_1_NORELOC = 0x00400000,
- DF_1_SYMINTPOSE = 0x00800000, // Object has individual interposers.
- DF_1_GLOBAUDIT = 0x01000000, // Global auditing required.
- DF_1_SINGLETON = 0x02000000 // Singleton symbols are used.
-};
-
-// DT_MIPS_FLAGS values.
-enum {
- RHF_NONE = 0x00000000, // No flags.
- RHF_QUICKSTART = 0x00000001, // Uses shortcut pointers.
- RHF_NOTPOT = 0x00000002, // Hash size is not a power of two.
- RHS_NO_LIBRARY_REPLACEMENT = 0x00000004, // Ignore LD_LIBRARY_PATH.
- RHF_NO_MOVE = 0x00000008, // DSO address may not be relocated.
- RHF_SGI_ONLY = 0x00000010, // SGI specific features.
- RHF_GUARANTEE_INIT = 0x00000020, // Guarantee that .init will finish
- // executing before any non-init
- // code in DSO is called.
- RHF_DELTA_C_PLUS_PLUS = 0x00000040, // Contains Delta C++ code.
- RHF_GUARANTEE_START_INIT = 0x00000080, // Guarantee that .init will start
- // executing before any non-init
- // code in DSO is called.
- RHF_PIXIE = 0x00000100, // Generated by pixie.
- RHF_DEFAULT_DELAY_LOAD = 0x00000200, // Delay-load DSO by default.
- RHF_REQUICKSTART = 0x00000400, // Object may be requickstarted
- RHF_REQUICKSTARTED = 0x00000800, // Object has been requickstarted
- RHF_CORD = 0x00001000, // Generated by cord.
- RHF_NO_UNRES_UNDEF = 0x00002000, // Object contains no unresolved
- // undef symbols.
- RHF_RLD_ORDER_SAFE = 0x00004000 // Symbol table is in a safe order.
-};
-
-// ElfXX_VerDef structure version (GNU versioning)
-enum { VER_DEF_NONE = 0, VER_DEF_CURRENT = 1 };
-
-// VerDef Flags (ElfXX_VerDef::vd_flags)
-enum { VER_FLG_BASE = 0x1, VER_FLG_WEAK = 0x2, VER_FLG_INFO = 0x4 };
-
-// Special constants for the version table. (SHT_GNU_versym/.gnu.version)
-enum {
- VER_NDX_LOCAL = 0, // Unversioned local symbol
- VER_NDX_GLOBAL = 1, // Unversioned global symbol
- VERSYM_VERSION = 0x7fff, // Version Index mask
- VERSYM_HIDDEN = 0x8000 // Hidden bit (non-default version)
-};
-
-// ElfXX_VerNeed structure version (GNU versioning)
-enum { VER_NEED_NONE = 0, VER_NEED_CURRENT = 1 };
-
-// SHT_NOTE section types
-enum {
- NT_GNU_ABI_TAG = 1,
- NT_GNU_HWCAP = 2,
- NT_GNU_BUILD_ID = 3,
- NT_GNU_GOLD_VERSION = 4,
-};
-
-enum {
- GNU_ABI_TAG_LINUX = 0,
- GNU_ABI_TAG_HURD = 1,
- GNU_ABI_TAG_SOLARIS = 2,
- GNU_ABI_TAG_FREEBSD = 3,
- GNU_ABI_TAG_NETBSD = 4,
- GNU_ABI_TAG_SYLLABLE = 5,
- GNU_ABI_TAG_NACL = 6,
-};
-
-// Compressed section header for ELF32.
-struct Elf32_Chdr {
- Elf32_Word ch_type;
- Elf32_Word ch_size;
- Elf32_Word ch_addralign;
-};
-
-// Compressed section header for ELF64.
-struct Elf64_Chdr {
- Elf64_Word ch_type;
- Elf64_Word ch_reserved;
- Elf64_Xword ch_size;
- Elf64_Xword ch_addralign;
-};
-
-// Legal values for ch_type field of compressed section header.
-enum {
- ELFCOMPRESS_ZLIB = 1, // ZLIB/DEFLATE algorithm.
- ELFCOMPRESS_LOOS = 0x60000000, // Start of OS-specific.
- ELFCOMPRESS_HIOS = 0x6fffffff, // End of OS-specific.
- ELFCOMPRESS_LOPROC = 0x70000000, // Start of processor-specific.
- ELFCOMPRESS_HIPROC = 0x7fffffff // End of processor-specific.
-};
-
-} // end namespace ELF
-
-} // end namespace llvm
-
-#endif
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def b/contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def
deleted file mode 100644
index c21df07..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/AArch64.def
+++ /dev/null
@@ -1,201 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// Based on ABI release 1.1-beta, dated 6 November 2013. NB: The cover page of
-// this document, IHI0056C_beta_aaelf64.pdf, on infocenter.arm.com, still
-// labels this as release 1.0.
-ELF_RELOC(R_AARCH64_NONE, 0)
-ELF_RELOC(R_AARCH64_ABS64, 0x101)
-ELF_RELOC(R_AARCH64_ABS32, 0x102)
-ELF_RELOC(R_AARCH64_ABS16, 0x103)
-ELF_RELOC(R_AARCH64_PREL64, 0x104)
-ELF_RELOC(R_AARCH64_PREL32, 0x105)
-ELF_RELOC(R_AARCH64_PREL16, 0x106)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G0, 0x107)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G0_NC, 0x108)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G1, 0x109)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G1_NC, 0x10a)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G2, 0x10b)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G2_NC, 0x10c)
-ELF_RELOC(R_AARCH64_MOVW_UABS_G3, 0x10d)
-ELF_RELOC(R_AARCH64_MOVW_SABS_G0, 0x10e)
-ELF_RELOC(R_AARCH64_MOVW_SABS_G1, 0x10f)
-ELF_RELOC(R_AARCH64_MOVW_SABS_G2, 0x110)
-ELF_RELOC(R_AARCH64_LD_PREL_LO19, 0x111)
-ELF_RELOC(R_AARCH64_ADR_PREL_LO21, 0x112)
-ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21, 0x113)
-ELF_RELOC(R_AARCH64_ADR_PREL_PG_HI21_NC, 0x114)
-ELF_RELOC(R_AARCH64_ADD_ABS_LO12_NC, 0x115)
-ELF_RELOC(R_AARCH64_LDST8_ABS_LO12_NC, 0x116)
-ELF_RELOC(R_AARCH64_TSTBR14, 0x117)
-ELF_RELOC(R_AARCH64_CONDBR19, 0x118)
-ELF_RELOC(R_AARCH64_JUMP26, 0x11a)
-ELF_RELOC(R_AARCH64_CALL26, 0x11b)
-ELF_RELOC(R_AARCH64_LDST16_ABS_LO12_NC, 0x11c)
-ELF_RELOC(R_AARCH64_LDST32_ABS_LO12_NC, 0x11d)
-ELF_RELOC(R_AARCH64_LDST64_ABS_LO12_NC, 0x11e)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G0, 0x11f)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G0_NC, 0x120)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G1, 0x121)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G1_NC, 0x122)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G2, 0x123)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G2_NC, 0x124)
-ELF_RELOC(R_AARCH64_MOVW_PREL_G3, 0x125)
-ELF_RELOC(R_AARCH64_LDST128_ABS_LO12_NC, 0x12b)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0, 0x12c)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G0_NC, 0x12d)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1, 0x12e)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G1_NC, 0x12f)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2, 0x130)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G2_NC, 0x131)
-ELF_RELOC(R_AARCH64_MOVW_GOTOFF_G3, 0x132)
-ELF_RELOC(R_AARCH64_GOTREL64, 0x133)
-ELF_RELOC(R_AARCH64_GOTREL32, 0x134)
-ELF_RELOC(R_AARCH64_GOT_LD_PREL19, 0x135)
-ELF_RELOC(R_AARCH64_LD64_GOTOFF_LO15, 0x136)
-ELF_RELOC(R_AARCH64_ADR_GOT_PAGE, 0x137)
-ELF_RELOC(R_AARCH64_LD64_GOT_LO12_NC, 0x138)
-ELF_RELOC(R_AARCH64_LD64_GOTPAGE_LO15, 0x139)
-ELF_RELOC(R_AARCH64_TLSGD_ADR_PREL21, 0x200)
-ELF_RELOC(R_AARCH64_TLSGD_ADR_PAGE21, 0x201)
-ELF_RELOC(R_AARCH64_TLSGD_ADD_LO12_NC, 0x202)
-ELF_RELOC(R_AARCH64_TLSGD_MOVW_G1, 0x203)
-ELF_RELOC(R_AARCH64_TLSGD_MOVW_G0_NC, 0x204)
-ELF_RELOC(R_AARCH64_TLSLD_ADR_PREL21, 0x205)
-ELF_RELOC(R_AARCH64_TLSLD_ADR_PAGE21, 0x206)
-ELF_RELOC(R_AARCH64_TLSLD_ADD_LO12_NC, 0x207)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_G1, 0x208)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_G0_NC, 0x209)
-ELF_RELOC(R_AARCH64_TLSLD_LD_PREL19, 0x20a)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G2, 0x20b)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1, 0x20c)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G1_NC, 0x20d)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0, 0x20e)
-ELF_RELOC(R_AARCH64_TLSLD_MOVW_DTPREL_G0_NC, 0x20f)
-ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_HI12, 0x210)
-ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12, 0x211)
-ELF_RELOC(R_AARCH64_TLSLD_ADD_DTPREL_LO12_NC, 0x212)
-ELF_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12, 0x213)
-ELF_RELOC(R_AARCH64_TLSLD_LDST8_DTPREL_LO12_NC, 0x214)
-ELF_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12, 0x215)
-ELF_RELOC(R_AARCH64_TLSLD_LDST16_DTPREL_LO12_NC, 0x216)
-ELF_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12, 0x217)
-ELF_RELOC(R_AARCH64_TLSLD_LDST32_DTPREL_LO12_NC, 0x218)
-ELF_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12, 0x219)
-ELF_RELOC(R_AARCH64_TLSLD_LDST64_DTPREL_LO12_NC, 0x21a)
-ELF_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G1, 0x21b)
-ELF_RELOC(R_AARCH64_TLSIE_MOVW_GOTTPREL_G0_NC, 0x21c)
-ELF_RELOC(R_AARCH64_TLSIE_ADR_GOTTPREL_PAGE21, 0x21d)
-ELF_RELOC(R_AARCH64_TLSIE_LD64_GOTTPREL_LO12_NC, 0x21e)
-ELF_RELOC(R_AARCH64_TLSIE_LD_GOTTPREL_PREL19, 0x21f)
-ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G2, 0x220)
-ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1, 0x221)
-ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G1_NC, 0x222)
-ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0, 0x223)
-ELF_RELOC(R_AARCH64_TLSLE_MOVW_TPREL_G0_NC, 0x224)
-ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_HI12, 0x225)
-ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12, 0x226)
-ELF_RELOC(R_AARCH64_TLSLE_ADD_TPREL_LO12_NC, 0x227)
-ELF_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12, 0x228)
-ELF_RELOC(R_AARCH64_TLSLE_LDST8_TPREL_LO12_NC, 0x229)
-ELF_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12, 0x22a)
-ELF_RELOC(R_AARCH64_TLSLE_LDST16_TPREL_LO12_NC, 0x22b)
-ELF_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12, 0x22c)
-ELF_RELOC(R_AARCH64_TLSLE_LDST32_TPREL_LO12_NC, 0x22d)
-ELF_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12, 0x22e)
-ELF_RELOC(R_AARCH64_TLSLE_LDST64_TPREL_LO12_NC, 0x22f)
-ELF_RELOC(R_AARCH64_TLSDESC_LD_PREL19, 0x230)
-ELF_RELOC(R_AARCH64_TLSDESC_ADR_PREL21, 0x231)
-ELF_RELOC(R_AARCH64_TLSDESC_ADR_PAGE21, 0x232)
-ELF_RELOC(R_AARCH64_TLSDESC_LD64_LO12_NC, 0x233)
-ELF_RELOC(R_AARCH64_TLSDESC_ADD_LO12_NC, 0x234)
-ELF_RELOC(R_AARCH64_TLSDESC_OFF_G1, 0x235)
-ELF_RELOC(R_AARCH64_TLSDESC_OFF_G0_NC, 0x236)
-ELF_RELOC(R_AARCH64_TLSDESC_LDR, 0x237)
-ELF_RELOC(R_AARCH64_TLSDESC_ADD, 0x238)
-ELF_RELOC(R_AARCH64_TLSDESC_CALL, 0x239)
-ELF_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12, 0x23a)
-ELF_RELOC(R_AARCH64_TLSLE_LDST128_TPREL_LO12_NC, 0x23b)
-ELF_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12, 0x23c)
-ELF_RELOC(R_AARCH64_TLSLD_LDST128_DTPREL_LO12_NC, 0x23d)
-ELF_RELOC(R_AARCH64_COPY, 0x400)
-ELF_RELOC(R_AARCH64_GLOB_DAT, 0x401)
-ELF_RELOC(R_AARCH64_JUMP_SLOT, 0x402)
-ELF_RELOC(R_AARCH64_RELATIVE, 0x403)
-ELF_RELOC(R_AARCH64_TLS_DTPREL64, 0x404)
-ELF_RELOC(R_AARCH64_TLS_DTPMOD64, 0x405)
-ELF_RELOC(R_AARCH64_TLS_TPREL64, 0x406)
-ELF_RELOC(R_AARCH64_TLSDESC, 0x407)
-ELF_RELOC(R_AARCH64_IRELATIVE, 0x408)
-
-// ELF_RELOC(R_AARCH64_P32_NONE, 0)
-ELF_RELOC(R_AARCH64_P32_ABS32, 0x001)
-ELF_RELOC(R_AARCH64_P32_ABS16, 0x002)
-ELF_RELOC(R_AARCH64_P32_PREL32, 0x003)
-ELF_RELOC(R_AARCH64_P32_PREL16, 0x004)
-ELF_RELOC(R_AARCH64_P32_MOVW_UABS_G0, 0x005)
-ELF_RELOC(R_AARCH64_P32_MOVW_UABS_G0_NC, 0x006)
-ELF_RELOC(R_AARCH64_P32_MOVW_UABS_G1, 0x007)
-ELF_RELOC(R_AARCH64_P32_MOVW_SABS_G0, 0x008)
-ELF_RELOC(R_AARCH64_P32_LD_PREL_LO19, 0x009)
-ELF_RELOC(R_AARCH64_P32_ADR_PREL_LO21, 0x00a)
-ELF_RELOC(R_AARCH64_P32_ADR_PREL_PG_HI21, 0x00b)
-ELF_RELOC(R_AARCH64_P32_ADD_ABS_LO12_NC, 0x00c)
-ELF_RELOC(R_AARCH64_P32_LDST8_ABS_LO12_NC, 0x00d)
-ELF_RELOC(R_AARCH64_P32_TSTBR14, 0x012)
-ELF_RELOC(R_AARCH64_P32_CONDBR19, 0x013)
-ELF_RELOC(R_AARCH64_P32_JUMP26, 0x014)
-ELF_RELOC(R_AARCH64_P32_CALL26, 0x015)
-ELF_RELOC(R_AARCH64_P32_LDST16_ABS_LO12_NC, 0x00e)
-ELF_RELOC(R_AARCH64_P32_LDST32_ABS_LO12_NC, 0x00f)
-ELF_RELOC(R_AARCH64_P32_LDST64_ABS_LO12_NC, 0x010)
-ELF_RELOC(R_AARCH64_P32_MOVW_PREL_G0, 0x016)
-ELF_RELOC(R_AARCH64_P32_MOVW_PREL_G0_NC, 0x017)
-ELF_RELOC(R_AARCH64_P32_MOVW_PREL_G1, 0x018)
-ELF_RELOC(R_AARCH64_P32_LDST128_ABS_LO12_NC, 0x011)
-ELF_RELOC(R_AARCH64_P32_GOT_LD_PREL19, 0x019)
-ELF_RELOC(R_AARCH64_P32_ADR_GOT_PAGE, 0x01a)
-ELF_RELOC(R_AARCH64_P32_LD64_GOT_LO12_NC, 0x01b)
-ELF_RELOC(R_AARCH64_P32_LD32_GOTPAGE_LO14, 0x01c)
-ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G1, 0x057)
-ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0, 0x058)
-ELF_RELOC(R_AARCH64_P32_TLSLD_MOVW_DTPREL_G0_NC, 0x059)
-ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_DTPREL_HI12, 0x05a)
-ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12, 0x05b)
-ELF_RELOC(R_AARCH64_P32_TLSLD_ADD_DTPREL_LO12_NC, 0x05c)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12, 0x05d)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST8_DTPREL_LO12_NC, 0x05e)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12, 0x05f)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST16_DTPREL_LO12_NC, 0x060)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12, 0x061)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST32_DTPREL_LO12_NC, 0x062)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12, 0x063)
-ELF_RELOC(R_AARCH64_P32_TLSLD_LDST64_DTPREL_LO12_NC, 0x064)
-ELF_RELOC(R_AARCH64_P32_TLSIE_ADR_GOTTPREL_PAGE21, 0x067)
-ELF_RELOC(R_AARCH64_P32_TLSIE_LD32_GOTTPREL_LO12_NC, 0x068)
-ELF_RELOC(R_AARCH64_P32_TLSIE_LD_GOTTPREL_PREL19, 0x069)
-ELF_RELOC(R_AARCH64_P32_TLSLE_MOVW_TPREL_G1, 0x06a)
-ELF_RELOC(R_AARCH64_P32_TLSLE_MOVW_TPREL_G0, 0x06b)
-ELF_RELOC(R_AARCH64_P32_TLSLE_MOVW_TPREL_G0_NC, 0x06c)
-ELF_RELOC(R_AARCH64_P32_TLSLE_ADD_TPREL_HI12, 0x06d)
-ELF_RELOC(R_AARCH64_P32_TLSLE_ADD_TPREL_LO12, 0x06e)
-ELF_RELOC(R_AARCH64_P32_TLSLE_ADD_TPREL_LO12_NC, 0x06f)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12, 0x070)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST8_TPREL_LO12_NC, 0x071)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12, 0x072)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST16_TPREL_LO12_NC, 0x073)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12, 0x074)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST32_TPREL_LO12_NC, 0x075)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12, 0x076)
-ELF_RELOC(R_AARCH64_P32_TLSLE_LDST64_TPREL_LO12_NC, 0x077)
-ELF_RELOC(R_AARCH64_P32_TLSDESC_ADR_PAGE21, 0x051)
-ELF_RELOC(R_AARCH64_P32_TLSDESC_LD32_LO12_NC, 0x07d)
-ELF_RELOC(R_AARCH64_P32_TLSDESC_ADD_LO12_NC, 0x034)
-ELF_RELOC(R_AARCH64_P32_TLSDESC_CALL, 0x07f)
-ELF_RELOC(R_AARCH64_P32_COPY, 0x0b4)
-ELF_RELOC(R_AARCH64_P32_GLOB_DAT, 0x0b5)
-ELF_RELOC(R_AARCH64_P32_JUMP_SLOT, 0x0b6)
-ELF_RELOC(R_AARCH64_P32_RELATIVE, 0x0b7)
-ELF_RELOC(R_AARCH64_P32_IRELATIVE, 0x0bc)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/AMDGPU.def b/contrib/llvm/include/llvm/Support/ELFRelocs/AMDGPU.def
deleted file mode 100644
index c66f88d1..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/AMDGPU.def
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_AMDGPU_NONE, 0)
-ELF_RELOC(R_AMDGPU_ABS32_LO, 1)
-ELF_RELOC(R_AMDGPU_ABS32_HI, 2)
-ELF_RELOC(R_AMDGPU_ABS64, 3)
-ELF_RELOC(R_AMDGPU_REL32, 4)
-ELF_RELOC(R_AMDGPU_REL64, 5)
-ELF_RELOC(R_AMDGPU_ABS32, 6)
-ELF_RELOC(R_AMDGPU_GOTPCREL, 7)
-ELF_RELOC(R_AMDGPU_GOTPCREL32_LO, 8)
-ELF_RELOC(R_AMDGPU_GOTPCREL32_HI, 9)
-ELF_RELOC(R_AMDGPU_REL32_LO, 10)
-ELF_RELOC(R_AMDGPU_REL32_HI, 11)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def b/contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def
deleted file mode 100644
index 730fc5b..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/ARM.def
+++ /dev/null
@@ -1,138 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// Meets 2.09 ABI Specs.
-ELF_RELOC(R_ARM_NONE, 0x00)
-ELF_RELOC(R_ARM_PC24, 0x01)
-ELF_RELOC(R_ARM_ABS32, 0x02)
-ELF_RELOC(R_ARM_REL32, 0x03)
-ELF_RELOC(R_ARM_LDR_PC_G0, 0x04)
-ELF_RELOC(R_ARM_ABS16, 0x05)
-ELF_RELOC(R_ARM_ABS12, 0x06)
-ELF_RELOC(R_ARM_THM_ABS5, 0x07)
-ELF_RELOC(R_ARM_ABS8, 0x08)
-ELF_RELOC(R_ARM_SBREL32, 0x09)
-ELF_RELOC(R_ARM_THM_CALL, 0x0a)
-ELF_RELOC(R_ARM_THM_PC8, 0x0b)
-ELF_RELOC(R_ARM_BREL_ADJ, 0x0c)
-ELF_RELOC(R_ARM_TLS_DESC, 0x0d)
-ELF_RELOC(R_ARM_THM_SWI8, 0x0e)
-ELF_RELOC(R_ARM_XPC25, 0x0f)
-ELF_RELOC(R_ARM_THM_XPC22, 0x10)
-ELF_RELOC(R_ARM_TLS_DTPMOD32, 0x11)
-ELF_RELOC(R_ARM_TLS_DTPOFF32, 0x12)
-ELF_RELOC(R_ARM_TLS_TPOFF32, 0x13)
-ELF_RELOC(R_ARM_COPY, 0x14)
-ELF_RELOC(R_ARM_GLOB_DAT, 0x15)
-ELF_RELOC(R_ARM_JUMP_SLOT, 0x16)
-ELF_RELOC(R_ARM_RELATIVE, 0x17)
-ELF_RELOC(R_ARM_GOTOFF32, 0x18)
-ELF_RELOC(R_ARM_BASE_PREL, 0x19)
-ELF_RELOC(R_ARM_GOT_BREL, 0x1a)
-ELF_RELOC(R_ARM_PLT32, 0x1b)
-ELF_RELOC(R_ARM_CALL, 0x1c)
-ELF_RELOC(R_ARM_JUMP24, 0x1d)
-ELF_RELOC(R_ARM_THM_JUMP24, 0x1e)
-ELF_RELOC(R_ARM_BASE_ABS, 0x1f)
-ELF_RELOC(R_ARM_ALU_PCREL_7_0, 0x20)
-ELF_RELOC(R_ARM_ALU_PCREL_15_8, 0x21)
-ELF_RELOC(R_ARM_ALU_PCREL_23_15, 0x22)
-ELF_RELOC(R_ARM_LDR_SBREL_11_0_NC, 0x23)
-ELF_RELOC(R_ARM_ALU_SBREL_19_12_NC, 0x24)
-ELF_RELOC(R_ARM_ALU_SBREL_27_20_CK, 0x25)
-ELF_RELOC(R_ARM_TARGET1, 0x26)
-ELF_RELOC(R_ARM_SBREL31, 0x27)
-ELF_RELOC(R_ARM_V4BX, 0x28)
-ELF_RELOC(R_ARM_TARGET2, 0x29)
-ELF_RELOC(R_ARM_PREL31, 0x2a)
-ELF_RELOC(R_ARM_MOVW_ABS_NC, 0x2b)
-ELF_RELOC(R_ARM_MOVT_ABS, 0x2c)
-ELF_RELOC(R_ARM_MOVW_PREL_NC, 0x2d)
-ELF_RELOC(R_ARM_MOVT_PREL, 0x2e)
-ELF_RELOC(R_ARM_THM_MOVW_ABS_NC, 0x2f)
-ELF_RELOC(R_ARM_THM_MOVT_ABS, 0x30)
-ELF_RELOC(R_ARM_THM_MOVW_PREL_NC, 0x31)
-ELF_RELOC(R_ARM_THM_MOVT_PREL, 0x32)
-ELF_RELOC(R_ARM_THM_JUMP19, 0x33)
-ELF_RELOC(R_ARM_THM_JUMP6, 0x34)
-ELF_RELOC(R_ARM_THM_ALU_PREL_11_0, 0x35)
-ELF_RELOC(R_ARM_THM_PC12, 0x36)
-ELF_RELOC(R_ARM_ABS32_NOI, 0x37)
-ELF_RELOC(R_ARM_REL32_NOI, 0x38)
-ELF_RELOC(R_ARM_ALU_PC_G0_NC, 0x39)
-ELF_RELOC(R_ARM_ALU_PC_G0, 0x3a)
-ELF_RELOC(R_ARM_ALU_PC_G1_NC, 0x3b)
-ELF_RELOC(R_ARM_ALU_PC_G1, 0x3c)
-ELF_RELOC(R_ARM_ALU_PC_G2, 0x3d)
-ELF_RELOC(R_ARM_LDR_PC_G1, 0x3e)
-ELF_RELOC(R_ARM_LDR_PC_G2, 0x3f)
-ELF_RELOC(R_ARM_LDRS_PC_G0, 0x40)
-ELF_RELOC(R_ARM_LDRS_PC_G1, 0x41)
-ELF_RELOC(R_ARM_LDRS_PC_G2, 0x42)
-ELF_RELOC(R_ARM_LDC_PC_G0, 0x43)
-ELF_RELOC(R_ARM_LDC_PC_G1, 0x44)
-ELF_RELOC(R_ARM_LDC_PC_G2, 0x45)
-ELF_RELOC(R_ARM_ALU_SB_G0_NC, 0x46)
-ELF_RELOC(R_ARM_ALU_SB_G0, 0x47)
-ELF_RELOC(R_ARM_ALU_SB_G1_NC, 0x48)
-ELF_RELOC(R_ARM_ALU_SB_G1, 0x49)
-ELF_RELOC(R_ARM_ALU_SB_G2, 0x4a)
-ELF_RELOC(R_ARM_LDR_SB_G0, 0x4b)
-ELF_RELOC(R_ARM_LDR_SB_G1, 0x4c)
-ELF_RELOC(R_ARM_LDR_SB_G2, 0x4d)
-ELF_RELOC(R_ARM_LDRS_SB_G0, 0x4e)
-ELF_RELOC(R_ARM_LDRS_SB_G1, 0x4f)
-ELF_RELOC(R_ARM_LDRS_SB_G2, 0x50)
-ELF_RELOC(R_ARM_LDC_SB_G0, 0x51)
-ELF_RELOC(R_ARM_LDC_SB_G1, 0x52)
-ELF_RELOC(R_ARM_LDC_SB_G2, 0x53)
-ELF_RELOC(R_ARM_MOVW_BREL_NC, 0x54)
-ELF_RELOC(R_ARM_MOVT_BREL, 0x55)
-ELF_RELOC(R_ARM_MOVW_BREL, 0x56)
-ELF_RELOC(R_ARM_THM_MOVW_BREL_NC, 0x57)
-ELF_RELOC(R_ARM_THM_MOVT_BREL, 0x58)
-ELF_RELOC(R_ARM_THM_MOVW_BREL, 0x59)
-ELF_RELOC(R_ARM_TLS_GOTDESC, 0x5a)
-ELF_RELOC(R_ARM_TLS_CALL, 0x5b)
-ELF_RELOC(R_ARM_TLS_DESCSEQ, 0x5c)
-ELF_RELOC(R_ARM_THM_TLS_CALL, 0x5d)
-ELF_RELOC(R_ARM_PLT32_ABS, 0x5e)
-ELF_RELOC(R_ARM_GOT_ABS, 0x5f)
-ELF_RELOC(R_ARM_GOT_PREL, 0x60)
-ELF_RELOC(R_ARM_GOT_BREL12, 0x61)
-ELF_RELOC(R_ARM_GOTOFF12, 0x62)
-ELF_RELOC(R_ARM_GOTRELAX, 0x63)
-ELF_RELOC(R_ARM_GNU_VTENTRY, 0x64)
-ELF_RELOC(R_ARM_GNU_VTINHERIT, 0x65)
-ELF_RELOC(R_ARM_THM_JUMP11, 0x66)
-ELF_RELOC(R_ARM_THM_JUMP8, 0x67)
-ELF_RELOC(R_ARM_TLS_GD32, 0x68)
-ELF_RELOC(R_ARM_TLS_LDM32, 0x69)
-ELF_RELOC(R_ARM_TLS_LDO32, 0x6a)
-ELF_RELOC(R_ARM_TLS_IE32, 0x6b)
-ELF_RELOC(R_ARM_TLS_LE32, 0x6c)
-ELF_RELOC(R_ARM_TLS_LDO12, 0x6d)
-ELF_RELOC(R_ARM_TLS_LE12, 0x6e)
-ELF_RELOC(R_ARM_TLS_IE12GP, 0x6f)
-ELF_RELOC(R_ARM_PRIVATE_0, 0x70)
-ELF_RELOC(R_ARM_PRIVATE_1, 0x71)
-ELF_RELOC(R_ARM_PRIVATE_2, 0x72)
-ELF_RELOC(R_ARM_PRIVATE_3, 0x73)
-ELF_RELOC(R_ARM_PRIVATE_4, 0x74)
-ELF_RELOC(R_ARM_PRIVATE_5, 0x75)
-ELF_RELOC(R_ARM_PRIVATE_6, 0x76)
-ELF_RELOC(R_ARM_PRIVATE_7, 0x77)
-ELF_RELOC(R_ARM_PRIVATE_8, 0x78)
-ELF_RELOC(R_ARM_PRIVATE_9, 0x79)
-ELF_RELOC(R_ARM_PRIVATE_10, 0x7a)
-ELF_RELOC(R_ARM_PRIVATE_11, 0x7b)
-ELF_RELOC(R_ARM_PRIVATE_12, 0x7c)
-ELF_RELOC(R_ARM_PRIVATE_13, 0x7d)
-ELF_RELOC(R_ARM_PRIVATE_14, 0x7e)
-ELF_RELOC(R_ARM_PRIVATE_15, 0x7f)
-ELF_RELOC(R_ARM_ME_TOO, 0x80)
-ELF_RELOC(R_ARM_THM_TLS_DESCSEQ16, 0x81)
-ELF_RELOC(R_ARM_THM_TLS_DESCSEQ32, 0x82)
-ELF_RELOC(R_ARM_IRELATIVE, 0xa0)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/AVR.def b/contrib/llvm/include/llvm/Support/ELFRelocs/AVR.def
deleted file mode 100644
index 5692d6c..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/AVR.def
+++ /dev/null
@@ -1,40 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_AVR_NONE, 0)
-ELF_RELOC(R_AVR_32, 1)
-ELF_RELOC(R_AVR_7_PCREL, 2)
-ELF_RELOC(R_AVR_13_PCREL, 3)
-ELF_RELOC(R_AVR_16, 4)
-ELF_RELOC(R_AVR_16_PM, 5)
-ELF_RELOC(R_AVR_LO8_LDI, 6)
-ELF_RELOC(R_AVR_HI8_LDI, 7)
-ELF_RELOC(R_AVR_HH8_LDI, 8)
-ELF_RELOC(R_AVR_LO8_LDI_NEG, 9)
-ELF_RELOC(R_AVR_HI8_LDI_NEG, 10)
-ELF_RELOC(R_AVR_HH8_LDI_NEG, 11)
-ELF_RELOC(R_AVR_LO8_LDI_PM, 12)
-ELF_RELOC(R_AVR_HI8_LDI_PM, 13)
-ELF_RELOC(R_AVR_HH8_LDI_PM, 14)
-ELF_RELOC(R_AVR_LO8_LDI_PM_NEG, 15)
-ELF_RELOC(R_AVR_HI8_LDI_PM_NEG, 16)
-ELF_RELOC(R_AVR_HH8_LDI_PM_NEG, 17)
-ELF_RELOC(R_AVR_CALL, 18)
-ELF_RELOC(R_AVR_LDI, 19)
-ELF_RELOC(R_AVR_6, 20)
-ELF_RELOC(R_AVR_6_ADIW, 21)
-ELF_RELOC(R_AVR_MS8_LDI, 22)
-ELF_RELOC(R_AVR_MS8_LDI_NEG, 23)
-ELF_RELOC(R_AVR_LO8_LDI_GS, 24)
-ELF_RELOC(R_AVR_HI8_LDI_GS, 25)
-ELF_RELOC(R_AVR_8, 26)
-ELF_RELOC(R_AVR_8_LO8, 27)
-ELF_RELOC(R_AVR_8_HI8, 28)
-ELF_RELOC(R_AVR_8_HLO8, 29)
-ELF_RELOC(R_AVR_SYM_DIFF, 30)
-ELF_RELOC(R_AVR_16_LDST, 31)
-ELF_RELOC(R_AVR_LDS_STS_16, 33)
-ELF_RELOC(R_AVR_PORT6, 34)
-ELF_RELOC(R_AVR_PORT5, 35)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/BPF.def b/contrib/llvm/include/llvm/Support/ELFRelocs/BPF.def
deleted file mode 100644
index 5dd7f70..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/BPF.def
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// No relocation
-ELF_RELOC(R_BPF_NONE, 0)
-ELF_RELOC(R_BPF_64_64, 1)
-ELF_RELOC(R_BPF_64_32, 10)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def
deleted file mode 100644
index 74e1d40..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/Hexagon.def
+++ /dev/null
@@ -1,101 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// Release 5 ABI
-ELF_RELOC(R_HEX_NONE, 0)
-ELF_RELOC(R_HEX_B22_PCREL, 1)
-ELF_RELOC(R_HEX_B15_PCREL, 2)
-ELF_RELOC(R_HEX_B7_PCREL, 3)
-ELF_RELOC(R_HEX_LO16, 4)
-ELF_RELOC(R_HEX_HI16, 5)
-ELF_RELOC(R_HEX_32, 6)
-ELF_RELOC(R_HEX_16, 7)
-ELF_RELOC(R_HEX_8, 8)
-ELF_RELOC(R_HEX_GPREL16_0, 9)
-ELF_RELOC(R_HEX_GPREL16_1, 10)
-ELF_RELOC(R_HEX_GPREL16_2, 11)
-ELF_RELOC(R_HEX_GPREL16_3, 12)
-ELF_RELOC(R_HEX_HL16, 13)
-ELF_RELOC(R_HEX_B13_PCREL, 14)
-ELF_RELOC(R_HEX_B9_PCREL, 15)
-ELF_RELOC(R_HEX_B32_PCREL_X, 16)
-ELF_RELOC(R_HEX_32_6_X, 17)
-ELF_RELOC(R_HEX_B22_PCREL_X, 18)
-ELF_RELOC(R_HEX_B15_PCREL_X, 19)
-ELF_RELOC(R_HEX_B13_PCREL_X, 20)
-ELF_RELOC(R_HEX_B9_PCREL_X, 21)
-ELF_RELOC(R_HEX_B7_PCREL_X, 22)
-ELF_RELOC(R_HEX_16_X, 23)
-ELF_RELOC(R_HEX_12_X, 24)
-ELF_RELOC(R_HEX_11_X, 25)
-ELF_RELOC(R_HEX_10_X, 26)
-ELF_RELOC(R_HEX_9_X, 27)
-ELF_RELOC(R_HEX_8_X, 28)
-ELF_RELOC(R_HEX_7_X, 29)
-ELF_RELOC(R_HEX_6_X, 30)
-ELF_RELOC(R_HEX_32_PCREL, 31)
-ELF_RELOC(R_HEX_COPY, 32)
-ELF_RELOC(R_HEX_GLOB_DAT, 33)
-ELF_RELOC(R_HEX_JMP_SLOT, 34)
-ELF_RELOC(R_HEX_RELATIVE, 35)
-ELF_RELOC(R_HEX_PLT_B22_PCREL, 36)
-ELF_RELOC(R_HEX_GOTREL_LO16, 37)
-ELF_RELOC(R_HEX_GOTREL_HI16, 38)
-ELF_RELOC(R_HEX_GOTREL_32, 39)
-ELF_RELOC(R_HEX_GOT_LO16, 40)
-ELF_RELOC(R_HEX_GOT_HI16, 41)
-ELF_RELOC(R_HEX_GOT_32, 42)
-ELF_RELOC(R_HEX_GOT_16, 43)
-ELF_RELOC(R_HEX_DTPMOD_32, 44)
-ELF_RELOC(R_HEX_DTPREL_LO16, 45)
-ELF_RELOC(R_HEX_DTPREL_HI16, 46)
-ELF_RELOC(R_HEX_DTPREL_32, 47)
-ELF_RELOC(R_HEX_DTPREL_16, 48)
-ELF_RELOC(R_HEX_GD_PLT_B22_PCREL, 49)
-ELF_RELOC(R_HEX_GD_GOT_LO16, 50)
-ELF_RELOC(R_HEX_GD_GOT_HI16, 51)
-ELF_RELOC(R_HEX_GD_GOT_32, 52)
-ELF_RELOC(R_HEX_GD_GOT_16, 53)
-ELF_RELOC(R_HEX_IE_LO16, 54)
-ELF_RELOC(R_HEX_IE_HI16, 55)
-ELF_RELOC(R_HEX_IE_32, 56)
-ELF_RELOC(R_HEX_IE_GOT_LO16, 57)
-ELF_RELOC(R_HEX_IE_GOT_HI16, 58)
-ELF_RELOC(R_HEX_IE_GOT_32, 59)
-ELF_RELOC(R_HEX_IE_GOT_16, 60)
-ELF_RELOC(R_HEX_TPREL_LO16, 61)
-ELF_RELOC(R_HEX_TPREL_HI16, 62)
-ELF_RELOC(R_HEX_TPREL_32, 63)
-ELF_RELOC(R_HEX_TPREL_16, 64)
-ELF_RELOC(R_HEX_6_PCREL_X, 65)
-ELF_RELOC(R_HEX_GOTREL_32_6_X, 66)
-ELF_RELOC(R_HEX_GOTREL_16_X, 67)
-ELF_RELOC(R_HEX_GOTREL_11_X, 68)
-ELF_RELOC(R_HEX_GOT_32_6_X, 69)
-ELF_RELOC(R_HEX_GOT_16_X, 70)
-ELF_RELOC(R_HEX_GOT_11_X, 71)
-ELF_RELOC(R_HEX_DTPREL_32_6_X, 72)
-ELF_RELOC(R_HEX_DTPREL_16_X, 73)
-ELF_RELOC(R_HEX_DTPREL_11_X, 74)
-ELF_RELOC(R_HEX_GD_GOT_32_6_X, 75)
-ELF_RELOC(R_HEX_GD_GOT_16_X, 76)
-ELF_RELOC(R_HEX_GD_GOT_11_X, 77)
-ELF_RELOC(R_HEX_IE_32_6_X, 78)
-ELF_RELOC(R_HEX_IE_16_X, 79)
-ELF_RELOC(R_HEX_IE_GOT_32_6_X, 80)
-ELF_RELOC(R_HEX_IE_GOT_16_X, 81)
-ELF_RELOC(R_HEX_IE_GOT_11_X, 82)
-ELF_RELOC(R_HEX_TPREL_32_6_X, 83)
-ELF_RELOC(R_HEX_TPREL_16_X, 84)
-ELF_RELOC(R_HEX_TPREL_11_X, 85)
-ELF_RELOC(R_HEX_LD_PLT_B22_PCREL, 86)
-ELF_RELOC(R_HEX_LD_GOT_LO16, 87)
-ELF_RELOC(R_HEX_LD_GOT_HI16, 88)
-ELF_RELOC(R_HEX_LD_GOT_32, 89)
-ELF_RELOC(R_HEX_LD_GOT_16, 90)
-ELF_RELOC(R_HEX_LD_GOT_32_6_X, 91)
-ELF_RELOC(R_HEX_LD_GOT_16_X, 92)
-ELF_RELOC(R_HEX_LD_GOT_11_X, 93)
-ELF_RELOC(R_HEX_23_REG, 94)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Lanai.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Lanai.def
deleted file mode 100644
index 77ecb04..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/Lanai.def
+++ /dev/null
@@ -1,19 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// No relocation
-ELF_RELOC(R_LANAI_NONE, 0)
-// 21-bit symbol relocation
-ELF_RELOC(R_LANAI_21, 1)
-// 21-bit symbol relocation with last two bits masked to 0
-ELF_RELOC(R_LANAI_21_F, 2)
-// 25-bit branch targets
-ELF_RELOC(R_LANAI_25, 3)
-// General 32-bit relocation
-ELF_RELOC(R_LANAI_32, 4)
-// Upper 16-bits of a symbolic relocation
-ELF_RELOC(R_LANAI_HI16, 5)
-// Lower 16-bits of a symbolic relocation
-ELF_RELOC(R_LANAI_LO16, 6)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def
deleted file mode 100644
index bc0088d..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/Mips.def
+++ /dev/null
@@ -1,117 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_MIPS_NONE, 0)
-ELF_RELOC(R_MIPS_16, 1)
-ELF_RELOC(R_MIPS_32, 2)
-ELF_RELOC(R_MIPS_REL32, 3)
-ELF_RELOC(R_MIPS_26, 4)
-ELF_RELOC(R_MIPS_HI16, 5)
-ELF_RELOC(R_MIPS_LO16, 6)
-ELF_RELOC(R_MIPS_GPREL16, 7)
-ELF_RELOC(R_MIPS_LITERAL, 8)
-ELF_RELOC(R_MIPS_GOT16, 9)
-ELF_RELOC(R_MIPS_PC16, 10)
-ELF_RELOC(R_MIPS_CALL16, 11)
-ELF_RELOC(R_MIPS_GPREL32, 12)
-ELF_RELOC(R_MIPS_UNUSED1, 13)
-ELF_RELOC(R_MIPS_UNUSED2, 14)
-ELF_RELOC(R_MIPS_UNUSED3, 15)
-ELF_RELOC(R_MIPS_SHIFT5, 16)
-ELF_RELOC(R_MIPS_SHIFT6, 17)
-ELF_RELOC(R_MIPS_64, 18)
-ELF_RELOC(R_MIPS_GOT_DISP, 19)
-ELF_RELOC(R_MIPS_GOT_PAGE, 20)
-ELF_RELOC(R_MIPS_GOT_OFST, 21)
-ELF_RELOC(R_MIPS_GOT_HI16, 22)
-ELF_RELOC(R_MIPS_GOT_LO16, 23)
-ELF_RELOC(R_MIPS_SUB, 24)
-ELF_RELOC(R_MIPS_INSERT_A, 25)
-ELF_RELOC(R_MIPS_INSERT_B, 26)
-ELF_RELOC(R_MIPS_DELETE, 27)
-ELF_RELOC(R_MIPS_HIGHER, 28)
-ELF_RELOC(R_MIPS_HIGHEST, 29)
-ELF_RELOC(R_MIPS_CALL_HI16, 30)
-ELF_RELOC(R_MIPS_CALL_LO16, 31)
-ELF_RELOC(R_MIPS_SCN_DISP, 32)
-ELF_RELOC(R_MIPS_REL16, 33)
-ELF_RELOC(R_MIPS_ADD_IMMEDIATE, 34)
-ELF_RELOC(R_MIPS_PJUMP, 35)
-ELF_RELOC(R_MIPS_RELGOT, 36)
-ELF_RELOC(R_MIPS_JALR, 37)
-ELF_RELOC(R_MIPS_TLS_DTPMOD32, 38)
-ELF_RELOC(R_MIPS_TLS_DTPREL32, 39)
-ELF_RELOC(R_MIPS_TLS_DTPMOD64, 40)
-ELF_RELOC(R_MIPS_TLS_DTPREL64, 41)
-ELF_RELOC(R_MIPS_TLS_GD, 42)
-ELF_RELOC(R_MIPS_TLS_LDM, 43)
-ELF_RELOC(R_MIPS_TLS_DTPREL_HI16, 44)
-ELF_RELOC(R_MIPS_TLS_DTPREL_LO16, 45)
-ELF_RELOC(R_MIPS_TLS_GOTTPREL, 46)
-ELF_RELOC(R_MIPS_TLS_TPREL32, 47)
-ELF_RELOC(R_MIPS_TLS_TPREL64, 48)
-ELF_RELOC(R_MIPS_TLS_TPREL_HI16, 49)
-ELF_RELOC(R_MIPS_TLS_TPREL_LO16, 50)
-ELF_RELOC(R_MIPS_GLOB_DAT, 51)
-ELF_RELOC(R_MIPS_PC21_S2, 60)
-ELF_RELOC(R_MIPS_PC26_S2, 61)
-ELF_RELOC(R_MIPS_PC18_S3, 62)
-ELF_RELOC(R_MIPS_PC19_S2, 63)
-ELF_RELOC(R_MIPS_PCHI16, 64)
-ELF_RELOC(R_MIPS_PCLO16, 65)
-ELF_RELOC(R_MIPS16_26, 100)
-ELF_RELOC(R_MIPS16_GPREL, 101)
-ELF_RELOC(R_MIPS16_GOT16, 102)
-ELF_RELOC(R_MIPS16_CALL16, 103)
-ELF_RELOC(R_MIPS16_HI16, 104)
-ELF_RELOC(R_MIPS16_LO16, 105)
-ELF_RELOC(R_MIPS16_TLS_GD, 106)
-ELF_RELOC(R_MIPS16_TLS_LDM, 107)
-ELF_RELOC(R_MIPS16_TLS_DTPREL_HI16, 108)
-ELF_RELOC(R_MIPS16_TLS_DTPREL_LO16, 109)
-ELF_RELOC(R_MIPS16_TLS_GOTTPREL, 110)
-ELF_RELOC(R_MIPS16_TLS_TPREL_HI16, 111)
-ELF_RELOC(R_MIPS16_TLS_TPREL_LO16, 112)
-ELF_RELOC(R_MIPS_COPY, 126)
-ELF_RELOC(R_MIPS_JUMP_SLOT, 127)
-ELF_RELOC(R_MICROMIPS_26_S1, 133)
-ELF_RELOC(R_MICROMIPS_HI16, 134)
-ELF_RELOC(R_MICROMIPS_LO16, 135)
-ELF_RELOC(R_MICROMIPS_GPREL16, 136)
-ELF_RELOC(R_MICROMIPS_LITERAL, 137)
-ELF_RELOC(R_MICROMIPS_GOT16, 138)
-ELF_RELOC(R_MICROMIPS_PC7_S1, 139)
-ELF_RELOC(R_MICROMIPS_PC10_S1, 140)
-ELF_RELOC(R_MICROMIPS_PC16_S1, 141)
-ELF_RELOC(R_MICROMIPS_CALL16, 142)
-ELF_RELOC(R_MICROMIPS_GOT_DISP, 145)
-ELF_RELOC(R_MICROMIPS_GOT_PAGE, 146)
-ELF_RELOC(R_MICROMIPS_GOT_OFST, 147)
-ELF_RELOC(R_MICROMIPS_GOT_HI16, 148)
-ELF_RELOC(R_MICROMIPS_GOT_LO16, 149)
-ELF_RELOC(R_MICROMIPS_SUB, 150)
-ELF_RELOC(R_MICROMIPS_HIGHER, 151)
-ELF_RELOC(R_MICROMIPS_HIGHEST, 152)
-ELF_RELOC(R_MICROMIPS_CALL_HI16, 153)
-ELF_RELOC(R_MICROMIPS_CALL_LO16, 154)
-ELF_RELOC(R_MICROMIPS_SCN_DISP, 155)
-ELF_RELOC(R_MICROMIPS_JALR, 156)
-ELF_RELOC(R_MICROMIPS_HI0_LO16, 157)
-ELF_RELOC(R_MICROMIPS_TLS_GD, 162)
-ELF_RELOC(R_MICROMIPS_TLS_LDM, 163)
-ELF_RELOC(R_MICROMIPS_TLS_DTPREL_HI16, 164)
-ELF_RELOC(R_MICROMIPS_TLS_DTPREL_LO16, 165)
-ELF_RELOC(R_MICROMIPS_TLS_GOTTPREL, 166)
-ELF_RELOC(R_MICROMIPS_TLS_TPREL_HI16, 169)
-ELF_RELOC(R_MICROMIPS_TLS_TPREL_LO16, 170)
-ELF_RELOC(R_MICROMIPS_GPREL7_S2, 172)
-ELF_RELOC(R_MICROMIPS_PC23_S2, 173)
-ELF_RELOC(R_MICROMIPS_PC21_S1, 174)
-ELF_RELOC(R_MICROMIPS_PC26_S1, 175)
-ELF_RELOC(R_MICROMIPS_PC18_S3, 176)
-ELF_RELOC(R_MICROMIPS_PC19_S2, 177)
-ELF_RELOC(R_MIPS_NUM, 218)
-ELF_RELOC(R_MIPS_PC32, 248)
-ELF_RELOC(R_MIPS_EH, 249)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def b/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def
deleted file mode 100644
index e4f8ee0..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC.def
+++ /dev/null
@@ -1,123 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// glibc's PowerPC asm/sigcontext.h, when compiling for PPC64, has the
-// unfortunate behavior of including asm/elf.h, which defines R_PPC_NONE, etc.
-// to their corresponding integer values. As a result, we need to undef them
-// here before continuing.
-
-#undef R_PPC_NONE
-#undef R_PPC_ADDR32
-#undef R_PPC_ADDR24
-#undef R_PPC_ADDR16
-#undef R_PPC_ADDR16_LO
-#undef R_PPC_ADDR16_HI
-#undef R_PPC_ADDR16_HA
-#undef R_PPC_ADDR14
-#undef R_PPC_ADDR14_BRTAKEN
-#undef R_PPC_ADDR14_BRNTAKEN
-#undef R_PPC_REL24
-#undef R_PPC_REL14
-#undef R_PPC_REL14_BRTAKEN
-#undef R_PPC_REL14_BRNTAKEN
-#undef R_PPC_GOT16
-#undef R_PPC_GOT16_LO
-#undef R_PPC_GOT16_HI
-#undef R_PPC_GOT16_HA
-#undef R_PPC_PLTREL24
-#undef R_PPC_JMP_SLOT
-#undef R_PPC_LOCAL24PC
-#undef R_PPC_REL32
-#undef R_PPC_TLS
-#undef R_PPC_DTPMOD32
-#undef R_PPC_TPREL16
-#undef R_PPC_TPREL16_LO
-#undef R_PPC_TPREL16_HI
-#undef R_PPC_TPREL16_HA
-#undef R_PPC_TPREL32
-#undef R_PPC_DTPREL16
-#undef R_PPC_DTPREL16_LO
-#undef R_PPC_DTPREL16_HI
-#undef R_PPC_DTPREL16_HA
-#undef R_PPC_DTPREL32
-#undef R_PPC_GOT_TLSGD16
-#undef R_PPC_GOT_TLSGD16_LO
-#undef R_PPC_GOT_TLSGD16_HI
-#undef R_PPC_GOT_TLSGD16_HA
-#undef R_PPC_GOT_TLSLD16
-#undef R_PPC_GOT_TLSLD16_LO
-#undef R_PPC_GOT_TLSLD16_HI
-#undef R_PPC_GOT_TLSLD16_HA
-#undef R_PPC_GOT_TPREL16
-#undef R_PPC_GOT_TPREL16_LO
-#undef R_PPC_GOT_TPREL16_HI
-#undef R_PPC_GOT_TPREL16_HA
-#undef R_PPC_GOT_DTPREL16
-#undef R_PPC_GOT_DTPREL16_LO
-#undef R_PPC_GOT_DTPREL16_HI
-#undef R_PPC_GOT_DTPREL16_HA
-#undef R_PPC_TLSGD
-#undef R_PPC_TLSLD
-#undef R_PPC_REL16
-#undef R_PPC_REL16_LO
-#undef R_PPC_REL16_HI
-#undef R_PPC_REL16_HA
-
-ELF_RELOC(R_PPC_NONE, 0) /* No relocation. */
-ELF_RELOC(R_PPC_ADDR32, 1)
-ELF_RELOC(R_PPC_ADDR24, 2)
-ELF_RELOC(R_PPC_ADDR16, 3)
-ELF_RELOC(R_PPC_ADDR16_LO, 4)
-ELF_RELOC(R_PPC_ADDR16_HI, 5)
-ELF_RELOC(R_PPC_ADDR16_HA, 6)
-ELF_RELOC(R_PPC_ADDR14, 7)
-ELF_RELOC(R_PPC_ADDR14_BRTAKEN, 8)
-ELF_RELOC(R_PPC_ADDR14_BRNTAKEN, 9)
-ELF_RELOC(R_PPC_REL24, 10)
-ELF_RELOC(R_PPC_REL14, 11)
-ELF_RELOC(R_PPC_REL14_BRTAKEN, 12)
-ELF_RELOC(R_PPC_REL14_BRNTAKEN, 13)
-ELF_RELOC(R_PPC_GOT16, 14)
-ELF_RELOC(R_PPC_GOT16_LO, 15)
-ELF_RELOC(R_PPC_GOT16_HI, 16)
-ELF_RELOC(R_PPC_GOT16_HA, 17)
-ELF_RELOC(R_PPC_PLTREL24, 18)
-ELF_RELOC(R_PPC_JMP_SLOT, 21)
-ELF_RELOC(R_PPC_LOCAL24PC, 23)
-ELF_RELOC(R_PPC_REL32, 26)
-ELF_RELOC(R_PPC_TLS, 67)
-ELF_RELOC(R_PPC_DTPMOD32, 68)
-ELF_RELOC(R_PPC_TPREL16, 69)
-ELF_RELOC(R_PPC_TPREL16_LO, 70)
-ELF_RELOC(R_PPC_TPREL16_HI, 71)
-ELF_RELOC(R_PPC_TPREL16_HA, 72)
-ELF_RELOC(R_PPC_TPREL32, 73)
-ELF_RELOC(R_PPC_DTPREL16, 74)
-ELF_RELOC(R_PPC_DTPREL16_LO, 75)
-ELF_RELOC(R_PPC_DTPREL16_HI, 76)
-ELF_RELOC(R_PPC_DTPREL16_HA, 77)
-ELF_RELOC(R_PPC_DTPREL32, 78)
-ELF_RELOC(R_PPC_GOT_TLSGD16, 79)
-ELF_RELOC(R_PPC_GOT_TLSGD16_LO, 80)
-ELF_RELOC(R_PPC_GOT_TLSGD16_HI, 81)
-ELF_RELOC(R_PPC_GOT_TLSGD16_HA, 82)
-ELF_RELOC(R_PPC_GOT_TLSLD16, 83)
-ELF_RELOC(R_PPC_GOT_TLSLD16_LO, 84)
-ELF_RELOC(R_PPC_GOT_TLSLD16_HI, 85)
-ELF_RELOC(R_PPC_GOT_TLSLD16_HA, 86)
-ELF_RELOC(R_PPC_GOT_TPREL16, 87)
-ELF_RELOC(R_PPC_GOT_TPREL16_LO, 88)
-ELF_RELOC(R_PPC_GOT_TPREL16_HI, 89)
-ELF_RELOC(R_PPC_GOT_TPREL16_HA, 90)
-ELF_RELOC(R_PPC_GOT_DTPREL16, 91)
-ELF_RELOC(R_PPC_GOT_DTPREL16_LO, 92)
-ELF_RELOC(R_PPC_GOT_DTPREL16_HI, 93)
-ELF_RELOC(R_PPC_GOT_DTPREL16_HA, 94)
-ELF_RELOC(R_PPC_TLSGD, 95)
-ELF_RELOC(R_PPC_TLSLD, 96)
-ELF_RELOC(R_PPC_REL16, 249)
-ELF_RELOC(R_PPC_REL16_LO, 250)
-ELF_RELOC(R_PPC_REL16_HI, 251)
-ELF_RELOC(R_PPC_REL16_HA, 252)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def b/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def
deleted file mode 100644
index 3a47c5a..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/PowerPC64.def
+++ /dev/null
@@ -1,181 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// glibc's PowerPC asm/sigcontext.h, when compiling for PPC64, has the
-// unfortunate behavior of including asm/elf.h, which defines R_PPC_NONE, etc.
-// to their corresponding integer values. As a result, we need to undef them
-// here before continuing.
-
-#undef R_PPC64_NONE
-#undef R_PPC64_ADDR32
-#undef R_PPC64_ADDR24
-#undef R_PPC64_ADDR16
-#undef R_PPC64_ADDR16_LO
-#undef R_PPC64_ADDR16_HI
-#undef R_PPC64_ADDR16_HA
-#undef R_PPC64_ADDR14
-#undef R_PPC64_ADDR14_BRTAKEN
-#undef R_PPC64_ADDR14_BRNTAKEN
-#undef R_PPC64_REL24
-#undef R_PPC64_REL14
-#undef R_PPC64_REL14_BRTAKEN
-#undef R_PPC64_REL14_BRNTAKEN
-#undef R_PPC64_GOT16
-#undef R_PPC64_GOT16_LO
-#undef R_PPC64_GOT16_HI
-#undef R_PPC64_GOT16_HA
-#undef R_PPC64_GLOB_DAT
-#undef R_PPC64_JMP_SLOT
-#undef R_PPC64_RELATIVE
-#undef R_PPC64_REL32
-#undef R_PPC64_ADDR64
-#undef R_PPC64_ADDR16_HIGHER
-#undef R_PPC64_ADDR16_HIGHERA
-#undef R_PPC64_ADDR16_HIGHEST
-#undef R_PPC64_ADDR16_HIGHESTA
-#undef R_PPC64_REL64
-#undef R_PPC64_TOC16
-#undef R_PPC64_TOC16_LO
-#undef R_PPC64_TOC16_HI
-#undef R_PPC64_TOC16_HA
-#undef R_PPC64_TOC
-#undef R_PPC64_ADDR16_DS
-#undef R_PPC64_ADDR16_LO_DS
-#undef R_PPC64_GOT16_DS
-#undef R_PPC64_GOT16_LO_DS
-#undef R_PPC64_TOC16_DS
-#undef R_PPC64_TOC16_LO_DS
-#undef R_PPC64_TLS
-#undef R_PPC64_DTPMOD64
-#undef R_PPC64_TPREL16
-#undef R_PPC64_TPREL16_LO
-#undef R_PPC64_TPREL16_HI
-#undef R_PPC64_TPREL16_HA
-#undef R_PPC64_TPREL64
-#undef R_PPC64_DTPREL16
-#undef R_PPC64_DTPREL16_LO
-#undef R_PPC64_DTPREL16_HI
-#undef R_PPC64_DTPREL16_HA
-#undef R_PPC64_DTPREL64
-#undef R_PPC64_GOT_TLSGD16
-#undef R_PPC64_GOT_TLSGD16_LO
-#undef R_PPC64_GOT_TLSGD16_HI
-#undef R_PPC64_GOT_TLSGD16_HA
-#undef R_PPC64_GOT_TLSLD16
-#undef R_PPC64_GOT_TLSLD16_LO
-#undef R_PPC64_GOT_TLSLD16_HI
-#undef R_PPC64_GOT_TLSLD16_HA
-#undef R_PPC64_GOT_TPREL16_DS
-#undef R_PPC64_GOT_TPREL16_LO_DS
-#undef R_PPC64_GOT_TPREL16_HI
-#undef R_PPC64_GOT_TPREL16_HA
-#undef R_PPC64_GOT_DTPREL16_DS
-#undef R_PPC64_GOT_DTPREL16_LO_DS
-#undef R_PPC64_GOT_DTPREL16_HI
-#undef R_PPC64_GOT_DTPREL16_HA
-#undef R_PPC64_TPREL16_DS
-#undef R_PPC64_TPREL16_LO_DS
-#undef R_PPC64_TPREL16_HIGHER
-#undef R_PPC64_TPREL16_HIGHERA
-#undef R_PPC64_TPREL16_HIGHEST
-#undef R_PPC64_TPREL16_HIGHESTA
-#undef R_PPC64_DTPREL16_DS
-#undef R_PPC64_DTPREL16_LO_DS
-#undef R_PPC64_DTPREL16_HIGHER
-#undef R_PPC64_DTPREL16_HIGHERA
-#undef R_PPC64_DTPREL16_HIGHEST
-#undef R_PPC64_DTPREL16_HIGHESTA
-#undef R_PPC64_TLSGD
-#undef R_PPC64_TLSLD
-#undef R_PPC64_REL16
-#undef R_PPC64_REL16_LO
-#undef R_PPC64_REL16_HI
-#undef R_PPC64_REL16_HA
-
-ELF_RELOC(R_PPC64_NONE, 0)
-ELF_RELOC(R_PPC64_ADDR32, 1)
-ELF_RELOC(R_PPC64_ADDR24, 2)
-ELF_RELOC(R_PPC64_ADDR16, 3)
-ELF_RELOC(R_PPC64_ADDR16_LO, 4)
-ELF_RELOC(R_PPC64_ADDR16_HI, 5)
-ELF_RELOC(R_PPC64_ADDR16_HA, 6)
-ELF_RELOC(R_PPC64_ADDR14, 7)
-ELF_RELOC(R_PPC64_ADDR14_BRTAKEN, 8)
-ELF_RELOC(R_PPC64_ADDR14_BRNTAKEN, 9)
-ELF_RELOC(R_PPC64_REL24, 10)
-ELF_RELOC(R_PPC64_REL14, 11)
-ELF_RELOC(R_PPC64_REL14_BRTAKEN, 12)
-ELF_RELOC(R_PPC64_REL14_BRNTAKEN, 13)
-ELF_RELOC(R_PPC64_GOT16, 14)
-ELF_RELOC(R_PPC64_GOT16_LO, 15)
-ELF_RELOC(R_PPC64_GOT16_HI, 16)
-ELF_RELOC(R_PPC64_GOT16_HA, 17)
-ELF_RELOC(R_PPC64_GLOB_DAT, 20)
-ELF_RELOC(R_PPC64_JMP_SLOT, 21)
-ELF_RELOC(R_PPC64_RELATIVE, 22)
-ELF_RELOC(R_PPC64_REL32, 26)
-ELF_RELOC(R_PPC64_ADDR64, 38)
-ELF_RELOC(R_PPC64_ADDR16_HIGHER, 39)
-ELF_RELOC(R_PPC64_ADDR16_HIGHERA, 40)
-ELF_RELOC(R_PPC64_ADDR16_HIGHEST, 41)
-ELF_RELOC(R_PPC64_ADDR16_HIGHESTA, 42)
-ELF_RELOC(R_PPC64_REL64, 44)
-ELF_RELOC(R_PPC64_TOC16, 47)
-ELF_RELOC(R_PPC64_TOC16_LO, 48)
-ELF_RELOC(R_PPC64_TOC16_HI, 49)
-ELF_RELOC(R_PPC64_TOC16_HA, 50)
-ELF_RELOC(R_PPC64_TOC, 51)
-ELF_RELOC(R_PPC64_ADDR16_DS, 56)
-ELF_RELOC(R_PPC64_ADDR16_LO_DS, 57)
-ELF_RELOC(R_PPC64_GOT16_DS, 58)
-ELF_RELOC(R_PPC64_GOT16_LO_DS, 59)
-ELF_RELOC(R_PPC64_TOC16_DS, 63)
-ELF_RELOC(R_PPC64_TOC16_LO_DS, 64)
-ELF_RELOC(R_PPC64_TLS, 67)
-ELF_RELOC(R_PPC64_DTPMOD64, 68)
-ELF_RELOC(R_PPC64_TPREL16, 69)
-ELF_RELOC(R_PPC64_TPREL16_LO, 70)
-ELF_RELOC(R_PPC64_TPREL16_HI, 71)
-ELF_RELOC(R_PPC64_TPREL16_HA, 72)
-ELF_RELOC(R_PPC64_TPREL64, 73)
-ELF_RELOC(R_PPC64_DTPREL16, 74)
-ELF_RELOC(R_PPC64_DTPREL16_LO, 75)
-ELF_RELOC(R_PPC64_DTPREL16_HI, 76)
-ELF_RELOC(R_PPC64_DTPREL16_HA, 77)
-ELF_RELOC(R_PPC64_DTPREL64, 78)
-ELF_RELOC(R_PPC64_GOT_TLSGD16, 79)
-ELF_RELOC(R_PPC64_GOT_TLSGD16_LO, 80)
-ELF_RELOC(R_PPC64_GOT_TLSGD16_HI, 81)
-ELF_RELOC(R_PPC64_GOT_TLSGD16_HA, 82)
-ELF_RELOC(R_PPC64_GOT_TLSLD16, 83)
-ELF_RELOC(R_PPC64_GOT_TLSLD16_LO, 84)
-ELF_RELOC(R_PPC64_GOT_TLSLD16_HI, 85)
-ELF_RELOC(R_PPC64_GOT_TLSLD16_HA, 86)
-ELF_RELOC(R_PPC64_GOT_TPREL16_DS, 87)
-ELF_RELOC(R_PPC64_GOT_TPREL16_LO_DS, 88)
-ELF_RELOC(R_PPC64_GOT_TPREL16_HI, 89)
-ELF_RELOC(R_PPC64_GOT_TPREL16_HA, 90)
-ELF_RELOC(R_PPC64_GOT_DTPREL16_DS, 91)
-ELF_RELOC(R_PPC64_GOT_DTPREL16_LO_DS, 92)
-ELF_RELOC(R_PPC64_GOT_DTPREL16_HI, 93)
-ELF_RELOC(R_PPC64_GOT_DTPREL16_HA, 94)
-ELF_RELOC(R_PPC64_TPREL16_DS, 95)
-ELF_RELOC(R_PPC64_TPREL16_LO_DS, 96)
-ELF_RELOC(R_PPC64_TPREL16_HIGHER, 97)
-ELF_RELOC(R_PPC64_TPREL16_HIGHERA, 98)
-ELF_RELOC(R_PPC64_TPREL16_HIGHEST, 99)
-ELF_RELOC(R_PPC64_TPREL16_HIGHESTA, 100)
-ELF_RELOC(R_PPC64_DTPREL16_DS, 101)
-ELF_RELOC(R_PPC64_DTPREL16_LO_DS, 102)
-ELF_RELOC(R_PPC64_DTPREL16_HIGHER, 103)
-ELF_RELOC(R_PPC64_DTPREL16_HIGHERA, 104)
-ELF_RELOC(R_PPC64_DTPREL16_HIGHEST, 105)
-ELF_RELOC(R_PPC64_DTPREL16_HIGHESTA, 106)
-ELF_RELOC(R_PPC64_TLSGD, 107)
-ELF_RELOC(R_PPC64_TLSLD, 108)
-ELF_RELOC(R_PPC64_REL16, 249)
-ELF_RELOC(R_PPC64_REL16_LO, 250)
-ELF_RELOC(R_PPC64_REL16_HI, 251)
-ELF_RELOC(R_PPC64_REL16_HA, 252)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/RISCV.def b/contrib/llvm/include/llvm/Support/ELFRelocs/RISCV.def
deleted file mode 100644
index 9ec4955..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/RISCV.def
+++ /dev/null
@@ -1,50 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_RISCV_NONE, 0)
-ELF_RELOC(R_RISCV_32, 1)
-ELF_RELOC(R_RISCV_64, 2)
-ELF_RELOC(R_RISCV_RELATIVE, 3)
-ELF_RELOC(R_RISCV_COPY, 4)
-ELF_RELOC(R_RISCV_JUMP_SLOT, 5)
-ELF_RELOC(R_RISCV_TLS_DTPMOD32, 6)
-ELF_RELOC(R_RISCV_TLS_DTPMOD64, 7)
-ELF_RELOC(R_RISCV_TLS_DTPREL32, 8)
-ELF_RELOC(R_RISCV_TLS_DTPREL64, 9)
-ELF_RELOC(R_RISCV_TLS_TPREL32, 10)
-ELF_RELOC(R_RISCV_TLS_TPREL64, 11)
-ELF_RELOC(R_RISCV_BRANCH, 16)
-ELF_RELOC(R_RISCV_JAL, 17)
-ELF_RELOC(R_RISCV_CALL, 18)
-ELF_RELOC(R_RISCV_CALL_PLT, 19)
-ELF_RELOC(R_RISCV_GOT_HI20, 20)
-ELF_RELOC(R_RISCV_TLS_GOT_HI20, 21)
-ELF_RELOC(R_RISCV_TLS_GD_HI20, 22)
-ELF_RELOC(R_RISCV_PCREL_HI20, 23)
-ELF_RELOC(R_RISCV_PCREL_LO12_I, 24)
-ELF_RELOC(R_RISCV_PCREL_LO12_S, 25)
-ELF_RELOC(R_RISCV_HI20, 26)
-ELF_RELOC(R_RISCV_LO12_I, 27)
-ELF_RELOC(R_RISCV_LO12_S, 28)
-ELF_RELOC(R_RISCV_TPREL_HI20, 29)
-ELF_RELOC(R_RISCV_TPREL_LO12_I, 30)
-ELF_RELOC(R_RISCV_TPREL_LO12_S, 31)
-ELF_RELOC(R_RISCV_TPREL_ADD, 32)
-ELF_RELOC(R_RISCV_ADD8, 33)
-ELF_RELOC(R_RISCV_ADD16, 34)
-ELF_RELOC(R_RISCV_ADD32, 35)
-ELF_RELOC(R_RISCV_ADD64, 36)
-ELF_RELOC(R_RISCV_SUB8, 37)
-ELF_RELOC(R_RISCV_SUB16, 38)
-ELF_RELOC(R_RISCV_SUB32, 39)
-ELF_RELOC(R_RISCV_SUB64, 40)
-ELF_RELOC(R_RISCV_GNU_VTINHERIT, 41)
-ELF_RELOC(R_RISCV_GNU_VTENTRY, 42)
-ELF_RELOC(R_RISCV_ALIGN, 43)
-ELF_RELOC(R_RISCV_RVC_BRANCH, 44)
-ELF_RELOC(R_RISCV_RVC_JUMP, 45)
-ELF_RELOC(R_RISCV_RVC_LUI, 46)
-ELF_RELOC(R_RISCV_GPREL_I, 47)
-ELF_RELOC(R_RISCV_GPREL_S, 48)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def b/contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def
deleted file mode 100644
index 7e01a4a..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/Sparc.def
+++ /dev/null
@@ -1,89 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_SPARC_NONE, 0)
-ELF_RELOC(R_SPARC_8, 1)
-ELF_RELOC(R_SPARC_16, 2)
-ELF_RELOC(R_SPARC_32, 3)
-ELF_RELOC(R_SPARC_DISP8, 4)
-ELF_RELOC(R_SPARC_DISP16, 5)
-ELF_RELOC(R_SPARC_DISP32, 6)
-ELF_RELOC(R_SPARC_WDISP30, 7)
-ELF_RELOC(R_SPARC_WDISP22, 8)
-ELF_RELOC(R_SPARC_HI22, 9)
-ELF_RELOC(R_SPARC_22, 10)
-ELF_RELOC(R_SPARC_13, 11)
-ELF_RELOC(R_SPARC_LO10, 12)
-ELF_RELOC(R_SPARC_GOT10, 13)
-ELF_RELOC(R_SPARC_GOT13, 14)
-ELF_RELOC(R_SPARC_GOT22, 15)
-ELF_RELOC(R_SPARC_PC10, 16)
-ELF_RELOC(R_SPARC_PC22, 17)
-ELF_RELOC(R_SPARC_WPLT30, 18)
-ELF_RELOC(R_SPARC_COPY, 19)
-ELF_RELOC(R_SPARC_GLOB_DAT, 20)
-ELF_RELOC(R_SPARC_JMP_SLOT, 21)
-ELF_RELOC(R_SPARC_RELATIVE, 22)
-ELF_RELOC(R_SPARC_UA32, 23)
-ELF_RELOC(R_SPARC_PLT32, 24)
-ELF_RELOC(R_SPARC_HIPLT22, 25)
-ELF_RELOC(R_SPARC_LOPLT10, 26)
-ELF_RELOC(R_SPARC_PCPLT32, 27)
-ELF_RELOC(R_SPARC_PCPLT22, 28)
-ELF_RELOC(R_SPARC_PCPLT10, 29)
-ELF_RELOC(R_SPARC_10, 30)
-ELF_RELOC(R_SPARC_11, 31)
-ELF_RELOC(R_SPARC_64, 32)
-ELF_RELOC(R_SPARC_OLO10, 33)
-ELF_RELOC(R_SPARC_HH22, 34)
-ELF_RELOC(R_SPARC_HM10, 35)
-ELF_RELOC(R_SPARC_LM22, 36)
-ELF_RELOC(R_SPARC_PC_HH22, 37)
-ELF_RELOC(R_SPARC_PC_HM10, 38)
-ELF_RELOC(R_SPARC_PC_LM22, 39)
-ELF_RELOC(R_SPARC_WDISP16, 40)
-ELF_RELOC(R_SPARC_WDISP19, 41)
-ELF_RELOC(R_SPARC_7, 43)
-ELF_RELOC(R_SPARC_5, 44)
-ELF_RELOC(R_SPARC_6, 45)
-ELF_RELOC(R_SPARC_DISP64, 46)
-ELF_RELOC(R_SPARC_PLT64, 47)
-ELF_RELOC(R_SPARC_HIX22, 48)
-ELF_RELOC(R_SPARC_LOX10, 49)
-ELF_RELOC(R_SPARC_H44, 50)
-ELF_RELOC(R_SPARC_M44, 51)
-ELF_RELOC(R_SPARC_L44, 52)
-ELF_RELOC(R_SPARC_REGISTER, 53)
-ELF_RELOC(R_SPARC_UA64, 54)
-ELF_RELOC(R_SPARC_UA16, 55)
-ELF_RELOC(R_SPARC_TLS_GD_HI22, 56)
-ELF_RELOC(R_SPARC_TLS_GD_LO10, 57)
-ELF_RELOC(R_SPARC_TLS_GD_ADD, 58)
-ELF_RELOC(R_SPARC_TLS_GD_CALL, 59)
-ELF_RELOC(R_SPARC_TLS_LDM_HI22, 60)
-ELF_RELOC(R_SPARC_TLS_LDM_LO10, 61)
-ELF_RELOC(R_SPARC_TLS_LDM_ADD, 62)
-ELF_RELOC(R_SPARC_TLS_LDM_CALL, 63)
-ELF_RELOC(R_SPARC_TLS_LDO_HIX22, 64)
-ELF_RELOC(R_SPARC_TLS_LDO_LOX10, 65)
-ELF_RELOC(R_SPARC_TLS_LDO_ADD, 66)
-ELF_RELOC(R_SPARC_TLS_IE_HI22, 67)
-ELF_RELOC(R_SPARC_TLS_IE_LO10, 68)
-ELF_RELOC(R_SPARC_TLS_IE_LD, 69)
-ELF_RELOC(R_SPARC_TLS_IE_LDX, 70)
-ELF_RELOC(R_SPARC_TLS_IE_ADD, 71)
-ELF_RELOC(R_SPARC_TLS_LE_HIX22, 72)
-ELF_RELOC(R_SPARC_TLS_LE_LOX10, 73)
-ELF_RELOC(R_SPARC_TLS_DTPMOD32, 74)
-ELF_RELOC(R_SPARC_TLS_DTPMOD64, 75)
-ELF_RELOC(R_SPARC_TLS_DTPOFF32, 76)
-ELF_RELOC(R_SPARC_TLS_DTPOFF64, 77)
-ELF_RELOC(R_SPARC_TLS_TPOFF32, 78)
-ELF_RELOC(R_SPARC_TLS_TPOFF64, 79)
-ELF_RELOC(R_SPARC_GOTDATA_HIX22, 80)
-ELF_RELOC(R_SPARC_GOTDATA_LOX10, 81)
-ELF_RELOC(R_SPARC_GOTDATA_OP_HIX22, 82)
-ELF_RELOC(R_SPARC_GOTDATA_OP_LOX10, 83)
-ELF_RELOC(R_SPARC_GOTDATA_OP, 84)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def b/contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def
deleted file mode 100644
index d6c0b79..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/SystemZ.def
+++ /dev/null
@@ -1,71 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_390_NONE, 0)
-ELF_RELOC(R_390_8, 1)
-ELF_RELOC(R_390_12, 2)
-ELF_RELOC(R_390_16, 3)
-ELF_RELOC(R_390_32, 4)
-ELF_RELOC(R_390_PC32, 5)
-ELF_RELOC(R_390_GOT12, 6)
-ELF_RELOC(R_390_GOT32, 7)
-ELF_RELOC(R_390_PLT32, 8)
-ELF_RELOC(R_390_COPY, 9)
-ELF_RELOC(R_390_GLOB_DAT, 10)
-ELF_RELOC(R_390_JMP_SLOT, 11)
-ELF_RELOC(R_390_RELATIVE, 12)
-ELF_RELOC(R_390_GOTOFF, 13)
-ELF_RELOC(R_390_GOTPC, 14)
-ELF_RELOC(R_390_GOT16, 15)
-ELF_RELOC(R_390_PC16, 16)
-ELF_RELOC(R_390_PC16DBL, 17)
-ELF_RELOC(R_390_PLT16DBL, 18)
-ELF_RELOC(R_390_PC32DBL, 19)
-ELF_RELOC(R_390_PLT32DBL, 20)
-ELF_RELOC(R_390_GOTPCDBL, 21)
-ELF_RELOC(R_390_64, 22)
-ELF_RELOC(R_390_PC64, 23)
-ELF_RELOC(R_390_GOT64, 24)
-ELF_RELOC(R_390_PLT64, 25)
-ELF_RELOC(R_390_GOTENT, 26)
-ELF_RELOC(R_390_GOTOFF16, 27)
-ELF_RELOC(R_390_GOTOFF64, 28)
-ELF_RELOC(R_390_GOTPLT12, 29)
-ELF_RELOC(R_390_GOTPLT16, 30)
-ELF_RELOC(R_390_GOTPLT32, 31)
-ELF_RELOC(R_390_GOTPLT64, 32)
-ELF_RELOC(R_390_GOTPLTENT, 33)
-ELF_RELOC(R_390_PLTOFF16, 34)
-ELF_RELOC(R_390_PLTOFF32, 35)
-ELF_RELOC(R_390_PLTOFF64, 36)
-ELF_RELOC(R_390_TLS_LOAD, 37)
-ELF_RELOC(R_390_TLS_GDCALL, 38)
-ELF_RELOC(R_390_TLS_LDCALL, 39)
-ELF_RELOC(R_390_TLS_GD32, 40)
-ELF_RELOC(R_390_TLS_GD64, 41)
-ELF_RELOC(R_390_TLS_GOTIE12, 42)
-ELF_RELOC(R_390_TLS_GOTIE32, 43)
-ELF_RELOC(R_390_TLS_GOTIE64, 44)
-ELF_RELOC(R_390_TLS_LDM32, 45)
-ELF_RELOC(R_390_TLS_LDM64, 46)
-ELF_RELOC(R_390_TLS_IE32, 47)
-ELF_RELOC(R_390_TLS_IE64, 48)
-ELF_RELOC(R_390_TLS_IEENT, 49)
-ELF_RELOC(R_390_TLS_LE32, 50)
-ELF_RELOC(R_390_TLS_LE64, 51)
-ELF_RELOC(R_390_TLS_LDO32, 52)
-ELF_RELOC(R_390_TLS_LDO64, 53)
-ELF_RELOC(R_390_TLS_DTPMOD, 54)
-ELF_RELOC(R_390_TLS_DTPOFF, 55)
-ELF_RELOC(R_390_TLS_TPOFF, 56)
-ELF_RELOC(R_390_20, 57)
-ELF_RELOC(R_390_GOT20, 58)
-ELF_RELOC(R_390_GOTPLT20, 59)
-ELF_RELOC(R_390_TLS_GOTIE20, 60)
-ELF_RELOC(R_390_IRELATIVE, 61)
-ELF_RELOC(R_390_PC12DBL, 62)
-ELF_RELOC(R_390_PLT12DBL, 63)
-ELF_RELOC(R_390_PC24DBL, 64)
-ELF_RELOC(R_390_PLT24DBL, 65)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/WebAssembly.def b/contrib/llvm/include/llvm/Support/ELFRelocs/WebAssembly.def
deleted file mode 100644
index 9a34349..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/WebAssembly.def
+++ /dev/null
@@ -1,8 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_WEBASSEMBLY_NONE, 0)
-ELF_RELOC(R_WEBASSEMBLY_DATA, 1)
-ELF_RELOC(R_WEBASSEMBLY_FUNCTION, 2)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/i386.def b/contrib/llvm/include/llvm/Support/ELFRelocs/i386.def
deleted file mode 100644
index 1d28cf5..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/i386.def
+++ /dev/null
@@ -1,47 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-// TODO: this is just a subset
-ELF_RELOC(R_386_NONE, 0)
-ELF_RELOC(R_386_32, 1)
-ELF_RELOC(R_386_PC32, 2)
-ELF_RELOC(R_386_GOT32, 3)
-ELF_RELOC(R_386_PLT32, 4)
-ELF_RELOC(R_386_COPY, 5)
-ELF_RELOC(R_386_GLOB_DAT, 6)
-ELF_RELOC(R_386_JUMP_SLOT, 7)
-ELF_RELOC(R_386_RELATIVE, 8)
-ELF_RELOC(R_386_GOTOFF, 9)
-ELF_RELOC(R_386_GOTPC, 10)
-ELF_RELOC(R_386_32PLT, 11)
-ELF_RELOC(R_386_TLS_TPOFF, 14)
-ELF_RELOC(R_386_TLS_IE, 15)
-ELF_RELOC(R_386_TLS_GOTIE, 16)
-ELF_RELOC(R_386_TLS_LE, 17)
-ELF_RELOC(R_386_TLS_GD, 18)
-ELF_RELOC(R_386_TLS_LDM, 19)
-ELF_RELOC(R_386_16, 20)
-ELF_RELOC(R_386_PC16, 21)
-ELF_RELOC(R_386_8, 22)
-ELF_RELOC(R_386_PC8, 23)
-ELF_RELOC(R_386_TLS_GD_32, 24)
-ELF_RELOC(R_386_TLS_GD_PUSH, 25)
-ELF_RELOC(R_386_TLS_GD_CALL, 26)
-ELF_RELOC(R_386_TLS_GD_POP, 27)
-ELF_RELOC(R_386_TLS_LDM_32, 28)
-ELF_RELOC(R_386_TLS_LDM_PUSH, 29)
-ELF_RELOC(R_386_TLS_LDM_CALL, 30)
-ELF_RELOC(R_386_TLS_LDM_POP, 31)
-ELF_RELOC(R_386_TLS_LDO_32, 32)
-ELF_RELOC(R_386_TLS_IE_32, 33)
-ELF_RELOC(R_386_TLS_LE_32, 34)
-ELF_RELOC(R_386_TLS_DTPMOD32, 35)
-ELF_RELOC(R_386_TLS_DTPOFF32, 36)
-ELF_RELOC(R_386_TLS_TPOFF32, 37)
-ELF_RELOC(R_386_TLS_GOTDESC, 39)
-ELF_RELOC(R_386_TLS_DESC_CALL, 40)
-ELF_RELOC(R_386_TLS_DESC, 41)
-ELF_RELOC(R_386_IRELATIVE, 42)
-ELF_RELOC(R_386_GOT32X, 43)
diff --git a/contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def b/contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def
deleted file mode 100644
index 18fdcf9..0000000
--- a/contrib/llvm/include/llvm/Support/ELFRelocs/x86_64.def
+++ /dev/null
@@ -1,45 +0,0 @@
-
-#ifndef ELF_RELOC
-#error "ELF_RELOC must be defined"
-#endif
-
-ELF_RELOC(R_X86_64_NONE, 0)
-ELF_RELOC(R_X86_64_64, 1)
-ELF_RELOC(R_X86_64_PC32, 2)
-ELF_RELOC(R_X86_64_GOT32, 3)
-ELF_RELOC(R_X86_64_PLT32, 4)
-ELF_RELOC(R_X86_64_COPY, 5)
-ELF_RELOC(R_X86_64_GLOB_DAT, 6)
-ELF_RELOC(R_X86_64_JUMP_SLOT, 7)
-ELF_RELOC(R_X86_64_RELATIVE, 8)
-ELF_RELOC(R_X86_64_GOTPCREL, 9)
-ELF_RELOC(R_X86_64_32, 10)
-ELF_RELOC(R_X86_64_32S, 11)
-ELF_RELOC(R_X86_64_16, 12)
-ELF_RELOC(R_X86_64_PC16, 13)
-ELF_RELOC(R_X86_64_8, 14)
-ELF_RELOC(R_X86_64_PC8, 15)
-ELF_RELOC(R_X86_64_DTPMOD64, 16)
-ELF_RELOC(R_X86_64_DTPOFF64, 17)
-ELF_RELOC(R_X86_64_TPOFF64, 18)
-ELF_RELOC(R_X86_64_TLSGD, 19)
-ELF_RELOC(R_X86_64_TLSLD, 20)
-ELF_RELOC(R_X86_64_DTPOFF32, 21)
-ELF_RELOC(R_X86_64_GOTTPOFF, 22)
-ELF_RELOC(R_X86_64_TPOFF32, 23)
-ELF_RELOC(R_X86_64_PC64, 24)
-ELF_RELOC(R_X86_64_GOTOFF64, 25)
-ELF_RELOC(R_X86_64_GOTPC32, 26)
-ELF_RELOC(R_X86_64_GOT64, 27)
-ELF_RELOC(R_X86_64_GOTPCREL64, 28)
-ELF_RELOC(R_X86_64_GOTPC64, 29)
-ELF_RELOC(R_X86_64_GOTPLT64, 30)
-ELF_RELOC(R_X86_64_PLTOFF64, 31)
-ELF_RELOC(R_X86_64_SIZE32, 32)
-ELF_RELOC(R_X86_64_SIZE64, 33)
-ELF_RELOC(R_X86_64_GOTPC32_TLSDESC, 34)
-ELF_RELOC(R_X86_64_TLSDESC_CALL, 35)
-ELF_RELOC(R_X86_64_TLSDESC, 36)
-ELF_RELOC(R_X86_64_IRELATIVE, 37)
-ELF_RELOC(R_X86_64_GOTPCRELX, 41)
-ELF_RELOC(R_X86_64_REX_GOTPCRELX, 42)
diff --git a/contrib/llvm/include/llvm/Support/Endian.h b/contrib/llvm/include/llvm/Support/Endian.h
index cbe3d67..f50d9b5 100644
--- a/contrib/llvm/include/llvm/Support/Endian.h
+++ b/contrib/llvm/include/llvm/Support/Endian.h
@@ -14,67 +14,101 @@
#ifndef LLVM_SUPPORT_ENDIAN_H
#define LLVM_SUPPORT_ENDIAN_H
+#include "llvm/Support/AlignOf.h"
+#include "llvm/Support/Compiler.h"
#include "llvm/Support/Host.h"
#include "llvm/Support/SwapByteOrder.h"
+#include <cassert>
+#include <cstddef>
+#include <cstdint>
+#include <cstring>
+#include <type_traits>
namespace llvm {
namespace support {
+
enum endianness {big, little, native};
// These are named values for common alignments.
enum {aligned = 0, unaligned = 1};
namespace detail {
- /// \brief ::value is either alignment, or alignof(T) if alignment is 0.
- template<class T, int alignment>
- struct PickAlignment {
- enum { value = alignment == 0 ? alignof(T) : alignment };
- };
+
+/// \brief ::value is either alignment, or alignof(T) if alignment is 0.
+template<class T, int alignment>
+struct PickAlignment {
+ enum { value = alignment == 0 ? alignof(T) : alignment };
+};
+
} // end namespace detail
namespace endian {
+
+constexpr endianness system_endianness() {
+ return sys::IsBigEndianHost ? big : little;
+}
+
+template <typename value_type>
+inline value_type byte_swap(value_type value, endianness endian) {
+ if ((endian != native) && (endian != system_endianness()))
+ sys::swapByteOrder(value);
+ return value;
+}
+
/// Swap the bytes of value to match the given endianness.
template<typename value_type, endianness endian>
inline value_type byte_swap(value_type value) {
- if (endian != native && sys::IsBigEndianHost != (endian == big))
- sys::swapByteOrder(value);
- return value;
+ return byte_swap(value, endian);
}
/// Read a value of a particular endianness from memory.
-template<typename value_type,
- endianness endian,
- std::size_t alignment>
-inline value_type read(const void *memory) {
+template <typename value_type, std::size_t alignment>
+inline value_type read(const void *memory, endianness endian) {
value_type ret;
memcpy(&ret,
- LLVM_ASSUME_ALIGNED(memory,
- (detail::PickAlignment<value_type, alignment>::value)),
+ LLVM_ASSUME_ALIGNED(
+ memory, (detail::PickAlignment<value_type, alignment>::value)),
sizeof(value_type));
- return byte_swap<value_type, endian>(ret);
+ return byte_swap<value_type>(ret, endian);
+}
+
+template<typename value_type,
+ endianness endian,
+ std::size_t alignment>
+inline value_type read(const void *memory) {
+ return read<value_type, alignment>(memory, endian);
}
/// Read a value of a particular endianness from a buffer, and increment the
/// buffer past that value.
+template <typename value_type, std::size_t alignment, typename CharT>
+inline value_type readNext(const CharT *&memory, endianness endian) {
+ value_type ret = read<value_type, alignment>(memory, endian);
+ memory += sizeof(value_type);
+ return ret;
+}
+
template<typename value_type, endianness endian, std::size_t alignment,
typename CharT>
inline value_type readNext(const CharT *&memory) {
- value_type ret = read<value_type, endian, alignment>(memory);
- memory += sizeof(value_type);
- return ret;
+ return readNext<value_type, alignment, CharT>(memory, endian);
}
/// Write a value to memory with a particular endianness.
+template <typename value_type, std::size_t alignment>
+inline void write(void *memory, value_type value, endianness endian) {
+ value = byte_swap<value_type>(value, endian);
+ memcpy(LLVM_ASSUME_ALIGNED(
+ memory, (detail::PickAlignment<value_type, alignment>::value)),
+ &value, sizeof(value_type));
+}
+
template<typename value_type,
endianness endian,
std::size_t alignment>
inline void write(void *memory, value_type value) {
- value = byte_swap<value_type, endian>(value);
- memcpy(LLVM_ASSUME_ALIGNED(memory,
- (detail::PickAlignment<value_type, alignment>::value)),
- &value,
- sizeof(value_type));
+ write<value_type, alignment>(memory, value, endian);
}
template <typename value_type>
@@ -165,9 +199,11 @@ inline void writeAtBitAlignment(void *memory, value_type value,
&val[0], sizeof(value_type) * 2);
}
}
+
} // end namespace endian
namespace detail {
+
template<typename value_type,
endianness endian,
std::size_t alignment>
@@ -229,81 +265,96 @@ public:
} // end namespace detail
-typedef detail::packed_endian_specific_integral
- <uint16_t, little, unaligned> ulittle16_t;
-typedef detail::packed_endian_specific_integral
- <uint32_t, little, unaligned> ulittle32_t;
-typedef detail::packed_endian_specific_integral
- <uint64_t, little, unaligned> ulittle64_t;
-
-typedef detail::packed_endian_specific_integral
- <int16_t, little, unaligned> little16_t;
-typedef detail::packed_endian_specific_integral
- <int32_t, little, unaligned> little32_t;
-typedef detail::packed_endian_specific_integral
- <int64_t, little, unaligned> little64_t;
-
-typedef detail::packed_endian_specific_integral
- <uint16_t, little, aligned> aligned_ulittle16_t;
-typedef detail::packed_endian_specific_integral
- <uint32_t, little, aligned> aligned_ulittle32_t;
-typedef detail::packed_endian_specific_integral
- <uint64_t, little, aligned> aligned_ulittle64_t;
-
-typedef detail::packed_endian_specific_integral
- <int16_t, little, aligned> aligned_little16_t;
-typedef detail::packed_endian_specific_integral
- <int32_t, little, aligned> aligned_little32_t;
-typedef detail::packed_endian_specific_integral
- <int64_t, little, aligned> aligned_little64_t;
-
-typedef detail::packed_endian_specific_integral
- <uint16_t, big, unaligned> ubig16_t;
-typedef detail::packed_endian_specific_integral
- <uint32_t, big, unaligned> ubig32_t;
-typedef detail::packed_endian_specific_integral
- <uint64_t, big, unaligned> ubig64_t;
-
-typedef detail::packed_endian_specific_integral
- <int16_t, big, unaligned> big16_t;
-typedef detail::packed_endian_specific_integral
- <int32_t, big, unaligned> big32_t;
-typedef detail::packed_endian_specific_integral
- <int64_t, big, unaligned> big64_t;
-
-typedef detail::packed_endian_specific_integral
- <uint16_t, big, aligned> aligned_ubig16_t;
-typedef detail::packed_endian_specific_integral
- <uint32_t, big, aligned> aligned_ubig32_t;
-typedef detail::packed_endian_specific_integral
- <uint64_t, big, aligned> aligned_ubig64_t;
-
-typedef detail::packed_endian_specific_integral
- <int16_t, big, aligned> aligned_big16_t;
-typedef detail::packed_endian_specific_integral
- <int32_t, big, aligned> aligned_big32_t;
-typedef detail::packed_endian_specific_integral
- <int64_t, big, aligned> aligned_big64_t;
-
-typedef detail::packed_endian_specific_integral
- <uint16_t, native, unaligned> unaligned_uint16_t;
-typedef detail::packed_endian_specific_integral
- <uint32_t, native, unaligned> unaligned_uint32_t;
-typedef detail::packed_endian_specific_integral
- <uint64_t, native, unaligned> unaligned_uint64_t;
-
-typedef detail::packed_endian_specific_integral
- <int16_t, native, unaligned> unaligned_int16_t;
-typedef detail::packed_endian_specific_integral
- <int32_t, native, unaligned> unaligned_int32_t;
-typedef detail::packed_endian_specific_integral
- <int64_t, native, unaligned> unaligned_int64_t;
+using ulittle16_t =
+ detail::packed_endian_specific_integral<uint16_t, little, unaligned>;
+using ulittle32_t =
+ detail::packed_endian_specific_integral<uint32_t, little, unaligned>;
+using ulittle64_t =
+ detail::packed_endian_specific_integral<uint64_t, little, unaligned>;
+
+using little16_t =
+ detail::packed_endian_specific_integral<int16_t, little, unaligned>;
+using little32_t =
+ detail::packed_endian_specific_integral<int32_t, little, unaligned>;
+using little64_t =
+ detail::packed_endian_specific_integral<int64_t, little, unaligned>;
+
+using aligned_ulittle16_t =
+ detail::packed_endian_specific_integral<uint16_t, little, aligned>;
+using aligned_ulittle32_t =
+ detail::packed_endian_specific_integral<uint32_t, little, aligned>;
+using aligned_ulittle64_t =
+ detail::packed_endian_specific_integral<uint64_t, little, aligned>;
+
+using aligned_little16_t =
+ detail::packed_endian_specific_integral<int16_t, little, aligned>;
+using aligned_little32_t =
+ detail::packed_endian_specific_integral<int32_t, little, aligned>;
+using aligned_little64_t =
+ detail::packed_endian_specific_integral<int64_t, little, aligned>;
+
+using ubig16_t =
+ detail::packed_endian_specific_integral<uint16_t, big, unaligned>;
+using ubig32_t =
+ detail::packed_endian_specific_integral<uint32_t, big, unaligned>;
+using ubig64_t =
+ detail::packed_endian_specific_integral<uint64_t, big, unaligned>;
+
+using big16_t =
+ detail::packed_endian_specific_integral<int16_t, big, unaligned>;
+using big32_t =
+ detail::packed_endian_specific_integral<int32_t, big, unaligned>;
+using big64_t =
+ detail::packed_endian_specific_integral<int64_t, big, unaligned>;
+
+using aligned_ubig16_t =
+ detail::packed_endian_specific_integral<uint16_t, big, aligned>;
+using aligned_ubig32_t =
+ detail::packed_endian_specific_integral<uint32_t, big, aligned>;
+using aligned_ubig64_t =
+ detail::packed_endian_specific_integral<uint64_t, big, aligned>;
+
+using aligned_big16_t =
+ detail::packed_endian_specific_integral<int16_t, big, aligned>;
+using aligned_big32_t =
+ detail::packed_endian_specific_integral<int32_t, big, aligned>;
+using aligned_big64_t =
+ detail::packed_endian_specific_integral<int64_t, big, aligned>;
+
+using unaligned_uint16_t =
+ detail::packed_endian_specific_integral<uint16_t, native, unaligned>;
+using unaligned_uint32_t =
+ detail::packed_endian_specific_integral<uint32_t, native, unaligned>;
+using unaligned_uint64_t =
+ detail::packed_endian_specific_integral<uint64_t, native, unaligned>;
+
+using unaligned_int16_t =
+ detail::packed_endian_specific_integral<int16_t, native, unaligned>;
+using unaligned_int32_t =
+ detail::packed_endian_specific_integral<int32_t, native, unaligned>;
+using unaligned_int64_t =
+ detail::packed_endian_specific_integral<int64_t, native, unaligned>;
namespace endian {
+
+template <typename T> inline T read(const void *P, endianness E) {
+ return read<T, unaligned>(P, E);
+}
+
template <typename T, endianness E> inline T read(const void *P) {
return *(const detail::packed_endian_specific_integral<T, E, unaligned> *)P;
}
+inline uint16_t read16(const void *P, endianness E) {
+ return read<uint16_t>(P, E);
+}
+inline uint32_t read32(const void *P, endianness E) {
+ return read<uint32_t>(P, E);
+}
+inline uint64_t read64(const void *P, endianness E) {
+ return read<uint64_t>(P, E);
+}
+
template <endianness E> inline uint16_t read16(const void *P) {
return read<uint16_t, E>(P);
}
@@ -321,10 +372,24 @@ inline uint16_t read16be(const void *P) { return read16<big>(P); }
inline uint32_t read32be(const void *P) { return read32<big>(P); }
inline uint64_t read64be(const void *P) { return read64<big>(P); }
+template <typename T> inline void write(void *P, T V, endianness E) {
+ write<T, unaligned>(P, V, E);
+}
+
template <typename T, endianness E> inline void write(void *P, T V) {
*(detail::packed_endian_specific_integral<T, E, unaligned> *)P = V;
}
+inline void write16(void *P, uint16_t V, endianness E) {
+ write<uint16_t>(P, V, E);
+}
+inline void write32(void *P, uint32_t V, endianness E) {
+ write<uint32_t>(P, V, E);
+}
+inline void write64(void *P, uint64_t V, endianness E) {
+ write<uint64_t>(P, V, E);
+}
+
template <endianness E> inline void write16(void *P, uint16_t V) {
write<uint16_t, E>(P, V);
}
@@ -341,8 +406,10 @@ inline void write64le(void *P, uint64_t V) { write64<little>(P, V); }
inline void write16be(void *P, uint16_t V) { write16<big>(P, V); }
inline void write32be(void *P, uint32_t V) { write32<big>(P, V); }
inline void write64be(void *P, uint64_t V) { write64<big>(P, V); }
+
} // end namespace endian
+
} // end namespace support
} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_ENDIAN_H
diff --git a/contrib/llvm/include/llvm/Support/Errno.h b/contrib/llvm/include/llvm/Support/Errno.h
index 8e145c7..35dc1ea 100644
--- a/contrib/llvm/include/llvm/Support/Errno.h
+++ b/contrib/llvm/include/llvm/Support/Errno.h
@@ -14,7 +14,9 @@
#ifndef LLVM_SUPPORT_ERRNO_H
#define LLVM_SUPPORT_ERRNO_H
+#include <cerrno>
#include <string>
+#include <type_traits>
namespace llvm {
namespace sys {
@@ -28,6 +30,16 @@ std::string StrError();
/// Like the no-argument version above, but uses \p errnum instead of errno.
std::string StrError(int errnum);
+template <typename FailT, typename Fun, typename... Args>
+inline auto RetryAfterSignal(const FailT &Fail, const Fun &F,
+ const Args &... As) -> decltype(F(As...)) {
+ decltype(F(As...)) Res;
+ do
+ Res = F(As...);
+ while (Res == Fail && errno == EINTR);
+ return Res;
+}
+
} // namespace sys
} // namespace llvm
diff --git a/contrib/llvm/include/llvm/Support/Error.h b/contrib/llvm/include/llvm/Support/Error.h
index f13c948..9a7fa0a 100644
--- a/contrib/llvm/include/llvm/Support/Error.h
+++ b/contrib/llvm/include/llvm/Support/Error.h
@@ -1,4 +1,4 @@
-//===----- llvm/Support/Error.h - Recoverable error handling ----*- C++ -*-===//
+//===- llvm/Support/Error.h - Recoverable error handling --------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -22,6 +22,7 @@
#include "llvm/Support/AlignOf.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/Debug.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
@@ -64,6 +65,12 @@ public:
/// using std::error_code. It will be removed in the future.
virtual std::error_code convertToErrorCode() const = 0;
+ // Returns the class ID for this type.
+ static const void *classID() { return &ID; }
+
+ // Returns the class ID for the dynamic type of this ErrorInfoBase instance.
+ virtual const void *dynamicClassID() const = 0;
+
// Check whether this instance is a subclass of the class identified by
// ClassID.
virtual bool isA(const void *const ClassID) const {
@@ -75,9 +82,6 @@ public:
return isA(ErrorInfoT::classID());
}
- // Returns the class ID for this type.
- static const void *classID() { return &ID; }
-
private:
virtual void anchor();
@@ -164,7 +168,7 @@ class LLVM_NODISCARD Error {
protected:
/// Create a success value. Prefer using 'Error::success()' for readability
- Error() : Payload(nullptr) {
+ Error() {
setPtr(nullptr);
setChecked(false);
}
@@ -179,7 +183,7 @@ public:
/// Move-construct an error value. The newly constructed error is considered
/// unchecked, even if the source error had been checked. The original error
/// becomes a checked Success value, regardless of its original state.
- Error(Error &&Other) : Payload(nullptr) {
+ Error(Error &&Other) {
setChecked(true);
*this = std::move(Other);
}
@@ -233,6 +237,14 @@ public:
return getPtr() && getPtr()->isA(ErrT::classID());
}
+ /// Returns the dynamic class id of this error, or null if this is a success
+ /// value.
+ const void* dynamicClassID() const {
+ if (!getPtr())
+ return nullptr;
+ return getPtr()->dynamicClassID();
+ }
+
private:
void assertIsChecked() {
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
@@ -288,7 +300,7 @@ private:
return Tmp;
}
- ErrorInfoBase *Payload;
+ ErrorInfoBase *Payload = nullptr;
};
/// Subclass of Error for the sole purpose of identifying the success path in
@@ -316,11 +328,13 @@ template <typename ErrT, typename... ArgTs> Error make_error(ArgTs &&... Args) {
template <typename ThisErrT, typename ParentErrT = ErrorInfoBase>
class ErrorInfo : public ParentErrT {
public:
+ static const void *classID() { return &ThisErrT::ID; }
+
+ const void *dynamicClassID() const override { return &ThisErrT::ID; }
+
bool isA(const void *const ClassID) const override {
return ClassID == classID() || ParentErrT::isA(ClassID);
}
-
- static const void *classID() { return &ThisErrT::ID; }
};
/// Special ErrorInfo subclass representing a list of ErrorInfos.
@@ -629,21 +643,24 @@ private:
/// takeError(). It also adds an bool errorIsA<ErrT>() method for testing the
/// error class type.
template <class T> class LLVM_NODISCARD Expected {
+ template <class T1> friend class ExpectedAsOutParameter;
template <class OtherT> friend class Expected;
+
static const bool isRef = std::is_reference<T>::value;
- typedef ReferenceStorage<typename std::remove_reference<T>::type> wrap;
- typedef std::unique_ptr<ErrorInfoBase> error_type;
+ using wrap = ReferenceStorage<typename std::remove_reference<T>::type>;
+
+ using error_type = std::unique_ptr<ErrorInfoBase>;
public:
- typedef typename std::conditional<isRef, wrap, T>::type storage_type;
- typedef T value_type;
+ using storage_type = typename std::conditional<isRef, wrap, T>::type;
+ using value_type = T;
private:
- typedef typename std::remove_reference<T>::type &reference;
- typedef const typename std::remove_reference<T>::type &const_reference;
- typedef typename std::remove_reference<T>::type *pointer;
- typedef const typename std::remove_reference<T>::type *const_pointer;
+ using reference = typename std::remove_reference<T>::type &;
+ using const_reference = const typename std::remove_reference<T>::type &;
+ using pointer = typename std::remove_reference<T>::type *;
+ using const_pointer = const typename std::remove_reference<T>::type *;
public:
/// Create an Expected<T> error value from the given Error.
@@ -737,7 +754,7 @@ public:
/// \brief Check that this Expected<T> is an error of type ErrT.
template <typename ErrT> bool errorIsA() const {
- return HasError && getErrorStorage()->template isA<ErrT>();
+ return HasError && (*getErrorStorage())->template isA<ErrT>();
}
/// \brief Take ownership of the stored error.
@@ -832,6 +849,18 @@ private:
return reinterpret_cast<error_type *>(ErrorStorage.buffer);
}
+ const error_type *getErrorStorage() const {
+ assert(HasError && "Cannot get error when a value exists!");
+ return reinterpret_cast<const error_type *>(ErrorStorage.buffer);
+ }
+
+ // Used by ExpectedAsOutParameter to reset the checked flag.
+ void setUnchecked() {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+ Unchecked = true;
+#endif
+ }
+
void assertIsChecked() {
#if LLVM_ENABLE_ABI_BREAKING_CHECKS
if (Unchecked) {
@@ -858,6 +887,27 @@ private:
#endif
};
+/// Helper for Expected<T>s used as out-parameters.
+///
+/// See ErrorAsOutParameter.
+template <typename T>
+class ExpectedAsOutParameter {
+public:
+ ExpectedAsOutParameter(Expected<T> *ValOrErr)
+ : ValOrErr(ValOrErr) {
+ if (ValOrErr)
+ (void)!!*ValOrErr;
+ }
+
+ ~ExpectedAsOutParameter() {
+ if (ValOrErr)
+ ValOrErr->setUnchecked();
+ }
+
+private:
+ Expected<T> *ValOrErr;
+};
+
/// This class wraps a std::error_code in a Error.
///
/// This is useful if you're writing an interface that returns a Error
@@ -926,6 +976,8 @@ public:
void log(raw_ostream &OS) const override;
std::error_code convertToErrorCode() const override;
+ const std::string &getMessage() const { return Msg; }
+
private:
std::string Msg;
std::error_code EC;
@@ -985,6 +1037,66 @@ private:
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err,
bool gen_crash_diag = true);
+/// Report a fatal error if Err is a failure value.
+///
+/// This function can be used to wrap calls to fallible functions ONLY when it
+/// is known that the Error will always be a success value. E.g.
+///
+/// @code{.cpp}
+/// // foo only attempts the fallible operation if DoFallibleOperation is
+/// // true. If DoFallibleOperation is false then foo always returns
+/// // Error::success().
+/// Error foo(bool DoFallibleOperation);
+///
+/// cantFail(foo(false));
+/// @endcode
+inline void cantFail(Error Err) {
+ if (Err)
+ llvm_unreachable("Failure value returned from cantFail wrapped call");
+}
+
+/// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and
+/// returns the contained value.
+///
+/// This function can be used to wrap calls to fallible functions ONLY when it
+/// is known that the Error will always be a success value. E.g.
+///
+/// @code{.cpp}
+/// // foo only attempts the fallible operation if DoFallibleOperation is
+/// // true. If DoFallibleOperation is false then foo always returns an int.
+/// Expected<int> foo(bool DoFallibleOperation);
+///
+/// int X = cantFail(foo(false));
+/// @endcode
+template <typename T>
+T cantFail(Expected<T> ValOrErr) {
+ if (ValOrErr)
+ return std::move(*ValOrErr);
+ else
+ llvm_unreachable("Failure value returned from cantFail wrapped call");
+}
+
+/// Report a fatal error if ValOrErr is a failure value, otherwise unwraps and
+/// returns the contained reference.
+///
+/// This function can be used to wrap calls to fallible functions ONLY when it
+/// is known that the Error will always be a success value. E.g.
+///
+/// @code{.cpp}
+/// // foo only attempts the fallible operation if DoFallibleOperation is
+/// // true. If DoFallibleOperation is false then foo always returns a Bar&.
+/// Expected<Bar&> foo(bool DoFallibleOperation);
+///
+/// Bar &X = cantFail(foo(false));
+/// @endcode
+template <typename T>
+T& cantFail(Expected<T&> ValOrErr) {
+ if (ValOrErr)
+ return *ValOrErr;
+ else
+ llvm_unreachable("Failure value returned from cantFail wrapped call");
+}
+
} // end namespace llvm
#endif // LLVM_SUPPORT_ERROR_H
diff --git a/contrib/llvm/include/llvm/Support/ErrorHandling.h b/contrib/llvm/include/llvm/Support/ErrorHandling.h
index 7c1edd8..b45f634 100644
--- a/contrib/llvm/include/llvm/Support/ErrorHandling.h
+++ b/contrib/llvm/include/llvm/Support/ErrorHandling.h
@@ -78,12 +78,48 @@ LLVM_ATTRIBUTE_NORETURN void report_fatal_error(StringRef reason,
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const Twine &reason,
bool gen_crash_diag = true);
- /// This function calls abort(), and prints the optional message to stderr.
- /// Use the llvm_unreachable macro (that adds location info), instead of
- /// calling this function directly.
- LLVM_ATTRIBUTE_NORETURN void
- llvm_unreachable_internal(const char *msg=nullptr, const char *file=nullptr,
- unsigned line=0);
+/// Installs a new bad alloc error handler that should be used whenever a
+/// bad alloc error, e.g. failing malloc/calloc, is encountered by LLVM.
+///
+/// The user can install a bad alloc handler, in order to define the behavior
+/// in case of failing allocations, e.g. throwing an exception. Note that this
+/// handler must not trigger any additional allocations itself.
+///
+/// If no error handler is installed the default is to print the error message
+/// to stderr, and call exit(1). If an error handler is installed then it is
+/// the handler's responsibility to log the message, it will no longer be
+/// printed to stderr. If the error handler returns, then exit(1) will be
+/// called.
+///
+///
+/// \param user_data - An argument which will be passed to the installed error
+/// handler.
+void install_bad_alloc_error_handler(fatal_error_handler_t handler,
+ void *user_data = nullptr);
+
+/// Restores default bad alloc error handling behavior.
+void remove_bad_alloc_error_handler();
+
+/// Reports a bad alloc error, calling any user defined bad alloc
+/// error handler. In contrast to the generic 'report_fatal_error'
+/// functions, this function is expected to return, e.g. the user
+/// defined error handler throws an exception.
+///
+/// Note: When throwing an exception in the bad alloc handler, make sure that
+/// the following unwind succeeds, e.g. do not trigger additional allocations
+/// in the unwind chain.
+///
+/// If no error handler is installed (default), then a bad_alloc exception
+/// is thrown if LLVM is compiled with exception support, otherwise an assertion
+/// is called.
+void report_bad_alloc_error(const char *Reason, bool GenCrashDiag = true);
+
+/// This function calls abort(), and prints the optional message to stderr.
+/// Use the llvm_unreachable macro (that adds location info), instead of
+/// calling this function directly.
+LLVM_ATTRIBUTE_NORETURN void
+llvm_unreachable_internal(const char *msg = nullptr, const char *file = nullptr,
+ unsigned line = 0);
}
/// Marks that the current location is not supposed to be reachable.
diff --git a/contrib/llvm/include/llvm/Support/ErrorOr.h b/contrib/llvm/include/llvm/Support/ErrorOr.h
index 877f406..061fb65 100644
--- a/contrib/llvm/include/llvm/Support/ErrorOr.h
+++ b/contrib/llvm/include/llvm/Support/ErrorOr.h
@@ -16,13 +16,14 @@
#ifndef LLVM_SUPPORT_ERROROR_H
#define LLVM_SUPPORT_ERROROR_H
-#include "llvm/ADT/PointerIntPair.h"
#include "llvm/Support/AlignOf.h"
#include <cassert>
#include <system_error>
#include <type_traits>
+#include <utility>
namespace llvm {
+
/// \brief Stores a reference that can be changed.
template <typename T>
class ReferenceStorage {
@@ -67,17 +68,19 @@ public:
template<class T>
class ErrorOr {
template <class OtherT> friend class ErrorOr;
+
static const bool isRef = std::is_reference<T>::value;
- typedef ReferenceStorage<typename std::remove_reference<T>::type> wrap;
+
+ using wrap = ReferenceStorage<typename std::remove_reference<T>::type>;
public:
- typedef typename std::conditional<isRef, wrap, T>::type storage_type;
+ using storage_type = typename std::conditional<isRef, wrap, T>::type;
private:
- typedef typename std::remove_reference<T>::type &reference;
- typedef const typename std::remove_reference<T>::type &const_reference;
- typedef typename std::remove_reference<T>::type *pointer;
- typedef const typename std::remove_reference<T>::type *const_pointer;
+ using reference = typename std::remove_reference<T>::type &;
+ using const_reference = const typename std::remove_reference<T>::type &;
+ using pointer = typename std::remove_reference<T>::type *;
+ using const_pointer = const typename std::remove_reference<T>::type *;
public:
template <class E>
@@ -282,6 +285,7 @@ typename std::enable_if<std::is_error_code_enum<E>::value ||
operator==(const ErrorOr<T> &Err, E Code) {
return Err.getError() == Code;
}
+
} // end namespace llvm
#endif // LLVM_SUPPORT_ERROROR_H
diff --git a/contrib/llvm/include/llvm/Support/FileSystem.h b/contrib/llvm/include/llvm/Support/FileSystem.h
index ad21d8a..21c5fcd 100644
--- a/contrib/llvm/include/llvm/Support/FileSystem.h
+++ b/contrib/llvm/include/llvm/Support/FileSystem.h
@@ -33,6 +33,7 @@
#include "llvm/Support/Chrono.h"
#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/ErrorOr.h"
+#include "llvm/Support/MD5.h"
#include <cassert>
#include <cstdint>
#include <ctime>
@@ -93,6 +94,7 @@ enum perms {
set_uid_on_exe = 04000,
set_gid_on_exe = 02000,
sticky_bit = 01000,
+ all_perms = all_all | set_uid_on_exe | set_gid_on_exe | sticky_bit,
perms_not_known = 0xFFFF
};
@@ -114,7 +116,9 @@ inline perms &operator&=(perms &l, perms r) {
return l;
}
inline perms operator~(perms x) {
- return static_cast<perms>(~static_cast<unsigned short>(x));
+ // Avoid UB by explicitly truncating the (unsigned) ~ result.
+ return static_cast<perms>(
+ static_cast<unsigned short>(~static_cast<unsigned short>(x)));
}
class UniqueID {
@@ -141,70 +145,61 @@ public:
/// a platform-specific member to store the result.
class file_status
{
+ friend bool equivalent(file_status A, file_status B);
+
#if defined(LLVM_ON_UNIX)
- dev_t fs_st_dev;
- ino_t fs_st_ino;
- time_t fs_st_atime;
- time_t fs_st_mtime;
- uid_t fs_st_uid;
- gid_t fs_st_gid;
- off_t fs_st_size;
+ dev_t fs_st_dev = 0;
+ nlink_t fs_st_nlinks = 0;
+ ino_t fs_st_ino = 0;
+ time_t fs_st_atime = 0;
+ time_t fs_st_mtime = 0;
+ uid_t fs_st_uid = 0;
+ gid_t fs_st_gid = 0;
+ off_t fs_st_size = 0;
#elif defined (LLVM_ON_WIN32)
- uint32_t LastAccessedTimeHigh;
- uint32_t LastAccessedTimeLow;
- uint32_t LastWriteTimeHigh;
- uint32_t LastWriteTimeLow;
- uint32_t VolumeSerialNumber;
- uint32_t FileSizeHigh;
- uint32_t FileSizeLow;
- uint32_t FileIndexHigh;
- uint32_t FileIndexLow;
+ uint32_t NumLinks = 0;
+ uint32_t LastAccessedTimeHigh = 0;
+ uint32_t LastAccessedTimeLow = 0;
+ uint32_t LastWriteTimeHigh = 0;
+ uint32_t LastWriteTimeLow = 0;
+ uint32_t VolumeSerialNumber = 0;
+ uint32_t FileSizeHigh = 0;
+ uint32_t FileSizeLow = 0;
+ uint32_t FileIndexHigh = 0;
+ uint32_t FileIndexLow = 0;
#endif
- friend bool equivalent(file_status A, file_status B);
- file_type Type;
- perms Perms;
+ file_type Type = file_type::status_error;
+ perms Perms = perms_not_known;
public:
#if defined(LLVM_ON_UNIX)
- file_status()
- : fs_st_dev(0), fs_st_ino(0), fs_st_atime(0), fs_st_mtime(0),
- fs_st_uid(0), fs_st_gid(0), fs_st_size(0),
- Type(file_type::status_error), Perms(perms_not_known) {}
-
- file_status(file_type Type)
- : fs_st_dev(0), fs_st_ino(0), fs_st_atime(0), fs_st_mtime(0),
- fs_st_uid(0), fs_st_gid(0), fs_st_size(0), Type(Type),
- Perms(perms_not_known) {}
-
- file_status(file_type Type, perms Perms, dev_t Dev, ino_t Ino, time_t ATime,
- time_t MTime, uid_t UID, gid_t GID, off_t Size)
- : fs_st_dev(Dev), fs_st_ino(Ino), fs_st_atime(ATime), fs_st_mtime(MTime),
- fs_st_uid(UID), fs_st_gid(GID), fs_st_size(Size), Type(Type),
- Perms(Perms) {}
+ file_status() = default;
+
+ file_status(file_type Type) : Type(Type) {}
+
+ file_status(file_type Type, perms Perms, dev_t Dev, nlink_t Links, ino_t Ino,
+ time_t ATime, time_t MTime, uid_t UID, gid_t GID, off_t Size)
+ : fs_st_dev(Dev), fs_st_nlinks(Links), fs_st_ino(Ino), fs_st_atime(ATime),
+ fs_st_mtime(MTime), fs_st_uid(UID), fs_st_gid(GID), fs_st_size(Size),
+ Type(Type), Perms(Perms) {}
#elif defined(LLVM_ON_WIN32)
- file_status()
- : LastAccessedTimeHigh(0), LastAccessedTimeLow(0), LastWriteTimeHigh(0),
- LastWriteTimeLow(0), VolumeSerialNumber(0), FileSizeHigh(0),
- FileSizeLow(0), FileIndexHigh(0), FileIndexLow(0),
- Type(file_type::status_error), Perms(perms_not_known) {}
-
- file_status(file_type Type)
- : LastAccessedTimeHigh(0), LastAccessedTimeLow(0), LastWriteTimeHigh(0),
- LastWriteTimeLow(0), VolumeSerialNumber(0), FileSizeHigh(0),
- FileSizeLow(0), FileIndexHigh(0), FileIndexLow(0), Type(Type),
- Perms(perms_not_known) {}
-
- file_status(file_type Type, uint32_t LastAccessTimeHigh,
- uint32_t LastAccessTimeLow, uint32_t LastWriteTimeHigh,
- uint32_t LastWriteTimeLow, uint32_t VolumeSerialNumber,
- uint32_t FileSizeHigh, uint32_t FileSizeLow,
- uint32_t FileIndexHigh, uint32_t FileIndexLow)
- : LastAccessedTimeHigh(LastAccessTimeHigh), LastAccessedTimeLow(LastAccessTimeLow),
+ file_status() = default;
+
+ file_status(file_type Type) : Type(Type) {}
+
+ file_status(file_type Type, perms Perms, uint32_t LinkCount,
+ uint32_t LastAccessTimeHigh, uint32_t LastAccessTimeLow,
+ uint32_t LastWriteTimeHigh, uint32_t LastWriteTimeLow,
+ uint32_t VolumeSerialNumber, uint32_t FileSizeHigh,
+ uint32_t FileSizeLow, uint32_t FileIndexHigh,
+ uint32_t FileIndexLow)
+ : NumLinks(LinkCount), LastAccessedTimeHigh(LastAccessTimeHigh),
+ LastAccessedTimeLow(LastAccessTimeLow),
LastWriteTimeHigh(LastWriteTimeHigh),
LastWriteTimeLow(LastWriteTimeLow),
VolumeSerialNumber(VolumeSerialNumber), FileSizeHigh(FileSizeHigh),
FileSizeLow(FileSizeLow), FileIndexHigh(FileIndexHigh),
- FileIndexLow(FileIndexLow), Type(Type), Perms(perms_not_known) {}
+ FileIndexLow(FileIndexLow), Type(Type), Perms(Perms) {}
#endif
// getters
@@ -213,6 +208,7 @@ public:
TimePoint<> getLastAccessedTime() const;
TimePoint<> getLastModificationTime() const;
UniqueID getUniqueID() const;
+ uint32_t getLinkCount() const;
#if defined(LLVM_ON_UNIX)
uint32_t getUser() const { return fs_st_uid; }
@@ -222,9 +218,11 @@ public:
uint32_t getUser() const {
return 9999; // Not applicable to Windows, so...
}
+
uint32_t getGroup() const {
return 9999; // Not applicable to Windows, so...
}
+
uint64_t getSize() const {
return (uint64_t(FileSizeHigh) << 32) + FileSizeLow;
}
@@ -235,50 +233,6 @@ public:
void permissions(perms p) { Perms = p; }
};
-/// file_magic - An "enum class" enumeration of file types based on magic (the first
-/// N bytes of the file).
-struct file_magic {
- enum Impl {
- unknown = 0, ///< Unrecognized file
- bitcode, ///< Bitcode file
- archive, ///< ar style archive file
- elf, ///< ELF Unknown type
- elf_relocatable, ///< ELF Relocatable object file
- elf_executable, ///< ELF Executable image
- elf_shared_object, ///< ELF dynamically linked shared lib
- elf_core, ///< ELF core image
- macho_object, ///< Mach-O Object file
- macho_executable, ///< Mach-O Executable
- macho_fixed_virtual_memory_shared_lib, ///< Mach-O Shared Lib, FVM
- macho_core, ///< Mach-O Core File
- macho_preload_executable, ///< Mach-O Preloaded Executable
- macho_dynamically_linked_shared_lib, ///< Mach-O dynlinked shared lib
- macho_dynamic_linker, ///< The Mach-O dynamic linker
- macho_bundle, ///< Mach-O Bundle file
- macho_dynamically_linked_shared_lib_stub, ///< Mach-O Shared lib stub
- macho_dsym_companion, ///< Mach-O dSYM companion file
- macho_kext_bundle, ///< Mach-O kext bundle file
- macho_universal_binary, ///< Mach-O universal binary
- coff_cl_gl_object, ///< Microsoft cl.exe's intermediate code file
- coff_object, ///< COFF object file
- coff_import_library, ///< COFF import library
- pecoff_executable, ///< PECOFF executable file
- windows_resource, ///< Windows compiled resource file (.rc)
- wasm_object ///< WebAssembly Object file
- };
-
- bool is_object() const {
- return V != unknown;
- }
-
- file_magic() : V(unknown) {}
- file_magic(Impl V) : V(V) {}
- operator Impl() const { return V; }
-
-private:
- Impl V;
-};
-
/// @}
/// @name Physical Operators
/// @{
@@ -350,6 +304,16 @@ std::error_code create_link(const Twine &to, const Twine &from);
/// specific error_code.
std::error_code create_hard_link(const Twine &to, const Twine &from);
+/// @brief Collapse all . and .. patterns, resolve all symlinks, and optionally
+/// expand ~ expressions to the user's home directory.
+///
+/// @param path The path to resolve.
+/// @param output The location to store the resolved path.
+/// @param expand_tilde If true, resolves ~ expressions to the user's home
+/// directory.
+std::error_code real_path(const Twine &path, SmallVectorImpl<char> &output,
+ bool expand_tilde = false);
+
/// @brief Get the current path.
///
/// @param result Holds the current path on return.
@@ -357,6 +321,13 @@ std::error_code create_hard_link(const Twine &to, const Twine &from);
/// otherwise a platform-specific error_code.
std::error_code current_path(SmallVectorImpl<char> &result);
+/// @brief Set the current path.
+///
+/// @param path The path to set.
+/// @returns errc::success if the current path was successfully set,
+/// otherwise a platform-specific error_code.
+std::error_code set_current_path(const Twine &path);
+
/// @brief Remove path. Equivalent to POSIX remove().
///
/// @param path Input path.
@@ -365,6 +336,13 @@ std::error_code current_path(SmallVectorImpl<char> &result);
/// returns error if the file didn't exist.
std::error_code remove(const Twine &path, bool IgnoreNonExisting = true);
+/// @brief Recursively delete a directory.
+///
+/// @param path Input path.
+/// @returns errc::success if path has been removed or didn't exist, otherwise a
+/// platform-specific error code.
+std::error_code remove_directories(const Twine &path, bool IgnoreErrors = true);
+
/// @brief Rename \a from to \a to. Files are renamed as if by POSIX rename().
///
/// @param from The path to rename from.
@@ -385,6 +363,16 @@ std::error_code copy_file(const Twine &From, const Twine &To);
/// platform-specific error_code.
std::error_code resize_file(int FD, uint64_t Size);
+/// @brief Compute an MD5 hash of a file's contents.
+///
+/// @param FD Input file descriptor.
+/// @returns An MD5Result with the hash computed, if successful, otherwise a
+/// std::error_code.
+ErrorOr<MD5::MD5Result> md5_contents(int FD);
+
+/// @brief Version of compute_md5 that doesn't require an open file descriptor.
+ErrorOr<MD5::MD5Result> md5_contents(const Twine &Path);
+
/// @}
/// @name Physical Observers
/// @{
@@ -457,6 +445,40 @@ inline bool equivalent(const Twine &A, const Twine &B) {
return !equivalent(A, B, result) && result;
}
+/// @brief Is the file mounted on a local filesystem?
+///
+/// @param path Input path.
+/// @param result Set to true if \a path is on fixed media such as a hard disk,
+/// false if it is not.
+/// @returns errc::success if result has been successfully set, otherwise a
+/// platform specific error_code.
+std::error_code is_local(const Twine &path, bool &result);
+
+/// @brief Version of is_local accepting an open file descriptor.
+std::error_code is_local(int FD, bool &result);
+
+/// @brief Simpler version of is_local for clients that don't need to
+/// differentiate between an error and false.
+inline bool is_local(const Twine &Path) {
+ bool Result;
+ return !is_local(Path, Result) && Result;
+}
+
+/// @brief Simpler version of is_local accepting an open file descriptor for
+/// clients that don't need to differentiate between an error and false.
+inline bool is_local(int FD) {
+ bool Result;
+ return !is_local(FD, Result) && Result;
+}
+
+/// @brief Does status represent a directory?
+///
+/// @param Path The path to get the type of.
+/// @param Follow For symbolic links, indicates whether to return the file type
+/// of the link itself, or of the target.
+/// @returns A value from the file_type enumeration indicating the type of file.
+file_type get_file_type(const Twine &Path, bool Follow = true);
+
/// @brief Does status represent a directory?
///
/// @param status A file_status previously returned from status.
@@ -466,8 +488,8 @@ bool is_directory(file_status status);
/// @brief Is path a directory?
///
/// @param path Input path.
-/// @param result Set to true if \a path is a directory, false if it is not.
-/// Undefined otherwise.
+/// @param result Set to true if \a path is a directory (after following
+/// symlinks, false if it is not. Undefined otherwise.
/// @returns errc::success if result has been successfully set, otherwise a
/// platform-specific error_code.
std::error_code is_directory(const Twine &path, bool &result);
@@ -488,8 +510,8 @@ bool is_regular_file(file_status status);
/// @brief Is path a regular file?
///
/// @param path Input path.
-/// @param result Set to true if \a path is a regular file, false if it is not.
-/// Undefined otherwise.
+/// @param result Set to true if \a path is a regular file (after following
+/// symlinks), false if it is not. Undefined otherwise.
/// @returns errc::success if result has been successfully set, otherwise a
/// platform-specific error_code.
std::error_code is_regular_file(const Twine &path, bool &result);
@@ -503,8 +525,32 @@ inline bool is_regular_file(const Twine &Path) {
return Result;
}
+/// @brief Does status represent a symlink file?
+///
+/// @param status A file_status previously returned from status.
+/// @returns status_known(status) && status.type() == file_type::symlink_file.
+bool is_symlink_file(file_status status);
+
+/// @brief Is path a symlink file?
+///
+/// @param path Input path.
+/// @param result Set to true if \a path is a symlink file, false if it is not.
+/// Undefined otherwise.
+/// @returns errc::success if result has been successfully set, otherwise a
+/// platform-specific error_code.
+std::error_code is_symlink_file(const Twine &path, bool &result);
+
+/// @brief Simpler version of is_symlink_file for clients that don't need to
+/// differentiate between an error and false.
+inline bool is_symlink_file(const Twine &Path) {
+ bool Result;
+ if (is_symlink_file(Path, Result))
+ return false;
+ return Result;
+}
+
/// @brief Does this status represent something that exists but is not a
-/// directory, regular file, or symlink?
+/// directory or regular file?
///
/// @param status A file_status previously returned from status.
/// @returns exists(s) && !is_regular_file(s) && !is_directory(s)
@@ -524,13 +570,37 @@ std::error_code is_other(const Twine &path, bool &result);
///
/// @param path Input path.
/// @param result Set to the file status.
+/// @param follow When true, follows symlinks. Otherwise, the symlink itself is
+/// statted.
/// @returns errc::success if result has been successfully set, otherwise a
/// platform-specific error_code.
-std::error_code status(const Twine &path, file_status &result);
+std::error_code status(const Twine &path, file_status &result,
+ bool follow = true);
/// @brief A version for when a file descriptor is already available.
std::error_code status(int FD, file_status &Result);
+/// @brief Set file permissions.
+///
+/// @param Path File to set permissions on.
+/// @param Permissions New file permissions.
+/// @returns errc::success if the permissions were successfully set, otherwise
+/// a platform-specific error_code.
+/// @note On Windows, all permissions except *_write are ignored. Using any of
+/// owner_write, group_write, or all_write will make the file writable.
+/// Otherwise, the file will be marked as read-only.
+std::error_code setPermissions(const Twine &Path, perms Permissions);
+
+/// @brief Get file permissions.
+///
+/// @param Path File to get permissions from.
+/// @returns the permissions if they were successfully retrieved, otherwise a
+/// platform-specific error_code.
+/// @note On Windows, if the file does not have the FILE_ATTRIBUTE_READONLY
+/// attribute, all_all will be returned. Otherwise, all_read | all_exe
+/// will be returned.
+ErrorOr<perms> getPermissions(const Twine &Path);
+
/// @brief Get file size.
///
/// @param Path Input path.
@@ -656,17 +726,6 @@ std::error_code openFileForWrite(const Twine &Name, int &ResultFD,
std::error_code openFileForRead(const Twine &Name, int &ResultFD,
SmallVectorImpl<char> *RealPath = nullptr);
-/// @brief Identify the type of a binary file based on how magical it is.
-file_magic identify_magic(StringRef magic);
-
-/// @brief Get and identify \a path's type based on its content.
-///
-/// @param path Input path.
-/// @param result Set to the type of file, or file_magic::unknown.
-/// @returns errc::success if result has been successfully set, otherwise a
-/// platform-specific error_code.
-std::error_code identify_magic(const Twine &path, file_magic &result);
-
std::error_code getUniqueID(const Twine Path, UniqueID &Result);
/// @brief Get disk space usage information.
@@ -735,12 +794,13 @@ std::string getMainExecutable(const char *argv0, void *MainExecAddr);
/// called.
class directory_entry {
std::string Path;
+ bool FollowSymlinks;
mutable file_status Status;
public:
- explicit directory_entry(const Twine &path, file_status st = file_status())
- : Path(path.str())
- , Status(st) {}
+ explicit directory_entry(const Twine &path, bool follow_symlinks = true,
+ file_status st = file_status())
+ : Path(path.str()), FollowSymlinks(follow_symlinks), Status(st) {}
directory_entry() = default;
@@ -763,9 +823,10 @@ public:
};
namespace detail {
+
struct DirIterState;
- std::error_code directory_iterator_construct(DirIterState &, StringRef);
+ std::error_code directory_iterator_construct(DirIterState &, StringRef, bool);
std::error_code directory_iterator_increment(DirIterState &);
std::error_code directory_iterator_destruct(DirIterState &);
@@ -778,6 +839,7 @@ namespace detail {
intptr_t IterationHandle = 0;
directory_entry CurrentEntry;
};
+
} // end namespace detail
/// directory_iterator - Iterates through the entries in path. There is no
@@ -785,18 +847,24 @@ namespace detail {
/// it call report_fatal_error on error.
class directory_iterator {
std::shared_ptr<detail::DirIterState> State;
+ bool FollowSymlinks = true;
public:
- explicit directory_iterator(const Twine &path, std::error_code &ec) {
+ explicit directory_iterator(const Twine &path, std::error_code &ec,
+ bool follow_symlinks = true)
+ : FollowSymlinks(follow_symlinks) {
State = std::make_shared<detail::DirIterState>();
SmallString<128> path_storage;
- ec = detail::directory_iterator_construct(*State,
- path.toStringRef(path_storage));
+ ec = detail::directory_iterator_construct(
+ *State, path.toStringRef(path_storage), FollowSymlinks);
}
- explicit directory_iterator(const directory_entry &de, std::error_code &ec) {
+ explicit directory_iterator(const directory_entry &de, std::error_code &ec,
+ bool follow_symlinks = true)
+ : FollowSymlinks(follow_symlinks) {
State = std::make_shared<detail::DirIterState>();
- ec = detail::directory_iterator_construct(*State, de.path());
+ ec =
+ detail::directory_iterator_construct(*State, de.path(), FollowSymlinks);
}
/// Construct end iterator.
@@ -829,24 +897,29 @@ public:
};
namespace detail {
+
/// Keeps state for the recursive_directory_iterator.
struct RecDirIterState {
std::stack<directory_iterator, std::vector<directory_iterator>> Stack;
uint16_t Level = 0;
bool HasNoPushRequest = false;
};
+
} // end namespace detail
/// recursive_directory_iterator - Same as directory_iterator except for it
/// recurses down into child directories.
class recursive_directory_iterator {
std::shared_ptr<detail::RecDirIterState> State;
+ bool Follow;
public:
recursive_directory_iterator() = default;
- explicit recursive_directory_iterator(const Twine &path, std::error_code &ec)
- : State(std::make_shared<detail::RecDirIterState>()) {
- State->Stack.push(directory_iterator(path, ec));
+ explicit recursive_directory_iterator(const Twine &path, std::error_code &ec,
+ bool follow_symlinks = true)
+ : State(std::make_shared<detail::RecDirIterState>()),
+ Follow(follow_symlinks) {
+ State->Stack.push(directory_iterator(path, ec, Follow));
if (State->Stack.top() == directory_iterator())
State.reset();
}
@@ -861,7 +934,7 @@ public:
file_status st;
if ((ec = State->Stack.top()->status(st))) return *this;
if (is_directory(st)) {
- State->Stack.push(directory_iterator(*State->Stack.top(), ec));
+ State->Stack.push(directory_iterator(*State->Stack.top(), ec, Follow));
if (ec) return *this;
if (State->Stack.top() != end_itr) {
++State->Level;
diff --git a/contrib/llvm/include/llvm/Support/Format.h b/contrib/llvm/include/llvm/Support/Format.h
index 017b497..bcbd2be 100644
--- a/contrib/llvm/include/llvm/Support/Format.h
+++ b/contrib/llvm/include/llvm/Support/Format.h
@@ -125,30 +125,39 @@ inline format_object<Ts...> format(const char *Fmt, const Ts &... Vals) {
return format_object<Ts...>(Fmt, Vals...);
}
-/// This is a helper class used for left_justify() and right_justify().
+/// This is a helper class for left_justify, right_justify, and center_justify.
class FormattedString {
+public:
+ enum Justification { JustifyNone, JustifyLeft, JustifyRight, JustifyCenter };
+ FormattedString(StringRef S, unsigned W, Justification J)
+ : Str(S), Width(W), Justify(J) {}
+
+private:
StringRef Str;
unsigned Width;
- bool RightJustify;
+ Justification Justify;
friend class raw_ostream;
-
-public:
- FormattedString(StringRef S, unsigned W, bool R)
- : Str(S), Width(W), RightJustify(R) { }
};
/// left_justify - append spaces after string so total output is
/// \p Width characters. If \p Str is larger that \p Width, full string
/// is written with no padding.
inline FormattedString left_justify(StringRef Str, unsigned Width) {
- return FormattedString(Str, Width, false);
+ return FormattedString(Str, Width, FormattedString::JustifyLeft);
}
/// right_justify - add spaces before string so total output is
/// \p Width characters. If \p Str is larger that \p Width, full string
/// is written with no padding.
inline FormattedString right_justify(StringRef Str, unsigned Width) {
- return FormattedString(Str, Width, true);
+ return FormattedString(Str, Width, FormattedString::JustifyRight);
+}
+
+/// center_justify - add spaces before and after string so total output is
+/// \p Width characters. If \p Str is larger that \p Width, full string
+/// is written with no padding.
+inline FormattedString center_justify(StringRef Str, unsigned Width) {
+ return FormattedString(Str, Width, FormattedString::JustifyCenter);
}
/// This is a helper class used for format_hex() and format_decimal().
diff --git a/contrib/llvm/include/llvm/Support/FormatAdapters.h b/contrib/llvm/include/llvm/Support/FormatAdapters.h
index 7bacd2e..197beb7 100644
--- a/contrib/llvm/include/llvm/Support/FormatAdapters.h
+++ b/contrib/llvm/include/llvm/Support/FormatAdapters.h
@@ -22,23 +22,22 @@ protected:
explicit FormatAdapter(T &&Item) : Item(Item) {}
T Item;
-
- static_assert(!detail::uses_missing_provider<T>::value,
- "Item does not have a format provider!");
};
namespace detail {
template <typename T> class AlignAdapter final : public FormatAdapter<T> {
AlignStyle Where;
size_t Amount;
+ char Fill;
public:
- AlignAdapter(T &&Item, AlignStyle Where, size_t Amount)
- : FormatAdapter<T>(std::forward<T>(Item)), Where(Where), Amount(Amount) {}
+ AlignAdapter(T &&Item, AlignStyle Where, size_t Amount, char Fill)
+ : FormatAdapter<T>(std::forward<T>(Item)), Where(Where), Amount(Amount),
+ Fill(Fill) {}
void format(llvm::raw_ostream &Stream, StringRef Style) {
auto Adapter = detail::build_format_adapter(std::forward<T>(this->Item));
- FmtAlign(Adapter, Where, Amount).format(Stream, Style);
+ FmtAlign(Adapter, Where, Amount, Fill).format(Stream, Style);
}
};
@@ -75,8 +74,9 @@ public:
}
template <typename T>
-detail::AlignAdapter<T> fmt_align(T &&Item, AlignStyle Where, size_t Amount) {
- return detail::AlignAdapter<T>(std::forward<T>(Item), Where, Amount);
+detail::AlignAdapter<T> fmt_align(T &&Item, AlignStyle Where, size_t Amount,
+ char Fill = ' ') {
+ return detail::AlignAdapter<T>(std::forward<T>(Item), Where, Amount, Fill);
}
template <typename T>
diff --git a/contrib/llvm/include/llvm/Support/FormatCommon.h b/contrib/llvm/include/llvm/Support/FormatCommon.h
index a8c5fde..36fbad2 100644
--- a/contrib/llvm/include/llvm/Support/FormatCommon.h
+++ b/contrib/llvm/include/llvm/Support/FormatCommon.h
@@ -21,9 +21,11 @@ struct FmtAlign {
detail::format_adapter &Adapter;
AlignStyle Where;
size_t Amount;
+ char Fill;
- FmtAlign(detail::format_adapter &Adapter, AlignStyle Where, size_t Amount)
- : Adapter(Adapter), Where(Where), Amount(Amount) {}
+ FmtAlign(detail::format_adapter &Adapter, AlignStyle Where, size_t Amount,
+ char Fill = ' ')
+ : Adapter(Adapter), Where(Where), Amount(Amount), Fill(Fill) {}
void format(raw_ostream &S, StringRef Options) {
// If we don't need to align, we can format straight into the underlying
@@ -48,21 +50,27 @@ struct FmtAlign {
switch (Where) {
case AlignStyle::Left:
S << Item;
- S.indent(PadAmount);
+ fill(S, PadAmount);
break;
case AlignStyle::Center: {
size_t X = PadAmount / 2;
- S.indent(X);
+ fill(S, X);
S << Item;
- S.indent(PadAmount - X);
+ fill(S, PadAmount - X);
break;
}
default:
- S.indent(PadAmount);
+ fill(S, PadAmount);
S << Item;
break;
}
}
+
+private:
+ void fill(llvm::raw_ostream &S, uint32_t Count) {
+ for (uint32_t I = 0; I < Count; ++I)
+ S << Fill;
+ }
};
}
diff --git a/contrib/llvm/include/llvm/Support/FormatProviders.h b/contrib/llvm/include/llvm/Support/FormatProviders.h
index 1f0768c..4e57034 100644
--- a/contrib/llvm/include/llvm/Support/FormatProviders.h
+++ b/contrib/llvm/include/llvm/Support/FormatProviders.h
@@ -18,6 +18,7 @@
#include "llvm/ADT/Optional.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringSwitch.h"
+#include "llvm/ADT/Twine.h"
#include "llvm/Support/FormatVariadicDetails.h"
#include "llvm/Support/NativeFormatting.h"
@@ -45,9 +46,8 @@ struct is_cstring
template <typename T>
struct use_string_formatter
- : public std::integral_constant<
- bool, is_one_of<T, llvm::StringRef, std::string>::value ||
- is_cstring<T>::value> {};
+ : public std::integral_constant<bool,
+ std::is_convertible<T, llvm::StringRef>::value> {};
template <typename T>
struct use_pointer_formatter
@@ -205,11 +205,22 @@ struct format_provider<
if (!Style.empty() && Style.getAsInteger(10, N)) {
assert(false && "Style is not a valid integer");
}
- llvm::StringRef S(V);
+ llvm::StringRef S = V;
Stream << S.substr(0, N);
}
};
+/// Implementation of format_provider<T> for llvm::Twine.
+///
+/// This follows the same rules as the string formatter.
+
+template <> struct format_provider<Twine> {
+ static void format(const Twine &V, llvm::raw_ostream &Stream,
+ StringRef Style) {
+ format_provider<std::string>::format(V.str(), Stream, Style);
+ }
+};
+
/// Implementation of format_provider<T> for characters.
///
/// The options string of a character type has the grammar:
@@ -359,8 +370,7 @@ template <typename IterT> class format_provider<llvm::iterator_range<IterT>> {
return Default;
}
- std::vector<const char *> Delims = {"[]", "<>", "()"};
- for (const char *D : Delims) {
+ for (const char *D : {"[]", "<>", "()"}) {
if (Style.front() != D[0])
continue;
size_t End = Style.find_first_of(D[1]);
diff --git a/contrib/llvm/include/llvm/Support/FormatVariadic.h b/contrib/llvm/include/llvm/Support/FormatVariadic.h
index e5f5c96..c1153e8 100644
--- a/contrib/llvm/include/llvm/Support/FormatVariadic.h
+++ b/contrib/llvm/include/llvm/Support/FormatVariadic.h
@@ -27,8 +27,8 @@
#define LLVM_SUPPORT_FORMATVARIADIC_H
#include "llvm/ADT/Optional.h"
-#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/FormatCommon.h"
#include "llvm/Support/FormatProviders.h"
@@ -196,7 +196,7 @@ public:
// "}}" to print a literal '}'.
//
// ===Parameter Indexing===
-// `index` specifies the index of the paramter in the parameter pack to format
+// `index` specifies the index of the parameter in the parameter pack to format
// into the output. Note that it is possible to refer to the same parameter
// index multiple times in a given format string. This makes it possible to
// output the same value multiple times without passing it multiple times to the
diff --git a/contrib/llvm/include/llvm/Support/GCOV.h b/contrib/llvm/include/llvm/Support/GCOV.h
index f297fe6..02016e7 100644
--- a/contrib/llvm/include/llvm/Support/GCOV.h
+++ b/contrib/llvm/include/llvm/Support/GCOV.h
@@ -16,12 +16,12 @@
#define LLVM_SUPPORT_GCOV_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/iterator.h"
-#include "llvm/ADT/iterator_range.h"
#include "llvm/ADT/MapVector.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/ADT/iterator.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/raw_ostream.h"
#include <cassert>
@@ -63,7 +63,7 @@ struct Options {
/// read operations.
class GCOVBuffer {
public:
- GCOVBuffer(MemoryBuffer *B) : Buffer(B), Cursor(0) {}
+ GCOVBuffer(MemoryBuffer *B) : Buffer(B) {}
/// readGCNOFormat - Check GCNO signature is valid at the beginning of buffer.
bool readGCNOFormat() {
@@ -234,48 +234,48 @@ public:
private:
MemoryBuffer *Buffer;
- uint64_t Cursor;
+ uint64_t Cursor = 0;
};
/// GCOVFile - Collects coverage information for one pair of coverage file
/// (.gcno and .gcda).
class GCOVFile {
public:
- GCOVFile()
- : GCNOInitialized(false), Checksum(0), RunCount(0),
- ProgramCount(0) {}
+ GCOVFile() = default;
bool readGCNO(GCOVBuffer &Buffer);
bool readGCDA(GCOVBuffer &Buffer);
uint32_t getChecksum() const { return Checksum; }
+ void print(raw_ostream &OS) const;
void dump() const;
void collectLineCounts(FileInfo &FI);
private:
- bool GCNOInitialized;
+ bool GCNOInitialized = false;
GCOV::GCOVVersion Version;
- uint32_t Checksum;
+ uint32_t Checksum = 0;
SmallVector<std::unique_ptr<GCOVFunction>, 16> Functions;
- uint32_t RunCount;
- uint32_t ProgramCount;
+ uint32_t RunCount = 0;
+ uint32_t ProgramCount = 0;
};
/// GCOVEdge - Collects edge information.
struct GCOVEdge {
- GCOVEdge(GCOVBlock &S, GCOVBlock &D) : Src(S), Dst(D), Count(0) {}
+ GCOVEdge(GCOVBlock &S, GCOVBlock &D) : Src(S), Dst(D) {}
GCOVBlock &Src;
GCOVBlock &Dst;
- uint64_t Count;
+ uint64_t Count = 0;
};
/// GCOVFunction - Collects function information.
class GCOVFunction {
public:
- typedef pointee_iterator<SmallVectorImpl<
- std::unique_ptr<GCOVBlock>>::const_iterator> BlockIterator;
+ using BlockIterator = pointee_iterator<SmallVectorImpl<
+ std::unique_ptr<GCOVBlock>>::const_iterator>;
+
+ GCOVFunction(GCOVFile &P) : Parent(P) {}
- GCOVFunction(GCOVFile &P) : Parent(P), Ident(0), LineNumber(0) {}
bool readGCNO(GCOVBuffer &Buffer, GCOV::GCOVVersion Version);
bool readGCDA(GCOVBuffer &Buffer, GCOV::GCOVVersion Version);
StringRef getName() const { return Name; }
@@ -290,14 +290,15 @@ public:
return make_range(block_begin(), block_end());
}
+ void print(raw_ostream &OS) const;
void dump() const;
void collectLineCounts(FileInfo &FI);
private:
GCOVFile &Parent;
- uint32_t Ident;
+ uint32_t Ident = 0;
uint32_t Checksum;
- uint32_t LineNumber;
+ uint32_t LineNumber = 0;
StringRef Name;
StringRef Filename;
SmallVector<std::unique_ptr<GCOVBlock>, 16> Blocks;
@@ -307,10 +308,10 @@ private:
/// GCOVBlock - Collects block information.
class GCOVBlock {
struct EdgeWeight {
- EdgeWeight(GCOVBlock *D) : Dst(D), Count(0) {}
+ EdgeWeight(GCOVBlock *D) : Dst(D) {}
GCOVBlock *Dst;
- uint64_t Count;
+ uint64_t Count = 0;
};
struct SortDstEdgesFunctor {
@@ -320,10 +321,9 @@ class GCOVBlock {
};
public:
- typedef SmallVectorImpl<GCOVEdge *>::const_iterator EdgeIterator;
+ using EdgeIterator = SmallVectorImpl<GCOVEdge *>::const_iterator;
- GCOVBlock(GCOVFunction &P, uint32_t N)
- : Parent(P), Number(N), Counter(0), DstEdgesAreSorted(true) {}
+ GCOVBlock(GCOVFunction &P, uint32_t N) : Parent(P), Number(N) {}
~GCOVBlock();
const GCOVFunction &getParent() const { return Parent; }
@@ -361,14 +361,15 @@ public:
return make_range(dst_begin(), dst_end());
}
+ void print(raw_ostream &OS) const;
void dump() const;
void collectLineCounts(FileInfo &FI);
private:
GCOVFunction &Parent;
uint32_t Number;
- uint64_t Counter;
- bool DstEdgesAreSorted;
+ uint64_t Counter = 0;
+ bool DstEdgesAreSorted = true;
SmallVector<GCOVEdge *, 16> SrcEdges;
SmallVector<GCOVEdge *, 16> DstEdges;
SmallVector<uint32_t, 16> Lines;
@@ -380,36 +381,34 @@ class FileInfo {
// Therefore this typedef allows LineData.Functions to store multiple
// functions
// per instance. This is rare, however, so optimize for the common case.
- typedef SmallVector<const GCOVFunction *, 1> FunctionVector;
- typedef DenseMap<uint32_t, FunctionVector> FunctionLines;
- typedef SmallVector<const GCOVBlock *, 4> BlockVector;
- typedef DenseMap<uint32_t, BlockVector> BlockLines;
+ using FunctionVector = SmallVector<const GCOVFunction *, 1>;
+ using FunctionLines = DenseMap<uint32_t, FunctionVector>;
+ using BlockVector = SmallVector<const GCOVBlock *, 4>;
+ using BlockLines = DenseMap<uint32_t, BlockVector>;
struct LineData {
- LineData() : LastLine(0) {}
+ LineData() = default;
+
BlockLines Blocks;
FunctionLines Functions;
- uint32_t LastLine;
+ uint32_t LastLine = 0;
};
struct GCOVCoverage {
- GCOVCoverage(StringRef Name)
- : Name(Name), LogicalLines(0), LinesExec(0), Branches(0),
- BranchesExec(0), BranchesTaken(0) {}
+ GCOVCoverage(StringRef Name) : Name(Name) {}
StringRef Name;
- uint32_t LogicalLines;
- uint32_t LinesExec;
+ uint32_t LogicalLines = 0;
+ uint32_t LinesExec = 0;
- uint32_t Branches;
- uint32_t BranchesExec;
- uint32_t BranchesTaken;
+ uint32_t Branches = 0;
+ uint32_t BranchesExec = 0;
+ uint32_t BranchesTaken = 0;
};
public:
- FileInfo(const GCOV::Options &Options)
- : Options(Options), RunCount(0), ProgramCount(0) {}
+ FileInfo(const GCOV::Options &Options) : Options(Options) {}
void addBlockLine(StringRef Filename, uint32_t Line, const GCOVBlock *Block) {
if (Line > LineInfo[Filename].LastLine)
@@ -446,11 +445,11 @@ private:
const GCOV::Options &Options;
StringMap<LineData> LineInfo;
- uint32_t RunCount;
- uint32_t ProgramCount;
+ uint32_t RunCount = 0;
+ uint32_t ProgramCount = 0;
- typedef SmallVector<std::pair<std::string, GCOVCoverage>, 4> FileCoverageList;
- typedef MapVector<const GCOVFunction *, GCOVCoverage> FuncCoverageMap;
+ using FileCoverageList = SmallVector<std::pair<std::string, GCOVCoverage>, 4>;
+ using FuncCoverageMap = MapVector<const GCOVFunction *, GCOVCoverage>;
FileCoverageList FileCoverages;
FuncCoverageMap FuncCoverages;
diff --git a/contrib/llvm/include/llvm/Support/GenericDomTree.h b/contrib/llvm/include/llvm/Support/GenericDomTree.h
index 6e6ee40..706320f 100644
--- a/contrib/llvm/include/llvm/Support/GenericDomTree.h
+++ b/contrib/llvm/include/llvm/Support/GenericDomTree.h
@@ -13,7 +13,7 @@
/// dominance queries on the CFG, but is fully generic w.r.t. the underlying
/// graph types.
///
-/// Unlike ADT/* graph algorithms, generic dominator tree has more reuiqrement
+/// Unlike ADT/* graph algorithms, generic dominator tree has more requirements
/// on the graph's NodeRef. The NodeRef should be a pointer and, depending on
/// the implementation, e.g. NodeRef->getParent() return the parent node.
///
@@ -25,82 +25,52 @@
#define LLVM_SUPPORT_GENERICDOMTREE_H
#include "llvm/ADT/DenseMap.h"
-#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/GraphTraits.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
+#include <cassert>
+#include <cstddef>
+#include <iterator>
+#include <memory>
+#include <type_traits>
+#include <utility>
+#include <vector>
namespace llvm {
-template <class NodeT> class DominatorTreeBase;
+template <typename NodeT, bool IsPostDom>
+class DominatorTreeBase;
-namespace detail {
-
-template <typename GT> struct DominatorTreeBaseTraits {
- static_assert(std::is_pointer<typename GT::NodeRef>::value,
- "Currently NodeRef must be a pointer type.");
- using type = DominatorTreeBase<
- typename std::remove_pointer<typename GT::NodeRef>::type>;
-};
-
-} // End namespace detail
-
-template <typename GT>
-using DominatorTreeBaseByGraphTraits =
- typename detail::DominatorTreeBaseTraits<GT>::type;
-
-/// \brief Base class that other, more interesting dominator analyses
-/// inherit from.
-template <class NodeT> class DominatorBase {
-protected:
- std::vector<NodeT *> Roots;
- bool IsPostDominators;
- explicit DominatorBase(bool isPostDom)
- : Roots(), IsPostDominators(isPostDom) {}
- DominatorBase(DominatorBase &&Arg)
- : Roots(std::move(Arg.Roots)),
- IsPostDominators(std::move(Arg.IsPostDominators)) {
- Arg.Roots.clear();
- }
- DominatorBase &operator=(DominatorBase &&RHS) {
- Roots = std::move(RHS.Roots);
- IsPostDominators = std::move(RHS.IsPostDominators);
- RHS.Roots.clear();
- return *this;
- }
-
-public:
- /// getRoots - Return the root blocks of the current CFG. This may include
- /// multiple blocks if we are computing post dominators. For forward
- /// dominators, this will always be a single block (the entry node).
- ///
- const std::vector<NodeT *> &getRoots() const { return Roots; }
-
- /// isPostDominator - Returns true if analysis based of postdoms
- ///
- bool isPostDominator() const { return IsPostDominators; }
-};
-
-struct PostDominatorTree;
+namespace DomTreeBuilder {
+template <class DomTreeT>
+struct SemiNCAInfo;
+} // namespace DomTreeBuilder
/// \brief Base class for the actual dominator tree node.
template <class NodeT> class DomTreeNodeBase {
+ friend struct PostDominatorTree;
+ friend class DominatorTreeBase<NodeT, false>;
+ friend class DominatorTreeBase<NodeT, true>;
+ friend struct DomTreeBuilder::SemiNCAInfo<DominatorTreeBase<NodeT, false>>;
+ friend struct DomTreeBuilder::SemiNCAInfo<DominatorTreeBase<NodeT, true>>;
+
NodeT *TheBB;
- DomTreeNodeBase<NodeT> *IDom;
- std::vector<DomTreeNodeBase<NodeT> *> Children;
- mutable int DFSNumIn, DFSNumOut;
+ DomTreeNodeBase *IDom;
+ unsigned Level;
+ std::vector<DomTreeNodeBase *> Children;
+ mutable unsigned DFSNumIn = ~0;
+ mutable unsigned DFSNumOut = ~0;
- template <class N> friend class DominatorTreeBase;
- friend struct PostDominatorTree;
+ public:
+ DomTreeNodeBase(NodeT *BB, DomTreeNodeBase *iDom)
+ : TheBB(BB), IDom(iDom), Level(IDom ? IDom->Level + 1 : 0) {}
-public:
- typedef typename std::vector<DomTreeNodeBase<NodeT> *>::iterator iterator;
- typedef typename std::vector<DomTreeNodeBase<NodeT> *>::const_iterator
- const_iterator;
+ using iterator = typename std::vector<DomTreeNodeBase *>::iterator;
+ using const_iterator =
+ typename std::vector<DomTreeNodeBase *>::const_iterator;
iterator begin() { return Children.begin(); }
iterator end() { return Children.end(); }
@@ -108,16 +78,13 @@ public:
const_iterator end() const { return Children.end(); }
NodeT *getBlock() const { return TheBB; }
- DomTreeNodeBase<NodeT> *getIDom() const { return IDom; }
- const std::vector<DomTreeNodeBase<NodeT> *> &getChildren() const {
- return Children;
- }
+ DomTreeNodeBase *getIDom() const { return IDom; }
+ unsigned getLevel() const { return Level; }
- DomTreeNodeBase(NodeT *BB, DomTreeNodeBase<NodeT> *iDom)
- : TheBB(BB), IDom(iDom), DFSNumIn(-1), DFSNumOut(-1) {}
+ const std::vector<DomTreeNodeBase *> &getChildren() const { return Children; }
- std::unique_ptr<DomTreeNodeBase<NodeT>>
- addChild(std::unique_ptr<DomTreeNodeBase<NodeT>> C) {
+ std::unique_ptr<DomTreeNodeBase> addChild(
+ std::unique_ptr<DomTreeNodeBase> C) {
Children.push_back(C.get());
return C;
}
@@ -126,10 +93,12 @@ public:
void clearAllChildren() { Children.clear(); }
- bool compare(const DomTreeNodeBase<NodeT> *Other) const {
+ bool compare(const DomTreeNodeBase *Other) const {
if (getNumChildren() != Other->getNumChildren())
return true;
+ if (Level != Other->Level) return true;
+
SmallPtrSet<const NodeT *, 4> OtherChildren;
for (const DomTreeNodeBase *I : *Other) {
const NodeT *Nd = I->getBlock();
@@ -144,20 +113,21 @@ public:
return false;
}
- void setIDom(DomTreeNodeBase<NodeT> *NewIDom) {
+ void setIDom(DomTreeNodeBase *NewIDom) {
assert(IDom && "No immediate dominator?");
- if (IDom != NewIDom) {
- typename std::vector<DomTreeNodeBase<NodeT> *>::iterator I =
- find(IDom->Children, this);
- assert(I != IDom->Children.end() &&
- "Not in immediate dominator children set!");
- // I am no longer your child...
- IDom->Children.erase(I);
+ if (IDom == NewIDom) return;
- // Switch to new dominator
- IDom = NewIDom;
- IDom->Children.push_back(this);
- }
+ auto I = find(IDom->Children, this);
+ assert(I != IDom->Children.end() &&
+ "Not in immediate dominator children set!");
+ // I am no longer your child...
+ IDom->Children.erase(I);
+
+ // Switch to new dominator
+ IDom = NewIDom;
+ IDom->Children.push_back(this);
+
+ UpdateLevel();
}
/// getDFSNumIn/getDFSNumOut - These return the DFS visitation order for nodes
@@ -169,208 +139,143 @@ public:
private:
// Return true if this node is dominated by other. Use this only if DFS info
// is valid.
- bool DominatedBy(const DomTreeNodeBase<NodeT> *other) const {
+ bool DominatedBy(const DomTreeNodeBase *other) const {
return this->DFSNumIn >= other->DFSNumIn &&
this->DFSNumOut <= other->DFSNumOut;
}
+
+ void UpdateLevel() {
+ assert(IDom);
+ if (Level == IDom->Level + 1) return;
+
+ SmallVector<DomTreeNodeBase *, 64> WorkStack = {this};
+
+ while (!WorkStack.empty()) {
+ DomTreeNodeBase *Current = WorkStack.pop_back_val();
+ Current->Level = Current->IDom->Level + 1;
+
+ for (DomTreeNodeBase *C : *Current) {
+ assert(C->IDom);
+ if (C->Level != C->IDom->Level + 1) WorkStack.push_back(C);
+ }
+ }
+ }
};
template <class NodeT>
-raw_ostream &operator<<(raw_ostream &o, const DomTreeNodeBase<NodeT> *Node) {
+raw_ostream &operator<<(raw_ostream &O, const DomTreeNodeBase<NodeT> *Node) {
if (Node->getBlock())
- Node->getBlock()->printAsOperand(o, false);
+ Node->getBlock()->printAsOperand(O, false);
else
- o << " <<exit node>>";
+ O << " <<exit node>>";
- o << " {" << Node->getDFSNumIn() << "," << Node->getDFSNumOut() << "}";
+ O << " {" << Node->getDFSNumIn() << "," << Node->getDFSNumOut() << "} ["
+ << Node->getLevel() << "]\n";
- return o << "\n";
+ return O;
}
template <class NodeT>
-void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &o,
+void PrintDomTree(const DomTreeNodeBase<NodeT> *N, raw_ostream &O,
unsigned Lev) {
- o.indent(2 * Lev) << "[" << Lev << "] " << N;
+ O.indent(2 * Lev) << "[" << Lev << "] " << N;
for (typename DomTreeNodeBase<NodeT>::const_iterator I = N->begin(),
E = N->end();
I != E; ++I)
- PrintDomTree<NodeT>(*I, o, Lev + 1);
+ PrintDomTree<NodeT>(*I, O, Lev + 1);
}
-// The calculate routine is provided in a separate header but referenced here.
-template <class FuncT, class N>
-void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<N>> &DT, FuncT &F);
+namespace DomTreeBuilder {
+// The routines below are provided in a separate header but referenced here.
+template <typename DomTreeT, typename FuncT>
+void Calculate(DomTreeT &DT, FuncT &F);
+
+template <class DomTreeT>
+void InsertEdge(DomTreeT &DT, typename DomTreeT::NodePtr From,
+ typename DomTreeT::NodePtr To);
+
+template <class DomTreeT>
+void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From,
+ typename DomTreeT::NodePtr To);
+
+template <typename DomTreeT>
+bool Verify(const DomTreeT &DT);
+} // namespace DomTreeBuilder
/// \brief Core dominator tree base class.
///
/// This class is a generic template over graph nodes. It is instantiated for
/// various graphs in the LLVM IR or in the code generator.
-template <class NodeT> class DominatorTreeBase : public DominatorBase<NodeT> {
- DominatorTreeBase(const DominatorTreeBase &) = delete;
- DominatorTreeBase &operator=(const DominatorTreeBase &) = delete;
-
- bool dominatedBySlowTreeWalk(const DomTreeNodeBase<NodeT> *A,
- const DomTreeNodeBase<NodeT> *B) const {
- assert(A != B);
- assert(isReachableFromEntry(B));
- assert(isReachableFromEntry(A));
-
- const DomTreeNodeBase<NodeT> *IDom;
- while ((IDom = B->getIDom()) != nullptr && IDom != A && IDom != B)
- B = IDom; // Walk up the tree
- return IDom != nullptr;
- }
-
- /// \brief Wipe this tree's state without releasing any resources.
- ///
- /// This is essentially a post-move helper only. It leaves the object in an
- /// assignable and destroyable state, but otherwise invalid.
- void wipe() {
- DomTreeNodes.clear();
- IDoms.clear();
- Vertex.clear();
- Info.clear();
- RootNode = nullptr;
- }
+template <typename NodeT, bool IsPostDom>
+class DominatorTreeBase {
+ protected:
+ std::vector<NodeT *> Roots;
-protected:
- typedef DenseMap<NodeT *, std::unique_ptr<DomTreeNodeBase<NodeT>>>
- DomTreeNodeMapType;
+ using DomTreeNodeMapType =
+ DenseMap<NodeT *, std::unique_ptr<DomTreeNodeBase<NodeT>>>;
DomTreeNodeMapType DomTreeNodes;
DomTreeNodeBase<NodeT> *RootNode;
+ using ParentPtr = decltype(std::declval<NodeT *>()->getParent());
+ ParentPtr Parent = nullptr;
- mutable bool DFSInfoValid;
- mutable unsigned int SlowQueries;
- // Information record used during immediate dominators computation.
- struct InfoRec {
- unsigned DFSNum;
- unsigned Parent;
- unsigned Semi;
- NodeT *Label;
-
- InfoRec() : DFSNum(0), Parent(0), Semi(0), Label(nullptr) {}
- };
-
- DenseMap<NodeT *, NodeT *> IDoms;
-
- // Vertex - Map the DFS number to the NodeT*
- std::vector<NodeT *> Vertex;
-
- // Info - Collection of information used during the computation of idoms.
- DenseMap<NodeT *, InfoRec> Info;
-
- void reset() {
- DomTreeNodes.clear();
- IDoms.clear();
- this->Roots.clear();
- Vertex.clear();
- RootNode = nullptr;
- DFSInfoValid = false;
- SlowQueries = 0;
- }
-
- // NewBB is split and now it has one successor. Update dominator tree to
- // reflect this change.
- template <class N, class GraphT>
- void Split(DominatorTreeBaseByGraphTraits<GraphT> &DT,
- typename GraphT::NodeRef NewBB) {
- assert(std::distance(GraphT::child_begin(NewBB),
- GraphT::child_end(NewBB)) == 1 &&
- "NewBB should have a single successor!");
- typename GraphT::NodeRef NewBBSucc = *GraphT::child_begin(NewBB);
-
- std::vector<typename GraphT::NodeRef> PredBlocks;
- typedef GraphTraits<Inverse<N>> InvTraits;
- for (typename InvTraits::ChildIteratorType
- PI = InvTraits::child_begin(NewBB),
- PE = InvTraits::child_end(NewBB);
- PI != PE; ++PI)
- PredBlocks.push_back(*PI);
-
- assert(!PredBlocks.empty() && "No predblocks?");
-
- bool NewBBDominatesNewBBSucc = true;
- for (typename InvTraits::ChildIteratorType
- PI = InvTraits::child_begin(NewBBSucc),
- E = InvTraits::child_end(NewBBSucc);
- PI != E; ++PI) {
- typename InvTraits::NodeRef ND = *PI;
- if (ND != NewBB && !DT.dominates(NewBBSucc, ND) &&
- DT.isReachableFromEntry(ND)) {
- NewBBDominatesNewBBSucc = false;
- break;
- }
- }
-
- // Find NewBB's immediate dominator and create new dominator tree node for
- // NewBB.
- NodeT *NewBBIDom = nullptr;
- unsigned i = 0;
- for (i = 0; i < PredBlocks.size(); ++i)
- if (DT.isReachableFromEntry(PredBlocks[i])) {
- NewBBIDom = PredBlocks[i];
- break;
- }
+ mutable bool DFSInfoValid = false;
+ mutable unsigned int SlowQueries = 0;
- // It's possible that none of the predecessors of NewBB are reachable;
- // in that case, NewBB itself is unreachable, so nothing needs to be
- // changed.
- if (!NewBBIDom)
- return;
+ friend struct DomTreeBuilder::SemiNCAInfo<DominatorTreeBase>;
- for (i = i + 1; i < PredBlocks.size(); ++i) {
- if (DT.isReachableFromEntry(PredBlocks[i]))
- NewBBIDom = DT.findNearestCommonDominator(NewBBIDom, PredBlocks[i]);
- }
+ public:
+ static_assert(std::is_pointer<typename GraphTraits<NodeT *>::NodeRef>::value,
+ "Currently DominatorTreeBase supports only pointer nodes");
+ using NodeType = NodeT;
+ using NodePtr = NodeT *;
+ static constexpr bool IsPostDominator = IsPostDom;
- // Create the new dominator tree node... and set the idom of NewBB.
- DomTreeNodeBase<NodeT> *NewBBNode = DT.addNewBlock(NewBB, NewBBIDom);
-
- // If NewBB strictly dominates other blocks, then it is now the immediate
- // dominator of NewBBSucc. Update the dominator tree as appropriate.
- if (NewBBDominatesNewBBSucc) {
- DomTreeNodeBase<NodeT> *NewBBSuccNode = DT.getNode(NewBBSucc);
- DT.changeImmediateDominator(NewBBSuccNode, NewBBNode);
- }
- }
-
-public:
- explicit DominatorTreeBase(bool isPostDom)
- : DominatorBase<NodeT>(isPostDom), DFSInfoValid(false), SlowQueries(0) {}
+ DominatorTreeBase() {}
DominatorTreeBase(DominatorTreeBase &&Arg)
- : DominatorBase<NodeT>(
- std::move(static_cast<DominatorBase<NodeT> &>(Arg))),
+ : Roots(std::move(Arg.Roots)),
DomTreeNodes(std::move(Arg.DomTreeNodes)),
- RootNode(std::move(Arg.RootNode)),
- DFSInfoValid(std::move(Arg.DFSInfoValid)),
- SlowQueries(std::move(Arg.SlowQueries)), IDoms(std::move(Arg.IDoms)),
- Vertex(std::move(Arg.Vertex)), Info(std::move(Arg.Info)) {
+ RootNode(Arg.RootNode),
+ Parent(Arg.Parent),
+ DFSInfoValid(Arg.DFSInfoValid),
+ SlowQueries(Arg.SlowQueries) {
Arg.wipe();
}
+
DominatorTreeBase &operator=(DominatorTreeBase &&RHS) {
- DominatorBase<NodeT>::operator=(
- std::move(static_cast<DominatorBase<NodeT> &>(RHS)));
+ Roots = std::move(RHS.Roots);
DomTreeNodes = std::move(RHS.DomTreeNodes);
- RootNode = std::move(RHS.RootNode);
- DFSInfoValid = std::move(RHS.DFSInfoValid);
- SlowQueries = std::move(RHS.SlowQueries);
- IDoms = std::move(RHS.IDoms);
- Vertex = std::move(RHS.Vertex);
- Info = std::move(RHS.Info);
+ RootNode = RHS.RootNode;
+ Parent = RHS.Parent;
+ DFSInfoValid = RHS.DFSInfoValid;
+ SlowQueries = RHS.SlowQueries;
RHS.wipe();
return *this;
}
+ DominatorTreeBase(const DominatorTreeBase &) = delete;
+ DominatorTreeBase &operator=(const DominatorTreeBase &) = delete;
+
+ /// getRoots - Return the root blocks of the current CFG. This may include
+ /// multiple blocks if we are computing post dominators. For forward
+ /// dominators, this will always be a single block (the entry node).
+ ///
+ const std::vector<NodeT *> &getRoots() const { return Roots; }
+
+ /// isPostDominator - Returns true if analysis based of postdoms
+ ///
+ bool isPostDominator() const { return IsPostDominator; }
+
/// compare - Return false if the other dominator tree base matches this
/// dominator tree base. Otherwise return true.
bool compare(const DominatorTreeBase &Other) const {
+ if (Parent != Other.Parent) return true;
const DomTreeNodeMapType &OtherDomTreeNodes = Other.DomTreeNodes;
if (DomTreeNodes.size() != OtherDomTreeNodes.size())
return true;
- for (const auto &DomTreeNode : this->DomTreeNodes) {
+ for (const auto &DomTreeNode : DomTreeNodes) {
NodeT *BB = DomTreeNode.first;
typename DomTreeNodeMapType::const_iterator OI =
OtherDomTreeNodes.find(BB);
@@ -470,6 +375,13 @@ public:
if (!isReachableFromEntry(A))
return false;
+ if (B->getIDom() == A) return true;
+
+ if (A->getIDom() == B) return false;
+
+ // A can only dominate B if it is higher in the tree.
+ if (A->getLevel() >= B->getLevel()) return false;
+
// Compare the result of the tree walk and the dfs numbers, if expensive
// checks are enabled.
#ifdef EXPENSIVE_CHECKS
@@ -501,7 +413,7 @@ public:
/// findNearestCommonDominator - Find nearest common dominator basic block
/// for basic block A and B. If there is no such block then return NULL.
- NodeT *findNearestCommonDominator(NodeT *A, NodeT *B) {
+ NodeT *findNearestCommonDominator(NodeT *A, NodeT *B) const {
assert(A->getParent() == B->getParent() &&
"Two blocks are not in same function");
@@ -513,64 +425,74 @@ public:
return &Entry;
}
- // If B dominates A then B is nearest common dominator.
- if (dominates(B, A))
- return B;
-
- // If A dominates B then A is nearest common dominator.
- if (dominates(A, B))
- return A;
-
DomTreeNodeBase<NodeT> *NodeA = getNode(A);
DomTreeNodeBase<NodeT> *NodeB = getNode(B);
- // If we have DFS info, then we can avoid all allocations by just querying
- // it from each IDom. Note that because we call 'dominates' twice above, we
- // expect to call through this code at most 16 times in a row without
- // building valid DFS information. This is important as below is a *very*
- // slow tree walk.
- if (DFSInfoValid) {
- DomTreeNodeBase<NodeT> *IDomA = NodeA->getIDom();
- while (IDomA) {
- if (NodeB->DominatedBy(IDomA))
- return IDomA->getBlock();
- IDomA = IDomA->getIDom();
- }
- return nullptr;
- }
-
- // Collect NodeA dominators set.
- SmallPtrSet<DomTreeNodeBase<NodeT> *, 16> NodeADoms;
- NodeADoms.insert(NodeA);
- DomTreeNodeBase<NodeT> *IDomA = NodeA->getIDom();
- while (IDomA) {
- NodeADoms.insert(IDomA);
- IDomA = IDomA->getIDom();
- }
+ if (!NodeA || !NodeB) return nullptr;
- // Walk NodeB immediate dominators chain and find common dominator node.
- DomTreeNodeBase<NodeT> *IDomB = NodeB->getIDom();
- while (IDomB) {
- if (NodeADoms.count(IDomB) != 0)
- return IDomB->getBlock();
+ // Use level information to go up the tree until the levels match. Then
+ // continue going up til we arrive at the same node.
+ while (NodeA && NodeA != NodeB) {
+ if (NodeA->getLevel() < NodeB->getLevel()) std::swap(NodeA, NodeB);
- IDomB = IDomB->getIDom();
+ NodeA = NodeA->IDom;
}
- return nullptr;
+ return NodeA ? NodeA->getBlock() : nullptr;
}
- const NodeT *findNearestCommonDominator(const NodeT *A, const NodeT *B) {
+ const NodeT *findNearestCommonDominator(const NodeT *A,
+ const NodeT *B) const {
// Cast away the const qualifiers here. This is ok since
// const is re-introduced on the return type.
return findNearestCommonDominator(const_cast<NodeT *>(A),
const_cast<NodeT *>(B));
}
+ bool isVirtualRoot(const DomTreeNodeBase<NodeT> *A) const {
+ return isPostDominator() && !A->getBlock();
+ }
+
//===--------------------------------------------------------------------===//
// API to update (Post)DominatorTree information based on modifications to
// the CFG...
+ /// Inform the dominator tree about a CFG edge insertion and update the tree.
+ ///
+ /// This function has to be called just before or just after making the update
+ /// on the actual CFG. There cannot be any other updates that the dominator
+ /// tree doesn't know about.
+ ///
+ /// Note that for postdominators it automatically takes care of inserting
+ /// a reverse edge internally (so there's no need to swap the parameters).
+ ///
+ void insertEdge(NodeT *From, NodeT *To) {
+ assert(From);
+ assert(To);
+ assert(From->getParent() == Parent);
+ assert(To->getParent() == Parent);
+ DomTreeBuilder::InsertEdge(*this, From, To);
+ }
+
+ /// Inform the dominator tree about a CFG edge deletion and update the tree.
+ ///
+ /// This function has to be called just after making the update
+ /// on the actual CFG. There cannot be any other updates that the dominator
+ /// tree doesn't know about. The only exception is when the deletion that the
+ /// tree is informed about makes some (domominator) subtree unreachable -- in
+ /// this case, it is fine to perform deletions within this subtree.
+ ///
+ /// Note that for postdominators it automatically takes care of deleting
+ /// a reverse edge internally (so there's no need to swap the parameters).
+ ///
+ void deleteEdge(NodeT *From, NodeT *To) {
+ assert(From);
+ assert(To);
+ assert(From->getParent() == Parent);
+ assert(To->getParent() == Parent);
+ DomTreeBuilder::DeleteEdge(*this, From, To);
+ }
+
/// Add a new node to the dominator tree information.
///
/// This creates a new node as a child of DomBB dominator node, linking it
@@ -599,7 +521,6 @@ public:
assert(!this->isPostDominator() &&
"Cannot change root of post-dominator tree");
DFSInfoValid = false;
- auto &Roots = DominatorBase<NodeT>::Roots;
DomTreeNodeBase<NodeT> *NewNode = (DomTreeNodes[BB] =
llvm::make_unique<DomTreeNodeBase<NodeT>>(BB, nullptr)).get();
if (Roots.empty()) {
@@ -607,8 +528,10 @@ public:
} else {
assert(Roots.size() == 1);
NodeT *OldRoot = Roots.front();
- DomTreeNodes[OldRoot] =
- NewNode->addChild(std::move(DomTreeNodes[OldRoot]));
+ auto &OldNode = DomTreeNodes[OldRoot];
+ OldNode = NewNode->addChild(std::move(DomTreeNodes[OldRoot]));
+ OldNode->IDom = NewNode;
+ OldNode->UpdateLevel();
Roots[0] = BB;
}
return RootNode = NewNode;
@@ -653,70 +576,32 @@ public:
/// splitBlock - BB is split and now it has one successor. Update dominator
/// tree to reflect this change.
void splitBlock(NodeT *NewBB) {
- if (this->IsPostDominators)
- this->Split<Inverse<NodeT *>, GraphTraits<Inverse<NodeT *>>>(*this,
- NewBB);
+ if (IsPostDominator)
+ Split<Inverse<NodeT *>>(NewBB);
else
- this->Split<NodeT *, GraphTraits<NodeT *>>(*this, NewBB);
+ Split<NodeT *>(NewBB);
}
/// print - Convert to human readable form
///
- void print(raw_ostream &o) const {
- o << "=============================--------------------------------\n";
+ void print(raw_ostream &O) const {
+ O << "=============================--------------------------------\n";
if (this->isPostDominator())
- o << "Inorder PostDominator Tree: ";
+ O << "Inorder PostDominator Tree: ";
else
- o << "Inorder Dominator Tree: ";
- if (!this->DFSInfoValid)
- o << "DFSNumbers invalid: " << SlowQueries << " slow queries.";
- o << "\n";
+ O << "Inorder Dominator Tree: ";
+ if (!DFSInfoValid)
+ O << "DFSNumbers invalid: " << SlowQueries << " slow queries.";
+ O << "\n";
// The postdom tree can have a null root if there are no returns.
- if (getRootNode())
- PrintDomTree<NodeT>(getRootNode(), o, 1);
- }
-
-protected:
- template <class GraphT>
- friend typename GraphT::NodeRef
- Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT, typename GraphT::NodeRef V,
- unsigned LastLinked);
-
- template <class GraphT>
- friend unsigned DFSPass(DominatorTreeBaseByGraphTraits<GraphT> &DT,
- typename GraphT::NodeRef V, unsigned N);
-
- template <class FuncT, class N>
- friend void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<N>> &DT,
- FuncT &F);
-
- DomTreeNodeBase<NodeT> *getNodeForBlock(NodeT *BB) {
- if (DomTreeNodeBase<NodeT> *Node = getNode(BB))
- return Node;
-
- // Haven't calculated this node yet? Get or calculate the node for the
- // immediate dominator.
- NodeT *IDom = getIDom(BB);
-
- assert(IDom || this->DomTreeNodes[nullptr]);
- DomTreeNodeBase<NodeT> *IDomNode = getNodeForBlock(IDom);
-
- // Add a new tree node for this NodeT, and link it as a child of
- // IDomNode
- return (this->DomTreeNodes[BB] = IDomNode->addChild(
- llvm::make_unique<DomTreeNodeBase<NodeT>>(BB, IDomNode))).get();
+ if (getRootNode()) PrintDomTree<NodeT>(getRootNode(), O, 1);
}
- NodeT *getIDom(NodeT *BB) const { return IDoms.lookup(BB); }
-
- void addRoot(NodeT *BB) { this->Roots.push_back(BB); }
-
public:
/// updateDFSNumbers - Assign In and Out numbers to the nodes while walking
/// dominator tree in dfs order.
void updateDFSNumbers() const {
-
if (DFSInfoValid) {
SlowQueries = 0;
return;
@@ -766,33 +651,131 @@ public:
/// recalculate - compute a dominator tree for the given function
template <class FT> void recalculate(FT &F) {
- typedef GraphTraits<FT *> TraitsTy;
+ using TraitsTy = GraphTraits<FT *>;
reset();
- this->Vertex.push_back(nullptr);
+ Parent = &F;
- if (!this->IsPostDominators) {
+ if (!IsPostDominator) {
// Initialize root
NodeT *entry = TraitsTy::getEntryNode(&F);
addRoot(entry);
-
- Calculate<FT, NodeT *>(*this, F);
} else {
// Initialize the roots list
- for (typename TraitsTy::nodes_iterator I = TraitsTy::nodes_begin(&F),
- E = TraitsTy::nodes_end(&F);
- I != E; ++I)
- if (TraitsTy::child_begin(*I) == TraitsTy::child_end(*I))
- addRoot(*I);
+ for (auto *Node : nodes(&F))
+ if (TraitsTy::child_begin(Node) == TraitsTy::child_end(Node))
+ addRoot(Node);
+ }
+
+ DomTreeBuilder::Calculate(*this, F);
+ }
+
+ /// verify - check parent and sibling property
+ bool verify() const { return DomTreeBuilder::Verify(*this); }
+
+ protected:
+ void addRoot(NodeT *BB) { this->Roots.push_back(BB); }
+
+ void reset() {
+ DomTreeNodes.clear();
+ Roots.clear();
+ RootNode = nullptr;
+ Parent = nullptr;
+ DFSInfoValid = false;
+ SlowQueries = 0;
+ }
- Calculate<FT, Inverse<NodeT *>>(*this, F);
+ // NewBB is split and now it has one successor. Update dominator tree to
+ // reflect this change.
+ template <class N>
+ void Split(typename GraphTraits<N>::NodeRef NewBB) {
+ using GraphT = GraphTraits<N>;
+ using NodeRef = typename GraphT::NodeRef;
+ assert(std::distance(GraphT::child_begin(NewBB),
+ GraphT::child_end(NewBB)) == 1 &&
+ "NewBB should have a single successor!");
+ NodeRef NewBBSucc = *GraphT::child_begin(NewBB);
+
+ std::vector<NodeRef> PredBlocks;
+ for (const auto &Pred : children<Inverse<N>>(NewBB))
+ PredBlocks.push_back(Pred);
+
+ assert(!PredBlocks.empty() && "No predblocks?");
+
+ bool NewBBDominatesNewBBSucc = true;
+ for (const auto &Pred : children<Inverse<N>>(NewBBSucc)) {
+ if (Pred != NewBB && !dominates(NewBBSucc, Pred) &&
+ isReachableFromEntry(Pred)) {
+ NewBBDominatesNewBBSucc = false;
+ break;
+ }
+ }
+
+ // Find NewBB's immediate dominator and create new dominator tree node for
+ // NewBB.
+ NodeT *NewBBIDom = nullptr;
+ unsigned i = 0;
+ for (i = 0; i < PredBlocks.size(); ++i)
+ if (isReachableFromEntry(PredBlocks[i])) {
+ NewBBIDom = PredBlocks[i];
+ break;
+ }
+
+ // It's possible that none of the predecessors of NewBB are reachable;
+ // in that case, NewBB itself is unreachable, so nothing needs to be
+ // changed.
+ if (!NewBBIDom) return;
+
+ for (i = i + 1; i < PredBlocks.size(); ++i) {
+ if (isReachableFromEntry(PredBlocks[i]))
+ NewBBIDom = findNearestCommonDominator(NewBBIDom, PredBlocks[i]);
+ }
+
+ // Create the new dominator tree node... and set the idom of NewBB.
+ DomTreeNodeBase<NodeT> *NewBBNode = addNewBlock(NewBB, NewBBIDom);
+
+ // If NewBB strictly dominates other blocks, then it is now the immediate
+ // dominator of NewBBSucc. Update the dominator tree as appropriate.
+ if (NewBBDominatesNewBBSucc) {
+ DomTreeNodeBase<NodeT> *NewBBSuccNode = getNode(NewBBSucc);
+ changeImmediateDominator(NewBBSuccNode, NewBBNode);
}
}
+
+ private:
+ bool dominatedBySlowTreeWalk(const DomTreeNodeBase<NodeT> *A,
+ const DomTreeNodeBase<NodeT> *B) const {
+ assert(A != B);
+ assert(isReachableFromEntry(B));
+ assert(isReachableFromEntry(A));
+
+ const DomTreeNodeBase<NodeT> *IDom;
+ while ((IDom = B->getIDom()) != nullptr && IDom != A && IDom != B)
+ B = IDom; // Walk up the tree
+ return IDom != nullptr;
+ }
+
+ /// \brief Wipe this tree's state without releasing any resources.
+ ///
+ /// This is essentially a post-move helper only. It leaves the object in an
+ /// assignable and destroyable state, but otherwise invalid.
+ void wipe() {
+ DomTreeNodes.clear();
+ RootNode = nullptr;
+ Parent = nullptr;
+ }
};
+template <typename T>
+using DomTreeBase = DominatorTreeBase<T, false>;
+
+template <typename T>
+using PostDomTreeBase = DominatorTreeBase<T, true>;
+
// These two functions are declared out of line as a workaround for building
// with old (< r147295) versions of clang because of pr11642.
-template <class NodeT>
-bool DominatorTreeBase<NodeT>::dominates(const NodeT *A, const NodeT *B) const {
+template <typename NodeT, bool IsPostDom>
+bool DominatorTreeBase<NodeT, IsPostDom>::dominates(const NodeT *A,
+ const NodeT *B) const {
if (A == B)
return true;
@@ -802,9 +785,9 @@ bool DominatorTreeBase<NodeT>::dominates(const NodeT *A, const NodeT *B) const {
return dominates(getNode(const_cast<NodeT *>(A)),
getNode(const_cast<NodeT *>(B)));
}
-template <class NodeT>
-bool DominatorTreeBase<NodeT>::properlyDominates(const NodeT *A,
- const NodeT *B) const {
+template <typename NodeT, bool IsPostDom>
+bool DominatorTreeBase<NodeT, IsPostDom>::properlyDominates(
+ const NodeT *A, const NodeT *B) const {
if (A == B)
return false;
@@ -815,6 +798,6 @@ bool DominatorTreeBase<NodeT>::properlyDominates(const NodeT *A,
getNode(const_cast<NodeT *>(B)));
}
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_GENERICDOMTREE_H
diff --git a/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h b/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h
index 54e55cc..be90afa 100644
--- a/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h
+++ b/contrib/llvm/include/llvm/Support/GenericDomTreeConstruction.h
@@ -10,278 +10,973 @@
///
/// Generic dominator tree construction - This file provides routines to
/// construct immediate dominator information for a flow-graph based on the
-/// algorithm described in this document:
+/// Semi-NCA algorithm described in this dissertation:
///
-/// A Fast Algorithm for Finding Dominators in a Flowgraph
-/// T. Lengauer & R. Tarjan, ACM TOPLAS July 1979, pgs 121-141.
+/// Linear-Time Algorithms for Dominators and Related Problems
+/// Loukas Georgiadis, Princeton University, November 2005, pp. 21-23:
+/// ftp://ftp.cs.princeton.edu/reports/2005/737.pdf
///
/// This implements the O(n*log(n)) versions of EVAL and LINK, because it turns
/// out that the theoretically slower O(n*log(n)) implementation is actually
/// faster than the almost-linear O(n*alpha(n)) version, even for large CFGs.
///
+/// The file uses the Depth Based Search algorithm to perform incremental
+/// upates (insertion and deletions). The implemented algorithm is based on this
+/// publication:
+///
+/// An Experimental Study of Dynamic Dominators
+/// Loukas Georgiadis, et al., April 12 2016, pp. 5-7, 9-10:
+/// https://arxiv.org/pdf/1604.02711.pdf
+///
//===----------------------------------------------------------------------===//
#ifndef LLVM_SUPPORT_GENERICDOMTREECONSTRUCTION_H
#define LLVM_SUPPORT_GENERICDOMTREECONSTRUCTION_H
+#include <queue>
+#include "llvm/ADT/DenseSet.h"
+#include "llvm/ADT/DepthFirstIterator.h"
#include "llvm/ADT/SmallPtrSet.h"
+#include "llvm/Support/Debug.h"
#include "llvm/Support/GenericDomTree.h"
+#define DEBUG_TYPE "dom-tree-builder"
+
namespace llvm {
+namespace DomTreeBuilder {
-template <class GraphT>
-unsigned DFSPass(DominatorTreeBaseByGraphTraits<GraphT> &DT,
- typename GraphT::NodeRef V, unsigned N) {
- // This is more understandable as a recursive algorithm, but we can't use the
- // recursive algorithm due to stack depth issues. Keep it here for
- // documentation purposes.
-#if 0
- InfoRec &VInfo = DT.Info[DT.Roots[i]];
- VInfo.DFSNum = VInfo.Semi = ++N;
- VInfo.Label = V;
-
- Vertex.push_back(V); // Vertex[n] = V;
-
- for (succ_iterator SI = succ_begin(V), E = succ_end(V); SI != E; ++SI) {
- InfoRec &SuccVInfo = DT.Info[*SI];
- if (SuccVInfo.Semi == 0) {
- SuccVInfo.Parent = V;
- N = DTDFSPass(DT, *SI, N);
- }
+template <typename NodePtr, bool Inverse>
+struct ChildrenGetter {
+ static auto Get(NodePtr N) -> decltype(reverse(children<NodePtr>(N))) {
+ return reverse(children<NodePtr>(N));
}
-#else
- bool IsChildOfArtificialExit = (N != 0);
-
- SmallVector<
- std::pair<typename GraphT::NodeRef, typename GraphT::ChildIteratorType>,
- 32>
- Worklist;
- Worklist.push_back(std::make_pair(V, GraphT::child_begin(V)));
- while (!Worklist.empty()) {
- typename GraphT::NodeRef BB = Worklist.back().first;
- typename GraphT::ChildIteratorType NextSucc = Worklist.back().second;
-
- auto &BBInfo = DT.Info[BB];
-
- // First time we visited this BB?
- if (NextSucc == GraphT::child_begin(BB)) {
- BBInfo.DFSNum = BBInfo.Semi = ++N;
+};
+
+template <typename NodePtr>
+struct ChildrenGetter<NodePtr, true> {
+ static auto Get(NodePtr N) -> decltype(inverse_children<NodePtr>(N)) {
+ return inverse_children<NodePtr>(N);
+ }
+};
+
+template <typename DomTreeT>
+struct SemiNCAInfo {
+ using NodePtr = typename DomTreeT::NodePtr;
+ using NodeT = typename DomTreeT::NodeType;
+ using TreeNodePtr = DomTreeNodeBase<NodeT> *;
+ static constexpr bool IsPostDom = DomTreeT::IsPostDominator;
+
+ // Information record used by Semi-NCA during tree construction.
+ struct InfoRec {
+ unsigned DFSNum = 0;
+ unsigned Parent = 0;
+ unsigned Semi = 0;
+ NodePtr Label = nullptr;
+ NodePtr IDom = nullptr;
+ SmallVector<NodePtr, 2> ReverseChildren;
+ };
+
+ // Number to node mapping is 1-based. Initialize the mapping to start with
+ // a dummy element.
+ std::vector<NodePtr> NumToNode = {nullptr};
+ DenseMap<NodePtr, InfoRec> NodeToInfo;
+
+ void clear() {
+ NumToNode = {nullptr}; // Restore to initial state with a dummy start node.
+ NodeToInfo.clear();
+ }
+
+ NodePtr getIDom(NodePtr BB) const {
+ auto InfoIt = NodeToInfo.find(BB);
+ if (InfoIt == NodeToInfo.end()) return nullptr;
+
+ return InfoIt->second.IDom;
+ }
+
+ TreeNodePtr getNodeForBlock(NodePtr BB, DomTreeT &DT) {
+ if (TreeNodePtr Node = DT.getNode(BB)) return Node;
+
+ // Haven't calculated this node yet? Get or calculate the node for the
+ // immediate dominator.
+ NodePtr IDom = getIDom(BB);
+
+ assert(IDom || DT.DomTreeNodes[nullptr]);
+ TreeNodePtr IDomNode = getNodeForBlock(IDom, DT);
+
+ // Add a new tree node for this NodeT, and link it as a child of
+ // IDomNode
+ return (DT.DomTreeNodes[BB] = IDomNode->addChild(
+ llvm::make_unique<DomTreeNodeBase<NodeT>>(BB, IDomNode)))
+ .get();
+ }
+
+ static bool AlwaysDescend(NodePtr, NodePtr) { return true; }
+
+ struct BlockNamePrinter {
+ NodePtr N;
+
+ BlockNamePrinter(NodePtr Block) : N(Block) {}
+ BlockNamePrinter(TreeNodePtr TN) : N(TN ? TN->getBlock() : nullptr) {}
+
+ friend raw_ostream &operator<<(raw_ostream &O, const BlockNamePrinter &BP) {
+ if (!BP.N)
+ O << "nullptr";
+ else
+ BP.N->printAsOperand(O, false);
+
+ return O;
+ }
+ };
+
+ // Custom DFS implementation which can skip nodes based on a provided
+ // predicate. It also collects ReverseChildren so that we don't have to spend
+ // time getting predecessors in SemiNCA.
+ template <bool Inverse, typename DescendCondition>
+ unsigned runDFS(NodePtr V, unsigned LastNum, DescendCondition Condition,
+ unsigned AttachToNum) {
+ assert(V);
+ SmallVector<NodePtr, 64> WorkList = {V};
+ if (NodeToInfo.count(V) != 0) NodeToInfo[V].Parent = AttachToNum;
+
+ while (!WorkList.empty()) {
+ const NodePtr BB = WorkList.pop_back_val();
+ auto &BBInfo = NodeToInfo[BB];
+
+ // Visited nodes always have positive DFS numbers.
+ if (BBInfo.DFSNum != 0) continue;
+ BBInfo.DFSNum = BBInfo.Semi = ++LastNum;
BBInfo.Label = BB;
+ NumToNode.push_back(BB);
+
+ for (const NodePtr Succ : ChildrenGetter<NodePtr, Inverse>::Get(BB)) {
+ const auto SIT = NodeToInfo.find(Succ);
+ // Don't visit nodes more than once but remember to collect
+ // RerverseChildren.
+ if (SIT != NodeToInfo.end() && SIT->second.DFSNum != 0) {
+ if (Succ != BB) SIT->second.ReverseChildren.push_back(BB);
+ continue;
+ }
+
+ if (!Condition(BB, Succ)) continue;
+
+ // It's fine to add Succ to the map, because we know that it will be
+ // visited later.
+ auto &SuccInfo = NodeToInfo[Succ];
+ WorkList.push_back(Succ);
+ SuccInfo.Parent = LastNum;
+ SuccInfo.ReverseChildren.push_back(BB);
+ }
+ }
+
+ return LastNum;
+ }
+
+ NodePtr eval(NodePtr VIn, unsigned LastLinked) {
+ auto &VInInfo = NodeToInfo[VIn];
+ if (VInInfo.DFSNum < LastLinked)
+ return VIn;
- DT.Vertex.push_back(BB); // Vertex[n] = V;
+ SmallVector<NodePtr, 32> Work;
+ SmallPtrSet<NodePtr, 32> Visited;
- if (IsChildOfArtificialExit)
- BBInfo.Parent = 1;
+ if (VInInfo.Parent >= LastLinked)
+ Work.push_back(VIn);
- IsChildOfArtificialExit = false;
+ while (!Work.empty()) {
+ NodePtr V = Work.back();
+ auto &VInfo = NodeToInfo[V];
+ NodePtr VAncestor = NumToNode[VInfo.Parent];
+
+ // Process Ancestor first
+ if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) {
+ Work.push_back(VAncestor);
+ continue;
+ }
+ Work.pop_back();
+
+ // Update VInfo based on Ancestor info
+ if (VInfo.Parent < LastLinked)
+ continue;
+
+ auto &VAInfo = NodeToInfo[VAncestor];
+ NodePtr VAncestorLabel = VAInfo.Label;
+ NodePtr VLabel = VInfo.Label;
+ if (NodeToInfo[VAncestorLabel].Semi < NodeToInfo[VLabel].Semi)
+ VInfo.Label = VAncestorLabel;
+ VInfo.Parent = VAInfo.Parent;
}
- // store the DFS number of the current BB - the reference to BBInfo might
- // get invalidated when processing the successors.
- unsigned BBDFSNum = BBInfo.DFSNum;
+ return VInInfo.Label;
+ }
- // If we are done with this block, remove it from the worklist.
- if (NextSucc == GraphT::child_end(BB)) {
- Worklist.pop_back();
- continue;
+ // This function requires DFS to be run before calling it.
+ void runSemiNCA(DomTreeT &DT, const unsigned MinLevel = 0) {
+ const unsigned NextDFSNum(NumToNode.size());
+ // Initialize IDoms to spanning tree parents.
+ for (unsigned i = 1; i < NextDFSNum; ++i) {
+ const NodePtr V = NumToNode[i];
+ auto &VInfo = NodeToInfo[V];
+ VInfo.IDom = NumToNode[VInfo.Parent];
}
- // Increment the successor number for the next time we get to it.
- ++Worklist.back().second;
+ // Step #1: Calculate the semidominators of all vertices.
+ for (unsigned i = NextDFSNum - 1; i >= 2; --i) {
+ NodePtr W = NumToNode[i];
+ auto &WInfo = NodeToInfo[W];
+
+ // Initialize the semi dominator to point to the parent node.
+ WInfo.Semi = WInfo.Parent;
+ for (const auto &N : WInfo.ReverseChildren) {
+ if (NodeToInfo.count(N) == 0) // Skip unreachable predecessors.
+ continue;
- // Visit the successor next, if it isn't already visited.
- typename GraphT::NodeRef Succ = *NextSucc;
+ const TreeNodePtr TN = DT.getNode(N);
+ // Skip predecessors whose level is above the subtree we are processing.
+ if (TN && TN->getLevel() < MinLevel)
+ continue;
+
+ unsigned SemiU = NodeToInfo[eval(N, i + 1)].Semi;
+ if (SemiU < WInfo.Semi) WInfo.Semi = SemiU;
+ }
+ }
- auto &SuccVInfo = DT.Info[Succ];
- if (SuccVInfo.Semi == 0) {
- SuccVInfo.Parent = BBDFSNum;
- Worklist.push_back(std::make_pair(Succ, GraphT::child_begin(Succ)));
+ // Step #2: Explicitly define the immediate dominator of each vertex.
+ // IDom[i] = NCA(SDom[i], SpanningTreeParent(i)).
+ // Note that the parents were stored in IDoms and later got invalidated
+ // during path compression in Eval.
+ for (unsigned i = 2; i < NextDFSNum; ++i) {
+ const NodePtr W = NumToNode[i];
+ auto &WInfo = NodeToInfo[W];
+ const unsigned SDomNum = NodeToInfo[NumToNode[WInfo.Semi]].DFSNum;
+ NodePtr WIDomCandidate = WInfo.IDom;
+ while (NodeToInfo[WIDomCandidate].DFSNum > SDomNum)
+ WIDomCandidate = NodeToInfo[WIDomCandidate].IDom;
+
+ WInfo.IDom = WIDomCandidate;
}
}
-#endif
- return N;
-}
-template <class GraphT>
-typename GraphT::NodeRef Eval(DominatorTreeBaseByGraphTraits<GraphT> &DT,
- typename GraphT::NodeRef VIn,
- unsigned LastLinked) {
- auto &VInInfo = DT.Info[VIn];
- if (VInInfo.DFSNum < LastLinked)
- return VIn;
-
- SmallVector<typename GraphT::NodeRef, 32> Work;
- SmallPtrSet<typename GraphT::NodeRef, 32> Visited;
-
- if (VInInfo.Parent >= LastLinked)
- Work.push_back(VIn);
-
- while (!Work.empty()) {
- typename GraphT::NodeRef V = Work.back();
- auto &VInfo = DT.Info[V];
- typename GraphT::NodeRef VAncestor = DT.Vertex[VInfo.Parent];
-
- // Process Ancestor first
- if (Visited.insert(VAncestor).second && VInfo.Parent >= LastLinked) {
- Work.push_back(VAncestor);
- continue;
+ template <typename DescendCondition>
+ unsigned doFullDFSWalk(const DomTreeT &DT, DescendCondition DC) {
+ unsigned Num = 0;
+
+ if (DT.Roots.size() > 1) {
+ auto &BBInfo = NodeToInfo[nullptr];
+ BBInfo.DFSNum = BBInfo.Semi = ++Num;
+ BBInfo.Label = nullptr;
+
+ NumToNode.push_back(nullptr); // NumToNode[n] = V;
}
- Work.pop_back();
-
- // Update VInfo based on Ancestor info
- if (VInfo.Parent < LastLinked)
- continue;
-
- auto &VAInfo = DT.Info[VAncestor];
- typename GraphT::NodeRef VAncestorLabel = VAInfo.Label;
- typename GraphT::NodeRef VLabel = VInfo.Label;
- if (DT.Info[VAncestorLabel].Semi < DT.Info[VLabel].Semi)
- VInfo.Label = VAncestorLabel;
- VInfo.Parent = VAInfo.Parent;
+
+ if (DT.isPostDominator()) {
+ for (auto *Root : DT.Roots) Num = runDFS<true>(Root, Num, DC, 1);
+ } else {
+ assert(DT.Roots.size() == 1);
+ Num = runDFS<false>(DT.Roots[0], Num, DC, Num);
+ }
+
+ return Num;
}
- return VInInfo.Label;
-}
+ void calculateFromScratch(DomTreeT &DT, const unsigned NumBlocks) {
+ // Step #0: Number blocks in depth-first order and initialize variables used
+ // in later stages of the algorithm.
+ const unsigned LastDFSNum = doFullDFSWalk(DT, AlwaysDescend);
+
+ runSemiNCA(DT);
+
+ if (DT.Roots.empty()) return;
+
+ // Add a node for the root. This node might be the actual root, if there is
+ // one exit block, or it may be the virtual exit (denoted by
+ // (BasicBlock *)0) which postdominates all real exits if there are multiple
+ // exit blocks, or an infinite loop.
+ // It might be that some blocks did not get a DFS number (e.g., blocks of
+ // infinite loops). In these cases an artificial exit node is required.
+ const bool MultipleRoots = DT.Roots.size() > 1 || (DT.isPostDominator() &&
+ LastDFSNum != NumBlocks);
+ NodePtr Root = !MultipleRoots ? DT.Roots[0] : nullptr;
+
+ DT.RootNode = (DT.DomTreeNodes[Root] =
+ llvm::make_unique<DomTreeNodeBase<NodeT>>(Root, nullptr))
+ .get();
+ attachNewSubtree(DT, DT.RootNode);
+ }
+
+ void attachNewSubtree(DomTreeT& DT, const TreeNodePtr AttachTo) {
+ // Attach the first unreachable block to AttachTo.
+ NodeToInfo[NumToNode[1]].IDom = AttachTo->getBlock();
+ // Loop over all of the discovered blocks in the function...
+ for (size_t i = 1, e = NumToNode.size(); i != e; ++i) {
+ NodePtr W = NumToNode[i];
+ DEBUG(dbgs() << "\tdiscovered a new reachable node "
+ << BlockNamePrinter(W) << "\n");
+
+ // Don't replace this with 'count', the insertion side effect is important
+ if (DT.DomTreeNodes[W]) continue; // Haven't calculated this node yet?
-template <class FuncT, class NodeT>
-void Calculate(DominatorTreeBaseByGraphTraits<GraphTraits<NodeT>> &DT,
- FuncT &F) {
- typedef GraphTraits<NodeT> GraphT;
- static_assert(std::is_pointer<typename GraphT::NodeRef>::value,
- "NodeRef should be pointer type");
- typedef typename std::remove_pointer<typename GraphT::NodeRef>::type NodeType;
-
- unsigned N = 0;
- bool MultipleRoots = (DT.Roots.size() > 1);
- if (MultipleRoots) {
- auto &BBInfo = DT.Info[nullptr];
- BBInfo.DFSNum = BBInfo.Semi = ++N;
- BBInfo.Label = nullptr;
-
- DT.Vertex.push_back(nullptr); // Vertex[n] = V;
+ NodePtr ImmDom = getIDom(W);
+
+ // Get or calculate the node for the immediate dominator
+ TreeNodePtr IDomNode = getNodeForBlock(ImmDom, DT);
+
+ // Add a new tree node for this BasicBlock, and link it as a child of
+ // IDomNode
+ DT.DomTreeNodes[W] = IDomNode->addChild(
+ llvm::make_unique<DomTreeNodeBase<NodeT>>(W, IDomNode));
+ }
}
- // Step #1: Number blocks in depth-first order and initialize variables used
- // in later stages of the algorithm.
- for (unsigned i = 0, e = static_cast<unsigned>(DT.Roots.size());
- i != e; ++i)
- N = DFSPass<GraphT>(DT, DT.Roots[i], N);
+ void reattachExistingSubtree(DomTreeT &DT, const TreeNodePtr AttachTo) {
+ NodeToInfo[NumToNode[1]].IDom = AttachTo->getBlock();
+ for (size_t i = 1, e = NumToNode.size(); i != e; ++i) {
+ const NodePtr N = NumToNode[i];
+ const TreeNodePtr TN = DT.getNode(N);
+ assert(TN);
+ const TreeNodePtr NewIDom = DT.getNode(NodeToInfo[N].IDom);
+ TN->setIDom(NewIDom);
+ }
+ }
- // it might be that some blocks did not get a DFS number (e.g., blocks of
- // infinite loops). In these cases an artificial exit node is required.
- MultipleRoots |= (DT.isPostDominator() && N != GraphTraits<FuncT*>::size(&F));
+ // Helper struct used during edge insertions.
+ struct InsertionInfo {
+ using BucketElementTy = std::pair<unsigned, TreeNodePtr>;
+ struct DecreasingLevel {
+ bool operator()(const BucketElementTy &First,
+ const BucketElementTy &Second) const {
+ return First.first > Second.first;
+ }
+ };
+
+ std::priority_queue<BucketElementTy, SmallVector<BucketElementTy, 8>,
+ DecreasingLevel>
+ Bucket; // Queue of tree nodes sorted by level in descending order.
+ SmallDenseSet<TreeNodePtr, 8> Affected;
+ SmallDenseSet<TreeNodePtr, 8> Visited;
+ SmallVector<TreeNodePtr, 8> AffectedQueue;
+ SmallVector<TreeNodePtr, 8> VisitedNotAffectedQueue;
+ };
+
+ static void InsertEdge(DomTreeT &DT, const NodePtr From, const NodePtr To) {
+ assert(From && To && "Cannot connect nullptrs");
+ DEBUG(dbgs() << "Inserting edge " << BlockNamePrinter(From) << " -> "
+ << BlockNamePrinter(To) << "\n");
+ const TreeNodePtr FromTN = DT.getNode(From);
+
+ // Ignore edges from unreachable nodes.
+ if (!FromTN) return;
+
+ DT.DFSInfoValid = false;
+
+ const TreeNodePtr ToTN = DT.getNode(To);
+ if (!ToTN)
+ InsertUnreachable(DT, FromTN, To);
+ else
+ InsertReachable(DT, FromTN, ToTN);
+ }
- // When naively implemented, the Lengauer-Tarjan algorithm requires a separate
- // bucket for each vertex. However, this is unnecessary, because each vertex
- // is only placed into a single bucket (that of its semidominator), and each
- // vertex's bucket is processed before it is added to any bucket itself.
- //
- // Instead of using a bucket per vertex, we use a single array Buckets that
- // has two purposes. Before the vertex V with preorder number i is processed,
- // Buckets[i] stores the index of the first element in V's bucket. After V's
- // bucket is processed, Buckets[i] stores the index of the next element in the
- // bucket containing V, if any.
- SmallVector<unsigned, 32> Buckets;
- Buckets.resize(N + 1);
- for (unsigned i = 1; i <= N; ++i)
- Buckets[i] = i;
-
- for (unsigned i = N; i >= 2; --i) {
- typename GraphT::NodeRef W = DT.Vertex[i];
- auto &WInfo = DT.Info[W];
-
- // Step #2: Implicitly define the immediate dominator of vertices
- for (unsigned j = i; Buckets[j] != i; j = Buckets[j]) {
- typename GraphT::NodeRef V = DT.Vertex[Buckets[j]];
- typename GraphT::NodeRef U = Eval<GraphT>(DT, V, i + 1);
- DT.IDoms[V] = DT.Info[U].Semi < i ? U : W;
+ // Handles insertion to a node already in the dominator tree.
+ static void InsertReachable(DomTreeT &DT, const TreeNodePtr From,
+ const TreeNodePtr To) {
+ DEBUG(dbgs() << "\tReachable " << BlockNamePrinter(From->getBlock())
+ << " -> " << BlockNamePrinter(To->getBlock()) << "\n");
+ const NodePtr NCDBlock =
+ DT.findNearestCommonDominator(From->getBlock(), To->getBlock());
+ assert(NCDBlock || DT.isPostDominator());
+ const TreeNodePtr NCD = DT.getNode(NCDBlock);
+ assert(NCD);
+
+ DEBUG(dbgs() << "\t\tNCA == " << BlockNamePrinter(NCD) << "\n");
+ const TreeNodePtr ToIDom = To->getIDom();
+
+ // Nothing affected -- NCA property holds.
+ // (Based on the lemma 2.5 from the second paper.)
+ if (NCD == To || NCD == ToIDom) return;
+
+ // Identify and collect affected nodes.
+ InsertionInfo II;
+ DEBUG(dbgs() << "Marking " << BlockNamePrinter(To) << " as affected\n");
+ II.Affected.insert(To);
+ const unsigned ToLevel = To->getLevel();
+ DEBUG(dbgs() << "Putting " << BlockNamePrinter(To) << " into a Bucket\n");
+ II.Bucket.push({ToLevel, To});
+
+ while (!II.Bucket.empty()) {
+ const TreeNodePtr CurrentNode = II.Bucket.top().second;
+ II.Bucket.pop();
+ DEBUG(dbgs() << "\tAdding to Visited and AffectedQueue: "
+ << BlockNamePrinter(CurrentNode) << "\n");
+ II.Visited.insert(CurrentNode);
+ II.AffectedQueue.push_back(CurrentNode);
+
+ // Discover and collect affected successors of the current node.
+ VisitInsertion(DT, CurrentNode, CurrentNode->getLevel(), NCD, II);
}
- // Step #3: Calculate the semidominators of all vertices
-
- // initialize the semi dominator to point to the parent node
- WInfo.Semi = WInfo.Parent;
- typedef GraphTraits<Inverse<NodeT> > InvTraits;
- for (typename InvTraits::ChildIteratorType CI =
- InvTraits::child_begin(W),
- E = InvTraits::child_end(W); CI != E; ++CI) {
- typename InvTraits::NodeRef N = *CI;
- if (DT.Info.count(N)) { // Only if this predecessor is reachable!
- unsigned SemiU = DT.Info[Eval<GraphT>(DT, N, i + 1)].Semi;
- if (SemiU < WInfo.Semi)
- WInfo.Semi = SemiU;
+ // Finish by updating immediate dominators and levels.
+ UpdateInsertion(DT, NCD, II);
+ }
+
+ // Visits an affected node and collect its affected successors.
+ static void VisitInsertion(DomTreeT &DT, const TreeNodePtr TN,
+ const unsigned RootLevel, const TreeNodePtr NCD,
+ InsertionInfo &II) {
+ const unsigned NCDLevel = NCD->getLevel();
+ DEBUG(dbgs() << "Visiting " << BlockNamePrinter(TN) << "\n");
+
+ assert(TN->getBlock());
+ for (const NodePtr Succ :
+ ChildrenGetter<NodePtr, IsPostDom>::Get(TN->getBlock())) {
+ const TreeNodePtr SuccTN = DT.getNode(Succ);
+ assert(SuccTN && "Unreachable successor found at reachable insertion");
+ const unsigned SuccLevel = SuccTN->getLevel();
+
+ DEBUG(dbgs() << "\tSuccessor " << BlockNamePrinter(Succ)
+ << ", level = " << SuccLevel << "\n");
+
+ // Succ dominated by subtree From -- not affected.
+ // (Based on the lemma 2.5 from the second paper.)
+ if (SuccLevel > RootLevel) {
+ DEBUG(dbgs() << "\t\tDominated by subtree From\n");
+ if (II.Visited.count(SuccTN) != 0) continue;
+
+ DEBUG(dbgs() << "\t\tMarking visited not affected "
+ << BlockNamePrinter(Succ) << "\n");
+ II.Visited.insert(SuccTN);
+ II.VisitedNotAffectedQueue.push_back(SuccTN);
+ VisitInsertion(DT, SuccTN, RootLevel, NCD, II);
+ } else if ((SuccLevel > NCDLevel + 1) && II.Affected.count(SuccTN) == 0) {
+ DEBUG(dbgs() << "\t\tMarking affected and adding "
+ << BlockNamePrinter(Succ) << " to a Bucket\n");
+ II.Affected.insert(SuccTN);
+ II.Bucket.push({SuccLevel, SuccTN});
}
}
+ }
- // If V is a non-root vertex and sdom(V) = parent(V), then idom(V) is
- // necessarily parent(V). In this case, set idom(V) here and avoid placing
- // V into a bucket.
- if (WInfo.Semi == WInfo.Parent) {
- DT.IDoms[W] = DT.Vertex[WInfo.Parent];
- } else {
- Buckets[i] = Buckets[WInfo.Semi];
- Buckets[WInfo.Semi] = i;
+ // Updates immediate dominators and levels after insertion.
+ static void UpdateInsertion(DomTreeT &DT, const TreeNodePtr NCD,
+ InsertionInfo &II) {
+ DEBUG(dbgs() << "Updating NCD = " << BlockNamePrinter(NCD) << "\n");
+
+ for (const TreeNodePtr TN : II.AffectedQueue) {
+ DEBUG(dbgs() << "\tIDom(" << BlockNamePrinter(TN)
+ << ") = " << BlockNamePrinter(NCD) << "\n");
+ TN->setIDom(NCD);
+ }
+
+ UpdateLevelsAfterInsertion(II);
+ }
+
+ static void UpdateLevelsAfterInsertion(InsertionInfo &II) {
+ DEBUG(dbgs() << "Updating levels for visited but not affected nodes\n");
+
+ for (const TreeNodePtr TN : II.VisitedNotAffectedQueue) {
+ DEBUG(dbgs() << "\tlevel(" << BlockNamePrinter(TN) << ") = ("
+ << BlockNamePrinter(TN->getIDom()) << ") "
+ << TN->getIDom()->getLevel() << " + 1\n");
+ TN->UpdateLevel();
+ }
+ }
+
+ // Handles insertion to previously unreachable nodes.
+ static void InsertUnreachable(DomTreeT &DT, const TreeNodePtr From,
+ const NodePtr To) {
+ DEBUG(dbgs() << "Inserting " << BlockNamePrinter(From)
+ << " -> (unreachable) " << BlockNamePrinter(To) << "\n");
+
+ // Collect discovered edges to already reachable nodes.
+ SmallVector<std::pair<NodePtr, TreeNodePtr>, 8> DiscoveredEdgesToReachable;
+ // Discover and connect nodes that became reachable with the insertion.
+ ComputeUnreachableDominators(DT, To, From, DiscoveredEdgesToReachable);
+
+ DEBUG(dbgs() << "Inserted " << BlockNamePrinter(From)
+ << " -> (prev unreachable) " << BlockNamePrinter(To) << "\n");
+
+ DEBUG(DT.print(dbgs()));
+
+ // Used the discovered edges and inset discovered connecting (incoming)
+ // edges.
+ for (const auto &Edge : DiscoveredEdgesToReachable) {
+ DEBUG(dbgs() << "\tInserting discovered connecting edge "
+ << BlockNamePrinter(Edge.first) << " -> "
+ << BlockNamePrinter(Edge.second) << "\n");
+ InsertReachable(DT, DT.getNode(Edge.first), Edge.second);
}
}
- if (N >= 1) {
- typename GraphT::NodeRef Root = DT.Vertex[1];
- for (unsigned j = 1; Buckets[j] != 1; j = Buckets[j]) {
- typename GraphT::NodeRef V = DT.Vertex[Buckets[j]];
- DT.IDoms[V] = Root;
+ // Connects nodes that become reachable with an insertion.
+ static void ComputeUnreachableDominators(
+ DomTreeT &DT, const NodePtr Root, const TreeNodePtr Incoming,
+ SmallVectorImpl<std::pair<NodePtr, TreeNodePtr>>
+ &DiscoveredConnectingEdges) {
+ assert(!DT.getNode(Root) && "Root must not be reachable");
+
+ // Visit only previously unreachable nodes.
+ auto UnreachableDescender = [&DT, &DiscoveredConnectingEdges](NodePtr From,
+ NodePtr To) {
+ const TreeNodePtr ToTN = DT.getNode(To);
+ if (!ToTN) return true;
+
+ DiscoveredConnectingEdges.push_back({From, ToTN});
+ return false;
+ };
+
+ SemiNCAInfo SNCA;
+ SNCA.runDFS<IsPostDom>(Root, 0, UnreachableDescender, 0);
+ SNCA.runSemiNCA(DT);
+ SNCA.attachNewSubtree(DT, Incoming);
+
+ DEBUG(dbgs() << "After adding unreachable nodes\n");
+ DEBUG(DT.print(dbgs()));
+ }
+
+ // Checks if the tree contains all reachable nodes in the input graph.
+ bool verifyReachability(const DomTreeT &DT) {
+ clear();
+ doFullDFSWalk(DT, AlwaysDescend);
+
+ for (auto &NodeToTN : DT.DomTreeNodes) {
+ const TreeNodePtr TN = NodeToTN.second.get();
+ const NodePtr BB = TN->getBlock();
+
+ // Virtual root has a corresponding virtual CFG node.
+ if (DT.isVirtualRoot(TN)) continue;
+
+ if (NodeToInfo.count(BB) == 0) {
+ errs() << "DomTree node " << BlockNamePrinter(BB)
+ << " not found by DFS walk!\n";
+ errs().flush();
+
+ return false;
+ }
}
+
+ for (const NodePtr N : NumToNode) {
+ if (N && !DT.getNode(N)) {
+ errs() << "CFG node " << BlockNamePrinter(N)
+ << " not found in the DomTree!\n";
+ errs().flush();
+
+ return false;
+ }
+ }
+
+ return true;
}
- // Step #4: Explicitly define the immediate dominator of each vertex
- for (unsigned i = 2; i <= N; ++i) {
- typename GraphT::NodeRef W = DT.Vertex[i];
- typename GraphT::NodeRef &WIDom = DT.IDoms[W];
- if (WIDom != DT.Vertex[DT.Info[W].Semi])
- WIDom = DT.IDoms[WIDom];
+ static void DeleteEdge(DomTreeT &DT, const NodePtr From, const NodePtr To) {
+ assert(From && To && "Cannot disconnect nullptrs");
+ DEBUG(dbgs() << "Deleting edge " << BlockNamePrinter(From) << " -> "
+ << BlockNamePrinter(To) << "\n");
+
+#ifndef NDEBUG
+ // Ensure that the edge was in fact deleted from the CFG before informing
+ // the DomTree about it.
+ // The check is O(N), so run it only in debug configuration.
+ auto IsSuccessor = [](const NodePtr SuccCandidate, const NodePtr Of) {
+ auto Successors = ChildrenGetter<NodePtr, IsPostDom>::Get(Of);
+ return llvm::find(Successors, SuccCandidate) != Successors.end();
+ };
+ (void)IsSuccessor;
+ assert(!IsSuccessor(To, From) && "Deleted edge still exists in the CFG!");
+#endif
+
+ const TreeNodePtr FromTN = DT.getNode(From);
+ // Deletion in an unreachable subtree -- nothing to do.
+ if (!FromTN) return;
+
+ const TreeNodePtr ToTN = DT.getNode(To);
+ assert(ToTN && "To already unreachable -- there is no edge to delete");
+ const NodePtr NCDBlock = DT.findNearestCommonDominator(From, To);
+ const TreeNodePtr NCD = DT.getNode(NCDBlock);
+
+ // To dominates From -- nothing to do.
+ if (ToTN == NCD) return;
+
+ const TreeNodePtr ToIDom = ToTN->getIDom();
+ DEBUG(dbgs() << "\tNCD " << BlockNamePrinter(NCD) << ", ToIDom "
+ << BlockNamePrinter(ToIDom) << "\n");
+
+ // To remains reachable after deletion.
+ // (Based on the caption under Figure 4. from the second paper.)
+ if (FromTN != ToIDom || HasProperSupport(DT, ToTN))
+ DeleteReachable(DT, FromTN, ToTN);
+ else
+ DeleteUnreachable(DT, ToTN);
+ }
+
+ // Handles deletions that leave destination nodes reachable.
+ static void DeleteReachable(DomTreeT &DT, const TreeNodePtr FromTN,
+ const TreeNodePtr ToTN) {
+ DEBUG(dbgs() << "Deleting reachable " << BlockNamePrinter(FromTN) << " -> "
+ << BlockNamePrinter(ToTN) << "\n");
+ DEBUG(dbgs() << "\tRebuilding subtree\n");
+
+ // Find the top of the subtree that needs to be rebuilt.
+ // (Based on the lemma 2.6 from the second paper.)
+ const NodePtr ToIDom =
+ DT.findNearestCommonDominator(FromTN->getBlock(), ToTN->getBlock());
+ assert(ToIDom || DT.isPostDominator());
+ const TreeNodePtr ToIDomTN = DT.getNode(ToIDom);
+ assert(ToIDomTN);
+ const TreeNodePtr PrevIDomSubTree = ToIDomTN->getIDom();
+ // Top of the subtree to rebuild is the root node. Rebuild the tree from
+ // scratch.
+ if (!PrevIDomSubTree) {
+ DEBUG(dbgs() << "The entire tree needs to be rebuilt\n");
+ DT.recalculate(*DT.Parent);
+ return;
+ }
+
+ // Only visit nodes in the subtree starting at To.
+ const unsigned Level = ToIDomTN->getLevel();
+ auto DescendBelow = [Level, &DT](NodePtr, NodePtr To) {
+ return DT.getNode(To)->getLevel() > Level;
+ };
+
+ DEBUG(dbgs() << "\tTop of subtree: " << BlockNamePrinter(ToIDomTN) << "\n");
+
+ SemiNCAInfo SNCA;
+ SNCA.runDFS<IsPostDom>(ToIDom, 0, DescendBelow, 0);
+ DEBUG(dbgs() << "\tRunning Semi-NCA\n");
+ SNCA.runSemiNCA(DT, Level);
+ SNCA.reattachExistingSubtree(DT, PrevIDomSubTree);
}
- if (DT.Roots.empty()) return;
+ // Checks if a node has proper support, as defined on the page 3 and later
+ // explained on the page 7 of the second paper.
+ static bool HasProperSupport(DomTreeT &DT, const TreeNodePtr TN) {
+ DEBUG(dbgs() << "IsReachableFromIDom " << BlockNamePrinter(TN) << "\n");
+ for (const NodePtr Pred :
+ ChildrenGetter<NodePtr, !IsPostDom>::Get(TN->getBlock())) {
+ DEBUG(dbgs() << "\tPred " << BlockNamePrinter(Pred) << "\n");
+ if (!DT.getNode(Pred)) continue;
+
+ const NodePtr Support =
+ DT.findNearestCommonDominator(TN->getBlock(), Pred);
+ DEBUG(dbgs() << "\tSupport " << BlockNamePrinter(Support) << "\n");
+ if (Support != TN->getBlock()) {
+ DEBUG(dbgs() << "\t" << BlockNamePrinter(TN)
+ << " is reachable from support "
+ << BlockNamePrinter(Support) << "\n");
+ return true;
+ }
+ }
- // Add a node for the root. This node might be the actual root, if there is
- // one exit block, or it may be the virtual exit (denoted by (BasicBlock *)0)
- // which postdominates all real exits if there are multiple exit blocks, or
- // an infinite loop.
- typename GraphT::NodeRef Root = !MultipleRoots ? DT.Roots[0] : nullptr;
+ return false;
+ }
- DT.RootNode =
- (DT.DomTreeNodes[Root] =
- llvm::make_unique<DomTreeNodeBase<NodeType>>(Root, nullptr))
- .get();
+ // Handle deletions that make destination node unreachable.
+ // (Based on the lemma 2.7 from the second paper.)
+ static void DeleteUnreachable(DomTreeT &DT, const TreeNodePtr ToTN) {
+ DEBUG(dbgs() << "Deleting unreachable subtree " << BlockNamePrinter(ToTN)
+ << "\n");
+ assert(ToTN);
+ assert(ToTN->getBlock());
+
+ SmallVector<NodePtr, 16> AffectedQueue;
+ const unsigned Level = ToTN->getLevel();
+
+ // Traverse destination node's descendants with greater level in the tree
+ // and collect visited nodes.
+ auto DescendAndCollect = [Level, &AffectedQueue, &DT](NodePtr, NodePtr To) {
+ const TreeNodePtr TN = DT.getNode(To);
+ assert(TN);
+ if (TN->getLevel() > Level) return true;
+ if (llvm::find(AffectedQueue, To) == AffectedQueue.end())
+ AffectedQueue.push_back(To);
+
+ return false;
+ };
+
+ SemiNCAInfo SNCA;
+ unsigned LastDFSNum =
+ SNCA.runDFS<IsPostDom>(ToTN->getBlock(), 0, DescendAndCollect, 0);
+
+ TreeNodePtr MinNode = ToTN;
+
+ // Identify the top of the subtree to rebuilt by finding the NCD of all
+ // the affected nodes.
+ for (const NodePtr N : AffectedQueue) {
+ const TreeNodePtr TN = DT.getNode(N);
+ const NodePtr NCDBlock =
+ DT.findNearestCommonDominator(TN->getBlock(), ToTN->getBlock());
+ assert(NCDBlock || DT.isPostDominator());
+ const TreeNodePtr NCD = DT.getNode(NCDBlock);
+ assert(NCD);
+
+ DEBUG(dbgs() << "Processing affected node " << BlockNamePrinter(TN)
+ << " with NCD = " << BlockNamePrinter(NCD)
+ << ", MinNode =" << BlockNamePrinter(MinNode) << "\n");
+ if (NCD != TN && NCD->getLevel() < MinNode->getLevel()) MinNode = NCD;
+ }
- // Loop over all of the reachable blocks in the function...
- for (unsigned i = 2; i <= N; ++i) {
- typename GraphT::NodeRef W = DT.Vertex[i];
+ // Root reached, rebuild the whole tree from scratch.
+ if (!MinNode->getIDom()) {
+ DEBUG(dbgs() << "The entire tree needs to be rebuilt\n");
+ DT.recalculate(*DT.Parent);
+ return;
+ }
- // Don't replace this with 'count', the insertion side effect is important
- if (DT.DomTreeNodes[W])
- continue; // Haven't calculated this node yet?
+ // Erase the unreachable subtree in reverse preorder to process all children
+ // before deleting their parent.
+ for (unsigned i = LastDFSNum; i > 0; --i) {
+ const NodePtr N = SNCA.NumToNode[i];
+ const TreeNodePtr TN = DT.getNode(N);
+ DEBUG(dbgs() << "Erasing node " << BlockNamePrinter(TN) << "\n");
- typename GraphT::NodeRef ImmDom = DT.getIDom(W);
+ EraseNode(DT, TN);
+ }
- assert(ImmDom || DT.DomTreeNodes[nullptr]);
+ // The affected subtree start at the To node -- there's no extra work to do.
+ if (MinNode == ToTN) return;
+
+ DEBUG(dbgs() << "DeleteUnreachable: running DFS with MinNode = "
+ << BlockNamePrinter(MinNode) << "\n");
+ const unsigned MinLevel = MinNode->getLevel();
+ const TreeNodePtr PrevIDom = MinNode->getIDom();
+ assert(PrevIDom);
+ SNCA.clear();
+
+ // Identify nodes that remain in the affected subtree.
+ auto DescendBelow = [MinLevel, &DT](NodePtr, NodePtr To) {
+ const TreeNodePtr ToTN = DT.getNode(To);
+ return ToTN && ToTN->getLevel() > MinLevel;
+ };
+ SNCA.runDFS<IsPostDom>(MinNode->getBlock(), 0, DescendBelow, 0);
+
+ DEBUG(dbgs() << "Previous IDom(MinNode) = " << BlockNamePrinter(PrevIDom)
+ << "\nRunning Semi-NCA\n");
+
+ // Rebuild the remaining part of affected subtree.
+ SNCA.runSemiNCA(DT, MinLevel);
+ SNCA.reattachExistingSubtree(DT, PrevIDom);
+ }
- // Get or calculate the node for the immediate dominator
- DomTreeNodeBase<NodeType> *IDomNode = DT.getNodeForBlock(ImmDom);
+ // Removes leaf tree nodes from the dominator tree.
+ static void EraseNode(DomTreeT &DT, const TreeNodePtr TN) {
+ assert(TN);
+ assert(TN->getNumChildren() == 0 && "Not a tree leaf");
- // Add a new tree node for this BasicBlock, and link it as a child of
- // IDomNode
- DT.DomTreeNodes[W] = IDomNode->addChild(
- llvm::make_unique<DomTreeNodeBase<NodeType>>(W, IDomNode));
+ const TreeNodePtr IDom = TN->getIDom();
+ assert(IDom);
+
+ auto ChIt = llvm::find(IDom->Children, TN);
+ assert(ChIt != IDom->Children.end());
+ std::swap(*ChIt, IDom->Children.back());
+ IDom->Children.pop_back();
+
+ DT.DomTreeNodes.erase(TN->getBlock());
}
- // Free temporary memory used to construct idom's
- DT.IDoms.clear();
- DT.Info.clear();
- DT.Vertex.clear();
- DT.Vertex.shrink_to_fit();
+ //~~
+ //===--------------- DomTree correctness verification ---------------------===
+ //~~
+
+ // Check if for every parent with a level L in the tree all of its children
+ // have level L + 1.
+ static bool VerifyLevels(const DomTreeT &DT) {
+ for (auto &NodeToTN : DT.DomTreeNodes) {
+ const TreeNodePtr TN = NodeToTN.second.get();
+ const NodePtr BB = TN->getBlock();
+ if (!BB) continue;
+
+ const TreeNodePtr IDom = TN->getIDom();
+ if (!IDom && TN->getLevel() != 0) {
+ errs() << "Node without an IDom " << BlockNamePrinter(BB)
+ << " has a nonzero level " << TN->getLevel() << "!\n";
+ errs().flush();
+
+ return false;
+ }
+
+ if (IDom && TN->getLevel() != IDom->getLevel() + 1) {
+ errs() << "Node " << BlockNamePrinter(BB) << " has level "
+ << TN->getLevel() << " while its IDom "
+ << BlockNamePrinter(IDom->getBlock()) << " has level "
+ << IDom->getLevel() << "!\n";
+ errs().flush();
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ // Checks if for every edge From -> To in the graph
+ // NCD(From, To) == IDom(To) or To.
+ bool verifyNCD(const DomTreeT &DT) {
+ clear();
+ doFullDFSWalk(DT, AlwaysDescend);
+
+ for (auto &BlockToInfo : NodeToInfo) {
+ auto &Info = BlockToInfo.second;
+
+ const NodePtr From = NumToNode[Info.Parent];
+ if (!From) continue;
+
+ const NodePtr To = BlockToInfo.first;
+ const TreeNodePtr ToTN = DT.getNode(To);
+ assert(ToTN);
+
+ const NodePtr NCD = DT.findNearestCommonDominator(From, To);
+ const TreeNodePtr NCDTN = DT.getNode(NCD);
+ const TreeNodePtr ToIDom = ToTN->getIDom();
+ if (NCDTN != ToTN && NCDTN != ToIDom) {
+ errs() << "NearestCommonDominator verification failed:\n\tNCD(From:"
+ << BlockNamePrinter(From) << ", To:" << BlockNamePrinter(To)
+ << ") = " << BlockNamePrinter(NCD)
+ << ",\t (should be To or IDom[To]: " << BlockNamePrinter(ToIDom)
+ << ")\n";
+ errs().flush();
+
+ return false;
+ }
+ }
+
+ return true;
+ }
+
+ // The below routines verify the correctness of the dominator tree relative to
+ // the CFG it's coming from. A tree is a dominator tree iff it has two
+ // properties, called the parent property and the sibling property. Tarjan
+ // and Lengauer prove (but don't explicitly name) the properties as part of
+ // the proofs in their 1972 paper, but the proofs are mostly part of proving
+ // things about semidominators and idoms, and some of them are simply asserted
+ // based on even earlier papers (see, e.g., lemma 2). Some papers refer to
+ // these properties as "valid" and "co-valid". See, e.g., "Dominators,
+ // directed bipolar orders, and independent spanning trees" by Loukas
+ // Georgiadis and Robert E. Tarjan, as well as "Dominator Tree Verification
+ // and Vertex-Disjoint Paths " by the same authors.
+
+ // A very simple and direct explanation of these properties can be found in
+ // "An Experimental Study of Dynamic Dominators", found at
+ // https://arxiv.org/abs/1604.02711
+
+ // The easiest way to think of the parent property is that it's a requirement
+ // of being a dominator. Let's just take immediate dominators. For PARENT to
+ // be an immediate dominator of CHILD, all paths in the CFG must go through
+ // PARENT before they hit CHILD. This implies that if you were to cut PARENT
+ // out of the CFG, there should be no paths to CHILD that are reachable. If
+ // there are, then you now have a path from PARENT to CHILD that goes around
+ // PARENT and still reaches CHILD, which by definition, means PARENT can't be
+ // a dominator of CHILD (let alone an immediate one).
+
+ // The sibling property is similar. It says that for each pair of sibling
+ // nodes in the dominator tree (LEFT and RIGHT) , they must not dominate each
+ // other. If sibling LEFT dominated sibling RIGHT, it means there are no
+ // paths in the CFG from sibling LEFT to sibling RIGHT that do not go through
+ // LEFT, and thus, LEFT is really an ancestor (in the dominator tree) of
+ // RIGHT, not a sibling.
+
+ // It is possible to verify the parent and sibling properties in
+ // linear time, but the algorithms are complex. Instead, we do it in a
+ // straightforward N^2 and N^3 way below, using direct path reachability.
+
+
+ // Checks if the tree has the parent property: if for all edges from V to W in
+ // the input graph, such that V is reachable, the parent of W in the tree is
+ // an ancestor of V in the tree.
+ //
+ // This means that if a node gets disconnected from the graph, then all of
+ // the nodes it dominated previously will now become unreachable.
+ bool verifyParentProperty(const DomTreeT &DT) {
+ for (auto &NodeToTN : DT.DomTreeNodes) {
+ const TreeNodePtr TN = NodeToTN.second.get();
+ const NodePtr BB = TN->getBlock();
+ if (!BB || TN->getChildren().empty()) continue;
+
+ clear();
+ doFullDFSWalk(DT, [BB](NodePtr From, NodePtr To) {
+ return From != BB && To != BB;
+ });
+
+ for (TreeNodePtr Child : TN->getChildren())
+ if (NodeToInfo.count(Child->getBlock()) != 0) {
+ errs() << "Child " << BlockNamePrinter(Child)
+ << " reachable after its parent " << BlockNamePrinter(BB)
+ << " is removed!\n";
+ errs().flush();
+
+ return false;
+ }
+ }
- DT.updateDFSNumbers();
+ return true;
+ }
+
+ // Check if the tree has sibling property: if a node V does not dominate a
+ // node W for all siblings V and W in the tree.
+ //
+ // This means that if a node gets disconnected from the graph, then all of its
+ // siblings will now still be reachable.
+ bool verifySiblingProperty(const DomTreeT &DT) {
+ for (auto &NodeToTN : DT.DomTreeNodes) {
+ const TreeNodePtr TN = NodeToTN.second.get();
+ const NodePtr BB = TN->getBlock();
+ if (!BB || TN->getChildren().empty()) continue;
+
+ const auto &Siblings = TN->getChildren();
+ for (const TreeNodePtr N : Siblings) {
+ clear();
+ NodePtr BBN = N->getBlock();
+ doFullDFSWalk(DT, [BBN](NodePtr From, NodePtr To) {
+ return From != BBN && To != BBN;
+ });
+
+ for (const TreeNodePtr S : Siblings) {
+ if (S == N) continue;
+
+ if (NodeToInfo.count(S->getBlock()) == 0) {
+ errs() << "Node " << BlockNamePrinter(S)
+ << " not reachable when its sibling " << BlockNamePrinter(N)
+ << " is removed!\n";
+ errs().flush();
+
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+};
+
+
+template <class DomTreeT, class FuncT>
+void Calculate(DomTreeT &DT, FuncT &F) {
+ SemiNCAInfo<DomTreeT> SNCA;
+ SNCA.calculateFromScratch(DT, GraphTraits<FuncT *>::size(&F));
+}
+
+template <class DomTreeT>
+void InsertEdge(DomTreeT &DT, typename DomTreeT::NodePtr From,
+ typename DomTreeT::NodePtr To) {
+ if (DT.isPostDominator()) std::swap(From, To);
+ SemiNCAInfo<DomTreeT>::InsertEdge(DT, From, To);
+}
+
+template <class DomTreeT>
+void DeleteEdge(DomTreeT &DT, typename DomTreeT::NodePtr From,
+ typename DomTreeT::NodePtr To) {
+ if (DT.isPostDominator()) std::swap(From, To);
+ SemiNCAInfo<DomTreeT>::DeleteEdge(DT, From, To);
}
+
+template <class DomTreeT>
+bool Verify(const DomTreeT &DT) {
+ SemiNCAInfo<DomTreeT> SNCA;
+ return SNCA.verifyReachability(DT) && SNCA.VerifyLevels(DT) &&
+ SNCA.verifyNCD(DT) && SNCA.verifyParentProperty(DT) &&
+ SNCA.verifySiblingProperty(DT);
}
+} // namespace DomTreeBuilder
+} // namespace llvm
+
+#undef DEBUG_TYPE
+
#endif
diff --git a/contrib/llvm/include/llvm/Support/GraphWriter.h b/contrib/llvm/include/llvm/Support/GraphWriter.h
index 7555d5b..3df5c86 100644
--- a/contrib/llvm/include/llvm/Support/GraphWriter.h
+++ b/contrib/llvm/include/llvm/Support/GraphWriter.h
@@ -1,4 +1,4 @@
-//===-- llvm/Support/GraphWriter.h - Write graph to a .dot file -*- C++ -*-===//
+//===- llvm/Support/GraphWriter.h - Write graph to a .dot file --*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -24,30 +24,40 @@
#define LLVM_SUPPORT_GRAPHWRITER_H
#include "llvm/ADT/GraphTraits.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/DOTGraphTraits.h"
#include "llvm/Support/raw_ostream.h"
+#include <algorithm>
+#include <cstddef>
+#include <iterator>
+#include <string>
+#include <type_traits>
#include <vector>
namespace llvm {
namespace DOT { // Private functions...
- std::string EscapeString(const std::string &Label);
- /// \brief Get a color string for this node number. Simply round-robin selects
- /// from a reasonable number of colors.
- StringRef getColorString(unsigned NodeNumber);
-}
+std::string EscapeString(const std::string &Label);
+
+/// \brief Get a color string for this node number. Simply round-robin selects
+/// from a reasonable number of colors.
+StringRef getColorString(unsigned NodeNumber);
+
+} // end namespace DOT
namespace GraphProgram {
- enum Name {
- DOT,
- FDP,
- NEATO,
- TWOPI,
- CIRCO
- };
-}
+
+enum Name {
+ DOT,
+ FDP,
+ NEATO,
+ TWOPI,
+ CIRCO
+};
+
+} // end namespace GraphProgram
bool DisplayGraph(StringRef Filename, bool wait = true,
GraphProgram::Name program = GraphProgram::DOT);
@@ -57,11 +67,11 @@ class GraphWriter {
raw_ostream &O;
const GraphType &G;
- typedef DOTGraphTraits<GraphType> DOTTraits;
- typedef GraphTraits<GraphType> GTraits;
- typedef typename GTraits::NodeRef NodeRef;
- typedef typename GTraits::nodes_iterator node_iterator;
- typedef typename GTraits::ChildIteratorType child_iterator;
+ using DOTTraits = DOTGraphTraits<GraphType>;
+ using GTraits = GraphTraits<GraphType>;
+ using NodeRef = typename GTraits::NodeRef;
+ using node_iterator = typename GTraits::nodes_iterator;
+ using child_iterator = typename GTraits::ChildIteratorType;
DOTTraits DTraits;
static_assert(std::is_pointer<NodeRef>::value,
@@ -143,10 +153,9 @@ public:
void writeNodes() {
// Loop over the graph, printing it out...
- for (node_iterator I = GTraits::nodes_begin(G), E = GTraits::nodes_end(G);
- I != E; ++I)
- if (!isNodeHidden(*I))
- writeNode(*I);
+ for (const auto Node : nodes<GraphType>(G))
+ if (!isNodeHidden(Node))
+ writeNode(Node);
}
bool isNodeHidden(NodeRef Node) {
@@ -347,6 +356,6 @@ void ViewGraph(const GraphType &G, const Twine &Name,
DisplayGraph(Filename, false, Program);
}
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_GRAPHWRITER_H
diff --git a/contrib/llvm/include/llvm/Support/Host.h b/contrib/llvm/include/llvm/Support/Host.h
index 9df584c..be93dd9 100644
--- a/contrib/llvm/include/llvm/Support/Host.h
+++ b/contrib/llvm/include/llvm/Support/Host.h
@@ -15,11 +15,22 @@
#define LLVM_SUPPORT_HOST_H
#include "llvm/ADT/StringMap.h"
+#include "llvm/Support/MemoryBuffer.h"
#if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__)
#include <endian.h>
#elif defined(_AIX)
#include <sys/machine.h>
+#elif defined(__sun)
+/* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */
+#include <sys/types.h>
+#define BIG_ENDIAN 4321
+#define LITTLE_ENDIAN 1234
+#if defined(_BIG_ENDIAN)
+#define BYTE_ORDER BIG_ENDIAN
+#else
+#define BYTE_ORDER LITTLE_ENDIAN
+#endif
#else
#if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32)
#include <machine/endian.h>
@@ -32,9 +43,9 @@ namespace llvm {
namespace sys {
#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN
- static const bool IsBigEndianHost = true;
+constexpr bool IsBigEndianHost = true;
#else
- static const bool IsBigEndianHost = false;
+constexpr bool IsBigEndianHost = false;
#endif
static const bool IsLittleEndianHost = !IsBigEndianHost;
@@ -75,6 +86,13 @@ namespace sys {
/// from thread::hardware_concurrency(), which includes hyperthreads).
/// Returns -1 if unknown for the current host system.
int getHostNumPhysicalCores();
+
+ namespace detail {
+ /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux.
+ StringRef getHostCPUNameForPowerPC(const StringRef &ProcCpuinfoContent);
+ StringRef getHostCPUNameForARM(const StringRef &ProcCpuinfoContent);
+ StringRef getHostCPUNameForS390x(const StringRef &ProcCpuinfoContent);
+ }
}
}
diff --git a/contrib/llvm/include/llvm/Support/KnownBits.h b/contrib/llvm/include/llvm/Support/KnownBits.h
new file mode 100644
index 0000000..2c77d40
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/KnownBits.h
@@ -0,0 +1,200 @@
+//===- llvm/Support/KnownBits.h - Stores known zeros/ones -------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file contains a class for representing known zeros and ones used by
+// computeKnownBits.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_KNOWNBITS_H
+#define LLVM_SUPPORT_KNOWNBITS_H
+
+#include "llvm/ADT/APInt.h"
+
+namespace llvm {
+
+// Struct for tracking the known zeros and ones of a value.
+struct KnownBits {
+ APInt Zero;
+ APInt One;
+
+private:
+ // Internal constructor for creating a ConstantRange from two APInts.
+ KnownBits(APInt Zero, APInt One)
+ : Zero(std::move(Zero)), One(std::move(One)) {}
+
+public:
+ // Default construct Zero and One.
+ KnownBits() {}
+
+ /// Create a known bits object of BitWidth bits initialized to unknown.
+ KnownBits(unsigned BitWidth) : Zero(BitWidth, 0), One(BitWidth, 0) {}
+
+ /// Get the bit width of this value.
+ unsigned getBitWidth() const {
+ assert(Zero.getBitWidth() == One.getBitWidth() &&
+ "Zero and One should have the same width!");
+ return Zero.getBitWidth();
+ }
+
+ /// Returns true if there is conflicting information.
+ bool hasConflict() const { return Zero.intersects(One); }
+
+ /// Returns true if we know the value of all bits.
+ bool isConstant() const {
+ assert(!hasConflict() && "KnownBits conflict!");
+ return Zero.countPopulation() + One.countPopulation() == getBitWidth();
+ }
+
+ /// Returns the value when all bits have a known value. This just returns One
+ /// with a protective assertion.
+ const APInt &getConstant() const {
+ assert(isConstant() && "Can only get value when all bits are known");
+ return One;
+ }
+
+ /// Returns true if we don't know any bits.
+ bool isUnknown() const { return Zero.isNullValue() && One.isNullValue(); }
+
+ /// Resets the known state of all bits.
+ void resetAll() {
+ Zero.clearAllBits();
+ One.clearAllBits();
+ }
+
+ /// Returns true if value is all zero.
+ bool isZero() const {
+ assert(!hasConflict() && "KnownBits conflict!");
+ return Zero.isAllOnesValue();
+ }
+
+ /// Returns true if value is all one bits.
+ bool isAllOnes() const {
+ assert(!hasConflict() && "KnownBits conflict!");
+ return One.isAllOnesValue();
+ }
+
+ /// Make all bits known to be zero and discard any previous information.
+ void setAllZero() {
+ Zero.setAllBits();
+ One.clearAllBits();
+ }
+
+ /// Make all bits known to be one and discard any previous information.
+ void setAllOnes() {
+ Zero.clearAllBits();
+ One.setAllBits();
+ }
+
+ /// Returns true if this value is known to be negative.
+ bool isNegative() const { return One.isSignBitSet(); }
+
+ /// Returns true if this value is known to be non-negative.
+ bool isNonNegative() const { return Zero.isSignBitSet(); }
+
+ /// Make this value negative.
+ void makeNegative() {
+ assert(!isNonNegative() && "Can't make a non-negative value negative");
+ One.setSignBit();
+ }
+
+ /// Make this value negative.
+ void makeNonNegative() {
+ assert(!isNegative() && "Can't make a negative value non-negative");
+ Zero.setSignBit();
+ }
+
+ /// Truncate the underlying known Zero and One bits. This is equivalent
+ /// to truncating the value we're tracking.
+ KnownBits trunc(unsigned BitWidth) {
+ return KnownBits(Zero.trunc(BitWidth), One.trunc(BitWidth));
+ }
+
+ /// Zero extends the underlying known Zero and One bits. This is equivalent
+ /// to zero extending the value we're tracking.
+ KnownBits zext(unsigned BitWidth) {
+ return KnownBits(Zero.zext(BitWidth), One.zext(BitWidth));
+ }
+
+ /// Sign extends the underlying known Zero and One bits. This is equivalent
+ /// to sign extending the value we're tracking.
+ KnownBits sext(unsigned BitWidth) {
+ return KnownBits(Zero.sext(BitWidth), One.sext(BitWidth));
+ }
+
+ /// Zero extends or truncates the underlying known Zero and One bits. This is
+ /// equivalent to zero extending or truncating the value we're tracking.
+ KnownBits zextOrTrunc(unsigned BitWidth) {
+ return KnownBits(Zero.zextOrTrunc(BitWidth), One.zextOrTrunc(BitWidth));
+ }
+
+ /// Returns the minimum number of trailing zero bits.
+ unsigned countMinTrailingZeros() const {
+ return Zero.countTrailingOnes();
+ }
+
+ /// Returns the minimum number of trailing one bits.
+ unsigned countMinTrailingOnes() const {
+ return One.countTrailingOnes();
+ }
+
+ /// Returns the minimum number of leading zero bits.
+ unsigned countMinLeadingZeros() const {
+ return Zero.countLeadingOnes();
+ }
+
+ /// Returns the minimum number of leading one bits.
+ unsigned countMinLeadingOnes() const {
+ return One.countLeadingOnes();
+ }
+
+ /// Returns the number of times the sign bit is replicated into the other
+ /// bits.
+ unsigned countMinSignBits() const {
+ if (isNonNegative())
+ return countMinLeadingZeros();
+ if (isNegative())
+ return countMinLeadingOnes();
+ return 0;
+ }
+
+ /// Returns the maximum number of trailing zero bits possible.
+ unsigned countMaxTrailingZeros() const {
+ return One.countTrailingZeros();
+ }
+
+ /// Returns the maximum number of trailing one bits possible.
+ unsigned countMaxTrailingOnes() const {
+ return Zero.countTrailingZeros();
+ }
+
+ /// Returns the maximum number of leading zero bits possible.
+ unsigned countMaxLeadingZeros() const {
+ return One.countLeadingZeros();
+ }
+
+ /// Returns the maximum number of leading one bits possible.
+ unsigned countMaxLeadingOnes() const {
+ return Zero.countLeadingZeros();
+ }
+
+ /// Returns the number of bits known to be one.
+ unsigned countMinPopulation() const {
+ return One.countPopulation();
+ }
+
+ /// Returns the maximum number of bits that could be one.
+ unsigned countMaxPopulation() const {
+ return getBitWidth() - Zero.countPopulation();
+ }
+};
+
+} // end namespace llvm
+
+#endif
diff --git a/contrib/llvm/include/llvm/Support/LEB128.h b/contrib/llvm/include/llvm/Support/LEB128.h
index 6a95432..29640db 100644
--- a/contrib/llvm/include/llvm/Support/LEB128.h
+++ b/contrib/llvm/include/llvm/Support/LEB128.h
@@ -20,7 +20,8 @@
namespace llvm {
/// Utility function to encode a SLEB128 value to an output stream.
-inline void encodeSLEB128(int64_t Value, raw_ostream &OS) {
+inline void encodeSLEB128(int64_t Value, raw_ostream &OS,
+ unsigned Padding = 0) {
bool More;
do {
uint8_t Byte = Value & 0x7f;
@@ -28,10 +29,44 @@ inline void encodeSLEB128(int64_t Value, raw_ostream &OS) {
Value >>= 7;
More = !((((Value == 0 ) && ((Byte & 0x40) == 0)) ||
((Value == -1) && ((Byte & 0x40) != 0))));
- if (More)
+ if (More || Padding != 0)
Byte |= 0x80; // Mark this byte to show that more bytes will follow.
OS << char(Byte);
} while (More);
+
+ // Pad with 0x80 and emit a terminating byte at the end.
+ if (Padding != 0) {
+ uint8_t PadValue = Value < 0 ? 0x7f : 0x00;
+ for (; Padding != 1; --Padding)
+ OS << char(PadValue | 0x80);
+ OS << char(PadValue);
+ }
+}
+
+/// Utility function to encode a SLEB128 value to a buffer. Returns
+/// the length in bytes of the encoded value.
+inline unsigned encodeSLEB128(int64_t Value, uint8_t *p, unsigned Padding = 0) {
+ uint8_t *orig_p = p;
+ bool More;
+ do {
+ uint8_t Byte = Value & 0x7f;
+ // NOTE: this assumes that this signed shift is an arithmetic right shift.
+ Value >>= 7;
+ More = !((((Value == 0 ) && ((Byte & 0x40) == 0)) ||
+ ((Value == -1) && ((Byte & 0x40) != 0))));
+ if (More || Padding != 0)
+ Byte |= 0x80; // Mark this byte to show that more bytes will follow.
+ *p++ = Byte;
+ } while (More);
+
+ // Pad with 0x80 and emit a terminating byte at the end.
+ if (Padding != 0) {
+ uint8_t PadValue = Value < 0 ? 0x7f : 0x00;
+ for (; Padding != 1; --Padding)
+ *p++ = (PadValue | 0x80);
+ *p++ = PadValue;
+ }
+ return (unsigned)(p - orig_p);
}
/// Utility function to encode a ULEB128 value to an output stream.
@@ -75,13 +110,31 @@ inline unsigned encodeULEB128(uint64_t Value, uint8_t *p,
return (unsigned)(p - orig_p);
}
-
/// Utility function to decode a ULEB128 value.
-inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr) {
+inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr,
+ const uint8_t *end = nullptr,
+ const char **error = nullptr) {
const uint8_t *orig_p = p;
uint64_t Value = 0;
unsigned Shift = 0;
+ if (error)
+ *error = nullptr;
do {
+ if (end && p == end) {
+ if (error)
+ *error = "malformed uleb128, extends past end";
+ if (n)
+ *n = (unsigned)(p - orig_p);
+ return 0;
+ }
+ uint64_t Slice = *p & 0x7f;
+ if (Shift >= 64 || Slice << Shift >> Shift != Slice) {
+ if (error)
+ *error = "uleb128 too big for uint64";
+ if (n)
+ *n = (unsigned)(p - orig_p);
+ return 0;
+ }
Value += uint64_t(*p & 0x7f) << Shift;
Shift += 7;
} while (*p++ >= 128);
@@ -91,14 +144,23 @@ inline uint64_t decodeULEB128(const uint8_t *p, unsigned *n = nullptr) {
}
/// Utility function to decode a SLEB128 value.
-inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr) {
+inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr,
+ const uint8_t *end = nullptr,
+ const char **error = nullptr) {
const uint8_t *orig_p = p;
int64_t Value = 0;
unsigned Shift = 0;
uint8_t Byte;
do {
+ if (end && p == end) {
+ if (error)
+ *error = "malformed sleb128, extends past end";
+ if (n)
+ *n = (unsigned)(p - orig_p);
+ return 0;
+ }
Byte = *p++;
- Value |= ((Byte & 0x7f) << Shift);
+ Value |= (int64_t(Byte & 0x7f) << Shift);
Shift += 7;
} while (Byte >= 128);
// Sign extend negative numbers.
@@ -109,13 +171,12 @@ inline int64_t decodeSLEB128(const uint8_t *p, unsigned *n = nullptr) {
return Value;
}
-
/// Utility function to get the size of the ULEB128-encoded value.
extern unsigned getULEB128Size(uint64_t Value);
/// Utility function to get the size of the SLEB128-encoded value.
extern unsigned getSLEB128Size(int64_t Value);
-} // namespace llvm
+} // namespace llvm
-#endif // LLVM_SYSTEM_LEB128_H
+#endif // LLVM_SYSTEM_LEB128_H
diff --git a/contrib/llvm/include/llvm/Support/LowLevelTypeImpl.h b/contrib/llvm/include/llvm/Support/LowLevelTypeImpl.h
new file mode 100644
index 0000000..c79dd0c
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/LowLevelTypeImpl.h
@@ -0,0 +1,309 @@
+//== llvm/Support/LowLevelTypeImpl.h --------------------------- -*- C++ -*-==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+/// Implement a low-level type suitable for MachineInstr level instruction
+/// selection.
+///
+/// For a type attached to a MachineInstr, we only care about 2 details: total
+/// size and the number of vector lanes (if any). Accordingly, there are 4
+/// possible valid type-kinds:
+///
+/// * `sN` for scalars and aggregates
+/// * `<N x sM>` for vectors, which must have at least 2 elements.
+/// * `pN` for pointers
+///
+/// Other information required for correct selection is expected to be carried
+/// by the opcode, or non-type flags. For example the distinction between G_ADD
+/// and G_FADD for int/float or fast-math flags.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_LOWLEVELTYPEIMPL_H
+#define LLVM_SUPPORT_LOWLEVELTYPEIMPL_H
+
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/CodeGen/MachineValueType.h"
+#include <cassert>
+
+namespace llvm {
+
+class DataLayout;
+class Type;
+class raw_ostream;
+
+class LLT {
+public:
+ /// Get a low-level scalar or aggregate "bag of bits".
+ static LLT scalar(unsigned SizeInBits) {
+ assert(SizeInBits > 0 && "invalid scalar size");
+ return LLT{/*isPointer=*/false, /*isVector=*/false, /*NumElements=*/0,
+ SizeInBits, /*AddressSpace=*/0};
+ }
+
+ /// Get a low-level pointer in the given address space (defaulting to 0).
+ static LLT pointer(uint16_t AddressSpace, unsigned SizeInBits) {
+ assert(SizeInBits > 0 && "invalid pointer size");
+ return LLT{/*isPointer=*/true, /*isVector=*/false, /*NumElements=*/0,
+ SizeInBits, AddressSpace};
+ }
+
+ /// Get a low-level vector of some number of elements and element width.
+ /// \p NumElements must be at least 2.
+ static LLT vector(uint16_t NumElements, unsigned ScalarSizeInBits) {
+ assert(NumElements > 1 && "invalid number of vector elements");
+ assert(ScalarSizeInBits > 0 && "invalid vector element size");
+ return LLT{/*isPointer=*/false, /*isVector=*/true, NumElements,
+ ScalarSizeInBits, /*AddressSpace=*/0};
+ }
+
+ /// Get a low-level vector of some number of elements and element type.
+ static LLT vector(uint16_t NumElements, LLT ScalarTy) {
+ assert(NumElements > 1 && "invalid number of vector elements");
+ assert(!ScalarTy.isVector() && "invalid vector element type");
+ return LLT{ScalarTy.isPointer(), /*isVector=*/true, NumElements,
+ ScalarTy.getSizeInBits(),
+ ScalarTy.isPointer() ? ScalarTy.getAddressSpace() : 0};
+ }
+
+ explicit LLT(bool isPointer, bool isVector, uint16_t NumElements,
+ unsigned SizeInBits, unsigned AddressSpace) {
+ init(isPointer, isVector, NumElements, SizeInBits, AddressSpace);
+ }
+ explicit LLT() : IsPointer(false), IsVector(false), RawData(0) {}
+
+ explicit LLT(MVT VT);
+
+ bool isValid() const { return RawData != 0; }
+
+ bool isScalar() const { return isValid() && !IsPointer && !IsVector; }
+
+ bool isPointer() const { return isValid() && IsPointer && !IsVector; }
+
+ bool isVector() const { return isValid() && IsVector; }
+
+ /// Returns the number of elements in a vector LLT. Must only be called on
+ /// vector types.
+ uint16_t getNumElements() const {
+ assert(IsVector && "cannot get number of elements on scalar/aggregate");
+ if (!IsPointer)
+ return getFieldValue(VectorElementsFieldInfo);
+ else
+ return getFieldValue(PointerVectorElementsFieldInfo);
+ }
+
+ /// Returns the total size of the type. Must only be called on sized types.
+ unsigned getSizeInBits() const {
+ if (isPointer() || isScalar())
+ return getScalarSizeInBits();
+ return getScalarSizeInBits() * getNumElements();
+ }
+
+ unsigned getScalarSizeInBits() const {
+ assert(RawData != 0 && "Invalid Type");
+ if (!IsVector) {
+ if (!IsPointer)
+ return getFieldValue(ScalarSizeFieldInfo);
+ else
+ return getFieldValue(PointerSizeFieldInfo);
+ } else {
+ if (!IsPointer)
+ return getFieldValue(VectorSizeFieldInfo);
+ else
+ return getFieldValue(PointerVectorSizeFieldInfo);
+ }
+ }
+
+ unsigned getAddressSpace() const {
+ assert(RawData != 0 && "Invalid Type");
+ assert(IsPointer && "cannot get address space of non-pointer type");
+ if (!IsVector)
+ return getFieldValue(PointerAddressSpaceFieldInfo);
+ else
+ return getFieldValue(PointerVectorAddressSpaceFieldInfo);
+ }
+
+ /// Returns the vector's element type. Only valid for vector types.
+ LLT getElementType() const {
+ assert(isVector() && "cannot get element type of scalar/aggregate");
+ if (IsPointer)
+ return pointer(getAddressSpace(), getScalarSizeInBits());
+ else
+ return scalar(getScalarSizeInBits());
+ }
+
+ /// Get a low-level type with half the size of the original, by halving the
+ /// size of the scalar type involved. For example `s32` will become `s16`,
+ /// `<2 x s32>` will become `<2 x s16>`.
+ LLT halfScalarSize() const {
+ assert(!IsPointer && getScalarSizeInBits() > 1 &&
+ getScalarSizeInBits() % 2 == 0 && "cannot half size of this type");
+ return LLT{/*isPointer=*/false, IsVector ? true : false,
+ IsVector ? getNumElements() : (uint16_t)0,
+ getScalarSizeInBits() / 2, /*AddressSpace=*/0};
+ }
+
+ /// Get a low-level type with twice the size of the original, by doubling the
+ /// size of the scalar type involved. For example `s32` will become `s64`,
+ /// `<2 x s32>` will become `<2 x s64>`.
+ LLT doubleScalarSize() const {
+ assert(!IsPointer && "cannot change size of this type");
+ return LLT{/*isPointer=*/false, IsVector ? true : false,
+ IsVector ? getNumElements() : (uint16_t)0,
+ getScalarSizeInBits() * 2, /*AddressSpace=*/0};
+ }
+
+ /// Get a low-level type with half the size of the original, by halving the
+ /// number of vector elements of the scalar type involved. The source must be
+ /// a vector type with an even number of elements. For example `<4 x s32>`
+ /// will become `<2 x s32>`, `<2 x s32>` will become `s32`.
+ LLT halfElements() const {
+ assert(isVector() && getNumElements() % 2 == 0 && "cannot half odd vector");
+ if (getNumElements() == 2)
+ return scalar(getScalarSizeInBits());
+
+ return LLT{/*isPointer=*/false, /*isVector=*/true,
+ (uint16_t)(getNumElements() / 2), getScalarSizeInBits(),
+ /*AddressSpace=*/0};
+ }
+
+ /// Get a low-level type with twice the size of the original, by doubling the
+ /// number of vector elements of the scalar type involved. The source must be
+ /// a vector type. For example `<2 x s32>` will become `<4 x s32>`. Doubling
+ /// the number of elements in sN produces <2 x sN>.
+ LLT doubleElements() const {
+ return LLT{IsPointer ? true : false, /*isVector=*/true,
+ (uint16_t)(getNumElements() * 2), getScalarSizeInBits(),
+ IsPointer ? getAddressSpace() : 0};
+ }
+
+ void print(raw_ostream &OS) const;
+
+ bool operator==(const LLT &RHS) const {
+ return IsPointer == RHS.IsPointer && IsVector == RHS.IsVector &&
+ RHS.RawData == RawData;
+ }
+
+ bool operator!=(const LLT &RHS) const { return !(*this == RHS); }
+
+ friend struct DenseMapInfo<LLT>;
+
+private:
+ /// LLT is packed into 64 bits as follows:
+ /// isPointer : 1
+ /// isVector : 1
+ /// with 62 bits remaining for Kind-specific data, packed in bitfields
+ /// as described below. As there isn't a simple portable way to pack bits
+ /// into bitfields, here the different fields in the packed structure is
+ /// described in static const *Field variables. Each of these variables
+ /// is a 2-element array, with the first element describing the bitfield size
+ /// and the second element describing the bitfield offset.
+ typedef int BitFieldInfo[2];
+ ///
+ /// This is how the bitfields are packed per Kind:
+ /// * Invalid:
+ /// gets encoded as RawData == 0, as that is an invalid encoding, since for
+ /// valid encodings, SizeInBits/SizeOfElement must be larger than 0.
+ /// * Non-pointer scalar (isPointer == 0 && isVector == 0):
+ /// SizeInBits: 32;
+ static const constexpr BitFieldInfo ScalarSizeFieldInfo{32, 0};
+ /// * Pointer (isPointer == 1 && isVector == 0):
+ /// SizeInBits: 16;
+ /// AddressSpace: 23;
+ static const constexpr BitFieldInfo PointerSizeFieldInfo{16, 0};
+ static const constexpr BitFieldInfo PointerAddressSpaceFieldInfo{
+ 23, PointerSizeFieldInfo[0] + PointerSizeFieldInfo[1]};
+ /// * Vector-of-non-pointer (isPointer == 0 && isVector == 1):
+ /// NumElements: 16;
+ /// SizeOfElement: 32;
+ static const constexpr BitFieldInfo VectorElementsFieldInfo{16, 0};
+ static const constexpr BitFieldInfo VectorSizeFieldInfo{
+ 32, VectorElementsFieldInfo[0] + VectorElementsFieldInfo[1]};
+ /// * Vector-of-pointer (isPointer == 1 && isVector == 1):
+ /// NumElements: 16;
+ /// SizeOfElement: 16;
+ /// AddressSpace: 23;
+ static const constexpr BitFieldInfo PointerVectorElementsFieldInfo{16, 0};
+ static const constexpr BitFieldInfo PointerVectorSizeFieldInfo{
+ 16,
+ PointerVectorElementsFieldInfo[1] + PointerVectorElementsFieldInfo[0]};
+ static const constexpr BitFieldInfo PointerVectorAddressSpaceFieldInfo{
+ 23, PointerVectorSizeFieldInfo[1] + PointerVectorSizeFieldInfo[0]};
+
+ uint64_t IsPointer : 1;
+ uint64_t IsVector : 1;
+ uint64_t RawData : 62;
+
+ static uint64_t getMask(const BitFieldInfo FieldInfo) {
+ const int FieldSizeInBits = FieldInfo[0];
+ return (((uint64_t)1) << FieldSizeInBits) - 1;
+ }
+ static uint64_t maskAndShift(uint64_t Val, uint64_t Mask, uint8_t Shift) {
+ assert(Val <= Mask && "Value too large for field");
+ return (Val & Mask) << Shift;
+ }
+ static uint64_t maskAndShift(uint64_t Val, const BitFieldInfo FieldInfo) {
+ return maskAndShift(Val, getMask(FieldInfo), FieldInfo[1]);
+ }
+ uint64_t getFieldValue(const BitFieldInfo FieldInfo) const {
+ return getMask(FieldInfo) & (RawData >> FieldInfo[1]);
+ }
+
+ void init(bool IsPointer, bool IsVector, uint16_t NumElements,
+ unsigned SizeInBits, unsigned AddressSpace) {
+ this->IsPointer = IsPointer;
+ this->IsVector = IsVector;
+ if (!IsVector) {
+ if (!IsPointer)
+ RawData = maskAndShift(SizeInBits, ScalarSizeFieldInfo);
+ else
+ RawData = maskAndShift(SizeInBits, PointerSizeFieldInfo) |
+ maskAndShift(AddressSpace, PointerAddressSpaceFieldInfo);
+ } else {
+ assert(NumElements > 1 && "invalid number of vector elements");
+ if (!IsPointer)
+ RawData = maskAndShift(NumElements, VectorElementsFieldInfo) |
+ maskAndShift(SizeInBits, VectorSizeFieldInfo);
+ else
+ RawData =
+ maskAndShift(NumElements, PointerVectorElementsFieldInfo) |
+ maskAndShift(SizeInBits, PointerVectorSizeFieldInfo) |
+ maskAndShift(AddressSpace, PointerVectorAddressSpaceFieldInfo);
+ }
+ }
+};
+
+inline raw_ostream& operator<<(raw_ostream &OS, const LLT &Ty) {
+ Ty.print(OS);
+ return OS;
+}
+
+template<> struct DenseMapInfo<LLT> {
+ static inline LLT getEmptyKey() {
+ LLT Invalid;
+ Invalid.IsPointer = true;
+ return Invalid;
+ }
+ static inline LLT getTombstoneKey() {
+ LLT Invalid;
+ Invalid.IsVector = true;
+ return Invalid;
+ }
+ static inline unsigned getHashValue(const LLT &Ty) {
+ uint64_t Val = ((uint64_t)Ty.RawData) << 2 | ((uint64_t)Ty.IsPointer) << 1 |
+ ((uint64_t)Ty.IsVector);
+ return DenseMapInfo<uint64_t>::getHashValue(Val);
+ }
+ static bool isEqual(const LLT &LHS, const LLT &RHS) {
+ return LHS == RHS;
+ }
+};
+
+}
+
+#endif // LLVM_SUPPORT_LOWLEVELTYPEIMPL_H
diff --git a/contrib/llvm/include/llvm/Support/MD5.h b/contrib/llvm/include/llvm/Support/MD5.h
index eb181bf..2c0dc76 100644
--- a/contrib/llvm/include/llvm/Support/MD5.h
+++ b/contrib/llvm/include/llvm/Support/MD5.h
@@ -1,4 +1,4 @@
-/*
+/* -*- C++ -*-
* This code is derived from (original license follows):
*
* This is an OpenSSL-compatible implementation of the RSA Data Security, Inc.
@@ -29,24 +29,55 @@
#define LLVM_SUPPORT_MD5_H
#include "llvm/ADT/SmallString.h"
-#include "llvm/Support/DataTypes.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Endian.h"
#include <array>
+#include <cstdint>
namespace llvm {
+
template <typename T> class ArrayRef;
class MD5 {
// Any 32-bit or wider unsigned integer data type will do.
typedef uint32_t MD5_u32plus;
- MD5_u32plus a, b, c, d;
- MD5_u32plus hi, lo;
+ MD5_u32plus a = 0x67452301;
+ MD5_u32plus b = 0xefcdab89;
+ MD5_u32plus c = 0x98badcfe;
+ MD5_u32plus d = 0x10325476;
+ MD5_u32plus hi = 0;
+ MD5_u32plus lo = 0;
uint8_t buffer[64];
MD5_u32plus block[16];
public:
- typedef uint8_t MD5Result[16];
+ struct MD5Result {
+ std::array<uint8_t, 16> Bytes;
+
+ operator std::array<uint8_t, 16>() const { return Bytes; }
+
+ const uint8_t &operator[](size_t I) const { return Bytes[I]; }
+ uint8_t &operator[](size_t I) { return Bytes[I]; }
+
+ SmallString<32> digest() const;
+
+ uint64_t low() const {
+ // Our MD5 implementation returns the result in little endian, so the low
+ // word is first.
+ using namespace support;
+ return endian::read<uint64_t, little, unaligned>(Bytes.data());
+ }
+
+ uint64_t high() const {
+ using namespace support;
+ return endian::read<uint64_t, little, unaligned>(Bytes.data() + 8);
+ }
+ std::pair<uint64_t, uint64_t> words() const {
+ using namespace support;
+ return std::make_pair(high(), low());
+ }
+ };
MD5();
@@ -70,18 +101,22 @@ private:
const uint8_t *body(ArrayRef<uint8_t> Data);
};
+inline bool operator==(const MD5::MD5Result &LHS, const MD5::MD5Result &RHS) {
+ return LHS.Bytes == RHS.Bytes;
+}
+
/// Helper to compute and return lower 64 bits of the given string's MD5 hash.
inline uint64_t MD5Hash(StringRef Str) {
+ using namespace support;
+
MD5 Hash;
Hash.update(Str);
- llvm::MD5::MD5Result Result;
+ MD5::MD5Result Result;
Hash.final(Result);
- // Return the least significant 8 bytes. Our MD5 implementation returns the
- // result in little endian, so we may need to swap bytes.
- using namespace llvm::support;
- return endian::read<uint64_t, little, unaligned>(Result);
+ // Return the least significant word.
+ return Result.low();
}
-}
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_MD5_H
diff --git a/contrib/llvm/include/llvm/Support/MachO.def b/contrib/llvm/include/llvm/Support/MachO.def
deleted file mode 100644
index 5752289..0000000
--- a/contrib/llvm/include/llvm/Support/MachO.def
+++ /dev/null
@@ -1,116 +0,0 @@
-//,,,-- llvm/Support/MachO.def - The MachO file definitions -----*- C++ -*-,,,//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//,,,----------------------------------------------------------------------,,,//
-//
-// Definitions for MachO files
-//
-//,,,----------------------------------------------------------------------,,,//
-
-#ifdef HANDLE_LOAD_COMMAND
-
-HANDLE_LOAD_COMMAND(LC_SEGMENT, 0x00000001u, segment_command)
-HANDLE_LOAD_COMMAND(LC_SYMTAB, 0x00000002u, symtab_command)
-// LC_SYMSEG is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_SYMSEG, 0x00000003u, symseg_command)
-HANDLE_LOAD_COMMAND(LC_THREAD, 0x00000004u, thread_command)
-HANDLE_LOAD_COMMAND(LC_UNIXTHREAD, 0x00000005u, thread_command)
-// LC_LOADFVMLIB is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_LOADFVMLIB, 0x00000006u, fvmlib_command)
-// LC_IDFVMLIB is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_IDFVMLIB, 0x00000007u, fvmlib_command)
-// LC_IDENT is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_IDENT, 0x00000008u, ident_command)
-// LC_FVMFILE is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_FVMFILE, 0x00000009u, fvmfile_command)
-// LC_PREPAGE is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_PREPAGE, 0x0000000Au, load_command)
-HANDLE_LOAD_COMMAND(LC_DYSYMTAB, 0x0000000Bu, dysymtab_command)
-HANDLE_LOAD_COMMAND(LC_LOAD_DYLIB, 0x0000000Cu, dylib_command)
-HANDLE_LOAD_COMMAND(LC_ID_DYLIB, 0x0000000Du, dylib_command)
-HANDLE_LOAD_COMMAND(LC_LOAD_DYLINKER, 0x0000000Eu, dylinker_command)
-HANDLE_LOAD_COMMAND(LC_ID_DYLINKER, 0x0000000Fu, dylinker_command)
-// LC_PREBOUND_DYLIB is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_PREBOUND_DYLIB, 0x00000010u, prebound_dylib_command)
-HANDLE_LOAD_COMMAND(LC_ROUTINES, 0x00000011u, routines_command)
-HANDLE_LOAD_COMMAND(LC_SUB_FRAMEWORK, 0x00000012u, sub_framework_command)
-HANDLE_LOAD_COMMAND(LC_SUB_UMBRELLA, 0x00000013u, sub_umbrella_command)
-HANDLE_LOAD_COMMAND(LC_SUB_CLIENT, 0x00000014u, sub_client_command)
-HANDLE_LOAD_COMMAND(LC_SUB_LIBRARY, 0x00000015u, sub_library_command)
-// LC_TWOLEVEL_HINTS is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_TWOLEVEL_HINTS, 0x00000016u, twolevel_hints_command)
-// LC_PREBIND_CKSUM is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_PREBIND_CKSUM, 0x00000017u, prebind_cksum_command)
-// LC_LOAD_WEAK_DYLIB is obsolete and no longer supported.
-HANDLE_LOAD_COMMAND(LC_LOAD_WEAK_DYLIB, 0x80000018u, dylib_command)
-HANDLE_LOAD_COMMAND(LC_SEGMENT_64, 0x00000019u, segment_command_64)
-HANDLE_LOAD_COMMAND(LC_ROUTINES_64, 0x0000001Au, routines_command_64)
-HANDLE_LOAD_COMMAND(LC_UUID, 0x0000001Bu, uuid_command)
-HANDLE_LOAD_COMMAND(LC_RPATH, 0x8000001Cu, rpath_command)
-HANDLE_LOAD_COMMAND(LC_CODE_SIGNATURE, 0x0000001Du, linkedit_data_command)
-HANDLE_LOAD_COMMAND(LC_SEGMENT_SPLIT_INFO, 0x0000001Eu, linkedit_data_command)
-HANDLE_LOAD_COMMAND(LC_REEXPORT_DYLIB, 0x8000001Fu, dylib_command)
-HANDLE_LOAD_COMMAND(LC_LAZY_LOAD_DYLIB, 0x00000020u, dylib_command)
-HANDLE_LOAD_COMMAND(LC_ENCRYPTION_INFO, 0x00000021u, encryption_info_command)
-HANDLE_LOAD_COMMAND(LC_DYLD_INFO, 0x00000022u, dyld_info_command)
-HANDLE_LOAD_COMMAND(LC_DYLD_INFO_ONLY, 0x80000022u, dyld_info_command)
-HANDLE_LOAD_COMMAND(LC_LOAD_UPWARD_DYLIB, 0x80000023u, dylib_command)
-HANDLE_LOAD_COMMAND(LC_VERSION_MIN_MACOSX, 0x00000024u, version_min_command)
-HANDLE_LOAD_COMMAND(LC_VERSION_MIN_IPHONEOS, 0x00000025u, version_min_command)
-HANDLE_LOAD_COMMAND(LC_FUNCTION_STARTS, 0x00000026u, linkedit_data_command)
-HANDLE_LOAD_COMMAND(LC_DYLD_ENVIRONMENT, 0x00000027u, dylinker_command)
-HANDLE_LOAD_COMMAND(LC_MAIN, 0x80000028u, entry_point_command)
-HANDLE_LOAD_COMMAND(LC_DATA_IN_CODE, 0x00000029u, linkedit_data_command)
-HANDLE_LOAD_COMMAND(LC_SOURCE_VERSION, 0x0000002Au, source_version_command)
-HANDLE_LOAD_COMMAND(LC_DYLIB_CODE_SIGN_DRS, 0x0000002Bu, linkedit_data_command)
-HANDLE_LOAD_COMMAND(LC_ENCRYPTION_INFO_64, 0x0000002Cu,
- encryption_info_command_64)
-HANDLE_LOAD_COMMAND(LC_LINKER_OPTION, 0x0000002Du, linker_option_command)
-HANDLE_LOAD_COMMAND(LC_LINKER_OPTIMIZATION_HINT, 0x0000002Eu, linkedit_data_command)
-HANDLE_LOAD_COMMAND(LC_VERSION_MIN_TVOS, 0x0000002Fu, version_min_command)
-HANDLE_LOAD_COMMAND(LC_VERSION_MIN_WATCHOS, 0x00000030u, version_min_command)
-
-#endif
-
-#ifdef LOAD_COMMAND_STRUCT
-
-LOAD_COMMAND_STRUCT(dyld_info_command)
-LOAD_COMMAND_STRUCT(dylib_command)
-LOAD_COMMAND_STRUCT(dylinker_command)
-LOAD_COMMAND_STRUCT(dysymtab_command)
-LOAD_COMMAND_STRUCT(encryption_info_command)
-LOAD_COMMAND_STRUCT(encryption_info_command_64)
-LOAD_COMMAND_STRUCT(entry_point_command)
-LOAD_COMMAND_STRUCT(fvmfile_command)
-LOAD_COMMAND_STRUCT(fvmlib_command)
-LOAD_COMMAND_STRUCT(ident_command)
-LOAD_COMMAND_STRUCT(linkedit_data_command)
-LOAD_COMMAND_STRUCT(linker_option_command)
-LOAD_COMMAND_STRUCT(load_command)
-LOAD_COMMAND_STRUCT(prebind_cksum_command)
-LOAD_COMMAND_STRUCT(prebound_dylib_command)
-LOAD_COMMAND_STRUCT(routines_command)
-LOAD_COMMAND_STRUCT(routines_command_64)
-LOAD_COMMAND_STRUCT(rpath_command)
-LOAD_COMMAND_STRUCT(segment_command)
-LOAD_COMMAND_STRUCT(segment_command_64)
-LOAD_COMMAND_STRUCT(source_version_command)
-LOAD_COMMAND_STRUCT(sub_client_command)
-LOAD_COMMAND_STRUCT(sub_framework_command)
-LOAD_COMMAND_STRUCT(sub_library_command)
-LOAD_COMMAND_STRUCT(sub_umbrella_command)
-LOAD_COMMAND_STRUCT(symseg_command)
-LOAD_COMMAND_STRUCT(symtab_command)
-LOAD_COMMAND_STRUCT(thread_command)
-LOAD_COMMAND_STRUCT(twolevel_hints_command)
-LOAD_COMMAND_STRUCT(uuid_command)
-LOAD_COMMAND_STRUCT(version_min_command)
-
-#endif
-
-#undef HANDLE_LOAD_COMMAND
-#undef LOAD_COMMAND_STRUCT
diff --git a/contrib/llvm/include/llvm/Support/MachO.h b/contrib/llvm/include/llvm/Support/MachO.h
deleted file mode 100644
index 2b23c0f..0000000
--- a/contrib/llvm/include/llvm/Support/MachO.h
+++ /dev/null
@@ -1,1936 +0,0 @@
-//===-- llvm/Support/MachO.h - The MachO file format ------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines manifest constants for the MachO object file format.
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_MACHO_H
-#define LLVM_SUPPORT_MACHO_H
-
-#include "llvm/Support/Compiler.h"
-#include "llvm/Support/DataTypes.h"
-#include "llvm/Support/Host.h"
-
-namespace llvm {
- namespace MachO {
- // Enums from <mach-o/loader.h>
- enum : uint32_t {
- // Constants for the "magic" field in llvm::MachO::mach_header and
- // llvm::MachO::mach_header_64
- MH_MAGIC = 0xFEEDFACEu,
- MH_CIGAM = 0xCEFAEDFEu,
- MH_MAGIC_64 = 0xFEEDFACFu,
- MH_CIGAM_64 = 0xCFFAEDFEu,
- FAT_MAGIC = 0xCAFEBABEu,
- FAT_CIGAM = 0xBEBAFECAu,
- FAT_MAGIC_64 = 0xCAFEBABFu,
- FAT_CIGAM_64 = 0xBFBAFECAu
- };
-
- enum HeaderFileType {
- // Constants for the "filetype" field in llvm::MachO::mach_header and
- // llvm::MachO::mach_header_64
- MH_OBJECT = 0x1u,
- MH_EXECUTE = 0x2u,
- MH_FVMLIB = 0x3u,
- MH_CORE = 0x4u,
- MH_PRELOAD = 0x5u,
- MH_DYLIB = 0x6u,
- MH_DYLINKER = 0x7u,
- MH_BUNDLE = 0x8u,
- MH_DYLIB_STUB = 0x9u,
- MH_DSYM = 0xAu,
- MH_KEXT_BUNDLE = 0xBu
- };
-
- enum {
- // Constant bits for the "flags" field in llvm::MachO::mach_header and
- // llvm::MachO::mach_header_64
- MH_NOUNDEFS = 0x00000001u,
- MH_INCRLINK = 0x00000002u,
- MH_DYLDLINK = 0x00000004u,
- MH_BINDATLOAD = 0x00000008u,
- MH_PREBOUND = 0x00000010u,
- MH_SPLIT_SEGS = 0x00000020u,
- MH_LAZY_INIT = 0x00000040u,
- MH_TWOLEVEL = 0x00000080u,
- MH_FORCE_FLAT = 0x00000100u,
- MH_NOMULTIDEFS = 0x00000200u,
- MH_NOFIXPREBINDING = 0x00000400u,
- MH_PREBINDABLE = 0x00000800u,
- MH_ALLMODSBOUND = 0x00001000u,
- MH_SUBSECTIONS_VIA_SYMBOLS = 0x00002000u,
- MH_CANONICAL = 0x00004000u,
- MH_WEAK_DEFINES = 0x00008000u,
- MH_BINDS_TO_WEAK = 0x00010000u,
- MH_ALLOW_STACK_EXECUTION = 0x00020000u,
- MH_ROOT_SAFE = 0x00040000u,
- MH_SETUID_SAFE = 0x00080000u,
- MH_NO_REEXPORTED_DYLIBS = 0x00100000u,
- MH_PIE = 0x00200000u,
- MH_DEAD_STRIPPABLE_DYLIB = 0x00400000u,
- MH_HAS_TLV_DESCRIPTORS = 0x00800000u,
- MH_NO_HEAP_EXECUTION = 0x01000000u,
- MH_APP_EXTENSION_SAFE = 0x02000000u
- };
-
- enum : uint32_t {
- // Flags for the "cmd" field in llvm::MachO::load_command
- LC_REQ_DYLD = 0x80000000u
- };
-
-#define HANDLE_LOAD_COMMAND(LCName, LCValue, LCStruct) \
- LCName = LCValue,
-
- enum LoadCommandType : uint32_t {
- #include "llvm/Support/MachO.def"
- };
-
-#undef HANDLE_LOAD_COMMAND
-
- enum : uint32_t {
- // Constant bits for the "flags" field in llvm::MachO::segment_command
- SG_HIGHVM = 0x1u,
- SG_FVMLIB = 0x2u,
- SG_NORELOC = 0x4u,
- SG_PROTECTED_VERSION_1 = 0x8u,
-
- // Constant masks for the "flags" field in llvm::MachO::section and
- // llvm::MachO::section_64
- SECTION_TYPE = 0x000000ffu, // SECTION_TYPE
- SECTION_ATTRIBUTES = 0xffffff00u, // SECTION_ATTRIBUTES
- SECTION_ATTRIBUTES_USR = 0xff000000u, // SECTION_ATTRIBUTES_USR
- SECTION_ATTRIBUTES_SYS = 0x00ffff00u // SECTION_ATTRIBUTES_SYS
- };
-
- /// These are the section type and attributes fields. A MachO section can
- /// have only one Type, but can have any of the attributes specified.
- enum SectionType : uint32_t {
- // Constant masks for the "flags[7:0]" field in llvm::MachO::section and
- // llvm::MachO::section_64 (mask "flags" with SECTION_TYPE)
-
- /// S_REGULAR - Regular section.
- S_REGULAR = 0x00u,
- /// S_ZEROFILL - Zero fill on demand section.
- S_ZEROFILL = 0x01u,
- /// S_CSTRING_LITERALS - Section with literal C strings.
- S_CSTRING_LITERALS = 0x02u,
- /// S_4BYTE_LITERALS - Section with 4 byte literals.
- S_4BYTE_LITERALS = 0x03u,
- /// S_8BYTE_LITERALS - Section with 8 byte literals.
- S_8BYTE_LITERALS = 0x04u,
- /// S_LITERAL_POINTERS - Section with pointers to literals.
- S_LITERAL_POINTERS = 0x05u,
- /// S_NON_LAZY_SYMBOL_POINTERS - Section with non-lazy symbol pointers.
- S_NON_LAZY_SYMBOL_POINTERS = 0x06u,
- /// S_LAZY_SYMBOL_POINTERS - Section with lazy symbol pointers.
- S_LAZY_SYMBOL_POINTERS = 0x07u,
- /// S_SYMBOL_STUBS - Section with symbol stubs, byte size of stub in
- /// the Reserved2 field.
- S_SYMBOL_STUBS = 0x08u,
- /// S_MOD_INIT_FUNC_POINTERS - Section with only function pointers for
- /// initialization.
- S_MOD_INIT_FUNC_POINTERS = 0x09u,
- /// S_MOD_TERM_FUNC_POINTERS - Section with only function pointers for
- /// termination.
- S_MOD_TERM_FUNC_POINTERS = 0x0au,
- /// S_COALESCED - Section contains symbols that are to be coalesced.
- S_COALESCED = 0x0bu,
- /// S_GB_ZEROFILL - Zero fill on demand section (that can be larger than 4
- /// gigabytes).
- S_GB_ZEROFILL = 0x0cu,
- /// S_INTERPOSING - Section with only pairs of function pointers for
- /// interposing.
- S_INTERPOSING = 0x0du,
- /// S_16BYTE_LITERALS - Section with only 16 byte literals.
- S_16BYTE_LITERALS = 0x0eu,
- /// S_DTRACE_DOF - Section contains DTrace Object Format.
- S_DTRACE_DOF = 0x0fu,
- /// S_LAZY_DYLIB_SYMBOL_POINTERS - Section with lazy symbol pointers to
- /// lazy loaded dylibs.
- S_LAZY_DYLIB_SYMBOL_POINTERS = 0x10u,
- /// S_THREAD_LOCAL_REGULAR - Thread local data section.
- S_THREAD_LOCAL_REGULAR = 0x11u,
- /// S_THREAD_LOCAL_ZEROFILL - Thread local zerofill section.
- S_THREAD_LOCAL_ZEROFILL = 0x12u,
- /// S_THREAD_LOCAL_VARIABLES - Section with thread local variable
- /// structure data.
- S_THREAD_LOCAL_VARIABLES = 0x13u,
- /// S_THREAD_LOCAL_VARIABLE_POINTERS - Section with pointers to thread
- /// local structures.
- S_THREAD_LOCAL_VARIABLE_POINTERS = 0x14u,
- /// S_THREAD_LOCAL_INIT_FUNCTION_POINTERS - Section with thread local
- /// variable initialization pointers to functions.
- S_THREAD_LOCAL_INIT_FUNCTION_POINTERS = 0x15u,
-
- LAST_KNOWN_SECTION_TYPE = S_THREAD_LOCAL_INIT_FUNCTION_POINTERS
- };
-
- enum : uint32_t {
- // Constant masks for the "flags[31:24]" field in llvm::MachO::section and
- // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_USR)
-
- /// S_ATTR_PURE_INSTRUCTIONS - Section contains only true machine
- /// instructions.
- S_ATTR_PURE_INSTRUCTIONS = 0x80000000u,
- /// S_ATTR_NO_TOC - Section contains coalesced symbols that are not to be
- /// in a ranlib table of contents.
- S_ATTR_NO_TOC = 0x40000000u,
- /// S_ATTR_STRIP_STATIC_SYMS - Ok to strip static symbols in this section
- /// in files with the MY_DYLDLINK flag.
- S_ATTR_STRIP_STATIC_SYMS = 0x20000000u,
- /// S_ATTR_NO_DEAD_STRIP - No dead stripping.
- S_ATTR_NO_DEAD_STRIP = 0x10000000u,
- /// S_ATTR_LIVE_SUPPORT - Blocks are live if they reference live blocks.
- S_ATTR_LIVE_SUPPORT = 0x08000000u,
- /// S_ATTR_SELF_MODIFYING_CODE - Used with i386 code stubs written on by
- /// dyld.
- S_ATTR_SELF_MODIFYING_CODE = 0x04000000u,
- /// S_ATTR_DEBUG - A debug section.
- S_ATTR_DEBUG = 0x02000000u,
-
- // Constant masks for the "flags[23:8]" field in llvm::MachO::section and
- // llvm::MachO::section_64 (mask "flags" with SECTION_ATTRIBUTES_SYS)
-
- /// S_ATTR_SOME_INSTRUCTIONS - Section contains some machine instructions.
- S_ATTR_SOME_INSTRUCTIONS = 0x00000400u,
- /// S_ATTR_EXT_RELOC - Section has external relocation entries.
- S_ATTR_EXT_RELOC = 0x00000200u,
- /// S_ATTR_LOC_RELOC - Section has local relocation entries.
- S_ATTR_LOC_RELOC = 0x00000100u,
-
- // Constant masks for the value of an indirect symbol in an indirect
- // symbol table
- INDIRECT_SYMBOL_LOCAL = 0x80000000u,
- INDIRECT_SYMBOL_ABS = 0x40000000u
- };
-
- enum DataRegionType {
- // Constants for the "kind" field in a data_in_code_entry structure
- DICE_KIND_DATA = 1u,
- DICE_KIND_JUMP_TABLE8 = 2u,
- DICE_KIND_JUMP_TABLE16 = 3u,
- DICE_KIND_JUMP_TABLE32 = 4u,
- DICE_KIND_ABS_JUMP_TABLE32 = 5u
- };
-
- enum RebaseType {
- REBASE_TYPE_POINTER = 1u,
- REBASE_TYPE_TEXT_ABSOLUTE32 = 2u,
- REBASE_TYPE_TEXT_PCREL32 = 3u
- };
-
- enum {
- REBASE_OPCODE_MASK = 0xF0u,
- REBASE_IMMEDIATE_MASK = 0x0Fu
- };
-
- enum RebaseOpcode {
- REBASE_OPCODE_DONE = 0x00u,
- REBASE_OPCODE_SET_TYPE_IMM = 0x10u,
- REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 0x20u,
- REBASE_OPCODE_ADD_ADDR_ULEB = 0x30u,
- REBASE_OPCODE_ADD_ADDR_IMM_SCALED = 0x40u,
- REBASE_OPCODE_DO_REBASE_IMM_TIMES = 0x50u,
- REBASE_OPCODE_DO_REBASE_ULEB_TIMES = 0x60u,
- REBASE_OPCODE_DO_REBASE_ADD_ADDR_ULEB = 0x70u,
- REBASE_OPCODE_DO_REBASE_ULEB_TIMES_SKIPPING_ULEB = 0x80u
- };
-
- enum BindType {
- BIND_TYPE_POINTER = 1u,
- BIND_TYPE_TEXT_ABSOLUTE32 = 2u,
- BIND_TYPE_TEXT_PCREL32 = 3u
- };
-
- enum BindSpecialDylib {
- BIND_SPECIAL_DYLIB_SELF = 0,
- BIND_SPECIAL_DYLIB_MAIN_EXECUTABLE = -1,
- BIND_SPECIAL_DYLIB_FLAT_LOOKUP = -2
- };
-
- enum {
- BIND_SYMBOL_FLAGS_WEAK_IMPORT = 0x1u,
- BIND_SYMBOL_FLAGS_NON_WEAK_DEFINITION = 0x8u,
-
- BIND_OPCODE_MASK = 0xF0u,
- BIND_IMMEDIATE_MASK = 0x0Fu
- };
-
- enum BindOpcode {
- BIND_OPCODE_DONE = 0x00u,
- BIND_OPCODE_SET_DYLIB_ORDINAL_IMM = 0x10u,
- BIND_OPCODE_SET_DYLIB_ORDINAL_ULEB = 0x20u,
- BIND_OPCODE_SET_DYLIB_SPECIAL_IMM = 0x30u,
- BIND_OPCODE_SET_SYMBOL_TRAILING_FLAGS_IMM = 0x40u,
- BIND_OPCODE_SET_TYPE_IMM = 0x50u,
- BIND_OPCODE_SET_ADDEND_SLEB = 0x60u,
- BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB = 0x70u,
- BIND_OPCODE_ADD_ADDR_ULEB = 0x80u,
- BIND_OPCODE_DO_BIND = 0x90u,
- BIND_OPCODE_DO_BIND_ADD_ADDR_ULEB = 0xA0u,
- BIND_OPCODE_DO_BIND_ADD_ADDR_IMM_SCALED = 0xB0u,
- BIND_OPCODE_DO_BIND_ULEB_TIMES_SKIPPING_ULEB = 0xC0u
- };
-
- enum {
- EXPORT_SYMBOL_FLAGS_KIND_MASK = 0x03u,
- EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION = 0x04u,
- EXPORT_SYMBOL_FLAGS_REEXPORT = 0x08u,
- EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER = 0x10u
- };
-
- enum ExportSymbolKind {
- EXPORT_SYMBOL_FLAGS_KIND_REGULAR = 0x00u,
- EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL = 0x01u,
- EXPORT_SYMBOL_FLAGS_KIND_ABSOLUTE = 0x02u
- };
-
- enum {
- // Constant masks for the "n_type" field in llvm::MachO::nlist and
- // llvm::MachO::nlist_64
- N_STAB = 0xe0,
- N_PEXT = 0x10,
- N_TYPE = 0x0e,
- N_EXT = 0x01
- };
-
- enum NListType : uint8_t {
- // Constants for the "n_type & N_TYPE" llvm::MachO::nlist and
- // llvm::MachO::nlist_64
- N_UNDF = 0x0u,
- N_ABS = 0x2u,
- N_SECT = 0xeu,
- N_PBUD = 0xcu,
- N_INDR = 0xau
- };
-
- enum SectionOrdinal {
- // Constants for the "n_sect" field in llvm::MachO::nlist and
- // llvm::MachO::nlist_64
- NO_SECT = 0u,
- MAX_SECT = 0xffu
- };
-
- enum {
- // Constant masks for the "n_desc" field in llvm::MachO::nlist and
- // llvm::MachO::nlist_64
- // The low 3 bits are the for the REFERENCE_TYPE.
- REFERENCE_TYPE = 0x7,
- REFERENCE_FLAG_UNDEFINED_NON_LAZY = 0,
- REFERENCE_FLAG_UNDEFINED_LAZY = 1,
- REFERENCE_FLAG_DEFINED = 2,
- REFERENCE_FLAG_PRIVATE_DEFINED = 3,
- REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY = 4,
- REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY = 5,
- // Flag bits (some overlap with the library ordinal bits).
- N_ARM_THUMB_DEF = 0x0008u,
- REFERENCED_DYNAMICALLY = 0x0010u,
- N_NO_DEAD_STRIP = 0x0020u,
- N_WEAK_REF = 0x0040u,
- N_WEAK_DEF = 0x0080u,
- N_SYMBOL_RESOLVER = 0x0100u,
- N_ALT_ENTRY = 0x0200u,
- // For undefined symbols coming from libraries, see GET_LIBRARY_ORDINAL()
- // as these are in the top 8 bits.
- SELF_LIBRARY_ORDINAL = 0x0,
- MAX_LIBRARY_ORDINAL = 0xfd,
- DYNAMIC_LOOKUP_ORDINAL = 0xfe,
- EXECUTABLE_ORDINAL = 0xff
- };
-
- enum StabType {
- // Constant values for the "n_type" field in llvm::MachO::nlist and
- // llvm::MachO::nlist_64 when "(n_type & N_STAB) != 0"
- N_GSYM = 0x20u,
- N_FNAME = 0x22u,
- N_FUN = 0x24u,
- N_STSYM = 0x26u,
- N_LCSYM = 0x28u,
- N_BNSYM = 0x2Eu,
- N_PC = 0x30u,
- N_AST = 0x32u,
- N_OPT = 0x3Cu,
- N_RSYM = 0x40u,
- N_SLINE = 0x44u,
- N_ENSYM = 0x4Eu,
- N_SSYM = 0x60u,
- N_SO = 0x64u,
- N_OSO = 0x66u,
- N_LSYM = 0x80u,
- N_BINCL = 0x82u,
- N_SOL = 0x84u,
- N_PARAMS = 0x86u,
- N_VERSION = 0x88u,
- N_OLEVEL = 0x8Au,
- N_PSYM = 0xA0u,
- N_EINCL = 0xA2u,
- N_ENTRY = 0xA4u,
- N_LBRAC = 0xC0u,
- N_EXCL = 0xC2u,
- N_RBRAC = 0xE0u,
- N_BCOMM = 0xE2u,
- N_ECOMM = 0xE4u,
- N_ECOML = 0xE8u,
- N_LENG = 0xFEu
- };
-
- enum : uint32_t {
- // Constant values for the r_symbolnum field in an
- // llvm::MachO::relocation_info structure when r_extern is 0.
- R_ABS = 0,
-
- // Constant bits for the r_address field in an
- // llvm::MachO::relocation_info structure.
- R_SCATTERED = 0x80000000
- };
-
- enum RelocationInfoType {
- // Constant values for the r_type field in an
- // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
- // structure.
- GENERIC_RELOC_VANILLA = 0,
- GENERIC_RELOC_PAIR = 1,
- GENERIC_RELOC_SECTDIFF = 2,
- GENERIC_RELOC_PB_LA_PTR = 3,
- GENERIC_RELOC_LOCAL_SECTDIFF = 4,
- GENERIC_RELOC_TLV = 5,
-
- // Constant values for the r_type field in a PowerPC architecture
- // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
- // structure.
- PPC_RELOC_VANILLA = GENERIC_RELOC_VANILLA,
- PPC_RELOC_PAIR = GENERIC_RELOC_PAIR,
- PPC_RELOC_BR14 = 2,
- PPC_RELOC_BR24 = 3,
- PPC_RELOC_HI16 = 4,
- PPC_RELOC_LO16 = 5,
- PPC_RELOC_HA16 = 6,
- PPC_RELOC_LO14 = 7,
- PPC_RELOC_SECTDIFF = 8,
- PPC_RELOC_PB_LA_PTR = 9,
- PPC_RELOC_HI16_SECTDIFF = 10,
- PPC_RELOC_LO16_SECTDIFF = 11,
- PPC_RELOC_HA16_SECTDIFF = 12,
- PPC_RELOC_JBSR = 13,
- PPC_RELOC_LO14_SECTDIFF = 14,
- PPC_RELOC_LOCAL_SECTDIFF = 15,
-
- // Constant values for the r_type field in an ARM architecture
- // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
- // structure.
- ARM_RELOC_VANILLA = GENERIC_RELOC_VANILLA,
- ARM_RELOC_PAIR = GENERIC_RELOC_PAIR,
- ARM_RELOC_SECTDIFF = GENERIC_RELOC_SECTDIFF,
- ARM_RELOC_LOCAL_SECTDIFF = 3,
- ARM_RELOC_PB_LA_PTR = 4,
- ARM_RELOC_BR24 = 5,
- ARM_THUMB_RELOC_BR22 = 6,
- ARM_THUMB_32BIT_BRANCH = 7, // obsolete
- ARM_RELOC_HALF = 8,
- ARM_RELOC_HALF_SECTDIFF = 9,
-
- // Constant values for the r_type field in an ARM64 architecture
- // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
- // structure.
-
- // For pointers.
- ARM64_RELOC_UNSIGNED = 0,
- // Must be followed by an ARM64_RELOC_UNSIGNED
- ARM64_RELOC_SUBTRACTOR = 1,
- // A B/BL instruction with 26-bit displacement.
- ARM64_RELOC_BRANCH26 = 2,
- // PC-rel distance to page of target.
- ARM64_RELOC_PAGE21 = 3,
- // Offset within page, scaled by r_length.
- ARM64_RELOC_PAGEOFF12 = 4,
- // PC-rel distance to page of GOT slot.
- ARM64_RELOC_GOT_LOAD_PAGE21 = 5,
- // Offset within page of GOT slot, scaled by r_length.
- ARM64_RELOC_GOT_LOAD_PAGEOFF12 = 6,
- // For pointers to GOT slots.
- ARM64_RELOC_POINTER_TO_GOT = 7,
- // PC-rel distance to page of TLVP slot.
- ARM64_RELOC_TLVP_LOAD_PAGE21 = 8,
- // Offset within page of TLVP slot, scaled by r_length.
- ARM64_RELOC_TLVP_LOAD_PAGEOFF12 = 9,
- // Must be followed by ARM64_RELOC_PAGE21 or ARM64_RELOC_PAGEOFF12.
- ARM64_RELOC_ADDEND = 10,
-
- // Constant values for the r_type field in an x86_64 architecture
- // llvm::MachO::relocation_info or llvm::MachO::scattered_relocation_info
- // structure
- X86_64_RELOC_UNSIGNED = 0,
- X86_64_RELOC_SIGNED = 1,
- X86_64_RELOC_BRANCH = 2,
- X86_64_RELOC_GOT_LOAD = 3,
- X86_64_RELOC_GOT = 4,
- X86_64_RELOC_SUBTRACTOR = 5,
- X86_64_RELOC_SIGNED_1 = 6,
- X86_64_RELOC_SIGNED_2 = 7,
- X86_64_RELOC_SIGNED_4 = 8,
- X86_64_RELOC_TLV = 9
- };
-
- // Values for segment_command.initprot.
- // From <mach/vm_prot.h>
- enum {
- VM_PROT_READ = 0x1,
- VM_PROT_WRITE = 0x2,
- VM_PROT_EXECUTE = 0x4
- };
-
- // Structs from <mach-o/loader.h>
-
- struct mach_header {
- uint32_t magic;
- uint32_t cputype;
- uint32_t cpusubtype;
- uint32_t filetype;
- uint32_t ncmds;
- uint32_t sizeofcmds;
- uint32_t flags;
- };
-
- struct mach_header_64 {
- uint32_t magic;
- uint32_t cputype;
- uint32_t cpusubtype;
- uint32_t filetype;
- uint32_t ncmds;
- uint32_t sizeofcmds;
- uint32_t flags;
- uint32_t reserved;
- };
-
- struct load_command {
- uint32_t cmd;
- uint32_t cmdsize;
- };
-
- struct segment_command {
- uint32_t cmd;
- uint32_t cmdsize;
- char segname[16];
- uint32_t vmaddr;
- uint32_t vmsize;
- uint32_t fileoff;
- uint32_t filesize;
- uint32_t maxprot;
- uint32_t initprot;
- uint32_t nsects;
- uint32_t flags;
- };
-
- struct segment_command_64 {
- uint32_t cmd;
- uint32_t cmdsize;
- char segname[16];
- uint64_t vmaddr;
- uint64_t vmsize;
- uint64_t fileoff;
- uint64_t filesize;
- uint32_t maxprot;
- uint32_t initprot;
- uint32_t nsects;
- uint32_t flags;
- };
-
- struct section {
- char sectname[16];
- char segname[16];
- uint32_t addr;
- uint32_t size;
- uint32_t offset;
- uint32_t align;
- uint32_t reloff;
- uint32_t nreloc;
- uint32_t flags;
- uint32_t reserved1;
- uint32_t reserved2;
- };
-
- struct section_64 {
- char sectname[16];
- char segname[16];
- uint64_t addr;
- uint64_t size;
- uint32_t offset;
- uint32_t align;
- uint32_t reloff;
- uint32_t nreloc;
- uint32_t flags;
- uint32_t reserved1;
- uint32_t reserved2;
- uint32_t reserved3;
- };
-
- struct fvmlib {
- uint32_t name;
- uint32_t minor_version;
- uint32_t header_addr;
- };
-
- // The fvmlib_command is obsolete and no longer supported.
- struct fvmlib_command {
- uint32_t cmd;
- uint32_t cmdsize;
- struct fvmlib fvmlib;
- };
-
- struct dylib {
- uint32_t name;
- uint32_t timestamp;
- uint32_t current_version;
- uint32_t compatibility_version;
- };
-
- struct dylib_command {
- uint32_t cmd;
- uint32_t cmdsize;
- struct dylib dylib;
- };
-
- struct sub_framework_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t umbrella;
- };
-
- struct sub_client_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t client;
- };
-
- struct sub_umbrella_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t sub_umbrella;
- };
-
- struct sub_library_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t sub_library;
- };
-
- // The prebound_dylib_command is obsolete and no longer supported.
- struct prebound_dylib_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t name;
- uint32_t nmodules;
- uint32_t linked_modules;
- };
-
- struct dylinker_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t name;
- };
-
- struct thread_command {
- uint32_t cmd;
- uint32_t cmdsize;
- };
-
- struct routines_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t init_address;
- uint32_t init_module;
- uint32_t reserved1;
- uint32_t reserved2;
- uint32_t reserved3;
- uint32_t reserved4;
- uint32_t reserved5;
- uint32_t reserved6;
- };
-
- struct routines_command_64 {
- uint32_t cmd;
- uint32_t cmdsize;
- uint64_t init_address;
- uint64_t init_module;
- uint64_t reserved1;
- uint64_t reserved2;
- uint64_t reserved3;
- uint64_t reserved4;
- uint64_t reserved5;
- uint64_t reserved6;
- };
-
- struct symtab_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t symoff;
- uint32_t nsyms;
- uint32_t stroff;
- uint32_t strsize;
- };
-
- struct dysymtab_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t ilocalsym;
- uint32_t nlocalsym;
- uint32_t iextdefsym;
- uint32_t nextdefsym;
- uint32_t iundefsym;
- uint32_t nundefsym;
- uint32_t tocoff;
- uint32_t ntoc;
- uint32_t modtaboff;
- uint32_t nmodtab;
- uint32_t extrefsymoff;
- uint32_t nextrefsyms;
- uint32_t indirectsymoff;
- uint32_t nindirectsyms;
- uint32_t extreloff;
- uint32_t nextrel;
- uint32_t locreloff;
- uint32_t nlocrel;
- };
-
- struct dylib_table_of_contents {
- uint32_t symbol_index;
- uint32_t module_index;
- };
-
- struct dylib_module {
- uint32_t module_name;
- uint32_t iextdefsym;
- uint32_t nextdefsym;
- uint32_t irefsym;
- uint32_t nrefsym;
- uint32_t ilocalsym;
- uint32_t nlocalsym;
- uint32_t iextrel;
- uint32_t nextrel;
- uint32_t iinit_iterm;
- uint32_t ninit_nterm;
- uint32_t objc_module_info_addr;
- uint32_t objc_module_info_size;
- };
-
- struct dylib_module_64 {
- uint32_t module_name;
- uint32_t iextdefsym;
- uint32_t nextdefsym;
- uint32_t irefsym;
- uint32_t nrefsym;
- uint32_t ilocalsym;
- uint32_t nlocalsym;
- uint32_t iextrel;
- uint32_t nextrel;
- uint32_t iinit_iterm;
- uint32_t ninit_nterm;
- uint32_t objc_module_info_size;
- uint64_t objc_module_info_addr;
- };
-
- struct dylib_reference {
- uint32_t isym:24,
- flags:8;
- };
-
- // The twolevel_hints_command is obsolete and no longer supported.
- struct twolevel_hints_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t offset;
- uint32_t nhints;
- };
-
- // The twolevel_hints_command is obsolete and no longer supported.
- struct twolevel_hint {
- uint32_t isub_image:8,
- itoc:24;
- };
-
- // The prebind_cksum_command is obsolete and no longer supported.
- struct prebind_cksum_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t cksum;
- };
-
- struct uuid_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint8_t uuid[16];
- };
-
- struct rpath_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t path;
- };
-
- struct linkedit_data_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t dataoff;
- uint32_t datasize;
- };
-
- struct data_in_code_entry {
- uint32_t offset;
- uint16_t length;
- uint16_t kind;
- };
-
- struct source_version_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint64_t version;
- };
-
- struct encryption_info_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t cryptoff;
- uint32_t cryptsize;
- uint32_t cryptid;
- };
-
- struct encryption_info_command_64 {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t cryptoff;
- uint32_t cryptsize;
- uint32_t cryptid;
- uint32_t pad;
- };
-
- struct version_min_command {
- uint32_t cmd; // LC_VERSION_MIN_MACOSX or
- // LC_VERSION_MIN_IPHONEOS
- uint32_t cmdsize; // sizeof(struct version_min_command)
- uint32_t version; // X.Y.Z is encoded in nibbles xxxx.yy.zz
- uint32_t sdk; // X.Y.Z is encoded in nibbles xxxx.yy.zz
- };
-
- struct dyld_info_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t rebase_off;
- uint32_t rebase_size;
- uint32_t bind_off;
- uint32_t bind_size;
- uint32_t weak_bind_off;
- uint32_t weak_bind_size;
- uint32_t lazy_bind_off;
- uint32_t lazy_bind_size;
- uint32_t export_off;
- uint32_t export_size;
- };
-
- struct linker_option_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t count;
- };
-
- // The symseg_command is obsolete and no longer supported.
- struct symseg_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t offset;
- uint32_t size;
- };
-
- // The ident_command is obsolete and no longer supported.
- struct ident_command {
- uint32_t cmd;
- uint32_t cmdsize;
- };
-
- // The fvmfile_command is obsolete and no longer supported.
- struct fvmfile_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint32_t name;
- uint32_t header_addr;
- };
-
- struct tlv_descriptor_32 {
- uint32_t thunk;
- uint32_t key;
- uint32_t offset;
- };
-
- struct tlv_descriptor_64 {
- uint64_t thunk;
- uint64_t key;
- uint64_t offset;
- };
-
- struct tlv_descriptor {
- uintptr_t thunk;
- uintptr_t key;
- uintptr_t offset;
- };
-
- struct entry_point_command {
- uint32_t cmd;
- uint32_t cmdsize;
- uint64_t entryoff;
- uint64_t stacksize;
- };
-
- // Structs from <mach-o/fat.h>
- struct fat_header {
- uint32_t magic;
- uint32_t nfat_arch;
- };
-
- struct fat_arch {
- uint32_t cputype;
- uint32_t cpusubtype;
- uint32_t offset;
- uint32_t size;
- uint32_t align;
- };
-
- struct fat_arch_64 {
- uint32_t cputype;
- uint32_t cpusubtype;
- uint64_t offset;
- uint64_t size;
- uint32_t align;
- uint32_t reserved;
- };
-
- // Structs from <mach-o/reloc.h>
- struct relocation_info {
- int32_t r_address;
- uint32_t r_symbolnum:24,
- r_pcrel:1,
- r_length:2,
- r_extern:1,
- r_type:4;
- };
-
- struct scattered_relocation_info {
-#if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && (BYTE_ORDER == BIG_ENDIAN)
- uint32_t r_scattered:1,
- r_pcrel:1,
- r_length:2,
- r_type:4,
- r_address:24;
-#else
- uint32_t r_address:24,
- r_type:4,
- r_length:2,
- r_pcrel:1,
- r_scattered:1;
-#endif
- int32_t r_value;
- };
-
- // Structs NOT from <mach-o/reloc.h>, but that make LLVM's life easier
- struct any_relocation_info {
- uint32_t r_word0, r_word1;
- };
-
- // Structs from <mach-o/nlist.h>
- struct nlist_base {
- uint32_t n_strx;
- uint8_t n_type;
- uint8_t n_sect;
- uint16_t n_desc;
- };
-
- struct nlist {
- uint32_t n_strx;
- uint8_t n_type;
- uint8_t n_sect;
- int16_t n_desc;
- uint32_t n_value;
- };
-
- struct nlist_64 {
- uint32_t n_strx;
- uint8_t n_type;
- uint8_t n_sect;
- uint16_t n_desc;
- uint64_t n_value;
- };
-
- // Byte order swapping functions for MachO structs
-
- inline void swapStruct(fat_header &mh) {
- sys::swapByteOrder(mh.magic);
- sys::swapByteOrder(mh.nfat_arch);
- }
-
- inline void swapStruct(fat_arch &mh) {
- sys::swapByteOrder(mh.cputype);
- sys::swapByteOrder(mh.cpusubtype);
- sys::swapByteOrder(mh.offset);
- sys::swapByteOrder(mh.size);
- sys::swapByteOrder(mh.align);
- }
-
- inline void swapStruct(fat_arch_64 &mh) {
- sys::swapByteOrder(mh.cputype);
- sys::swapByteOrder(mh.cpusubtype);
- sys::swapByteOrder(mh.offset);
- sys::swapByteOrder(mh.size);
- sys::swapByteOrder(mh.align);
- sys::swapByteOrder(mh.reserved);
- }
-
- inline void swapStruct(mach_header &mh) {
- sys::swapByteOrder(mh.magic);
- sys::swapByteOrder(mh.cputype);
- sys::swapByteOrder(mh.cpusubtype);
- sys::swapByteOrder(mh.filetype);
- sys::swapByteOrder(mh.ncmds);
- sys::swapByteOrder(mh.sizeofcmds);
- sys::swapByteOrder(mh.flags);
- }
-
- inline void swapStruct(mach_header_64 &H) {
- sys::swapByteOrder(H.magic);
- sys::swapByteOrder(H.cputype);
- sys::swapByteOrder(H.cpusubtype);
- sys::swapByteOrder(H.filetype);
- sys::swapByteOrder(H.ncmds);
- sys::swapByteOrder(H.sizeofcmds);
- sys::swapByteOrder(H.flags);
- sys::swapByteOrder(H.reserved);
- }
-
- inline void swapStruct(load_command &lc) {
- sys::swapByteOrder(lc.cmd);
- sys::swapByteOrder(lc.cmdsize);
- }
-
- inline void swapStruct(symtab_command &lc) {
- sys::swapByteOrder(lc.cmd);
- sys::swapByteOrder(lc.cmdsize);
- sys::swapByteOrder(lc.symoff);
- sys::swapByteOrder(lc.nsyms);
- sys::swapByteOrder(lc.stroff);
- sys::swapByteOrder(lc.strsize);
- }
-
- inline void swapStruct(segment_command_64 &seg) {
- sys::swapByteOrder(seg.cmd);
- sys::swapByteOrder(seg.cmdsize);
- sys::swapByteOrder(seg.vmaddr);
- sys::swapByteOrder(seg.vmsize);
- sys::swapByteOrder(seg.fileoff);
- sys::swapByteOrder(seg.filesize);
- sys::swapByteOrder(seg.maxprot);
- sys::swapByteOrder(seg.initprot);
- sys::swapByteOrder(seg.nsects);
- sys::swapByteOrder(seg.flags);
- }
-
- inline void swapStruct(segment_command &seg) {
- sys::swapByteOrder(seg.cmd);
- sys::swapByteOrder(seg.cmdsize);
- sys::swapByteOrder(seg.vmaddr);
- sys::swapByteOrder(seg.vmsize);
- sys::swapByteOrder(seg.fileoff);
- sys::swapByteOrder(seg.filesize);
- sys::swapByteOrder(seg.maxprot);
- sys::swapByteOrder(seg.initprot);
- sys::swapByteOrder(seg.nsects);
- sys::swapByteOrder(seg.flags);
- }
-
- inline void swapStruct(section_64 &sect) {
- sys::swapByteOrder(sect.addr);
- sys::swapByteOrder(sect.size);
- sys::swapByteOrder(sect.offset);
- sys::swapByteOrder(sect.align);
- sys::swapByteOrder(sect.reloff);
- sys::swapByteOrder(sect.nreloc);
- sys::swapByteOrder(sect.flags);
- sys::swapByteOrder(sect.reserved1);
- sys::swapByteOrder(sect.reserved2);
- }
-
- inline void swapStruct(section &sect) {
- sys::swapByteOrder(sect.addr);
- sys::swapByteOrder(sect.size);
- sys::swapByteOrder(sect.offset);
- sys::swapByteOrder(sect.align);
- sys::swapByteOrder(sect.reloff);
- sys::swapByteOrder(sect.nreloc);
- sys::swapByteOrder(sect.flags);
- sys::swapByteOrder(sect.reserved1);
- sys::swapByteOrder(sect.reserved2);
- }
-
- inline void swapStruct(dyld_info_command &info) {
- sys::swapByteOrder(info.cmd);
- sys::swapByteOrder(info.cmdsize);
- sys::swapByteOrder(info.rebase_off);
- sys::swapByteOrder(info.rebase_size);
- sys::swapByteOrder(info.bind_off);
- sys::swapByteOrder(info.bind_size);
- sys::swapByteOrder(info.weak_bind_off);
- sys::swapByteOrder(info.weak_bind_size);
- sys::swapByteOrder(info.lazy_bind_off);
- sys::swapByteOrder(info.lazy_bind_size);
- sys::swapByteOrder(info.export_off);
- sys::swapByteOrder(info.export_size);
- }
-
- inline void swapStruct(dylib_command &d) {
- sys::swapByteOrder(d.cmd);
- sys::swapByteOrder(d.cmdsize);
- sys::swapByteOrder(d.dylib.name);
- sys::swapByteOrder(d.dylib.timestamp);
- sys::swapByteOrder(d.dylib.current_version);
- sys::swapByteOrder(d.dylib.compatibility_version);
- }
-
- inline void swapStruct(sub_framework_command &s) {
- sys::swapByteOrder(s.cmd);
- sys::swapByteOrder(s.cmdsize);
- sys::swapByteOrder(s.umbrella);
- }
-
- inline void swapStruct(sub_umbrella_command &s) {
- sys::swapByteOrder(s.cmd);
- sys::swapByteOrder(s.cmdsize);
- sys::swapByteOrder(s.sub_umbrella);
- }
-
- inline void swapStruct(sub_library_command &s) {
- sys::swapByteOrder(s.cmd);
- sys::swapByteOrder(s.cmdsize);
- sys::swapByteOrder(s.sub_library);
- }
-
- inline void swapStruct(sub_client_command &s) {
- sys::swapByteOrder(s.cmd);
- sys::swapByteOrder(s.cmdsize);
- sys::swapByteOrder(s.client);
- }
-
- inline void swapStruct(routines_command &r) {
- sys::swapByteOrder(r.cmd);
- sys::swapByteOrder(r.cmdsize);
- sys::swapByteOrder(r.init_address);
- sys::swapByteOrder(r.init_module);
- sys::swapByteOrder(r.reserved1);
- sys::swapByteOrder(r.reserved2);
- sys::swapByteOrder(r.reserved3);
- sys::swapByteOrder(r.reserved4);
- sys::swapByteOrder(r.reserved5);
- sys::swapByteOrder(r.reserved6);
- }
-
- inline void swapStruct(routines_command_64 &r) {
- sys::swapByteOrder(r.cmd);
- sys::swapByteOrder(r.cmdsize);
- sys::swapByteOrder(r.init_address);
- sys::swapByteOrder(r.init_module);
- sys::swapByteOrder(r.reserved1);
- sys::swapByteOrder(r.reserved2);
- sys::swapByteOrder(r.reserved3);
- sys::swapByteOrder(r.reserved4);
- sys::swapByteOrder(r.reserved5);
- sys::swapByteOrder(r.reserved6);
- }
-
- inline void swapStruct(thread_command &t) {
- sys::swapByteOrder(t.cmd);
- sys::swapByteOrder(t.cmdsize);
- }
-
- inline void swapStruct(dylinker_command &d) {
- sys::swapByteOrder(d.cmd);
- sys::swapByteOrder(d.cmdsize);
- sys::swapByteOrder(d.name);
- }
-
- inline void swapStruct(uuid_command &u) {
- sys::swapByteOrder(u.cmd);
- sys::swapByteOrder(u.cmdsize);
- }
-
- inline void swapStruct(rpath_command &r) {
- sys::swapByteOrder(r.cmd);
- sys::swapByteOrder(r.cmdsize);
- sys::swapByteOrder(r.path);
- }
-
- inline void swapStruct(source_version_command &s) {
- sys::swapByteOrder(s.cmd);
- sys::swapByteOrder(s.cmdsize);
- sys::swapByteOrder(s.version);
- }
-
- inline void swapStruct(entry_point_command &e) {
- sys::swapByteOrder(e.cmd);
- sys::swapByteOrder(e.cmdsize);
- sys::swapByteOrder(e.entryoff);
- sys::swapByteOrder(e.stacksize);
- }
-
- inline void swapStruct(encryption_info_command &e) {
- sys::swapByteOrder(e.cmd);
- sys::swapByteOrder(e.cmdsize);
- sys::swapByteOrder(e.cryptoff);
- sys::swapByteOrder(e.cryptsize);
- sys::swapByteOrder(e.cryptid);
- }
-
- inline void swapStruct(encryption_info_command_64 &e) {
- sys::swapByteOrder(e.cmd);
- sys::swapByteOrder(e.cmdsize);
- sys::swapByteOrder(e.cryptoff);
- sys::swapByteOrder(e.cryptsize);
- sys::swapByteOrder(e.cryptid);
- sys::swapByteOrder(e.pad);
- }
-
- inline void swapStruct(dysymtab_command &dst) {
- sys::swapByteOrder(dst.cmd);
- sys::swapByteOrder(dst.cmdsize);
- sys::swapByteOrder(dst.ilocalsym);
- sys::swapByteOrder(dst.nlocalsym);
- sys::swapByteOrder(dst.iextdefsym);
- sys::swapByteOrder(dst.nextdefsym);
- sys::swapByteOrder(dst.iundefsym);
- sys::swapByteOrder(dst.nundefsym);
- sys::swapByteOrder(dst.tocoff);
- sys::swapByteOrder(dst.ntoc);
- sys::swapByteOrder(dst.modtaboff);
- sys::swapByteOrder(dst.nmodtab);
- sys::swapByteOrder(dst.extrefsymoff);
- sys::swapByteOrder(dst.nextrefsyms);
- sys::swapByteOrder(dst.indirectsymoff);
- sys::swapByteOrder(dst.nindirectsyms);
- sys::swapByteOrder(dst.extreloff);
- sys::swapByteOrder(dst.nextrel);
- sys::swapByteOrder(dst.locreloff);
- sys::swapByteOrder(dst.nlocrel);
- }
-
- inline void swapStruct(any_relocation_info &reloc) {
- sys::swapByteOrder(reloc.r_word0);
- sys::swapByteOrder(reloc.r_word1);
- }
-
- inline void swapStruct(nlist_base &S) {
- sys::swapByteOrder(S.n_strx);
- sys::swapByteOrder(S.n_desc);
- }
-
- inline void swapStruct(nlist &sym) {
- sys::swapByteOrder(sym.n_strx);
- sys::swapByteOrder(sym.n_desc);
- sys::swapByteOrder(sym.n_value);
- }
-
- inline void swapStruct(nlist_64 &sym) {
- sys::swapByteOrder(sym.n_strx);
- sys::swapByteOrder(sym.n_desc);
- sys::swapByteOrder(sym.n_value);
- }
-
- inline void swapStruct(linkedit_data_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.dataoff);
- sys::swapByteOrder(C.datasize);
- }
-
- inline void swapStruct(linker_option_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.count);
- }
-
- inline void swapStruct(version_min_command&C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.version);
- sys::swapByteOrder(C.sdk);
- }
-
- inline void swapStruct(data_in_code_entry &C) {
- sys::swapByteOrder(C.offset);
- sys::swapByteOrder(C.length);
- sys::swapByteOrder(C.kind);
- }
-
- inline void swapStruct(uint32_t &C) {
- sys::swapByteOrder(C);
- }
-
- // The prebind_cksum_command is obsolete and no longer supported.
- inline void swapStruct(prebind_cksum_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.cksum);
- }
-
- // The twolevel_hints_command is obsolete and no longer supported.
- inline void swapStruct(twolevel_hints_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.offset);
- sys::swapByteOrder(C.nhints);
- }
-
- // The prebound_dylib_command is obsolete and no longer supported.
- inline void swapStruct(prebound_dylib_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.name);
- sys::swapByteOrder(C.nmodules);
- sys::swapByteOrder(C.linked_modules);
- }
-
- // The fvmfile_command is obsolete and no longer supported.
- inline void swapStruct(fvmfile_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.name);
- sys::swapByteOrder(C.header_addr);
- }
-
- // The symseg_command is obsolete and no longer supported.
- inline void swapStruct(symseg_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- sys::swapByteOrder(C.offset);
- sys::swapByteOrder(C.size);
- }
-
- // The ident_command is obsolete and no longer supported.
- inline void swapStruct(ident_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- }
-
- inline void swapStruct(fvmlib &C) {
- sys::swapByteOrder(C.name);
- sys::swapByteOrder(C.minor_version);
- sys::swapByteOrder(C.header_addr);
- }
-
- // The fvmlib_command is obsolete and no longer supported.
- inline void swapStruct(fvmlib_command &C) {
- sys::swapByteOrder(C.cmd);
- sys::swapByteOrder(C.cmdsize);
- swapStruct(C.fvmlib);
- }
-
- // Get/Set functions from <mach-o/nlist.h>
-
- static inline uint16_t GET_LIBRARY_ORDINAL(uint16_t n_desc) {
- return (((n_desc) >> 8u) & 0xffu);
- }
-
- static inline void SET_LIBRARY_ORDINAL(uint16_t &n_desc, uint8_t ordinal) {
- n_desc = (((n_desc) & 0x00ff) | (((ordinal) & 0xff) << 8));
- }
-
- static inline uint8_t GET_COMM_ALIGN (uint16_t n_desc) {
- return (n_desc >> 8u) & 0x0fu;
- }
-
- static inline void SET_COMM_ALIGN (uint16_t &n_desc, uint8_t align) {
- n_desc = ((n_desc & 0xf0ffu) | ((align & 0x0fu) << 8u));
- }
-
- // Enums from <mach/machine.h>
- enum : uint32_t {
- // Capability bits used in the definition of cpu_type.
- CPU_ARCH_MASK = 0xff000000, // Mask for architecture bits
- CPU_ARCH_ABI64 = 0x01000000 // 64 bit ABI
- };
-
- // Constants for the cputype field.
- enum CPUType {
- CPU_TYPE_ANY = -1,
- CPU_TYPE_X86 = 7,
- CPU_TYPE_I386 = CPU_TYPE_X86,
- CPU_TYPE_X86_64 = CPU_TYPE_X86 | CPU_ARCH_ABI64,
- /* CPU_TYPE_MIPS = 8, */
- CPU_TYPE_MC98000 = 10, // Old Motorola PowerPC
- CPU_TYPE_ARM = 12,
- CPU_TYPE_ARM64 = CPU_TYPE_ARM | CPU_ARCH_ABI64,
- CPU_TYPE_SPARC = 14,
- CPU_TYPE_POWERPC = 18,
- CPU_TYPE_POWERPC64 = CPU_TYPE_POWERPC | CPU_ARCH_ABI64
- };
-
- enum : uint32_t {
- // Capability bits used in the definition of cpusubtype.
- CPU_SUBTYPE_MASK = 0xff000000, // Mask for architecture bits
- CPU_SUBTYPE_LIB64 = 0x80000000, // 64 bit libraries
-
- // Special CPU subtype constants.
- CPU_SUBTYPE_MULTIPLE = ~0u
- };
-
- // Constants for the cpusubtype field.
- enum CPUSubTypeX86 {
- CPU_SUBTYPE_I386_ALL = 3,
- CPU_SUBTYPE_386 = 3,
- CPU_SUBTYPE_486 = 4,
- CPU_SUBTYPE_486SX = 0x84,
- CPU_SUBTYPE_586 = 5,
- CPU_SUBTYPE_PENT = CPU_SUBTYPE_586,
- CPU_SUBTYPE_PENTPRO = 0x16,
- CPU_SUBTYPE_PENTII_M3 = 0x36,
- CPU_SUBTYPE_PENTII_M5 = 0x56,
- CPU_SUBTYPE_CELERON = 0x67,
- CPU_SUBTYPE_CELERON_MOBILE = 0x77,
- CPU_SUBTYPE_PENTIUM_3 = 0x08,
- CPU_SUBTYPE_PENTIUM_3_M = 0x18,
- CPU_SUBTYPE_PENTIUM_3_XEON = 0x28,
- CPU_SUBTYPE_PENTIUM_M = 0x09,
- CPU_SUBTYPE_PENTIUM_4 = 0x0a,
- CPU_SUBTYPE_PENTIUM_4_M = 0x1a,
- CPU_SUBTYPE_ITANIUM = 0x0b,
- CPU_SUBTYPE_ITANIUM_2 = 0x1b,
- CPU_SUBTYPE_XEON = 0x0c,
- CPU_SUBTYPE_XEON_MP = 0x1c,
-
- CPU_SUBTYPE_X86_ALL = 3,
- CPU_SUBTYPE_X86_64_ALL = 3,
- CPU_SUBTYPE_X86_ARCH1 = 4,
- CPU_SUBTYPE_X86_64_H = 8
- };
- static inline int CPU_SUBTYPE_INTEL(int Family, int Model) {
- return Family | (Model << 4);
- }
- static inline int CPU_SUBTYPE_INTEL_FAMILY(CPUSubTypeX86 ST) {
- return ((int)ST) & 0x0f;
- }
- static inline int CPU_SUBTYPE_INTEL_MODEL(CPUSubTypeX86 ST) {
- return ((int)ST) >> 4;
- }
- enum {
- CPU_SUBTYPE_INTEL_FAMILY_MAX = 15,
- CPU_SUBTYPE_INTEL_MODEL_ALL = 0
- };
-
- enum CPUSubTypeARM {
- CPU_SUBTYPE_ARM_ALL = 0,
- CPU_SUBTYPE_ARM_V4T = 5,
- CPU_SUBTYPE_ARM_V6 = 6,
- CPU_SUBTYPE_ARM_V5 = 7,
- CPU_SUBTYPE_ARM_V5TEJ = 7,
- CPU_SUBTYPE_ARM_XSCALE = 8,
- CPU_SUBTYPE_ARM_V7 = 9,
- // unused ARM_V7F = 10,
- CPU_SUBTYPE_ARM_V7S = 11,
- CPU_SUBTYPE_ARM_V7K = 12,
- CPU_SUBTYPE_ARM_V6M = 14,
- CPU_SUBTYPE_ARM_V7M = 15,
- CPU_SUBTYPE_ARM_V7EM = 16
- };
-
- enum CPUSubTypeARM64 {
- CPU_SUBTYPE_ARM64_ALL = 0
- };
-
- enum CPUSubTypeSPARC {
- CPU_SUBTYPE_SPARC_ALL = 0
- };
-
- enum CPUSubTypePowerPC {
- CPU_SUBTYPE_POWERPC_ALL = 0,
- CPU_SUBTYPE_POWERPC_601 = 1,
- CPU_SUBTYPE_POWERPC_602 = 2,
- CPU_SUBTYPE_POWERPC_603 = 3,
- CPU_SUBTYPE_POWERPC_603e = 4,
- CPU_SUBTYPE_POWERPC_603ev = 5,
- CPU_SUBTYPE_POWERPC_604 = 6,
- CPU_SUBTYPE_POWERPC_604e = 7,
- CPU_SUBTYPE_POWERPC_620 = 8,
- CPU_SUBTYPE_POWERPC_750 = 9,
- CPU_SUBTYPE_POWERPC_7400 = 10,
- CPU_SUBTYPE_POWERPC_7450 = 11,
- CPU_SUBTYPE_POWERPC_970 = 100,
-
- CPU_SUBTYPE_MC980000_ALL = CPU_SUBTYPE_POWERPC_ALL,
- CPU_SUBTYPE_MC98601 = CPU_SUBTYPE_POWERPC_601
- };
-
- struct x86_thread_state64_t {
- uint64_t rax;
- uint64_t rbx;
- uint64_t rcx;
- uint64_t rdx;
- uint64_t rdi;
- uint64_t rsi;
- uint64_t rbp;
- uint64_t rsp;
- uint64_t r8;
- uint64_t r9;
- uint64_t r10;
- uint64_t r11;
- uint64_t r12;
- uint64_t r13;
- uint64_t r14;
- uint64_t r15;
- uint64_t rip;
- uint64_t rflags;
- uint64_t cs;
- uint64_t fs;
- uint64_t gs;
- };
-
- enum x86_fp_control_precis {
- x86_FP_PREC_24B = 0,
- x86_FP_PREC_53B = 2,
- x86_FP_PREC_64B = 3
- };
-
- enum x86_fp_control_rc {
- x86_FP_RND_NEAR = 0,
- x86_FP_RND_DOWN = 1,
- x86_FP_RND_UP = 2,
- x86_FP_CHOP = 3
- };
-
- struct fp_control_t {
- unsigned short
- invalid :1,
- denorm :1,
- zdiv :1,
- ovrfl :1,
- undfl :1,
- precis :1,
- :2,
- pc :2,
- rc :2,
- :1,
- :3;
- };
-
- struct fp_status_t {
- unsigned short
- invalid :1,
- denorm :1,
- zdiv :1,
- ovrfl :1,
- undfl :1,
- precis :1,
- stkflt :1,
- errsumm :1,
- c0 :1,
- c1 :1,
- c2 :1,
- tos :3,
- c3 :1,
- busy :1;
- };
-
- struct mmst_reg_t {
- char mmst_reg[10];
- char mmst_rsrv[6];
- };
-
- struct xmm_reg_t {
- char xmm_reg[16];
- };
-
- struct x86_float_state64_t {
- int32_t fpu_reserved[2];
- fp_control_t fpu_fcw;
- fp_status_t fpu_fsw;
- uint8_t fpu_ftw;
- uint8_t fpu_rsrv1;
- uint16_t fpu_fop;
- uint32_t fpu_ip;
- uint16_t fpu_cs;
- uint16_t fpu_rsrv2;
- uint32_t fpu_dp;
- uint16_t fpu_ds;
- uint16_t fpu_rsrv3;
- uint32_t fpu_mxcsr;
- uint32_t fpu_mxcsrmask;
- mmst_reg_t fpu_stmm0;
- mmst_reg_t fpu_stmm1;
- mmst_reg_t fpu_stmm2;
- mmst_reg_t fpu_stmm3;
- mmst_reg_t fpu_stmm4;
- mmst_reg_t fpu_stmm5;
- mmst_reg_t fpu_stmm6;
- mmst_reg_t fpu_stmm7;
- xmm_reg_t fpu_xmm0;
- xmm_reg_t fpu_xmm1;
- xmm_reg_t fpu_xmm2;
- xmm_reg_t fpu_xmm3;
- xmm_reg_t fpu_xmm4;
- xmm_reg_t fpu_xmm5;
- xmm_reg_t fpu_xmm6;
- xmm_reg_t fpu_xmm7;
- xmm_reg_t fpu_xmm8;
- xmm_reg_t fpu_xmm9;
- xmm_reg_t fpu_xmm10;
- xmm_reg_t fpu_xmm11;
- xmm_reg_t fpu_xmm12;
- xmm_reg_t fpu_xmm13;
- xmm_reg_t fpu_xmm14;
- xmm_reg_t fpu_xmm15;
- char fpu_rsrv4[6*16];
- uint32_t fpu_reserved1;
- };
-
- struct x86_exception_state64_t {
- uint16_t trapno;
- uint16_t cpu;
- uint32_t err;
- uint64_t faultvaddr;
- };
-
- inline void swapStruct(x86_thread_state64_t &x) {
- sys::swapByteOrder(x.rax);
- sys::swapByteOrder(x.rbx);
- sys::swapByteOrder(x.rcx);
- sys::swapByteOrder(x.rdx);
- sys::swapByteOrder(x.rdi);
- sys::swapByteOrder(x.rsi);
- sys::swapByteOrder(x.rbp);
- sys::swapByteOrder(x.rsp);
- sys::swapByteOrder(x.r8);
- sys::swapByteOrder(x.r9);
- sys::swapByteOrder(x.r10);
- sys::swapByteOrder(x.r11);
- sys::swapByteOrder(x.r12);
- sys::swapByteOrder(x.r13);
- sys::swapByteOrder(x.r14);
- sys::swapByteOrder(x.r15);
- sys::swapByteOrder(x.rip);
- sys::swapByteOrder(x.rflags);
- sys::swapByteOrder(x.cs);
- sys::swapByteOrder(x.fs);
- sys::swapByteOrder(x.gs);
- }
-
- inline void swapStruct(x86_float_state64_t &x) {
- sys::swapByteOrder(x.fpu_reserved[0]);
- sys::swapByteOrder(x.fpu_reserved[1]);
- // TODO swap: fp_control_t fpu_fcw;
- // TODO swap: fp_status_t fpu_fsw;
- sys::swapByteOrder(x.fpu_fop);
- sys::swapByteOrder(x.fpu_ip);
- sys::swapByteOrder(x.fpu_cs);
- sys::swapByteOrder(x.fpu_rsrv2);
- sys::swapByteOrder(x.fpu_dp);
- sys::swapByteOrder(x.fpu_ds);
- sys::swapByteOrder(x.fpu_rsrv3);
- sys::swapByteOrder(x.fpu_mxcsr);
- sys::swapByteOrder(x.fpu_mxcsrmask);
- sys::swapByteOrder(x.fpu_reserved1);
- }
-
- inline void swapStruct(x86_exception_state64_t &x) {
- sys::swapByteOrder(x.trapno);
- sys::swapByteOrder(x.cpu);
- sys::swapByteOrder(x.err);
- sys::swapByteOrder(x.faultvaddr);
- }
-
- struct x86_state_hdr_t {
- uint32_t flavor;
- uint32_t count;
- };
-
- struct x86_thread_state_t {
- x86_state_hdr_t tsh;
- union {
- x86_thread_state64_t ts64;
- } uts;
- };
-
- struct x86_float_state_t {
- x86_state_hdr_t fsh;
- union {
- x86_float_state64_t fs64;
- } ufs;
- };
-
- struct x86_exception_state_t {
- x86_state_hdr_t esh;
- union {
- x86_exception_state64_t es64;
- } ues;
- };
-
- inline void swapStruct(x86_state_hdr_t &x) {
- sys::swapByteOrder(x.flavor);
- sys::swapByteOrder(x.count);
- }
-
- enum X86ThreadFlavors {
- x86_THREAD_STATE32 = 1,
- x86_FLOAT_STATE32 = 2,
- x86_EXCEPTION_STATE32 = 3,
- x86_THREAD_STATE64 = 4,
- x86_FLOAT_STATE64 = 5,
- x86_EXCEPTION_STATE64 = 6,
- x86_THREAD_STATE = 7,
- x86_FLOAT_STATE = 8,
- x86_EXCEPTION_STATE = 9,
- x86_DEBUG_STATE32 = 10,
- x86_DEBUG_STATE64 = 11,
- x86_DEBUG_STATE = 12
- };
-
- inline void swapStruct(x86_thread_state_t &x) {
- swapStruct(x.tsh);
- if (x.tsh.flavor == x86_THREAD_STATE64)
- swapStruct(x.uts.ts64);
- }
-
- inline void swapStruct(x86_float_state_t &x) {
- swapStruct(x.fsh);
- if (x.fsh.flavor == x86_FLOAT_STATE64)
- swapStruct(x.ufs.fs64);
- }
-
- inline void swapStruct(x86_exception_state_t &x) {
- swapStruct(x.esh);
- if (x.esh.flavor == x86_EXCEPTION_STATE64)
- swapStruct(x.ues.es64);
- }
-
- const uint32_t x86_THREAD_STATE64_COUNT =
- sizeof(x86_thread_state64_t) / sizeof(uint32_t);
- const uint32_t x86_FLOAT_STATE64_COUNT =
- sizeof(x86_float_state64_t) / sizeof(uint32_t);
- const uint32_t x86_EXCEPTION_STATE64_COUNT =
- sizeof(x86_exception_state64_t) / sizeof(uint32_t);
-
- const uint32_t x86_THREAD_STATE_COUNT =
- sizeof(x86_thread_state_t) / sizeof(uint32_t);
- const uint32_t x86_FLOAT_STATE_COUNT =
- sizeof(x86_float_state_t) / sizeof(uint32_t);
- const uint32_t x86_EXCEPTION_STATE_COUNT =
- sizeof(x86_exception_state_t) / sizeof(uint32_t);
-
- struct arm_thread_state32_t {
- uint32_t r[13];
- uint32_t sp;
- uint32_t lr;
- uint32_t pc;
- uint32_t cpsr;
- };
-
- inline void swapStruct(arm_thread_state32_t &x) {
- for (int i = 0; i < 13; i++)
- sys::swapByteOrder(x.r[i]);
- sys::swapByteOrder(x.sp);
- sys::swapByteOrder(x.lr);
- sys::swapByteOrder(x.pc);
- sys::swapByteOrder(x.cpsr);
- }
-
- struct arm_thread_state64_t {
- uint64_t x[29];
- uint64_t fp;
- uint64_t lr;
- uint64_t sp;
- uint64_t pc;
- uint32_t cpsr;
- uint32_t pad;
- };
-
- inline void swapStruct(arm_thread_state64_t &x) {
- for (int i = 0; i < 29; i++)
- sys::swapByteOrder(x.x[i]);
- sys::swapByteOrder(x.fp);
- sys::swapByteOrder(x.lr);
- sys::swapByteOrder(x.sp);
- sys::swapByteOrder(x.pc);
- sys::swapByteOrder(x.cpsr);
- }
-
- struct arm_state_hdr_t {
- uint32_t flavor;
- uint32_t count;
- };
-
- struct arm_thread_state_t {
- arm_state_hdr_t tsh;
- union {
- arm_thread_state32_t ts32;
- } uts;
- };
-
- inline void swapStruct(arm_state_hdr_t &x) {
- sys::swapByteOrder(x.flavor);
- sys::swapByteOrder(x.count);
- }
-
- enum ARMThreadFlavors {
- ARM_THREAD_STATE = 1,
- ARM_VFP_STATE = 2,
- ARM_EXCEPTION_STATE = 3,
- ARM_DEBUG_STATE = 4,
- ARN_THREAD_STATE_NONE = 5,
- ARM_THREAD_STATE64 = 6,
- ARM_EXCEPTION_STATE64 = 7
- };
-
- inline void swapStruct(arm_thread_state_t &x) {
- swapStruct(x.tsh);
- if (x.tsh.flavor == ARM_THREAD_STATE)
- swapStruct(x.uts.ts32);
- }
-
- const uint32_t ARM_THREAD_STATE_COUNT =
- sizeof(arm_thread_state32_t) / sizeof(uint32_t);
-
- const uint32_t ARM_THREAD_STATE64_COUNT =
- sizeof(arm_thread_state64_t) / sizeof(uint32_t);
-
- struct ppc_thread_state32_t {
- uint32_t srr0;
- uint32_t srr1;
- uint32_t r0;
- uint32_t r1;
- uint32_t r2;
- uint32_t r3;
- uint32_t r4;
- uint32_t r5;
- uint32_t r6;
- uint32_t r7;
- uint32_t r8;
- uint32_t r9;
- uint32_t r10;
- uint32_t r11;
- uint32_t r12;
- uint32_t r13;
- uint32_t r14;
- uint32_t r15;
- uint32_t r16;
- uint32_t r17;
- uint32_t r18;
- uint32_t r19;
- uint32_t r20;
- uint32_t r21;
- uint32_t r22;
- uint32_t r23;
- uint32_t r24;
- uint32_t r25;
- uint32_t r26;
- uint32_t r27;
- uint32_t r28;
- uint32_t r29;
- uint32_t r30;
- uint32_t r31;
- uint32_t ct;
- uint32_t xer;
- uint32_t lr;
- uint32_t ctr;
- uint32_t mq;
- uint32_t vrsave;
- };
-
- inline void swapStruct(ppc_thread_state32_t &x) {
- sys::swapByteOrder(x.srr0);
- sys::swapByteOrder(x.srr1);
- sys::swapByteOrder(x.r0);
- sys::swapByteOrder(x.r1);
- sys::swapByteOrder(x.r2);
- sys::swapByteOrder(x.r3);
- sys::swapByteOrder(x.r4);
- sys::swapByteOrder(x.r5);
- sys::swapByteOrder(x.r6);
- sys::swapByteOrder(x.r7);
- sys::swapByteOrder(x.r8);
- sys::swapByteOrder(x.r9);
- sys::swapByteOrder(x.r10);
- sys::swapByteOrder(x.r11);
- sys::swapByteOrder(x.r12);
- sys::swapByteOrder(x.r13);
- sys::swapByteOrder(x.r14);
- sys::swapByteOrder(x.r15);
- sys::swapByteOrder(x.r16);
- sys::swapByteOrder(x.r17);
- sys::swapByteOrder(x.r18);
- sys::swapByteOrder(x.r19);
- sys::swapByteOrder(x.r20);
- sys::swapByteOrder(x.r21);
- sys::swapByteOrder(x.r22);
- sys::swapByteOrder(x.r23);
- sys::swapByteOrder(x.r24);
- sys::swapByteOrder(x.r25);
- sys::swapByteOrder(x.r26);
- sys::swapByteOrder(x.r27);
- sys::swapByteOrder(x.r28);
- sys::swapByteOrder(x.r29);
- sys::swapByteOrder(x.r30);
- sys::swapByteOrder(x.r31);
- sys::swapByteOrder(x.ct);
- sys::swapByteOrder(x.xer);
- sys::swapByteOrder(x.lr);
- sys::swapByteOrder(x.ctr);
- sys::swapByteOrder(x.mq);
- sys::swapByteOrder(x.vrsave);
- }
-
- struct ppc_state_hdr_t {
- uint32_t flavor;
- uint32_t count;
- };
-
- struct ppc_thread_state_t {
- ppc_state_hdr_t tsh;
- union {
- ppc_thread_state32_t ts32;
- } uts;
- };
-
- inline void swapStruct(ppc_state_hdr_t &x) {
- sys::swapByteOrder(x.flavor);
- sys::swapByteOrder(x.count);
- }
-
- enum PPCThreadFlavors {
- PPC_THREAD_STATE = 1,
- PPC_FLOAT_STATE = 2,
- PPC_EXCEPTION_STATE = 3,
- PPC_VECTOR_STATE = 4,
- PPC_THREAD_STATE64 = 5,
- PPC_EXCEPTION_STATE64 = 6,
- PPC_THREAD_STATE_NONE = 7
- };
-
- inline void swapStruct(ppc_thread_state_t &x) {
- swapStruct(x.tsh);
- if (x.tsh.flavor == PPC_THREAD_STATE)
- swapStruct(x.uts.ts32);
- }
-
- const uint32_t PPC_THREAD_STATE_COUNT =
- sizeof(ppc_thread_state32_t) / sizeof(uint32_t);
-
- // Define a union of all load command structs
- #define LOAD_COMMAND_STRUCT(LCStruct) LCStruct LCStruct##_data;
-
- union macho_load_command {
- #include "llvm/Support/MachO.def"
- };
-
- } // end namespace MachO
-} // end namespace llvm
-
-#endif
diff --git a/contrib/llvm/include/llvm/Support/ManagedStatic.h b/contrib/llvm/include/llvm/Support/ManagedStatic.h
index 7ce86ee..b4bf321 100644
--- a/contrib/llvm/include/llvm/Support/ManagedStatic.h
+++ b/contrib/llvm/include/llvm/Support/ManagedStatic.h
@@ -14,25 +14,22 @@
#ifndef LLVM_SUPPORT_MANAGEDSTATIC_H
#define LLVM_SUPPORT_MANAGEDSTATIC_H
-#include "llvm/Support/Compiler.h"
#include <atomic>
#include <cstddef>
namespace llvm {
/// object_creator - Helper method for ManagedStatic.
-template<class C>
-LLVM_LIBRARY_VISIBILITY void* object_creator() {
- return new C();
-}
+template <class C> struct object_creator {
+ static void *call() { return new C(); }
+};
/// object_deleter - Helper method for ManagedStatic.
///
-template <typename T> struct LLVM_LIBRARY_VISIBILITY object_deleter {
+template <typename T> struct object_deleter {
static void call(void *Ptr) { delete (T *)Ptr; }
};
-template <typename T, size_t N>
-struct LLVM_LIBRARY_VISIBILITY object_deleter<T[N]> {
+template <typename T, size_t N> struct object_deleter<T[N]> {
static void call(void *Ptr) { delete[](T *)Ptr; }
};
@@ -59,14 +56,15 @@ public:
/// libraries that link in LLVM components) and for making destruction be
/// explicit through the llvm_shutdown() function call.
///
-template<class C>
+template <class C, class Creator = object_creator<C>,
+ class Deleter = object_deleter<C>>
class ManagedStatic : public ManagedStaticBase {
public:
// Accessors.
C &operator*() {
void *Tmp = Ptr.load(std::memory_order_acquire);
if (!Tmp)
- RegisterManagedStatic(object_creator<C>, object_deleter<C>::call);
+ RegisterManagedStatic(Creator::call, Deleter::call);
return *static_cast<C *>(Ptr.load(std::memory_order_relaxed));
}
@@ -76,7 +74,7 @@ public:
const C &operator*() const {
void *Tmp = Ptr.load(std::memory_order_acquire);
if (!Tmp)
- RegisterManagedStatic(object_creator<C>, object_deleter<C>::call);
+ RegisterManagedStatic(Creator::call, Deleter::call);
return *static_cast<C *>(Ptr.load(std::memory_order_relaxed));
}
diff --git a/contrib/llvm/include/llvm/Support/MathExtras.h b/contrib/llvm/include/llvm/Support/MathExtras.h
index 77970f4..fd29865 100644
--- a/contrib/llvm/include/llvm/Support/MathExtras.h
+++ b/contrib/llvm/include/llvm/Support/MathExtras.h
@@ -18,9 +18,10 @@
#include "llvm/Support/SwapByteOrder.h"
#include <algorithm>
#include <cassert>
+#include <climits>
#include <cstring>
-#include <type_traits>
#include <limits>
+#include <type_traits>
#ifdef _MSC_VER
#include <intrin.h>
@@ -112,7 +113,7 @@ std::size_t countTrailingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
static_assert(std::numeric_limits<T>::is_integer &&
!std::numeric_limits<T>::is_signed,
"Only unsigned integral types are allowed.");
- return detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
+ return llvm::detail::TrailingZerosCounter<T, sizeof(T)>::count(Val, ZB);
}
namespace detail {
@@ -181,7 +182,7 @@ std::size_t countLeadingZeros(T Val, ZeroBehavior ZB = ZB_Width) {
static_assert(std::numeric_limits<T>::is_integer &&
!std::numeric_limits<T>::is_signed,
"Only unsigned integral types are allowed.");
- return detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
+ return llvm::detail::LeadingZerosCounter<T, sizeof(T)>::count(Val, ZB);
}
/// \brief Get the index of the first set bit starting from the least
@@ -198,6 +199,33 @@ template <typename T> T findFirstSet(T Val, ZeroBehavior ZB = ZB_Max) {
return countTrailingZeros(Val, ZB_Undefined);
}
+/// \brief Create a bitmask with the N right-most bits set to 1, and all other
+/// bits set to 0. Only unsigned types are allowed.
+template <typename T> T maskTrailingOnes(unsigned N) {
+ static_assert(std::is_unsigned<T>::value, "Invalid type!");
+ const unsigned Bits = CHAR_BIT * sizeof(T);
+ assert(N <= Bits && "Invalid bit index");
+ return N == 0 ? 0 : (T(-1) >> (Bits - N));
+}
+
+/// \brief Create a bitmask with the N left-most bits set to 1, and all other
+/// bits set to 0. Only unsigned types are allowed.
+template <typename T> T maskLeadingOnes(unsigned N) {
+ return ~maskTrailingOnes<T>(CHAR_BIT * sizeof(T) - N);
+}
+
+/// \brief Create a bitmask with the N right-most bits set to 0, and all other
+/// bits set to 1. Only unsigned types are allowed.
+template <typename T> T maskTrailingZeros(unsigned N) {
+ return maskLeadingOnes<T>(CHAR_BIT * sizeof(T) - N);
+}
+
+/// \brief Create a bitmask with the N left-most bits set to 0, and all other
+/// bits set to 1. Only unsigned types are allowed.
+template <typename T> T maskLeadingZeros(unsigned N) {
+ return maskTrailingOnes<T>(CHAR_BIT * sizeof(T) - N);
+}
+
/// \brief Get the index of the last set bit starting from the least
/// significant bit.
///
@@ -244,23 +272,22 @@ T reverseBits(T Val) {
// type overloading so that signed and unsigned integers can be used without
// ambiguity.
-/// Hi_32 - This function returns the high 32 bits of a 64 bit value.
+/// Return the high 32 bits of a 64 bit value.
constexpr inline uint32_t Hi_32(uint64_t Value) {
return static_cast<uint32_t>(Value >> 32);
}
-/// Lo_32 - This function returns the low 32 bits of a 64 bit value.
+/// Return the low 32 bits of a 64 bit value.
constexpr inline uint32_t Lo_32(uint64_t Value) {
return static_cast<uint32_t>(Value);
}
-/// Make_64 - This functions makes a 64-bit integer from a high / low pair of
-/// 32-bit integers.
+/// Make a 64-bit integer from a high / low pair of 32-bit integers.
constexpr inline uint64_t Make_64(uint32_t High, uint32_t Low) {
return ((uint64_t)High << 32) | (uint64_t)Low;
}
-/// isInt - Checks if an integer fits into the given bit width.
+/// Checks if an integer fits into the given bit width.
template <unsigned N> constexpr inline bool isInt(int64_t x) {
return N >= 64 || (-(INT64_C(1)<<(N-1)) <= x && x < (INT64_C(1)<<(N-1)));
}
@@ -275,8 +302,7 @@ template <> constexpr inline bool isInt<32>(int64_t x) {
return static_cast<int32_t>(x) == x;
}
-/// isShiftedInt<N,S> - Checks if a signed integer is an N bit number shifted
-/// left by S.
+/// Checks if a signed integer is an N bit number shifted left by S.
template <unsigned N, unsigned S>
constexpr inline bool isShiftedInt(int64_t x) {
static_assert(
@@ -285,7 +311,7 @@ constexpr inline bool isShiftedInt(int64_t x) {
return isInt<N + S>(x) && (x % (UINT64_C(1) << S) == 0);
}
-/// isUInt - Checks if an unsigned integer fits into the given bit width.
+/// Checks if an unsigned integer fits into the given bit width.
///
/// This is written as two functions rather than as simply
///
@@ -355,71 +381,63 @@ inline int64_t maxIntN(int64_t N) {
return (UINT64_C(1) << (N - 1)) - 1;
}
-/// isUIntN - Checks if an unsigned integer fits into the given (dynamic)
-/// bit width.
+/// Checks if an unsigned integer fits into the given (dynamic) bit width.
inline bool isUIntN(unsigned N, uint64_t x) {
return N >= 64 || x <= maxUIntN(N);
}
-/// isIntN - Checks if an signed integer fits into the given (dynamic)
-/// bit width.
+/// Checks if an signed integer fits into the given (dynamic) bit width.
inline bool isIntN(unsigned N, int64_t x) {
return N >= 64 || (minIntN(N) <= x && x <= maxIntN(N));
}
-/// isMask_32 - This function returns true if the argument is a non-empty
-/// sequence of ones starting at the least significant bit with the remainder
-/// zero (32 bit version). Ex. isMask_32(0x0000FFFFU) == true.
+/// Return true if the argument is a non-empty sequence of ones starting at the
+/// least significant bit with the remainder zero (32 bit version).
+/// Ex. isMask_32(0x0000FFFFU) == true.
constexpr inline bool isMask_32(uint32_t Value) {
return Value && ((Value + 1) & Value) == 0;
}
-/// isMask_64 - This function returns true if the argument is a non-empty
-/// sequence of ones starting at the least significant bit with the remainder
-/// zero (64 bit version).
+/// Return true if the argument is a non-empty sequence of ones starting at the
+/// least significant bit with the remainder zero (64 bit version).
constexpr inline bool isMask_64(uint64_t Value) {
return Value && ((Value + 1) & Value) == 0;
}
-/// isShiftedMask_32 - This function returns true if the argument contains a
-/// non-empty sequence of ones with the remainder zero (32 bit version.)
-/// Ex. isShiftedMask_32(0x0000FF00U) == true.
+/// Return true if the argument contains a non-empty sequence of ones with the
+/// remainder zero (32 bit version.) Ex. isShiftedMask_32(0x0000FF00U) == true.
constexpr inline bool isShiftedMask_32(uint32_t Value) {
return Value && isMask_32((Value - 1) | Value);
}
-/// isShiftedMask_64 - This function returns true if the argument contains a
-/// non-empty sequence of ones with the remainder zero (64 bit version.)
+/// Return true if the argument contains a non-empty sequence of ones with the
+/// remainder zero (64 bit version.)
constexpr inline bool isShiftedMask_64(uint64_t Value) {
return Value && isMask_64((Value - 1) | Value);
}
-/// isPowerOf2_32 - This function returns true if the argument is a power of
-/// two > 0. Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
+/// Return true if the argument is a power of two > 0.
+/// Ex. isPowerOf2_32(0x00100000U) == true (32 bit edition.)
constexpr inline bool isPowerOf2_32(uint32_t Value) {
return Value && !(Value & (Value - 1));
}
-/// isPowerOf2_64 - This function returns true if the argument is a power of two
-/// > 0 (64 bit edition.)
+/// Return true if the argument is a power of two > 0 (64 bit edition.)
constexpr inline bool isPowerOf2_64(uint64_t Value) {
return Value && !(Value & (Value - int64_t(1L)));
}
-/// ByteSwap_16 - This function returns a byte-swapped representation of the
-/// 16-bit argument, Value.
+/// Return a byte-swapped representation of the 16-bit argument.
inline uint16_t ByteSwap_16(uint16_t Value) {
return sys::SwapByteOrder_16(Value);
}
-/// ByteSwap_32 - This function returns a byte-swapped representation of the
-/// 32-bit argument, Value.
+/// Return a byte-swapped representation of the 32-bit argument.
inline uint32_t ByteSwap_32(uint32_t Value) {
return sys::SwapByteOrder_32(Value);
}
-/// ByteSwap_64 - This function returns a byte-swapped representation of the
-/// 64-bit argument, Value.
+/// Return a byte-swapped representation of the 64-bit argument.
inline uint64_t ByteSwap_64(uint64_t Value) {
return sys::SwapByteOrder_64(Value);
}
@@ -427,7 +445,7 @@ inline uint64_t ByteSwap_64(uint64_t Value) {
/// \brief Count the number of ones from the most significant bit to the first
/// zero bit.
///
-/// Ex. CountLeadingOnes(0xFF0FFF00) == 8.
+/// Ex. countLeadingOnes(0xFF0FFF00) == 8.
/// Only unsigned integral types are allowed.
///
/// \param ZB the behavior on an input of all ones. Only ZB_Width and
@@ -498,7 +516,7 @@ inline unsigned countPopulation(T Value) {
return detail::PopulationCounter<T, sizeof(T)>::count(Value);
}
-/// Log2 - This function returns the log base 2 of the specified value
+/// Return the log base 2 of the specified value.
inline double Log2(double Value) {
#if defined(__ANDROID_API__) && __ANDROID_API__ < 18
return __builtin_log(Value) / __builtin_log(2.0);
@@ -507,34 +525,33 @@ inline double Log2(double Value) {
#endif
}
-/// Log2_32 - This function returns the floor log base 2 of the specified value,
-/// -1 if the value is zero. (32 bit edition.)
+/// Return the floor log base 2 of the specified value, -1 if the value is zero.
+/// (32 bit edition.)
/// Ex. Log2_32(32) == 5, Log2_32(1) == 0, Log2_32(0) == -1, Log2_32(6) == 2
inline unsigned Log2_32(uint32_t Value) {
return 31 - countLeadingZeros(Value);
}
-/// Log2_64 - This function returns the floor log base 2 of the specified value,
-/// -1 if the value is zero. (64 bit edition.)
+/// Return the floor log base 2 of the specified value, -1 if the value is zero.
+/// (64 bit edition.)
inline unsigned Log2_64(uint64_t Value) {
return 63 - countLeadingZeros(Value);
}
-/// Log2_32_Ceil - This function returns the ceil log base 2 of the specified
-/// value, 32 if the value is zero. (32 bit edition).
+/// Return the ceil log base 2 of the specified value, 32 if the value is zero.
+/// (32 bit edition).
/// Ex. Log2_32_Ceil(32) == 5, Log2_32_Ceil(1) == 0, Log2_32_Ceil(6) == 3
inline unsigned Log2_32_Ceil(uint32_t Value) {
return 32 - countLeadingZeros(Value - 1);
}
-/// Log2_64_Ceil - This function returns the ceil log base 2 of the specified
-/// value, 64 if the value is zero. (64 bit edition.)
+/// Return the ceil log base 2 of the specified value, 64 if the value is zero.
+/// (64 bit edition.)
inline unsigned Log2_64_Ceil(uint64_t Value) {
return 64 - countLeadingZeros(Value - 1);
}
-/// GreatestCommonDivisor64 - Return the greatest common divisor of the two
-/// values using Euclid's algorithm.
+/// Return the greatest common divisor of the values using Euclid's algorithm.
inline uint64_t GreatestCommonDivisor64(uint64_t A, uint64_t B) {
while (B) {
uint64_t T = B;
@@ -544,8 +561,7 @@ inline uint64_t GreatestCommonDivisor64(uint64_t A, uint64_t B) {
return A;
}
-/// BitsToDouble - This function takes a 64-bit integer and returns the bit
-/// equivalent double.
+/// This function takes a 64-bit integer and returns the bit equivalent double.
inline double BitsToDouble(uint64_t Bits) {
double D;
static_assert(sizeof(uint64_t) == sizeof(double), "Unexpected type sizes");
@@ -553,8 +569,7 @@ inline double BitsToDouble(uint64_t Bits) {
return D;
}
-/// BitsToFloat - This function takes a 32-bit integer and returns the bit
-/// equivalent float.
+/// This function takes a 32-bit integer and returns the bit equivalent float.
inline float BitsToFloat(uint32_t Bits) {
float F;
static_assert(sizeof(uint32_t) == sizeof(float), "Unexpected type sizes");
@@ -562,10 +577,9 @@ inline float BitsToFloat(uint32_t Bits) {
return F;
}
-/// DoubleToBits - This function takes a double and returns the bit
-/// equivalent 64-bit integer. Note that copying doubles around
-/// changes the bits of NaNs on some hosts, notably x86, so this
-/// routine cannot be used if these bits are needed.
+/// This function takes a double and returns the bit equivalent 64-bit integer.
+/// Note that copying doubles around changes the bits of NaNs on some hosts,
+/// notably x86, so this routine cannot be used if these bits are needed.
inline uint64_t DoubleToBits(double Double) {
uint64_t Bits;
static_assert(sizeof(uint64_t) == sizeof(double), "Unexpected type sizes");
@@ -573,10 +587,9 @@ inline uint64_t DoubleToBits(double Double) {
return Bits;
}
-/// FloatToBits - This function takes a float and returns the bit
-/// equivalent 32-bit integer. Note that copying floats around
-/// changes the bits of NaNs on some hosts, notably x86, so this
-/// routine cannot be used if these bits are needed.
+/// This function takes a float and returns the bit equivalent 32-bit integer.
+/// Note that copying floats around changes the bits of NaNs on some hosts,
+/// notably x86, so this routine cannot be used if these bits are needed.
inline uint32_t FloatToBits(float Float) {
uint32_t Bits;
static_assert(sizeof(uint32_t) == sizeof(float), "Unexpected type sizes");
@@ -584,8 +597,8 @@ inline uint32_t FloatToBits(float Float) {
return Bits;
}
-/// MinAlign - A and B are either alignments or offsets. Return the minimum
-/// alignment that may be assumed after adding the two together.
+/// A and B are either alignments or offsets. Return the minimum alignment that
+/// may be assumed after adding the two together.
constexpr inline uint64_t MinAlign(uint64_t A, uint64_t B) {
// The largest power of 2 that divides both A and B.
//
@@ -614,8 +627,8 @@ inline size_t alignmentAdjustment(const void *Ptr, size_t Alignment) {
return alignAddr(Ptr, Alignment) - (uintptr_t)Ptr;
}
-/// NextPowerOf2 - Returns the next power of two (in 64-bits)
-/// that is strictly greater than A. Returns zero on overflow.
+/// Returns the next power of two (in 64-bits) that is strictly greater than A.
+/// Returns zero on overflow.
inline uint64_t NextPowerOf2(uint64_t A) {
A |= (A >> 1);
A |= (A >> 2);
diff --git a/contrib/llvm/include/llvm/Support/MemoryBuffer.h b/contrib/llvm/include/llvm/Support/MemoryBuffer.h
index f739d19..73f0251 100644
--- a/contrib/llvm/include/llvm/Support/MemoryBuffer.h
+++ b/contrib/llvm/include/llvm/Support/MemoryBuffer.h
@@ -14,14 +14,14 @@
#ifndef LLVM_SUPPORT_MEMORYBUFFER_H
#define LLVM_SUPPORT_MEMORYBUFFER_H
+#include "llvm-c/Types.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/CBindingWrapping.h"
#include "llvm/Support/ErrorOr.h"
-#include "llvm-c/Types.h"
-#include <memory>
#include <cstddef>
#include <cstdint>
+#include <memory>
namespace llvm {
@@ -69,12 +69,12 @@ public:
/// means that the client knows that the file exists and that it has the
/// specified size.
///
- /// \param IsVolatileSize Set to true to indicate that the file size may be
- /// changing, e.g. when libclang tries to parse while the user is
- /// editing/updating the file.
+ /// \param IsVolatile Set to true to indicate that the contents of the file
+ /// can change outside the user's control, e.g. when libclang tries to parse
+ /// while the user is editing/updating the file or if the file is on an NFS.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getFile(const Twine &Filename, int64_t FileSize = -1,
- bool RequiresNullTerminator = true, bool IsVolatileSize = false);
+ bool RequiresNullTerminator = true, bool IsVolatile = false);
/// Read all of the specified file into a MemoryBuffer as a stream
/// (i.e. until EOF reached). This is useful for special files that
@@ -87,17 +87,17 @@ public:
/// Since this is in the middle of a file, the buffer is not null terminated.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getOpenFileSlice(int FD, const Twine &Filename, uint64_t MapSize,
- int64_t Offset);
+ int64_t Offset, bool IsVolatile = false);
/// Given an already-open file descriptor, read the file and return a
/// MemoryBuffer.
///
- /// \param IsVolatileSize Set to true to indicate that the file size may be
- /// changing, e.g. when libclang tries to parse while the user is
- /// editing/updating the file.
+ /// \param IsVolatile Set to true to indicate that the contents of the file
+ /// can change outside the user's control, e.g. when libclang tries to parse
+ /// while the user is editing/updating the file or if the file is on an NFS.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
getOpenFile(int FD, const Twine &Filename, uint64_t FileSize,
- bool RequiresNullTerminator = true, bool IsVolatileSize = false);
+ bool RequiresNullTerminator = true, bool IsVolatile = false);
/// Open the specified memory range as a MemoryBuffer. Note that InputData
/// must be null terminated if RequiresNullTerminator is true.
@@ -136,7 +136,7 @@ public:
/// Map a subrange of the specified file as a MemoryBuffer.
static ErrorOr<std::unique_ptr<MemoryBuffer>>
- getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset);
+ getFileSlice(const Twine &Filename, uint64_t MapSize, uint64_t Offset, bool IsVolatile = false);
//===--------------------------------------------------------------------===//
// Provided for performance analysis.
diff --git a/contrib/llvm/include/llvm/Support/Parallel.h b/contrib/llvm/include/llvm/Support/Parallel.h
new file mode 100644
index 0000000..e36e0cc
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/Parallel.h
@@ -0,0 +1,249 @@
+//===- llvm/Support/Parallel.h - Parallel algorithms ----------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_SUPPORT_PARALLEL_H
+#define LLVM_SUPPORT_PARALLEL_H
+
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/Config/llvm-config.h"
+#include "llvm/Support/MathExtras.h"
+
+#include <algorithm>
+#include <condition_variable>
+#include <functional>
+#include <mutex>
+
+#if defined(_MSC_VER) && LLVM_ENABLE_THREADS
+#pragma warning(push)
+#pragma warning(disable : 4530)
+#include <concrt.h>
+#include <ppl.h>
+#pragma warning(pop)
+#endif
+
+namespace llvm {
+
+namespace parallel {
+struct sequential_execution_policy {};
+struct parallel_execution_policy {};
+
+template <typename T>
+struct is_execution_policy
+ : public std::integral_constant<
+ bool, llvm::is_one_of<T, sequential_execution_policy,
+ parallel_execution_policy>::value> {};
+
+constexpr sequential_execution_policy seq{};
+constexpr parallel_execution_policy par{};
+
+namespace detail {
+
+#if LLVM_ENABLE_THREADS
+
+class Latch {
+ uint32_t Count;
+ mutable std::mutex Mutex;
+ mutable std::condition_variable Cond;
+
+public:
+ explicit Latch(uint32_t Count = 0) : Count(Count) {}
+ ~Latch() { sync(); }
+
+ void inc() {
+ std::unique_lock<std::mutex> lock(Mutex);
+ ++Count;
+ }
+
+ void dec() {
+ std::unique_lock<std::mutex> lock(Mutex);
+ if (--Count == 0)
+ Cond.notify_all();
+ }
+
+ void sync() const {
+ std::unique_lock<std::mutex> lock(Mutex);
+ Cond.wait(lock, [&] { return Count == 0; });
+ }
+};
+
+class TaskGroup {
+ Latch L;
+
+public:
+ void spawn(std::function<void()> f);
+
+ void sync() const { L.sync(); }
+};
+
+#if defined(_MSC_VER)
+template <class RandomAccessIterator, class Comparator>
+void parallel_sort(RandomAccessIterator Start, RandomAccessIterator End,
+ const Comparator &Comp) {
+ concurrency::parallel_sort(Start, End, Comp);
+}
+template <class IterTy, class FuncTy>
+void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) {
+ concurrency::parallel_for_each(Begin, End, Fn);
+}
+
+template <class IndexTy, class FuncTy>
+void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn) {
+ concurrency::parallel_for(Begin, End, Fn);
+}
+
+#else
+const ptrdiff_t MinParallelSize = 1024;
+
+/// \brief Inclusive median.
+template <class RandomAccessIterator, class Comparator>
+RandomAccessIterator medianOf3(RandomAccessIterator Start,
+ RandomAccessIterator End,
+ const Comparator &Comp) {
+ RandomAccessIterator Mid = Start + (std::distance(Start, End) / 2);
+ return Comp(*Start, *(End - 1))
+ ? (Comp(*Mid, *(End - 1)) ? (Comp(*Start, *Mid) ? Mid : Start)
+ : End - 1)
+ : (Comp(*Mid, *Start) ? (Comp(*(End - 1), *Mid) ? Mid : End - 1)
+ : Start);
+}
+
+template <class RandomAccessIterator, class Comparator>
+void parallel_quick_sort(RandomAccessIterator Start, RandomAccessIterator End,
+ const Comparator &Comp, TaskGroup &TG, size_t Depth) {
+ // Do a sequential sort for small inputs.
+ if (std::distance(Start, End) < detail::MinParallelSize || Depth == 0) {
+ std::sort(Start, End, Comp);
+ return;
+ }
+
+ // Partition.
+ auto Pivot = medianOf3(Start, End, Comp);
+ // Move Pivot to End.
+ std::swap(*(End - 1), *Pivot);
+ Pivot = std::partition(Start, End - 1, [&Comp, End](decltype(*Start) V) {
+ return Comp(V, *(End - 1));
+ });
+ // Move Pivot to middle of partition.
+ std::swap(*Pivot, *(End - 1));
+
+ // Recurse.
+ TG.spawn([=, &Comp, &TG] {
+ parallel_quick_sort(Start, Pivot, Comp, TG, Depth - 1);
+ });
+ parallel_quick_sort(Pivot + 1, End, Comp, TG, Depth - 1);
+}
+
+template <class RandomAccessIterator, class Comparator>
+void parallel_sort(RandomAccessIterator Start, RandomAccessIterator End,
+ const Comparator &Comp) {
+ TaskGroup TG;
+ parallel_quick_sort(Start, End, Comp, TG,
+ llvm::Log2_64(std::distance(Start, End)) + 1);
+}
+
+template <class IterTy, class FuncTy>
+void parallel_for_each(IterTy Begin, IterTy End, FuncTy Fn) {
+ // TaskGroup has a relatively high overhead, so we want to reduce
+ // the number of spawn() calls. We'll create up to 1024 tasks here.
+ // (Note that 1024 is an arbitrary number. This code probably needs
+ // improving to take the number of available cores into account.)
+ ptrdiff_t TaskSize = std::distance(Begin, End) / 1024;
+ if (TaskSize == 0)
+ TaskSize = 1;
+
+ TaskGroup TG;
+ while (TaskSize <= std::distance(Begin, End)) {
+ TG.spawn([=, &Fn] { std::for_each(Begin, Begin + TaskSize, Fn); });
+ Begin += TaskSize;
+ }
+ TG.spawn([=, &Fn] { std::for_each(Begin, End, Fn); });
+}
+
+template <class IndexTy, class FuncTy>
+void parallel_for_each_n(IndexTy Begin, IndexTy End, FuncTy Fn) {
+ ptrdiff_t TaskSize = (End - Begin) / 1024;
+ if (TaskSize == 0)
+ TaskSize = 1;
+
+ TaskGroup TG;
+ IndexTy I = Begin;
+ for (; I + TaskSize < End; I += TaskSize) {
+ TG.spawn([=, &Fn] {
+ for (IndexTy J = I, E = I + TaskSize; J != E; ++J)
+ Fn(J);
+ });
+ }
+ TG.spawn([=, &Fn] {
+ for (IndexTy J = I; J < End; ++J)
+ Fn(J);
+ });
+}
+
+#endif
+
+#endif
+
+template <typename Iter>
+using DefComparator =
+ std::less<typename std::iterator_traits<Iter>::value_type>;
+
+} // namespace detail
+
+// sequential algorithm implementations.
+template <class Policy, class RandomAccessIterator,
+ class Comparator = detail::DefComparator<RandomAccessIterator>>
+void sort(Policy policy, RandomAccessIterator Start, RandomAccessIterator End,
+ const Comparator &Comp = Comparator()) {
+ static_assert(is_execution_policy<Policy>::value,
+ "Invalid execution policy!");
+ std::sort(Start, End, Comp);
+}
+
+template <class Policy, class IterTy, class FuncTy>
+void for_each(Policy policy, IterTy Begin, IterTy End, FuncTy Fn) {
+ static_assert(is_execution_policy<Policy>::value,
+ "Invalid execution policy!");
+ std::for_each(Begin, End, Fn);
+}
+
+template <class Policy, class IndexTy, class FuncTy>
+void for_each_n(Policy policy, IndexTy Begin, IndexTy End, FuncTy Fn) {
+ static_assert(is_execution_policy<Policy>::value,
+ "Invalid execution policy!");
+ for (IndexTy I = Begin; I != End; ++I)
+ Fn(I);
+}
+
+// Parallel algorithm implementations, only available when LLVM_ENABLE_THREADS
+// is true.
+#if LLVM_ENABLE_THREADS
+template <class RandomAccessIterator,
+ class Comparator = detail::DefComparator<RandomAccessIterator>>
+void sort(parallel_execution_policy policy, RandomAccessIterator Start,
+ RandomAccessIterator End, const Comparator &Comp = Comparator()) {
+ detail::parallel_sort(Start, End, Comp);
+}
+
+template <class IterTy, class FuncTy>
+void for_each(parallel_execution_policy policy, IterTy Begin, IterTy End,
+ FuncTy Fn) {
+ detail::parallel_for_each(Begin, End, Fn);
+}
+
+template <class IndexTy, class FuncTy>
+void for_each_n(parallel_execution_policy policy, IndexTy Begin, IndexTy End,
+ FuncTy Fn) {
+ detail::parallel_for_each_n(Begin, End, Fn);
+}
+#endif
+
+} // namespace parallel
+} // namespace llvm
+
+#endif // LLVM_SUPPORT_PARALLEL_H
diff --git a/contrib/llvm/include/llvm/Support/Path.h b/contrib/llvm/include/llvm/Support/Path.h
index 2bbcef0..e597967 100644
--- a/contrib/llvm/include/llvm/Support/Path.h
+++ b/contrib/llvm/include/llvm/Support/Path.h
@@ -17,6 +17,7 @@
#define LLVM_SUPPORT_PATH_H
#include "llvm/ADT/Twine.h"
+#include "llvm/ADT/iterator.h"
#include "llvm/Support/DataTypes.h"
#include <iterator>
@@ -24,6 +25,8 @@ namespace llvm {
namespace sys {
namespace path {
+enum class Style { windows, posix, native };
+
/// @name Lexical Component Iterator
/// @{
@@ -47,21 +50,21 @@ namespace path {
/// C:\foo\bar => C:,/,foo,bar
/// @endcode
class const_iterator
- : public std::iterator<std::input_iterator_tag, const StringRef> {
+ : public iterator_facade_base<const_iterator, std::input_iterator_tag,
+ const StringRef> {
StringRef Path; ///< The entire path.
StringRef Component; ///< The current component. Not necessarily in Path.
size_t Position; ///< The iterators current position within Path.
+ Style S; ///< The path style to use.
// An end iterator has Position = Path.size() + 1.
- friend const_iterator begin(StringRef path);
+ friend const_iterator begin(StringRef path, Style style);
friend const_iterator end(StringRef path);
public:
reference operator*() const { return Component; }
- pointer operator->() const { return &Component; }
const_iterator &operator++(); // preincrement
bool operator==(const const_iterator &RHS) const;
- bool operator!=(const const_iterator &RHS) const { return !(*this == RHS); }
/// @brief Difference in bytes between this and RHS.
ptrdiff_t operator-(const const_iterator &RHS) const;
@@ -73,20 +76,20 @@ public:
/// \a path in reverse order. The traversal order is exactly reversed from that
/// of \a const_iterator
class reverse_iterator
- : public std::iterator<std::input_iterator_tag, const StringRef> {
+ : public iterator_facade_base<reverse_iterator, std::input_iterator_tag,
+ const StringRef> {
StringRef Path; ///< The entire path.
StringRef Component; ///< The current component. Not necessarily in Path.
size_t Position; ///< The iterators current position within Path.
+ Style S; ///< The path style to use.
- friend reverse_iterator rbegin(StringRef path);
+ friend reverse_iterator rbegin(StringRef path, Style style);
friend reverse_iterator rend(StringRef path);
public:
reference operator*() const { return Component; }
- pointer operator->() const { return &Component; }
reverse_iterator &operator++(); // preincrement
bool operator==(const reverse_iterator &RHS) const;
- bool operator!=(const reverse_iterator &RHS) const { return !(*this == RHS); }
/// @brief Difference in bytes between this and RHS.
ptrdiff_t operator-(const reverse_iterator &RHS) const;
@@ -95,7 +98,7 @@ public:
/// @brief Get begin iterator over \a path.
/// @param path Input path.
/// @returns Iterator initialized with the first component of \a path.
-const_iterator begin(StringRef path);
+const_iterator begin(StringRef path, Style style = Style::native);
/// @brief Get end iterator over \a path.
/// @param path Input path.
@@ -105,7 +108,7 @@ const_iterator end(StringRef path);
/// @brief Get reverse begin iterator over \a path.
/// @param path Input path.
/// @returns Iterator initialized with the first reverse component of \a path.
-reverse_iterator rbegin(StringRef path);
+reverse_iterator rbegin(StringRef path, Style style = Style::native);
/// @brief Get reverse end iterator over \a path.
/// @param path Input path.
@@ -126,7 +129,7 @@ reverse_iterator rend(StringRef path);
/// @endcode
///
/// @param path A path that is modified to not have a file component.
-void remove_filename(SmallVectorImpl<char> &path);
+void remove_filename(SmallVectorImpl<char> &path, Style style = Style::native);
/// @brief Replace the file extension of \a path with \a extension.
///
@@ -140,7 +143,8 @@ void remove_filename(SmallVectorImpl<char> &path);
/// @param extension The extension to be added. It may be empty. It may also
/// optionally start with a '.', if it does not, one will be
/// prepended.
-void replace_extension(SmallVectorImpl<char> &path, const Twine &extension);
+void replace_extension(SmallVectorImpl<char> &path, const Twine &extension,
+ Style style = Style::native);
/// @brief Replace matching path prefix with another path.
///
@@ -156,8 +160,8 @@ void replace_extension(SmallVectorImpl<char> &path, const Twine &extension);
/// @param OldPrefix The path prefix to strip from \a Path.
/// @param NewPrefix The path prefix to replace \a NewPrefix with.
void replace_path_prefix(SmallVectorImpl<char> &Path,
- const StringRef &OldPrefix,
- const StringRef &NewPrefix);
+ const StringRef &OldPrefix, const StringRef &NewPrefix,
+ Style style = Style::native);
/// @brief Append to path.
///
@@ -174,6 +178,9 @@ void append(SmallVectorImpl<char> &path, const Twine &a,
const Twine &c = "",
const Twine &d = "");
+void append(SmallVectorImpl<char> &path, Style style, const Twine &a,
+ const Twine &b = "", const Twine &c = "", const Twine &d = "");
+
/// @brief Append to path.
///
/// @code
@@ -185,8 +192,8 @@ void append(SmallVectorImpl<char> &path, const Twine &a,
/// @param path Set to \a path + [\a begin, \a end).
/// @param begin Start of components to append.
/// @param end One past the end of components to append.
-void append(SmallVectorImpl<char> &path,
- const_iterator begin, const_iterator end);
+void append(SmallVectorImpl<char> &path, const_iterator begin,
+ const_iterator end, Style style = Style::native);
/// @}
/// @name Transforms (or some other better name)
@@ -198,14 +205,15 @@ void append(SmallVectorImpl<char> &path,
///
/// @param path A path that is transformed to native format.
/// @param result Holds the result of the transformation.
-void native(const Twine &path, SmallVectorImpl<char> &result);
+void native(const Twine &path, SmallVectorImpl<char> &result,
+ Style style = Style::native);
/// Convert path to the native form in place. This is used to give paths to
/// users and operating system calls in the platform's normal way. For example,
/// on Windows all '/' are converted to '\'.
///
/// @param path A path that is transformed to native format.
-void native(SmallVectorImpl<char> &path);
+void native(SmallVectorImpl<char> &path, Style style = Style::native);
/// @brief Replaces backslashes with slashes if Windows.
///
@@ -213,7 +221,7 @@ void native(SmallVectorImpl<char> &path);
/// @result The result of replacing backslashes with forward slashes if Windows.
/// On Unix, this function is a no-op because backslashes are valid path
/// chracters.
-std::string convert_to_slash(StringRef path);
+std::string convert_to_slash(StringRef path, Style style = Style::native);
/// @}
/// @name Lexical Observers
@@ -229,7 +237,7 @@ std::string convert_to_slash(StringRef path);
///
/// @param path Input path.
/// @result The root name of \a path if it has one, otherwise "".
-StringRef root_name(StringRef path);
+StringRef root_name(StringRef path, Style style = Style::native);
/// @brief Get root directory.
///
@@ -242,7 +250,7 @@ StringRef root_name(StringRef path);
/// @param path Input path.
/// @result The root directory of \a path if it has one, otherwise
/// "".
-StringRef root_directory(StringRef path);
+StringRef root_directory(StringRef path, Style style = Style::native);
/// @brief Get root path.
///
@@ -250,7 +258,7 @@ StringRef root_directory(StringRef path);
///
/// @param path Input path.
/// @result The root path of \a path if it has one, otherwise "".
-StringRef root_path(StringRef path);
+StringRef root_path(StringRef path, Style style = Style::native);
/// @brief Get relative path.
///
@@ -262,7 +270,7 @@ StringRef root_path(StringRef path);
///
/// @param path Input path.
/// @result The path starting after root_path if one exists, otherwise "".
-StringRef relative_path(StringRef path);
+StringRef relative_path(StringRef path, Style style = Style::native);
/// @brief Get parent path.
///
@@ -274,7 +282,7 @@ StringRef relative_path(StringRef path);
///
/// @param path Input path.
/// @result The parent path of \a path if one exists, otherwise "".
-StringRef parent_path(StringRef path);
+StringRef parent_path(StringRef path, Style style = Style::native);
/// @brief Get filename.
///
@@ -288,7 +296,7 @@ StringRef parent_path(StringRef path);
/// @param path Input path.
/// @result The filename part of \a path. This is defined as the last component
/// of \a path.
-StringRef filename(StringRef path);
+StringRef filename(StringRef path, Style style = Style::native);
/// @brief Get stem.
///
@@ -306,7 +314,7 @@ StringRef filename(StringRef path);
///
/// @param path Input path.
/// @result The stem of \a path.
-StringRef stem(StringRef path);
+StringRef stem(StringRef path, Style style = Style::native);
/// @brief Get extension.
///
@@ -322,18 +330,18 @@ StringRef stem(StringRef path);
///
/// @param path Input path.
/// @result The extension of \a path.
-StringRef extension(StringRef path);
+StringRef extension(StringRef path, Style style = Style::native);
/// @brief Check whether the given char is a path separator on the host OS.
///
/// @param value a character
/// @result true if \a value is a path separator character on the host OS
-bool is_separator(char value);
+bool is_separator(char value, Style style = Style::native);
/// @brief Return the preferred separator for this platform.
///
/// @result StringRef of the preferred separator, null-terminated.
-StringRef get_separator();
+StringRef get_separator(Style style = Style::native);
/// @brief Get the typical temporary directory for the system, e.g.,
/// "/var/tmp" or "C:/TEMP"
@@ -374,7 +382,7 @@ bool user_cache_directory(SmallVectorImpl<char> &Result, const Twine &Path1,
///
/// @param path Input path.
/// @result True if the path has a root name, false otherwise.
-bool has_root_name(const Twine &path);
+bool has_root_name(const Twine &path, Style style = Style::native);
/// @brief Has root directory?
///
@@ -382,7 +390,7 @@ bool has_root_name(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a root directory, false otherwise.
-bool has_root_directory(const Twine &path);
+bool has_root_directory(const Twine &path, Style style = Style::native);
/// @brief Has root path?
///
@@ -390,7 +398,7 @@ bool has_root_directory(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a root path, false otherwise.
-bool has_root_path(const Twine &path);
+bool has_root_path(const Twine &path, Style style = Style::native);
/// @brief Has relative path?
///
@@ -398,7 +406,7 @@ bool has_root_path(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a relative path, false otherwise.
-bool has_relative_path(const Twine &path);
+bool has_relative_path(const Twine &path, Style style = Style::native);
/// @brief Has parent path?
///
@@ -406,7 +414,7 @@ bool has_relative_path(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a parent path, false otherwise.
-bool has_parent_path(const Twine &path);
+bool has_parent_path(const Twine &path, Style style = Style::native);
/// @brief Has filename?
///
@@ -414,7 +422,7 @@ bool has_parent_path(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a filename, false otherwise.
-bool has_filename(const Twine &path);
+bool has_filename(const Twine &path, Style style = Style::native);
/// @brief Has stem?
///
@@ -422,7 +430,7 @@ bool has_filename(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a stem, false otherwise.
-bool has_stem(const Twine &path);
+bool has_stem(const Twine &path, Style style = Style::native);
/// @brief Has extension?
///
@@ -430,25 +438,25 @@ bool has_stem(const Twine &path);
///
/// @param path Input path.
/// @result True if the path has a extension, false otherwise.
-bool has_extension(const Twine &path);
+bool has_extension(const Twine &path, Style style = Style::native);
/// @brief Is path absolute?
///
/// @param path Input path.
/// @result True if the path is absolute, false if it is not.
-bool is_absolute(const Twine &path);
+bool is_absolute(const Twine &path, Style style = Style::native);
/// @brief Is path relative?
///
/// @param path Input path.
/// @result True if the path is relative, false if it is not.
-bool is_relative(const Twine &path);
+bool is_relative(const Twine &path, Style style = Style::native);
/// @brief Remove redundant leading "./" pieces and consecutive separators.
///
/// @param path Input path.
/// @result The cleaned-up \a path.
-StringRef remove_leading_dotslash(StringRef path);
+StringRef remove_leading_dotslash(StringRef path, Style style = Style::native);
/// @brief In-place remove any './' and optionally '../' components from a path.
///
@@ -456,7 +464,8 @@ StringRef remove_leading_dotslash(StringRef path);
/// @param remove_dot_dot specify if '../' (except for leading "../") should be
/// removed
/// @result True if path was changed
-bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot = false);
+bool remove_dots(SmallVectorImpl<char> &path, bool remove_dot_dot = false,
+ Style style = Style::native);
} // end namespace path
} // end namespace sys
diff --git a/contrib/llvm/include/llvm/Support/PointerLikeTypeTraits.h b/contrib/llvm/include/llvm/Support/PointerLikeTypeTraits.h
index 9ff894e..521a496 100644
--- a/contrib/llvm/include/llvm/Support/PointerLikeTypeTraits.h
+++ b/contrib/llvm/include/llvm/Support/PointerLikeTypeTraits.h
@@ -60,6 +60,20 @@ public:
enum { NumLowBitsAvailable = 2 };
};
+// Provide PointerLikeTypeTraits for const things.
+template <typename T> class PointerLikeTypeTraits<const T> {
+ typedef PointerLikeTypeTraits<T> NonConst;
+
+public:
+ static inline const void *getAsVoidPointer(const T P) {
+ return NonConst::getAsVoidPointer(P);
+ }
+ static inline const T getFromVoidPointer(const void *P) {
+ return NonConst::getFromVoidPointer(const_cast<void *>(P));
+ }
+ enum { NumLowBitsAvailable = NonConst::NumLowBitsAvailable };
+};
+
// Provide PointerLikeTypeTraits for const pointers.
template <typename T> class PointerLikeTypeTraits<const T *> {
typedef PointerLikeTypeTraits<T *> NonConst;
diff --git a/contrib/llvm/include/llvm/Support/RWMutex.h b/contrib/llvm/include/llvm/Support/RWMutex.h
index e4736b8..85f4fc0 100644
--- a/contrib/llvm/include/llvm/Support/RWMutex.h
+++ b/contrib/llvm/include/llvm/Support/RWMutex.h
@@ -14,7 +14,7 @@
#ifndef LLVM_SUPPORT_RWMUTEX_H
#define LLVM_SUPPORT_RWMUTEX_H
-#include "llvm/Support/Compiler.h"
+#include "llvm/Config/llvm-config.h"
#include "llvm/Support/Threading.h"
#include <cassert>
@@ -32,6 +32,13 @@ namespace sys {
/// @brief Default Constructor.
explicit RWMutexImpl();
+ /// @}
+ /// @name Do Not Implement
+ /// @{
+ RWMutexImpl(const RWMutexImpl & original) = delete;
+ RWMutexImpl &operator=(const RWMutexImpl &) = delete;
+ /// @}
+
/// Releases and removes the lock
/// @brief Destructor
~RWMutexImpl();
@@ -70,16 +77,8 @@ namespace sys {
/// @{
private:
#if defined(LLVM_ENABLE_THREADS) && LLVM_ENABLE_THREADS != 0
- void* data_; ///< We don't know what the data will be
+ void* data_ = nullptr; ///< We don't know what the data will be
#endif
-
- /// @}
- /// @name Do Not Implement
- /// @{
- private:
- RWMutexImpl(const RWMutexImpl & original) = delete;
- void operator=(const RWMutexImpl &) = delete;
- /// @}
};
/// SmartMutex - An R/W mutex with a compile time constant parameter that
@@ -93,6 +92,8 @@ namespace sys {
public:
explicit SmartRWMutex() = default;
+ SmartRWMutex(const SmartRWMutex<mt_only> & original) = delete;
+ SmartRWMutex<mt_only> &operator=(const SmartRWMutex<mt_only> &) = delete;
bool lock_shared() {
if (!mt_only || llvm_is_multithreaded())
@@ -136,10 +137,6 @@ namespace sys {
--writers;
return true;
}
-
- private:
- SmartRWMutex(const SmartRWMutex<mt_only> & original);
- void operator=(const SmartRWMutex<mt_only> &);
};
typedef SmartRWMutex<false> RWMutex;
diff --git a/contrib/llvm/include/llvm/Support/Recycler.h b/contrib/llvm/include/llvm/Support/Recycler.h
index 1523aad..53db2e8 100644
--- a/contrib/llvm/include/llvm/Support/Recycler.h
+++ b/contrib/llvm/include/llvm/Support/Recycler.h
@@ -42,13 +42,16 @@ class Recycler {
FreeNode *pop_val() {
auto *Val = FreeList;
+ __asan_unpoison_memory_region(Val, Size);
FreeList = FreeList->Next;
+ __msan_allocated_memory(Val, Size);
return Val;
}
void push(FreeNode *N) {
N->Next = FreeList;
FreeList = N;
+ __asan_poison_memory_region(N, Size);
}
public:
diff --git a/contrib/llvm/include/llvm/Support/Regex.h b/contrib/llvm/include/llvm/Support/Regex.h
index 83db803..f498835 100644
--- a/contrib/llvm/include/llvm/Support/Regex.h
+++ b/contrib/llvm/include/llvm/Support/Regex.h
@@ -57,7 +57,7 @@ namespace llvm {
/// isValid - returns the error encountered during regex compilation, or
/// matching, if any.
- bool isValid(std::string &Error);
+ bool isValid(std::string &Error) const;
/// getNumMatches - In a valid regex, return the number of parenthesized
/// matches it contains. The number filled in by match will include this
diff --git a/contrib/llvm/include/llvm/Support/ReverseIteration.h b/contrib/llvm/include/llvm/Support/ReverseIteration.h
new file mode 100644
index 0000000..cb97b60
--- /dev/null
+++ b/contrib/llvm/include/llvm/Support/ReverseIteration.h
@@ -0,0 +1,17 @@
+#ifndef LLVM_SUPPORT_REVERSEITERATION_H
+#define LLVM_SUPPORT_REVERSEITERATION_H
+
+#include "llvm/Config/abi-breaking.h"
+
+namespace llvm {
+#if LLVM_ENABLE_ABI_BREAKING_CHECKS
+template <class T = void> struct ReverseIterate { static bool value; };
+#if LLVM_ENABLE_REVERSE_ITERATION
+template <class T> bool ReverseIterate<T>::value = true;
+#else
+template <class T> bool ReverseIterate<T>::value = false;
+#endif
+#endif
+}
+
+#endif
diff --git a/contrib/llvm/include/llvm/Support/SMLoc.h b/contrib/llvm/include/llvm/Support/SMLoc.h
index eb3a1ba..5b8be55 100644
--- a/contrib/llvm/include/llvm/Support/SMLoc.h
+++ b/contrib/llvm/include/llvm/Support/SMLoc.h
@@ -22,10 +22,10 @@ namespace llvm {
/// Represents a location in source code.
class SMLoc {
- const char *Ptr;
+ const char *Ptr = nullptr;
public:
- SMLoc() : Ptr(nullptr) {}
+ SMLoc() = default;
bool isValid() const { return Ptr != nullptr; }
diff --git a/contrib/llvm/include/llvm/Support/ScopedPrinter.h b/contrib/llvm/include/llvm/Support/ScopedPrinter.h
index a2f2e09..1b66519 100644
--- a/contrib/llvm/include/llvm/Support/ScopedPrinter.h
+++ b/contrib/llvm/include/llvm/Support/ScopedPrinter.h
@@ -295,6 +295,11 @@ public:
printBinaryImpl(Label, StringRef(), V, false);
}
+ void printBinaryBlock(StringRef Label, ArrayRef<uint8_t> Value,
+ uint32_t StartOffset) {
+ printBinaryImpl(Label, StringRef(), Value, true, StartOffset);
+ }
+
void printBinaryBlock(StringRef Label, ArrayRef<uint8_t> Value) {
printBinaryImpl(Label, StringRef(), Value, true);
}
@@ -333,7 +338,7 @@ private:
}
void printBinaryImpl(StringRef Label, StringRef Str, ArrayRef<uint8_t> Value,
- bool Block);
+ bool Block, uint32_t StartOffset = 0);
raw_ostream &OS;
int IndentLevel;
diff --git a/contrib/llvm/include/llvm/Support/Solaris.h b/contrib/llvm/include/llvm/Support/Solaris/sys/regset.h
index b082285..6a69ebe 100644
--- a/contrib/llvm/include/llvm/Support/Solaris.h
+++ b/contrib/llvm/include/llvm/Support/Solaris/sys/regset.h
@@ -1,4 +1,4 @@
-/*===- llvm/Support/Solaris.h ------------------------------------*- C++ -*-===*
+/*===- llvm/Support/Solaris/sys/regset.h ------------------------*- C++ -*-===*
*
* The LLVM Compiler Infrastructure
*
@@ -7,24 +7,14 @@
*
*===----------------------------------------------------------------------===*
*
- * This file contains portability fixes for Solaris hosts.
+ * This file works around excessive name space pollution from the system header
+ * on Solaris hosts.
*
*===----------------------------------------------------------------------===*/
-#ifndef LLVM_SUPPORT_SOLARIS_H
-#define LLVM_SUPPORT_SOLARIS_H
+#ifndef LLVM_SUPPORT_SOLARIS_SYS_REGSET_H
-#include <sys/types.h>
-#include <sys/regset.h>
-
-/* Solaris doesn't have endian.h. SPARC is the only supported big-endian ISA. */
-#define BIG_ENDIAN 4321
-#define LITTLE_ENDIAN 1234
-#if defined(__sparc) || defined(__sparc__)
-#define BYTE_ORDER BIG_ENDIAN
-#else
-#define BYTE_ORDER LITTLE_ENDIAN
-#endif
+#include_next <sys/regset.h>
#undef CS
#undef DS
diff --git a/contrib/llvm/include/llvm/Support/SourceMgr.h b/contrib/llvm/include/llvm/Support/SourceMgr.h
index bc7478e..399f8dc 100644
--- a/contrib/llvm/include/llvm/Support/SourceMgr.h
+++ b/contrib/llvm/include/llvm/Support/SourceMgr.h
@@ -17,18 +17,24 @@
#define LLVM_SUPPORT_SOURCEMGR_H
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Twine.h"
#include "llvm/Support/MemoryBuffer.h"
#include "llvm/Support/SMLoc.h"
+#include <algorithm>
+#include <cassert>
+#include <memory>
#include <string>
+#include <utility>
+#include <vector>
namespace llvm {
- class SourceMgr;
- class SMDiagnostic;
- class SMFixIt;
- class Twine;
- class raw_ostream;
+
+class raw_ostream;
+class SMDiagnostic;
+class SMFixIt;
/// This owns the files read by a parser, handles include stacks,
/// and handles diagnostic wrangling.
@@ -43,7 +49,8 @@ public:
/// Clients that want to handle their own diagnostics in a custom way can
/// register a function pointer+context as a diagnostic handler.
/// It gets called each time PrintMessage is invoked.
- typedef void (*DiagHandlerTy)(const SMDiagnostic &, void *Context);
+ using DiagHandlerTy = void (*)(const SMDiagnostic &, void *Context);
+
private:
struct SrcBuffer {
/// The memory buffer for the file.
@@ -61,18 +68,17 @@ private:
/// This is a cache for line number queries, its implementation is really
/// private to SourceMgr.cpp.
- mutable void *LineNoCache;
+ mutable void *LineNoCache = nullptr;
- DiagHandlerTy DiagHandler;
- void *DiagContext;
+ DiagHandlerTy DiagHandler = nullptr;
+ void *DiagContext = nullptr;
bool isValidBufferID(unsigned i) const { return i && i <= Buffers.size(); }
- SourceMgr(const SourceMgr&) = delete;
- void operator=(const SourceMgr&) = delete;
public:
- SourceMgr()
- : LineNoCache(nullptr), DiagHandler(nullptr), DiagContext(nullptr) {}
+ SourceMgr() = default;
+ SourceMgr(const SourceMgr &) = delete;
+ SourceMgr &operator=(const SourceMgr &) = delete;
~SourceMgr();
void setIncludeDirs(const std::vector<std::string> &Dirs) {
@@ -190,7 +196,6 @@ public:
void PrintIncludeStack(SMLoc IncludeLoc, raw_ostream &OS) const;
};
-
/// Represents a single fixit, a replacement of one range of text with another.
class SMFixIt {
SMRange Range;
@@ -222,33 +227,31 @@ public:
}
};
-
/// Instances of this class encapsulate one diagnostic report, allowing
/// printing to a raw_ostream as a caret diagnostic.
class SMDiagnostic {
- const SourceMgr *SM;
+ const SourceMgr *SM = nullptr;
SMLoc Loc;
std::string Filename;
- int LineNo, ColumnNo;
- SourceMgr::DiagKind Kind;
+ int LineNo = 0;
+ int ColumnNo = 0;
+ SourceMgr::DiagKind Kind = SourceMgr::DK_Error;
std::string Message, LineContents;
- std::vector<std::pair<unsigned, unsigned> > Ranges;
+ std::vector<std::pair<unsigned, unsigned>> Ranges;
SmallVector<SMFixIt, 4> FixIts;
public:
// Null diagnostic.
- SMDiagnostic()
- : SM(nullptr), LineNo(0), ColumnNo(0), Kind(SourceMgr::DK_Error) {}
+ SMDiagnostic() = default;
// Diagnostic with no location (e.g. file not found, command line arg error).
SMDiagnostic(StringRef filename, SourceMgr::DiagKind Knd, StringRef Msg)
- : SM(nullptr), Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd),
- Message(Msg) {}
+ : Filename(filename), LineNo(-1), ColumnNo(-1), Kind(Knd), Message(Msg) {}
// Diagnostic with a location.
SMDiagnostic(const SourceMgr &sm, SMLoc L, StringRef FN,
int Line, int Col, SourceMgr::DiagKind Kind,
StringRef Msg, StringRef LineStr,
- ArrayRef<std::pair<unsigned,unsigned> > Ranges,
+ ArrayRef<std::pair<unsigned,unsigned>> Ranges,
ArrayRef<SMFixIt> FixIts = None);
const SourceMgr *getSourceMgr() const { return SM; }
@@ -259,9 +262,7 @@ public:
SourceMgr::DiagKind getKind() const { return Kind; }
StringRef getMessage() const { return Message; }
StringRef getLineContents() const { return LineContents; }
- ArrayRef<std::pair<unsigned, unsigned> > getRanges() const {
- return Ranges;
- }
+ ArrayRef<std::pair<unsigned, unsigned>> getRanges() const { return Ranges; }
void addFixIt(const SMFixIt &Hint) {
FixIts.push_back(Hint);
@@ -275,6 +276,6 @@ public:
bool ShowKindLabel = true) const;
};
-} // end llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_SOURCEMGR_H
diff --git a/contrib/llvm/include/llvm/Support/StringPool.h b/contrib/llvm/include/llvm/Support/StringPool.h
index 2ec0c3b..bb5fd07 100644
--- a/contrib/llvm/include/llvm/Support/StringPool.h
+++ b/contrib/llvm/include/llvm/Support/StringPool.h
@@ -1,4 +1,4 @@
-//===-- StringPool.h - Interned string pool ---------------------*- C++ -*-===//
+//===- StringPool.h - Interned string pool ----------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -30,6 +30,7 @@
#define LLVM_SUPPORT_STRINGPOOL_H
#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
#include <cassert>
namespace llvm {
@@ -43,17 +44,17 @@ namespace llvm {
/// PooledString - This is the value of an entry in the pool's interning
/// table.
struct PooledString {
- StringPool *Pool; ///< So the string can remove itself.
- unsigned Refcount; ///< Number of referencing PooledStringPtrs.
+ StringPool *Pool = nullptr; ///< So the string can remove itself.
+ unsigned Refcount = 0; ///< Number of referencing PooledStringPtrs.
public:
- PooledString() : Pool(nullptr), Refcount(0) { }
+ PooledString() = default;
};
friend class PooledStringPtr;
- typedef StringMap<PooledString> table_t;
- typedef StringMapEntry<PooledString> entry_t;
+ using table_t = StringMap<PooledString>;
+ using entry_t = StringMapEntry<PooledString>;
table_t InternTable;
public:
@@ -76,11 +77,12 @@ namespace llvm {
/// a single pointer, but it does have reference-counting overhead when
/// copied.
class PooledStringPtr {
- typedef StringPool::entry_t entry_t;
- entry_t *S;
+ using entry_t = StringPool::entry_t;
+
+ entry_t *S = nullptr;
public:
- PooledStringPtr() : S(nullptr) {}
+ PooledStringPtr() = default;
explicit PooledStringPtr(entry_t *E) : S(E) {
if (S) ++S->getValue().Refcount;
@@ -133,6 +135,6 @@ namespace llvm {
inline bool operator!=(const PooledStringPtr &That) const { return S != That.S; }
};
-} // End llvm namespace
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_STRINGPOOL_H
diff --git a/contrib/llvm/include/llvm/Support/StringSaver.h b/contrib/llvm/include/llvm/Support/StringSaver.h
index fcddd4c..e85b289 100644
--- a/contrib/llvm/include/llvm/Support/StringSaver.h
+++ b/contrib/llvm/include/llvm/Support/StringSaver.h
@@ -26,7 +26,7 @@ public:
StringRef save(const char *S) { return save(StringRef(S)); }
StringRef save(StringRef S);
StringRef save(const Twine &S) { return save(StringRef(S.str())); }
- StringRef save(std::string &S) { return save(StringRef(S)); }
+ StringRef save(const std::string &S) { return save(StringRef(S)); }
};
}
#endif
diff --git a/contrib/llvm/include/llvm/Support/TargetParser.h b/contrib/llvm/include/llvm/Support/TargetParser.h
index 63aeca7..e13582f 100644
--- a/contrib/llvm/include/llvm/Support/TargetParser.h
+++ b/contrib/llvm/include/llvm/Support/TargetParser.h
@@ -17,6 +17,7 @@
// FIXME: vector is used because that's what clang uses for subtarget feature
// lists, but SmallVector would probably be better
+#include "llvm/ADT/Triple.h"
#include <vector>
namespace llvm {
@@ -75,7 +76,7 @@ enum ArchExtKind : unsigned {
AEK_CRC = 0x2,
AEK_CRYPTO = 0x4,
AEK_FP = 0x8,
- AEK_HWDIV = 0x10,
+ AEK_HWDIVTHUMB = 0x10,
AEK_HWDIVARM = 0x20,
AEK_MP = 0x40,
AEK_SIMD = 0x80,
@@ -84,6 +85,7 @@ enum ArchExtKind : unsigned {
AEK_DSP = 0x400,
AEK_FP16 = 0x800,
AEK_RAS = 0x1000,
+ AEK_SVE = 0x2000,
// Unsupported extensions.
AEK_OS = 0x8000000,
AEK_IWMMXT = 0x10000000,
@@ -140,9 +142,11 @@ unsigned parseArchEndian(StringRef Arch);
unsigned parseArchProfile(StringRef Arch);
unsigned parseArchVersion(StringRef Arch);
+StringRef computeDefaultTargetABI(const Triple &TT, StringRef CPU);
+
} // namespace ARM
-// FIXME:This should be made into class design,to avoid dupplication.
+// FIXME:This should be made into class design,to avoid dupplication.
namespace AArch64 {
// Arch names.
@@ -163,7 +167,8 @@ enum ArchExtKind : unsigned {
AEK_FP16 = 0x20,
AEK_PROFILE = 0x40,
AEK_RAS = 0x80,
- AEK_LSE = 0x100
+ AEK_LSE = 0x100,
+ AEK_SVE = 0x200
};
StringRef getCanonicalArchName(StringRef Arch);
diff --git a/contrib/llvm/include/llvm/Support/TargetRegistry.h b/contrib/llvm/include/llvm/Support/TargetRegistry.h
index 954cdb1..8454b27 100644
--- a/contrib/llvm/include/llvm/Support/TargetRegistry.h
+++ b/contrib/llvm/include/llvm/Support/TargetRegistry.h
@@ -1,4 +1,4 @@
-//===-- Support/TargetRegistry.h - Target Registration ----------*- C++ -*-===//
+//===- Support/TargetRegistry.h - Target Registration -----------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -21,14 +21,21 @@
#include "llvm-c/Disassembler.h"
#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/Triple.h"
+#include "llvm/ADT/iterator_range.h"
#include "llvm/Support/CodeGen.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Support/FormattedStream.h"
+#include <algorithm>
#include <cassert>
+#include <cstddef>
+#include <iterator>
#include <memory>
#include <string>
namespace llvm {
+
class AsmPrinter;
class MCAsmBackend;
class MCAsmInfo;
@@ -36,22 +43,21 @@ class MCAsmParser;
class MCCodeEmitter;
class MCContext;
class MCDisassembler;
-class MCInstrAnalysis;
class MCInstPrinter;
+class MCInstrAnalysis;
class MCInstrInfo;
class MCRegisterInfo;
+class MCRelocationInfo;
class MCStreamer;
class MCSubtargetInfo;
class MCSymbolizer;
-class MCRelocationInfo;
class MCTargetAsmParser;
class MCTargetOptions;
class MCTargetStreamer;
-class TargetMachine;
-class TargetOptions;
class raw_ostream;
class raw_pwrite_stream;
-class formatted_raw_ostream;
+class TargetMachine;
+class TargetOptions;
MCStreamer *createNullStreamer(MCContext &Ctx);
MCStreamer *createAsmStreamer(MCContext &Ctx,
@@ -68,6 +74,9 @@ MCStreamer *createMachOStreamer(MCContext &Ctx, MCAsmBackend &TAB,
raw_pwrite_stream &OS, MCCodeEmitter *CE,
bool RelaxAll, bool DWARFMustBeAtTheEnd,
bool LabelSections = false);
+MCStreamer *createWasmStreamer(MCContext &Ctx, MCAsmBackend &TAB,
+ raw_pwrite_stream &OS, MCCodeEmitter *CE,
+ bool RelaxAll);
MCRelocationInfo *createMCRelocationInfo(const Triple &TT, MCContext &Ctx);
@@ -88,70 +97,75 @@ class Target {
public:
friend struct TargetRegistry;
- typedef bool (*ArchMatchFnTy)(Triple::ArchType Arch);
+ using ArchMatchFnTy = bool (*)(Triple::ArchType Arch);
- typedef MCAsmInfo *(*MCAsmInfoCtorFnTy)(const MCRegisterInfo &MRI,
- const Triple &TT);
- typedef void (*MCAdjustCodeGenOptsFnTy)(const Triple &TT, Reloc::Model RM,
- CodeModel::Model &CM);
+ using MCAsmInfoCtorFnTy = MCAsmInfo *(*)(const MCRegisterInfo &MRI,
+ const Triple &TT);
+ using MCAdjustCodeGenOptsFnTy = void (*)(const Triple &TT, Reloc::Model RM,
+ CodeModel::Model &CM);
- typedef MCInstrInfo *(*MCInstrInfoCtorFnTy)(void);
- typedef MCInstrAnalysis *(*MCInstrAnalysisCtorFnTy)(const MCInstrInfo *Info);
- typedef MCRegisterInfo *(*MCRegInfoCtorFnTy)(const Triple &TT);
- typedef MCSubtargetInfo *(*MCSubtargetInfoCtorFnTy)(const Triple &TT,
- StringRef CPU,
- StringRef Features);
- typedef TargetMachine *(*TargetMachineCtorTy)(
+ using MCInstrInfoCtorFnTy = MCInstrInfo *(*)();
+ using MCInstrAnalysisCtorFnTy = MCInstrAnalysis *(*)(const MCInstrInfo *Info);
+ using MCRegInfoCtorFnTy = MCRegisterInfo *(*)(const Triple &TT);
+ using MCSubtargetInfoCtorFnTy = MCSubtargetInfo *(*)(const Triple &TT,
+ StringRef CPU,
+ StringRef Features);
+ using TargetMachineCtorTy = TargetMachine *(*)(
const Target &T, const Triple &TT, StringRef CPU, StringRef Features,
const TargetOptions &Options, Optional<Reloc::Model> RM,
CodeModel::Model CM, CodeGenOpt::Level OL);
// If it weren't for layering issues (this header is in llvm/Support, but
// depends on MC?) this should take the Streamer by value rather than rvalue
// reference.
- typedef AsmPrinter *(*AsmPrinterCtorTy)(
+ using AsmPrinterCtorTy = AsmPrinter *(*)(
TargetMachine &TM, std::unique_ptr<MCStreamer> &&Streamer);
- typedef MCAsmBackend *(*MCAsmBackendCtorTy)(const Target &T,
- const MCRegisterInfo &MRI,
- const Triple &TT, StringRef CPU,
- const MCTargetOptions &Options);
- typedef MCTargetAsmParser *(*MCAsmParserCtorTy)(
+ using MCAsmBackendCtorTy = MCAsmBackend *(*)(const Target &T,
+ const MCRegisterInfo &MRI,
+ const Triple &TT, StringRef CPU,
+ const MCTargetOptions &Options);
+ using MCAsmParserCtorTy = MCTargetAsmParser *(*)(
const MCSubtargetInfo &STI, MCAsmParser &P, const MCInstrInfo &MII,
const MCTargetOptions &Options);
- typedef MCDisassembler *(*MCDisassemblerCtorTy)(const Target &T,
- const MCSubtargetInfo &STI,
- MCContext &Ctx);
- typedef MCInstPrinter *(*MCInstPrinterCtorTy)(const Triple &T,
- unsigned SyntaxVariant,
- const MCAsmInfo &MAI,
- const MCInstrInfo &MII,
- const MCRegisterInfo &MRI);
- typedef MCCodeEmitter *(*MCCodeEmitterCtorTy)(const MCInstrInfo &II,
- const MCRegisterInfo &MRI,
- MCContext &Ctx);
- typedef MCStreamer *(*ELFStreamerCtorTy)(const Triple &T, MCContext &Ctx,
- MCAsmBackend &TAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll);
- typedef MCStreamer *(*MachOStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
+ using MCDisassemblerCtorTy = MCDisassembler *(*)(const Target &T,
+ const MCSubtargetInfo &STI,
+ MCContext &Ctx);
+ using MCInstPrinterCtorTy = MCInstPrinter *(*)(const Triple &T,
+ unsigned SyntaxVariant,
+ const MCAsmInfo &MAI,
+ const MCInstrInfo &MII,
+ const MCRegisterInfo &MRI);
+ using MCCodeEmitterCtorTy = MCCodeEmitter *(*)(const MCInstrInfo &II,
+ const MCRegisterInfo &MRI,
+ MCContext &Ctx);
+ using ELFStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
+ MCAsmBackend &TAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter,
+ bool RelaxAll);
+ using MachOStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter,
+ bool RelaxAll,
+ bool DWARFMustBeAtTheEnd);
+ using COFFStreamerCtorTy = MCStreamer *(*)(MCContext &Ctx, MCAsmBackend &TAB,
raw_pwrite_stream &OS,
MCCodeEmitter *Emitter,
bool RelaxAll,
- bool DWARFMustBeAtTheEnd);
- typedef MCStreamer *(*COFFStreamerCtorTy)(MCContext &Ctx, MCAsmBackend &TAB,
- raw_pwrite_stream &OS,
- MCCodeEmitter *Emitter,
- bool RelaxAll,
- bool IncrementalLinkerCompatible);
- typedef MCTargetStreamer *(*NullTargetStreamerCtorTy)(MCStreamer &S);
- typedef MCTargetStreamer *(*AsmTargetStreamerCtorTy)(
+ bool IncrementalLinkerCompatible);
+ using WasmStreamerCtorTy = MCStreamer *(*)(const Triple &T, MCContext &Ctx,
+ MCAsmBackend &TAB,
+ raw_pwrite_stream &OS,
+ MCCodeEmitter *Emitter,
+ bool RelaxAll);
+ using NullTargetStreamerCtorTy = MCTargetStreamer *(*)(MCStreamer &S);
+ using AsmTargetStreamerCtorTy = MCTargetStreamer *(*)(
MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint,
bool IsVerboseAsm);
- typedef MCTargetStreamer *(*ObjectTargetStreamerCtorTy)(
+ using ObjectTargetStreamerCtorTy = MCTargetStreamer *(*)(
MCStreamer &S, const MCSubtargetInfo &STI);
- typedef MCRelocationInfo *(*MCRelocationInfoCtorTy)(const Triple &TT,
- MCContext &Ctx);
- typedef MCSymbolizer *(*MCSymbolizerCtorTy)(
+ using MCRelocationInfoCtorTy = MCRelocationInfo *(*)(const Triple &TT,
+ MCContext &Ctx);
+ using MCSymbolizerCtorTy = MCSymbolizer *(*)(
const Triple &TT, LLVMOpInfoCallback GetOpInfo,
LLVMSymbolLookupCallback SymbolLookUp, void *DisInfo, MCContext *Ctx,
std::unique_ptr<MCRelocationInfo> &&RelInfo);
@@ -224,36 +238,33 @@ private:
MCCodeEmitterCtorTy MCCodeEmitterCtorFn;
// Construction functions for the various object formats, if registered.
- COFFStreamerCtorTy COFFStreamerCtorFn;
- MachOStreamerCtorTy MachOStreamerCtorFn;
- ELFStreamerCtorTy ELFStreamerCtorFn;
+ COFFStreamerCtorTy COFFStreamerCtorFn = nullptr;
+ MachOStreamerCtorTy MachOStreamerCtorFn = nullptr;
+ ELFStreamerCtorTy ELFStreamerCtorFn = nullptr;
+ WasmStreamerCtorTy WasmStreamerCtorFn = nullptr;
/// Construction function for this target's null TargetStreamer, if
/// registered (default = nullptr).
- NullTargetStreamerCtorTy NullTargetStreamerCtorFn;
+ NullTargetStreamerCtorTy NullTargetStreamerCtorFn = nullptr;
/// Construction function for this target's asm TargetStreamer, if
/// registered (default = nullptr).
- AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn;
+ AsmTargetStreamerCtorTy AsmTargetStreamerCtorFn = nullptr;
/// Construction function for this target's obj TargetStreamer, if
/// registered (default = nullptr).
- ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn;
+ ObjectTargetStreamerCtorTy ObjectTargetStreamerCtorFn = nullptr;
/// MCRelocationInfoCtorFn - Construction function for this target's
/// MCRelocationInfo, if registered (default = llvm::createMCRelocationInfo)
- MCRelocationInfoCtorTy MCRelocationInfoCtorFn;
+ MCRelocationInfoCtorTy MCRelocationInfoCtorFn = nullptr;
/// MCSymbolizerCtorFn - Construction function for this target's
/// MCSymbolizer, if registered (default = llvm::createMCSymbolizer)
- MCSymbolizerCtorTy MCSymbolizerCtorFn;
+ MCSymbolizerCtorTy MCSymbolizerCtorFn = nullptr;
public:
- Target()
- : COFFStreamerCtorFn(nullptr), MachOStreamerCtorFn(nullptr),
- ELFStreamerCtorFn(nullptr), NullTargetStreamerCtorFn(nullptr),
- AsmTargetStreamerCtorFn(nullptr), ObjectTargetStreamerCtorFn(nullptr),
- MCRelocationInfoCtorFn(nullptr), MCSymbolizerCtorFn(nullptr) {}
+ Target() = default;
/// @name Target Information
/// @{
@@ -461,6 +472,12 @@ public:
else
S = createELFStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
break;
+ case Triple::Wasm:
+ if (WasmStreamerCtorFn)
+ S = WasmStreamerCtorFn(T, Ctx, TAB, OS, Emitter, RelaxAll);
+ else
+ S = createWasmStreamer(Ctx, TAB, OS, Emitter, RelaxAll);
+ break;
}
if (ObjectTargetStreamerCtorFn)
ObjectTargetStreamerCtorFn(*S, STI);
@@ -548,12 +565,14 @@ struct TargetRegistry {
class iterator
: public std::iterator<std::forward_iterator_tag, Target, ptrdiff_t> {
- const Target *Current;
- explicit iterator(Target *T) : Current(T) {}
friend struct TargetRegistry;
+ const Target *Current = nullptr;
+
+ explicit iterator(Target *T) : Current(T) {}
+
public:
- iterator() : Current(nullptr) {}
+ iterator() = default;
bool operator==(const iterator &x) const { return Current == x.Current; }
bool operator!=(const iterator &x) const { return !operator==(x); }
@@ -800,6 +819,10 @@ struct TargetRegistry {
T.ELFStreamerCtorFn = Fn;
}
+ static void RegisterWasmStreamer(Target &T, Target::WasmStreamerCtorTy Fn) {
+ T.WasmStreamerCtorFn = Fn;
+ }
+
static void RegisterNullTargetStreamer(Target &T,
Target::NullTargetStreamerCtorTy Fn) {
T.NullTargetStreamerCtorFn = Fn;
@@ -1147,6 +1170,7 @@ private:
return new MCCodeEmitterImpl();
}
};
-}
-#endif
+} // end namespace llvm
+
+#endif // LLVM_SUPPORT_TARGETREGISTRY_H
diff --git a/contrib/llvm/include/llvm/Support/ThreadPool.h b/contrib/llvm/include/llvm/Support/ThreadPool.h
index 665cec2..9ada946 100644
--- a/contrib/llvm/include/llvm/Support/ThreadPool.h
+++ b/contrib/llvm/include/llvm/Support/ThreadPool.h
@@ -16,23 +16,8 @@
#include "llvm/Support/thread.h"
-#ifdef _MSC_VER
-// concrt.h depends on eh.h for __uncaught_exception declaration
-// even if we disable exceptions.
-#include <eh.h>
-
-// Disable warnings from ppltasks.h transitively included by <future>.
-#pragma warning(push)
-#pragma warning(disable:4530)
-#pragma warning(disable:4062)
-#endif
-
#include <future>
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
#include <atomic>
#include <condition_variable>
#include <functional>
@@ -50,17 +35,8 @@ namespace llvm {
/// for some work to become available.
class ThreadPool {
public:
-#ifndef _MSC_VER
- using VoidTy = void;
using TaskTy = std::function<void()>;
using PackagedTaskTy = std::packaged_task<void()>;
-#else
- // MSVC 2013 has a bug and can't use std::packaged_task<void()>;
- // We force it to use bool(bool) instead.
- using VoidTy = bool;
- using TaskTy = std::function<bool(bool)>;
- using PackagedTaskTy = std::packaged_task<bool(bool)>;
-#endif
/// Construct a pool with the number of core available on the system (or
/// whatever the value returned by std::thread::hardware_concurrency() is).
@@ -75,30 +51,17 @@ public:
/// Asynchronous submission of a task to the pool. The returned future can be
/// used to wait for the task to finish and is *non-blocking* on destruction.
template <typename Function, typename... Args>
- inline std::shared_future<VoidTy> async(Function &&F, Args &&... ArgList) {
+ inline std::shared_future<void> async(Function &&F, Args &&... ArgList) {
auto Task =
std::bind(std::forward<Function>(F), std::forward<Args>(ArgList)...);
-#ifndef _MSC_VER
return asyncImpl(std::move(Task));
-#else
- // This lambda has to be marked mutable because MSVC 2013's std::bind call
- // operator isn't const qualified.
- return asyncImpl([Task](VoidTy) mutable -> VoidTy {
- Task();
- return VoidTy();
- });
-#endif
}
/// Asynchronous submission of a task to the pool. The returned future can be
/// used to wait for the task to finish and is *non-blocking* on destruction.
template <typename Function>
- inline std::shared_future<VoidTy> async(Function &&F) {
-#ifndef _MSC_VER
+ inline std::shared_future<void> async(Function &&F) {
return asyncImpl(std::forward<Function>(F));
-#else
- return asyncImpl([F] (VoidTy) -> VoidTy { F(); return VoidTy(); });
-#endif
}
/// Blocking wait for all the threads to complete and the queue to be empty.
@@ -108,7 +71,7 @@ public:
private:
/// Asynchronous submission of a task to the pool. The returned future can be
/// used to wait for the task to finish and is *non-blocking* on destruction.
- std::shared_future<VoidTy> asyncImpl(TaskTy F);
+ std::shared_future<void> asyncImpl(TaskTy F);
/// Threads in flight
std::vector<llvm::thread> Threads;
diff --git a/contrib/llvm/include/llvm/Support/Threading.h b/contrib/llvm/include/llvm/Support/Threading.h
index 4bef7ec..03963a2 100644
--- a/contrib/llvm/include/llvm/Support/Threading.h
+++ b/contrib/llvm/include/llvm/Support/Threading.h
@@ -15,16 +15,22 @@
#ifndef LLVM_SUPPORT_THREADING_H
#define LLVM_SUPPORT_THREADING_H
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Config/llvm-config.h" // for LLVM_ON_UNIX
#include "llvm/Support/Compiler.h"
#include <ciso646> // So we can check the C++ standard lib macros.
#include <functional>
+#if defined(_MSC_VER)
+// MSVC's call_once implementation worked since VS 2015, which is the minimum
+// supported version as of this writing.
+#define LLVM_THREADING_USE_STD_CALL_ONCE 1
+#elif defined(LLVM_ON_UNIX) && \
+ (defined(_LIBCPP_VERSION) || \
+ !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__ppc__)))
// std::call_once from libc++ is used on all Unix platforms. Other
// implementations like libstdc++ are known to have problems on NetBSD,
// OpenBSD and PowerPC.
-#if defined(LLVM_ON_UNIX) && (defined(_LIBCPP_VERSION) || \
- !(defined(__NetBSD__) || defined(__OpenBSD__) || defined(__ppc__)))
#define LLVM_THREADING_USE_STD_CALL_ONCE 1
#else
#define LLVM_THREADING_USE_STD_CALL_ONCE 0
@@ -37,41 +43,43 @@
#endif
namespace llvm {
- /// Returns true if LLVM is compiled with support for multi-threading, and
- /// false otherwise.
- bool llvm_is_multithreaded();
-
- /// llvm_execute_on_thread - Execute the given \p UserFn on a separate
- /// thread, passing it the provided \p UserData and waits for thread
- /// completion.
- ///
- /// This function does not guarantee that the code will actually be executed
- /// on a separate thread or honoring the requested stack size, but tries to do
- /// so where system support is available.
- ///
- /// \param UserFn - The callback to execute.
- /// \param UserData - An argument to pass to the callback function.
- /// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
- /// the thread stack.
- void llvm_execute_on_thread(void (*UserFn)(void*), void *UserData,
- unsigned RequestedStackSize = 0);
+class Twine;
+
+/// Returns true if LLVM is compiled with support for multi-threading, and
+/// false otherwise.
+bool llvm_is_multithreaded();
+
+/// llvm_execute_on_thread - Execute the given \p UserFn on a separate
+/// thread, passing it the provided \p UserData and waits for thread
+/// completion.
+///
+/// This function does not guarantee that the code will actually be executed
+/// on a separate thread or honoring the requested stack size, but tries to do
+/// so where system support is available.
+///
+/// \param UserFn - The callback to execute.
+/// \param UserData - An argument to pass to the callback function.
+/// \param RequestedStackSize - If non-zero, a requested size (in bytes) for
+/// the thread stack.
+void llvm_execute_on_thread(void (*UserFn)(void *), void *UserData,
+ unsigned RequestedStackSize = 0);
#if LLVM_THREADING_USE_STD_CALL_ONCE
typedef std::once_flag once_flag;
- /// This macro is the only way you should define your once flag for LLVM's
- /// call_once.
-#define LLVM_DEFINE_ONCE_FLAG(flag) static once_flag flag
-
#else
enum InitStatus { Uninitialized = 0, Wait = 1, Done = 2 };
- typedef volatile sys::cas_flag once_flag;
- /// This macro is the only way you should define your once flag for LLVM's
- /// call_once.
-#define LLVM_DEFINE_ONCE_FLAG(flag) static once_flag flag = Uninitialized
+ /// \brief The llvm::once_flag structure
+ ///
+ /// This type is modeled after std::once_flag to use with llvm::call_once.
+ /// This structure must be used as an opaque object. It is a struct to force
+ /// autoinitialization and behave like std::once_flag.
+ struct once_flag {
+ volatile sys::cas_flag status = Uninitialized;
+ };
#endif
@@ -81,7 +89,7 @@ namespace llvm {
/// \code
/// void foo() {...};
/// ...
- /// LLVM_DEFINE_ONCE_FLAG(flag);
+ /// static once_flag flag;
/// call_once(flag, foo);
/// \endcode
///
@@ -95,24 +103,24 @@ namespace llvm {
#else
// For other platforms we use a generic (if brittle) version based on our
// atomics.
- sys::cas_flag old_val = sys::CompareAndSwap(&flag, Wait, Uninitialized);
+ sys::cas_flag old_val = sys::CompareAndSwap(&flag.status, Wait, Uninitialized);
if (old_val == Uninitialized) {
std::forward<Function>(F)(std::forward<Args>(ArgList)...);
sys::MemoryFence();
TsanIgnoreWritesBegin();
- TsanHappensBefore(&flag);
- flag = Done;
+ TsanHappensBefore(&flag.status);
+ flag.status = Done;
TsanIgnoreWritesEnd();
} else {
// Wait until any thread doing the call has finished.
- sys::cas_flag tmp = flag;
+ sys::cas_flag tmp = flag.status;
sys::MemoryFence();
while (tmp != Done) {
- tmp = flag;
+ tmp = flag.status;
sys::MemoryFence();
}
}
- TsanHappensAfter(&flag);
+ TsanHappensAfter(&flag.status);
#endif
}
@@ -122,6 +130,32 @@ namespace llvm {
/// thread::hardware_concurrency().
/// Returns 1 when LLVM is configured with LLVM_ENABLE_THREADS=OFF
unsigned heavyweight_hardware_concurrency();
+
+ /// \brief Return the current thread id, as used in various OS system calls.
+ /// Note that not all platforms guarantee that the value returned will be
+ /// unique across the entire system, so portable code should not assume
+ /// this.
+ uint64_t get_threadid();
+
+ /// \brief Get the maximum length of a thread name on this platform.
+ /// A value of 0 means there is no limit.
+ uint32_t get_max_thread_name_length();
+
+ /// \brief Set the name of the current thread. Setting a thread's name can
+ /// be helpful for enabling useful diagnostics under a debugger or when
+ /// logging. The level of support for setting a thread's name varies
+ /// wildly across operating systems, and we only make a best effort to
+ /// perform the operation on supported platforms. No indication of success
+ /// or failure is returned.
+ void set_thread_name(const Twine &Name);
+
+ /// \brief Get the name of the current thread. The level of support for
+ /// getting a thread's name varies wildly across operating systems, and it
+ /// is not even guaranteed that if you can successfully set a thread's name
+ /// that you can later get it back. This function is intended for diagnostic
+ /// purposes, and as with setting a thread's name no indication of whether
+ /// the operation succeeded or failed is returned.
+ void get_thread_name(SmallVectorImpl<char> &Name);
}
#endif
diff --git a/contrib/llvm/include/llvm/Support/Timer.h b/contrib/llvm/include/llvm/Support/Timer.h
index 80e8f13..198855a 100644
--- a/contrib/llvm/include/llvm/Support/Timer.h
+++ b/contrib/llvm/include/llvm/Support/Timer.h
@@ -207,6 +207,9 @@ public:
/// This static method prints all timers and clears them all out.
static void printAll(raw_ostream &OS);
+ /// Prints all timers as JSON key/value pairs, and clears them all out.
+ static const char *printAllJSONValues(raw_ostream &OS, const char *delim);
+
/// Ensure global timer group lists are initialized. This function is mostly
/// used by the Statistic code to influence the construction and destruction
/// order of the global timer lists.
@@ -221,7 +224,6 @@ private:
void printJSONValue(raw_ostream &OS, const PrintRecord &R,
const char *suffix, double Value);
const char *printJSONValues(raw_ostream &OS, const char *delim);
- static const char *printAllJSONValues(raw_ostream &OS, const char *delim);
};
} // end namespace llvm
diff --git a/contrib/llvm/include/llvm/Support/TrailingObjects.h b/contrib/llvm/include/llvm/Support/TrailingObjects.h
index 4d35572..cb5a52b 100644
--- a/contrib/llvm/include/llvm/Support/TrailingObjects.h
+++ b/contrib/llvm/include/llvm/Support/TrailingObjects.h
@@ -294,7 +294,14 @@ class TrailingObjects : private trailing_objects_internal::TrailingObjectsImpl<
public:
// Make this (privately inherited) member public.
+#ifndef _MSC_VER
using ParentType::OverloadToken;
+#else
+ // MSVC bug prevents the above from working, at least up through CL
+ // 19.10.24629.
+ template <typename T>
+ using OverloadToken = typename ParentType::template OverloadToken<T>;
+#endif
/// Returns a pointer to the trailing object array of the given type
/// (which must be one of those specified in the class template). The
diff --git a/contrib/llvm/include/llvm/Support/UnicodeCharRanges.h b/contrib/llvm/include/llvm/Support/UnicodeCharRanges.h
index d4d4d8e..4c65583 100644
--- a/contrib/llvm/include/llvm/Support/UnicodeCharRanges.h
+++ b/contrib/llvm/include/llvm/Support/UnicodeCharRanges.h
@@ -18,11 +18,11 @@
#include "llvm/Support/raw_ostream.h"
#include <algorithm>
+#define DEBUG_TYPE "unicode"
+
namespace llvm {
namespace sys {
-#define DEBUG_TYPE "unicode"
-
/// \brief Represents a closed range of Unicode code points [Lower, Upper].
struct UnicodeCharRange {
uint32_t Lower;
@@ -99,10 +99,9 @@ private:
const CharRanges Ranges;
};
-#undef DEBUG_TYPE // "unicode"
-
} // namespace sys
} // namespace llvm
+#undef DEBUG_TYPE // "unicode"
#endif // LLVM_SUPPORT_UNICODECHARRANGES_H
diff --git a/contrib/llvm/include/llvm/Support/UniqueLock.h b/contrib/llvm/include/llvm/Support/UniqueLock.h
index 529284d..b4675f4 100644
--- a/contrib/llvm/include/llvm/Support/UniqueLock.h
+++ b/contrib/llvm/include/llvm/Support/UniqueLock.h
@@ -1,4 +1,4 @@
-//===-- Support/UniqueLock.h - Acquire/Release Mutex In Scope ---*- C++ -*-===//
+//===- Support/UniqueLock.h - Acquire/Release Mutex In Scope ----*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -15,9 +15,10 @@
#ifndef LLVM_SUPPORT_UNIQUE_LOCK_H
#define LLVM_SUPPORT_UNIQUE_LOCK_H
-#include "llvm/Support/Mutex.h"
+#include <cassert>
namespace llvm {
+
/// A pared-down imitation of std::unique_lock from C++11. Contrary to the
/// name, it's really more of a wrapper for a lock. It may or may not have
/// an associated mutex, which is guaranteed to be locked upon creation
@@ -26,14 +27,14 @@ namespace llvm {
/// @brief Guard a section of code with a mutex.
template<typename MutexT>
class unique_lock {
- MutexT *M;
- bool locked;
+ MutexT *M = nullptr;
+ bool locked = false;
- unique_lock(const unique_lock &) = delete;
- void operator=(const unique_lock &) = delete;
public:
- unique_lock() : M(nullptr), locked(false) {}
+ unique_lock() = default;
explicit unique_lock(MutexT &m) : M(&m), locked(true) { M->lock(); }
+ unique_lock(const unique_lock &) = delete;
+ unique_lock &operator=(const unique_lock &) = delete;
void operator=(unique_lock &&o) {
if (owns_lock())
@@ -62,6 +63,7 @@ namespace llvm {
bool owns_lock() { return locked; }
};
-}
+
+} // end namespace llvm
#endif // LLVM_SUPPORT_UNIQUE_LOCK_H
diff --git a/contrib/llvm/include/llvm/Support/Wasm.h b/contrib/llvm/include/llvm/Support/Wasm.h
deleted file mode 100644
index 8ac6b90..0000000
--- a/contrib/llvm/include/llvm/Support/Wasm.h
+++ /dev/null
@@ -1,87 +0,0 @@
-//===- Wasm.h - Wasm object file format -------------------------*- C++ -*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===----------------------------------------------------------------------===//
-//
-// This file defines manifest constants for the wasm object file format.
-// See: https://github.com/WebAssembly/design/blob/master/BinaryEncoding.md
-//
-//===----------------------------------------------------------------------===//
-
-#ifndef LLVM_SUPPORT_WASM_H
-#define LLVM_SUPPORT_WASM_H
-
-#include "llvm/ADT/ArrayRef.h"
-
-namespace llvm {
-namespace wasm {
-
-// Object file magic string.
-const char WasmMagic[] = {'\0', 'a', 's', 'm'};
-// Wasm binary format version
-const uint32_t WasmVersion = 0xd;
-
-struct WasmObjectHeader {
- StringRef Magic;
- uint32_t Version;
-};
-
-struct WasmSection {
- uint32_t Type; // Section type (See below)
- uint32_t Offset; // Offset with in the file
- StringRef Name; // Section name (User-defined sections only)
- ArrayRef<uint8_t> Content; // Section content
-};
-
-enum : unsigned {
- WASM_SEC_USER = 0, // User-defined section
- WASM_SEC_TYPE = 1, // Function signature declarations
- WASM_SEC_IMPORT = 2, // Import declarations
- WASM_SEC_FUNCTION = 3, // Function declarations
- WASM_SEC_TABLE = 4, // Indirect function table and other tables
- WASM_SEC_MEMORY = 5, // Memory attributes
- WASM_SEC_GLOBAL = 6, // Global declarations
- WASM_SEC_EXPORT = 7, // Exports
- WASM_SEC_START = 8, // Start function declaration
- WASM_SEC_ELEM = 9, // Elements section
- WASM_SEC_CODE = 10, // Function bodies (code)
- WASM_SEC_DATA = 11 // Data segments
-};
-
-// Type immediate encodings used in various contexts.
-enum : unsigned {
- WASM_TYPE_I32 = 0x7f,
- WASM_TYPE_I64 = 0x7e,
- WASM_TYPE_F32 = 0x7d,
- WASM_TYPE_F64 = 0x7c,
- WASM_TYPE_ANYFUNC = 0x70,
- WASM_TYPE_FUNC = 0x60,
- WASM_TYPE_NORESULT = 0x40, // for blocks with no result values
-};
-
-// Kinds of externals (for imports and exports).
-enum : unsigned {
- WASM_EXTERNAL_FUNCTION = 0x0,
- WASM_EXTERNAL_TABLE = 0x1,
- WASM_EXTERNAL_MEMORY = 0x2,
- WASM_EXTERNAL_GLOBAL = 0x3,
-};
-
-// Opcodes used in initializer expressions.
-enum : unsigned {
- WASM_OPCODE_END = 0x0b,
- WASM_OPCODE_GET_GLOBAL = 0x23,
- WASM_OPCODE_I32_CONST = 0x41,
- WASM_OPCODE_I64_CONST = 0x42,
- WASM_OPCODE_F32_CONST = 0x43,
- WASM_OPCODE_F64_CONST = 0x44,
-};
-
-} // end namespace wasm
-} // end namespace llvm
-
-#endif
diff --git a/contrib/llvm/include/llvm/Support/YAMLParser.h b/contrib/llvm/include/llvm/Support/YAMLParser.h
index b9e3fa4..549da3c 100644
--- a/contrib/llvm/include/llvm/Support/YAMLParser.h
+++ b/contrib/llvm/include/llvm/Support/YAMLParser.h
@@ -1,4 +1,4 @@
-//===--- YAMLParser.h - Simple YAML parser --------------------------------===//
+//===- YAMLParser.h - Simple YAML parser ------------------------*- C++ -*-===//
//
// The LLVM Compiler Infrastructure
//
@@ -41,20 +41,25 @@
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Allocator.h"
#include "llvm/Support/SMLoc.h"
+#include <cassert>
+#include <cstddef>
+#include <iterator>
#include <map>
+#include <memory>
+#include <string>
#include <system_error>
-#include <utility>
namespace llvm {
+
class MemoryBufferRef;
class SourceMgr;
-class Twine;
class raw_ostream;
+class Twine;
namespace yaml {
-class document_iterator;
class Document;
+class document_iterator;
class Node;
class Scanner;
struct Token;
@@ -87,6 +92,7 @@ public:
document_iterator end();
void skip();
bool failed();
+
bool validate() {
skip();
return !failed();
@@ -95,10 +101,10 @@ public:
void printError(Node *N, const Twine &Msg);
private:
+ friend class Document;
+
std::unique_ptr<Scanner> scanner;
std::unique_ptr<Document> CurrentDoc;
-
- friend class Document;
};
/// \brief Abstract base class for all Nodes.
@@ -119,6 +125,18 @@ public:
Node(unsigned int Type, std::unique_ptr<Document> &, StringRef Anchor,
StringRef Tag);
+ void *operator new(size_t Size, BumpPtrAllocator &Alloc,
+ size_t Alignment = 16) noexcept {
+ return Alloc.Allocate(Size, Alignment);
+ }
+
+ void operator delete(void *Ptr, BumpPtrAllocator &Alloc,
+ size_t Size) noexcept {
+ Alloc.Deallocate(Ptr, Size);
+ }
+
+ void operator delete(void *) noexcept = delete;
+
/// \brief Get the value of the anchor attached to this node. If it does not
/// have one, getAnchor().size() will be 0.
StringRef getAnchor() const { return Anchor; }
@@ -146,22 +164,10 @@ public:
unsigned int getType() const { return TypeID; }
- void *operator new(size_t Size, BumpPtrAllocator &Alloc,
- size_t Alignment = 16) noexcept {
- return Alloc.Allocate(Size, Alignment);
- }
-
- void operator delete(void *Ptr, BumpPtrAllocator &Alloc,
- size_t Size) noexcept {
- Alloc.Deallocate(Ptr, Size);
- }
-
protected:
std::unique_ptr<Document> &Doc;
SMRange SourceRange;
- void operator delete(void *) noexcept = delete;
-
~Node() = default;
private:
@@ -182,7 +188,7 @@ public:
NullNode(std::unique_ptr<Document> &D)
: Node(NK_Null, D, StringRef(), StringRef()) {}
- static inline bool classof(const Node *N) { return N->getType() == NK_Null; }
+ static bool classof(const Node *N) { return N->getType() == NK_Null; }
};
/// \brief A scalar node is an opaque datum that can be presented as a
@@ -214,7 +220,7 @@ public:
/// This happens with escaped characters and multi-line literals.
StringRef getValue(SmallVectorImpl<char> &Storage) const;
- static inline bool classof(const Node *N) {
+ static bool classof(const Node *N) {
return N->getType() == NK_Scalar;
}
@@ -248,7 +254,7 @@ public:
/// \brief Gets the value of this node as a StringRef.
StringRef getValue() const { return Value; }
- static inline bool classof(const Node *N) {
+ static bool classof(const Node *N) {
return N->getType() == NK_BlockScalar;
}
@@ -268,8 +274,7 @@ class KeyValueNode final : public Node {
public:
KeyValueNode(std::unique_ptr<Document> &D)
- : Node(NK_KeyValue, D, StringRef(), StringRef()), Key(nullptr),
- Value(nullptr) {}
+ : Node(NK_KeyValue, D, StringRef(), StringRef()) {}
/// \brief Parse and return the key.
///
@@ -291,13 +296,13 @@ public:
Val->skip();
}
- static inline bool classof(const Node *N) {
+ static bool classof(const Node *N) {
return N->getType() == NK_KeyValue;
}
private:
- Node *Key;
- Node *Value;
+ Node *Key = nullptr;
+ Node *Value = nullptr;
};
/// \brief This is an iterator abstraction over YAML collections shared by both
@@ -309,7 +314,7 @@ template <class BaseT, class ValueT>
class basic_collection_iterator
: public std::iterator<std::input_iterator_tag, ValueT> {
public:
- basic_collection_iterator() : Base(nullptr) {}
+ basic_collection_iterator() = default;
basic_collection_iterator(BaseT *B) : Base(B) {}
ValueT *operator->() const {
@@ -358,7 +363,7 @@ public:
}
private:
- BaseT *Base;
+ BaseT *Base = nullptr;
};
// The following two templates are used for both MappingNode and Sequence Node.
@@ -399,11 +404,12 @@ public:
MappingNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
MappingType MT)
- : Node(NK_Mapping, D, Anchor, Tag), Type(MT), IsAtBeginning(true),
- IsAtEnd(false), CurrentEntry(nullptr) {}
+ : Node(NK_Mapping, D, Anchor, Tag), Type(MT) {}
friend class basic_collection_iterator<MappingNode, KeyValueNode>;
- typedef basic_collection_iterator<MappingNode, KeyValueNode> iterator;
+
+ using iterator = basic_collection_iterator<MappingNode, KeyValueNode>;
+
template <class T> friend typename T::iterator yaml::begin(T &);
template <class T> friend void yaml::skip(T &);
@@ -413,15 +419,15 @@ public:
void skip() override { yaml::skip(*this); }
- static inline bool classof(const Node *N) {
+ static bool classof(const Node *N) {
return N->getType() == NK_Mapping;
}
private:
MappingType Type;
- bool IsAtBeginning;
- bool IsAtEnd;
- KeyValueNode *CurrentEntry;
+ bool IsAtBeginning = true;
+ bool IsAtEnd = false;
+ KeyValueNode *CurrentEntry = nullptr;
void increment();
};
@@ -453,13 +459,12 @@ public:
SequenceNode(std::unique_ptr<Document> &D, StringRef Anchor, StringRef Tag,
SequenceType ST)
- : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST), IsAtBeginning(true),
- IsAtEnd(false),
- WasPreviousTokenFlowEntry(true), // Start with an imaginary ','.
- CurrentEntry(nullptr) {}
+ : Node(NK_Sequence, D, Anchor, Tag), SeqType(ST) {}
friend class basic_collection_iterator<SequenceNode, Node>;
- typedef basic_collection_iterator<SequenceNode, Node> iterator;
+
+ using iterator = basic_collection_iterator<SequenceNode, Node>;
+
template <class T> friend typename T::iterator yaml::begin(T &);
template <class T> friend void yaml::skip(T &);
@@ -471,16 +476,16 @@ public:
void skip() override { yaml::skip(*this); }
- static inline bool classof(const Node *N) {
+ static bool classof(const Node *N) {
return N->getType() == NK_Sequence;
}
private:
SequenceType SeqType;
- bool IsAtBeginning;
- bool IsAtEnd;
- bool WasPreviousTokenFlowEntry;
- Node *CurrentEntry;
+ bool IsAtBeginning = true;
+ bool IsAtEnd = false;
+ bool WasPreviousTokenFlowEntry = true; // Start with an imaginary ','.
+ Node *CurrentEntry = nullptr;
};
/// \brief Represents an alias to a Node with an anchor.
@@ -497,7 +502,7 @@ public:
StringRef getName() const { return Name; }
Node *getTarget();
- static inline bool classof(const Node *N) { return N->getType() == NK_Alias; }
+ static bool classof(const Node *N) { return N->getType() == NK_Alias; }
private:
StringRef Name;
@@ -507,11 +512,11 @@ private:
/// node.
class Document {
public:
+ Document(Stream &ParentStream);
+
/// \brief Root for parsing a node. Returns a single node.
Node *parseBlockNode();
- Document(Stream &ParentStream);
-
/// \brief Finish parsing the current document and return true if there are
/// more. Return false otherwise.
bool skip();
@@ -564,7 +569,7 @@ private:
/// \brief Iterator abstraction for Documents over a Stream.
class document_iterator {
public:
- document_iterator() : Doc(nullptr) {}
+ document_iterator() = default;
document_iterator(std::unique_ptr<Document> &D) : Doc(&D) {}
bool operator==(const document_iterator &Other) {
@@ -593,11 +598,11 @@ public:
private:
bool isAtEnd() const { return !Doc || !*Doc; }
- std::unique_ptr<Document> *Doc;
+ std::unique_ptr<Document> *Doc = nullptr;
};
-} // End namespace yaml.
+} // end namespace yaml
-} // End namespace llvm.
+} // end namespace llvm
-#endif
+#endif // LLVM_SUPPORT_YAMLPARSER_H
diff --git a/contrib/llvm/include/llvm/Support/YAMLTraits.h b/contrib/llvm/include/llvm/Support/YAMLTraits.h
index cbba9c0..71fdf47 100644
--- a/contrib/llvm/include/llvm/Support/YAMLTraits.h
+++ b/contrib/llvm/include/llvm/Support/YAMLTraits.h
@@ -26,6 +26,7 @@
#include <cctype>
#include <cstddef>
#include <cstdint>
+#include <map>
#include <memory>
#include <new>
#include <string>
@@ -179,17 +180,17 @@ struct BlockScalarTraits {
/// to/from a YAML sequence. For example:
///
/// template<>
-/// struct SequenceTraits< std::vector<MyType>> {
-/// static size_t size(IO &io, std::vector<MyType> &seq) {
+/// struct SequenceTraits<MyContainer> {
+/// static size_t size(IO &io, MyContainer &seq) {
/// return seq.size();
/// }
-/// static MyType& element(IO &, std::vector<MyType> &seq, size_t index) {
+/// static MyType& element(IO &, MyContainer &seq, size_t index) {
/// if ( index >= seq.size() )
/// seq.resize(index+1);
/// return seq[index];
/// }
/// };
-template<typename T>
+template<typename T, typename EnableIf = void>
struct SequenceTraits {
// Must provide:
// static size_t size(IO &io, T &seq);
@@ -200,6 +201,14 @@ struct SequenceTraits {
// static const bool flow = true;
};
+/// This class should be specialized by any type for which vectors of that
+/// type need to be converted to/from a YAML sequence.
+template<typename T, typename EnableIf = void>
+struct SequenceElementTraits {
+ // Must provide:
+ // static const bool flow;
+};
+
/// This class should be specialized by any type that needs to be converted
/// to/from a list of YAML documents.
template<typename T>
@@ -226,7 +235,7 @@ struct MissingTrait;
template <class T>
struct has_ScalarEnumerationTraits
{
- typedef void (*Signature_enumeration)(class IO&, T&);
+ using Signature_enumeration = void (*)(class IO&, T&);
template <typename U>
static char test(SameType<Signature_enumeration, &U::enumeration>*);
@@ -243,7 +252,7 @@ public:
template <class T>
struct has_ScalarBitSetTraits
{
- typedef void (*Signature_bitset)(class IO&, T&);
+ using Signature_bitset = void (*)(class IO&, T&);
template <typename U>
static char test(SameType<Signature_bitset, &U::bitset>*);
@@ -259,9 +268,9 @@ public:
template <class T>
struct has_ScalarTraits
{
- typedef StringRef (*Signature_input)(StringRef, void*, T&);
- typedef void (*Signature_output)(const T&, void*, llvm::raw_ostream&);
- typedef bool (*Signature_mustQuote)(StringRef);
+ using Signature_input = StringRef (*)(StringRef, void*, T&);
+ using Signature_output = void (*)(const T&, void*, raw_ostream&);
+ using Signature_mustQuote = bool (*)(StringRef);
template <typename U>
static char test(SameType<Signature_input, &U::input> *,
@@ -280,8 +289,8 @@ public:
template <class T>
struct has_BlockScalarTraits
{
- typedef StringRef (*Signature_input)(StringRef, void *, T &);
- typedef void (*Signature_output)(const T &, void *, llvm::raw_ostream &);
+ using Signature_input = StringRef (*)(StringRef, void *, T &);
+ using Signature_output = void (*)(const T &, void *, raw_ostream &);
template <typename U>
static char test(SameType<Signature_input, &U::input> *,
@@ -297,7 +306,7 @@ public:
// Test if MappingContextTraits<T> is defined on type T.
template <class T, class Context> struct has_MappingTraits {
- typedef void (*Signature_mapping)(class IO &, T &, Context &);
+ using Signature_mapping = void (*)(class IO &, T &, Context &);
template <typename U>
static char test(SameType<Signature_mapping, &U::mapping>*);
@@ -312,7 +321,7 @@ public:
// Test if MappingTraits<T> is defined on type T.
template <class T> struct has_MappingTraits<T, EmptyContext> {
- typedef void (*Signature_mapping)(class IO &, T &);
+ using Signature_mapping = void (*)(class IO &, T &);
template <typename U>
static char test(SameType<Signature_mapping, &U::mapping> *);
@@ -325,7 +334,7 @@ public:
// Test if MappingContextTraits<T>::validate() is defined on type T.
template <class T, class Context> struct has_MappingValidateTraits {
- typedef StringRef (*Signature_validate)(class IO &, T &, Context &);
+ using Signature_validate = StringRef (*)(class IO &, T &, Context &);
template <typename U>
static char test(SameType<Signature_validate, &U::validate>*);
@@ -340,7 +349,7 @@ public:
// Test if MappingTraits<T>::validate() is defined on type T.
template <class T> struct has_MappingValidateTraits<T, EmptyContext> {
- typedef StringRef (*Signature_validate)(class IO &, T &);
+ using Signature_validate = StringRef (*)(class IO &, T &);
template <typename U>
static char test(SameType<Signature_validate, &U::validate> *);
@@ -355,7 +364,7 @@ public:
template <class T>
struct has_SequenceMethodTraits
{
- typedef size_t (*Signature_size)(class IO&, T&);
+ using Signature_size = size_t (*)(class IO&, T&);
template <typename U>
static char test(SameType<Signature_size, &U::size>*);
@@ -371,7 +380,7 @@ public:
template <class T>
struct has_CustomMappingTraits
{
- typedef void (*Signature_input)(IO &io, StringRef key, T &v);
+ using Signature_input = void (*)(IO &io, StringRef key, T &v);
template <typename U>
static char test(SameType<Signature_input, &U::inputOne>*);
@@ -422,7 +431,7 @@ struct has_SequenceTraits : public std::integral_constant<bool,
template <class T>
struct has_DocumentListTraits
{
- typedef size_t (*Signature_size)(class IO&, T&);
+ using Signature_size = size_t (*)(class IO &, T &);
template <typename U>
static char test(SameType<Signature_size, &U::size>*);
@@ -537,7 +546,7 @@ struct unvalidatedMappingTraits
// Base class for Input and Output.
class IO {
public:
- IO(void *Ctxt=nullptr);
+ IO(void *Ctxt = nullptr);
virtual ~IO();
virtual bool outputting() = 0;
@@ -606,7 +615,7 @@ public:
template <typename T>
void bitSetCase(T &Val, const char* Str, const T ConstVal) {
if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
- Val = Val | ConstVal;
+ Val = static_cast<T>(Val | ConstVal);
}
}
@@ -614,7 +623,7 @@ public:
template <typename T>
void bitSetCase(T &Val, const char* Str, const uint32_t ConstVal) {
if ( bitSetMatch(Str, outputting() && (Val & ConstVal) == ConstVal) ) {
- Val = Val | ConstVal;
+ Val = static_cast<T>(Val | ConstVal);
}
}
@@ -638,6 +647,7 @@ public:
EmptyContext Ctx;
this->processKey(Key, Val, true, Ctx);
}
+
template <typename T, typename Context>
void mapRequired(const char *Key, T &Val, Context &Ctx) {
this->processKey(Key, Val, true, Ctx);
@@ -689,11 +699,12 @@ private:
assert(DefaultValue.hasValue() == false &&
"Optional<T> shouldn't have a value!");
void *SaveInfo;
- bool UseDefault;
+ bool UseDefault = true;
const bool sameAsDefault = outputting() && !Val.hasValue();
if (!outputting() && !Val.hasValue())
Val = T();
- if (this->preflightKey(Key, Required, sameAsDefault, UseDefault,
+ if (Val.hasValue() &&
+ this->preflightKey(Key, Required, sameAsDefault, UseDefault,
SaveInfo)) {
yamlize(*this, Val.getValue(), Required, Ctx);
this->postflightKey(SaveInfo);
@@ -731,7 +742,7 @@ private:
}
private:
- void *Ctxt;
+ void *Ctxt;
};
namespace detail {
@@ -772,7 +783,7 @@ typename std::enable_if<has_ScalarTraits<T>::value, void>::type
yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
if ( io.outputting() ) {
std::string Storage;
- llvm::raw_string_ostream Buffer(Storage);
+ raw_string_ostream Buffer(Storage);
ScalarTraits<T>::output(Val, io.getContext(), Buffer);
StringRef Str = Buffer.str();
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
@@ -782,7 +793,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
io.scalarString(Str, ScalarTraits<T>::mustQuote(Str));
StringRef Result = ScalarTraits<T>::input(Str, io.getContext(), Val);
if ( !Result.empty() ) {
- io.setError(llvm::Twine(Result));
+ io.setError(Twine(Result));
}
}
}
@@ -792,7 +803,7 @@ typename std::enable_if<has_BlockScalarTraits<T>::value, void>::type
yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
if (YamlIO.outputting()) {
std::string Storage;
- llvm::raw_string_ostream Buffer(Storage);
+ raw_string_ostream Buffer(Storage);
BlockScalarTraits<T>::output(Val, YamlIO.getContext(), Buffer);
StringRef Str = Buffer.str();
YamlIO.blockScalarString(Str);
@@ -802,7 +813,7 @@ yamlize(IO &YamlIO, T &Val, bool, EmptyContext &Ctx) {
StringRef Result =
BlockScalarTraits<T>::input(Str, YamlIO.getContext(), Val);
if (!Result.empty())
- YamlIO.setError(llvm::Twine(Result));
+ YamlIO.setError(Twine(Result));
}
}
@@ -816,7 +827,7 @@ yamlize(IO &io, T &Val, bool, Context &Ctx) {
if (io.outputting()) {
StringRef Err = MappingTraits<T>::validate(io, Val);
if (!Err.empty()) {
- llvm::errs() << Err << "\n";
+ errs() << Err << "\n";
assert(Err.empty() && "invalid struct trying to be written as yaml");
}
}
@@ -870,7 +881,7 @@ yamlize(IO &io, T &Val, bool, EmptyContext &Ctx) {
template <typename T, typename Context>
typename std::enable_if<has_SequenceTraits<T>::value, void>::type
yamlize(IO &io, T &Seq, bool, Context &Ctx) {
- if ( has_FlowTraits< SequenceTraits<T> >::value ) {
+ if ( has_FlowTraits< SequenceTraits<T>>::value ) {
unsigned incnt = io.beginFlowSequence();
unsigned count = io.outputting() ? SequenceTraits<T>::size(io, Seq) : incnt;
for(unsigned i=0; i < count; ++i) {
@@ -898,92 +909,92 @@ yamlize(IO &io, T &Seq, bool, Context &Ctx) {
template<>
struct ScalarTraits<bool> {
- static void output(const bool &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, bool &);
+ static void output(const bool &, void* , raw_ostream &);
+ static StringRef input(StringRef, void *, bool &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<StringRef> {
- static void output(const StringRef &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, StringRef &);
+ static void output(const StringRef &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, StringRef &);
static bool mustQuote(StringRef S) { return needsQuotes(S); }
};
template<>
struct ScalarTraits<std::string> {
- static void output(const std::string &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, std::string &);
+ static void output(const std::string &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, std::string &);
static bool mustQuote(StringRef S) { return needsQuotes(S); }
};
template<>
struct ScalarTraits<uint8_t> {
- static void output(const uint8_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint8_t &);
+ static void output(const uint8_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint8_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<uint16_t> {
- static void output(const uint16_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint16_t &);
+ static void output(const uint16_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint16_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<uint32_t> {
- static void output(const uint32_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint32_t &);
+ static void output(const uint32_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint32_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<uint64_t> {
- static void output(const uint64_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, uint64_t &);
+ static void output(const uint64_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, uint64_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int8_t> {
- static void output(const int8_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int8_t &);
+ static void output(const int8_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int8_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int16_t> {
- static void output(const int16_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int16_t &);
+ static void output(const int16_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int16_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int32_t> {
- static void output(const int32_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int32_t &);
+ static void output(const int32_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int32_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<int64_t> {
- static void output(const int64_t &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, int64_t &);
+ static void output(const int64_t &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, int64_t &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<float> {
- static void output(const float &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, float &);
+ static void output(const float &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, float &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<double> {
- static void output(const double &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, double &);
+ static void output(const double &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, double &);
static bool mustQuote(StringRef) { return false; }
};
@@ -993,12 +1004,11 @@ struct ScalarTraits<double> {
template <typename value_type, support::endianness endian, size_t alignment>
struct ScalarTraits<support::detail::packed_endian_specific_integral<
value_type, endian, alignment>> {
- typedef support::detail::packed_endian_specific_integral<value_type, endian,
- alignment>
- endian_type;
+ using endian_type =
+ support::detail::packed_endian_specific_integral<value_type, endian,
+ alignment>;
- static void output(const endian_type &E, void *Ctx,
- llvm::raw_ostream &Stream) {
+ static void output(const endian_type &E, void *Ctx, raw_ostream &Stream) {
ScalarTraits<value_type>::output(static_cast<value_type>(E), Ctx, Stream);
}
@@ -1038,7 +1048,7 @@ struct MappingNormalization {
TNorm* operator->() { return BufPtr; }
private:
- typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
+ using Storage = AlignedCharArrayUnion<TNorm>;
Storage Buffer;
IO &io;
@@ -1050,9 +1060,8 @@ private:
// to [de]normalize an object for use with YAML conversion.
template <typename TNorm, typename TFinal>
struct MappingNormalizationHeap {
- MappingNormalizationHeap(IO &i_o, TFinal &Obj,
- llvm::BumpPtrAllocator *allocator)
- : io(i_o), BufPtr(nullptr), Result(Obj) {
+ MappingNormalizationHeap(IO &i_o, TFinal &Obj, BumpPtrAllocator *allocator)
+ : io(i_o), Result(Obj) {
if ( io.outputting() ) {
BufPtr = new (&Buffer) TNorm(io, Obj);
}
@@ -1076,11 +1085,11 @@ struct MappingNormalizationHeap {
TNorm* operator->() { return BufPtr; }
private:
- typedef llvm::AlignedCharArrayUnion<TNorm> Storage;
+ using Storage = AlignedCharArrayUnion<TNorm>;
Storage Buffer;
IO &io;
- TNorm *BufPtr;
+ TNorm *BufPtr = nullptr;
TFinal &Result;
};
@@ -1105,6 +1114,10 @@ public:
void *Ctxt = nullptr,
SourceMgr::DiagHandlerTy DiagHandler = nullptr,
void *DiagHandlerCtxt = nullptr);
+ Input(MemoryBufferRef Input,
+ void *Ctxt = nullptr,
+ SourceMgr::DiagHandlerTy DiagHandler = nullptr,
+ void *DiagHandlerCtxt = nullptr);
~Input() override;
// Check if there was an syntax or semantic error during parsing.
@@ -1147,7 +1160,7 @@ private:
HNode(Node *n) : _node(n) { }
virtual ~HNode() = default;
- static inline bool classof(const HNode *) { return true; }
+ static bool classof(const HNode *) { return true; }
Node *_node;
};
@@ -1158,11 +1171,9 @@ private:
public:
EmptyHNode(Node *n) : HNode(n) { }
- static inline bool classof(const HNode *n) {
- return NullNode::classof(n->_node);
- }
+ static bool classof(const HNode *n) { return NullNode::classof(n->_node); }
- static inline bool classof(const EmptyHNode *) { return true; }
+ static bool classof(const EmptyHNode *) { return true; }
};
class ScalarHNode : public HNode {
@@ -1173,12 +1184,12 @@ private:
StringRef value() const { return _value; }
- static inline bool classof(const HNode *n) {
+ static bool classof(const HNode *n) {
return ScalarNode::classof(n->_node) ||
BlockScalarNode::classof(n->_node);
}
- static inline bool classof(const ScalarHNode *) { return true; }
+ static bool classof(const ScalarHNode *) { return true; }
protected:
StringRef _value;
@@ -1190,16 +1201,16 @@ private:
public:
MapHNode(Node *n) : HNode(n) { }
- static inline bool classof(const HNode *n) {
+ static bool classof(const HNode *n) {
return MappingNode::classof(n->_node);
}
- static inline bool classof(const MapHNode *) { return true; }
+ static bool classof(const MapHNode *) { return true; }
- typedef llvm::StringMap<std::unique_ptr<HNode>> NameToNode;
+ using NameToNode = StringMap<std::unique_ptr<HNode>>;
- NameToNode Mapping;
- llvm::SmallVector<std::string, 6> ValidKeys;
+ NameToNode Mapping;
+ SmallVector<std::string, 6> ValidKeys;
};
class SequenceHNode : public HNode {
@@ -1208,11 +1219,11 @@ private:
public:
SequenceHNode(Node *n) : HNode(n) { }
- static inline bool classof(const HNode *n) {
+ static bool classof(const HNode *n) {
return SequenceNode::classof(n->_node);
}
- static inline bool classof(const SequenceHNode *) { return true; }
+ static bool classof(const SequenceHNode *) { return true; }
std::vector<std::unique_ptr<HNode>> Entries;
};
@@ -1231,14 +1242,14 @@ public:
const Node *getCurrentNode() const;
private:
- llvm::SourceMgr SrcMgr; // must be before Strm
+ SourceMgr SrcMgr; // must be before Strm
std::unique_ptr<llvm::yaml::Stream> Strm;
std::unique_ptr<HNode> TopNode;
std::error_code EC;
- llvm::BumpPtrAllocator StringAllocator;
- llvm::yaml::document_iterator DocIterator;
+ BumpPtrAllocator StringAllocator;
+ document_iterator DocIterator;
std::vector<bool> BitValuesUsed;
- HNode *CurrentNode;
+ HNode *CurrentNode = nullptr;
bool ScalarMatchFound;
};
@@ -1248,9 +1259,16 @@ private:
///
class Output : public IO {
public:
- Output(llvm::raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
+ Output(raw_ostream &, void *Ctxt = nullptr, int WrapColumn = 70);
~Output() override;
+ /// \brief Set whether or not to output optional values which are equal
+ /// to the default value. By default, when outputting if you attempt
+ /// to write a value that is equal to the default, the value gets ignored.
+ /// Sometimes, it is useful to be able to see these in the resulting YAML
+ /// anyway.
+ void setWriteDefaultValues(bool Write) { WriteDefaultValues = Write; }
+
bool outputting() override;
bool mapTag(StringRef, bool) override;
void beginMapping() override;
@@ -1304,16 +1322,17 @@ private:
inFlowMapOtherKey
};
- llvm::raw_ostream &Out;
- int WrapColumn;
- SmallVector<InState, 8> StateStack;
- int Column;
- int ColumnAtFlowStart;
- int ColumnAtMapFlowStart;
- bool NeedBitValueComma;
- bool NeedFlowSequenceComma;
- bool EnumerationMatchFound;
- bool NeedsNewLine;
+ raw_ostream &Out;
+ int WrapColumn;
+ SmallVector<InState, 8> StateStack;
+ int Column = 0;
+ int ColumnAtFlowStart = 0;
+ int ColumnAtMapFlowStart = 0;
+ bool NeedBitValueComma = false;
+ bool NeedFlowSequenceComma = false;
+ bool EnumerationMatchFound = false;
+ bool NeedsNewLine = false;
+ bool WriteDefaultValues = false;
};
/// YAML I/O does conversion based on types. But often native data types
@@ -1336,7 +1355,7 @@ private:
bool operator==(const _base &rhs) const { return value == rhs; } \
bool operator<(const _type &rhs) const { return value < rhs.value; } \
_base value; \
- typedef _base BaseType; \
+ using BaseType = _base; \
};
///
@@ -1350,29 +1369,29 @@ LLVM_YAML_STRONG_TYPEDEF(uint64_t, Hex64)
template<>
struct ScalarTraits<Hex8> {
- static void output(const Hex8 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex8 &);
+ static void output(const Hex8 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex8 &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<Hex16> {
- static void output(const Hex16 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex16 &);
+ static void output(const Hex16 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex16 &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<Hex32> {
- static void output(const Hex32 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex32 &);
+ static void output(const Hex32 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex32 &);
static bool mustQuote(StringRef) { return false; }
};
template<>
struct ScalarTraits<Hex64> {
- static void output(const Hex64 &, void*, llvm::raw_ostream &);
- static StringRef input(StringRef, void*, Hex64 &);
+ static void output(const Hex64 &, void *, raw_ostream &);
+ static StringRef input(StringRef, void *, Hex64 &);
static bool mustQuote(StringRef) { return false; }
};
@@ -1535,22 +1554,67 @@ operator<<(Output &yout, T &seq) {
return yout;
}
-template <typename T> struct SequenceTraitsImpl {
- typedef typename T::value_type _type;
+template <bool B> struct IsFlowSequenceBase {};
+template <> struct IsFlowSequenceBase<true> { static const bool flow = true; };
+
+template <typename T, bool Flow>
+struct SequenceTraitsImpl : IsFlowSequenceBase<Flow> {
+private:
+ using type = typename T::value_type;
+
+public:
static size_t size(IO &io, T &seq) { return seq.size(); }
- static _type &element(IO &io, T &seq, size_t index) {
+
+ static type &element(IO &io, T &seq, size_t index) {
if (index >= seq.size())
seq.resize(index + 1);
return seq[index];
}
};
+// Simple helper to check an expression can be used as a bool-valued template
+// argument.
+template <bool> struct CheckIsBool { static const bool value = true; };
+
+// If T has SequenceElementTraits, then vector<T> and SmallVector<T, N> have
+// SequenceTraits that do the obvious thing.
+template <typename T>
+struct SequenceTraits<std::vector<T>,
+ typename std::enable_if<CheckIsBool<
+ SequenceElementTraits<T>::flow>::value>::type>
+ : SequenceTraitsImpl<std::vector<T>, SequenceElementTraits<T>::flow> {};
+template <typename T, unsigned N>
+struct SequenceTraits<SmallVector<T, N>,
+ typename std::enable_if<CheckIsBool<
+ SequenceElementTraits<T>::flow>::value>::type>
+ : SequenceTraitsImpl<SmallVector<T, N>, SequenceElementTraits<T>::flow> {};
+
+// Sequences of fundamental types use flow formatting.
+template <typename T>
+struct SequenceElementTraits<
+ T, typename std::enable_if<std::is_fundamental<T>::value>::type> {
+ static const bool flow = true;
+};
+
+// Sequences of strings use block formatting.
+template<> struct SequenceElementTraits<std::string> {
+ static const bool flow = false;
+};
+template<> struct SequenceElementTraits<StringRef> {
+ static const bool flow = false;
+};
+template<> struct SequenceElementTraits<std::pair<std::string, std::string>> {
+ static const bool flow = false;
+};
+
/// Implementation of CustomMappingTraits for std::map<std::string, T>.
template <typename T> struct StdMapStringCustomMappingTraitsImpl {
- typedef std::map<std::string, T> map_type;
+ using map_type = std::map<std::string, T>;
+
static void inputOne(IO &io, StringRef key, map_type &v) {
io.mapRequired(key.str().c_str(), v[key]);
}
+
static void output(IO &io, map_type &v) {
for (auto &p : v)
io.mapRequired(p.first.c_str(), p.second);
@@ -1560,39 +1624,64 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
} // end namespace yaml
} // end namespace llvm
-/// Utility for declaring that a std::vector of a particular type
-/// should be considered a YAML sequence.
-#define LLVM_YAML_IS_SEQUENCE_VECTOR(_type) \
+#define LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(TYPE, FLOW) \
namespace llvm { \
namespace yaml { \
- template <> \
- struct SequenceTraits<std::vector<_type>> \
- : public SequenceTraitsImpl<std::vector<_type>> {}; \
- template <unsigned N> \
- struct SequenceTraits<SmallVector<_type, N>> \
- : public SequenceTraitsImpl<SmallVector<_type, N>> {}; \
+ static_assert( \
+ !std::is_fundamental<TYPE>::value && \
+ !std::is_same<TYPE, std::string>::value && \
+ !std::is_same<TYPE, llvm::StringRef>::value, \
+ "only use LLVM_YAML_IS_SEQUENCE_VECTOR for types you control"); \
+ template <> struct SequenceElementTraits<TYPE> { \
+ static const bool flow = FLOW; \
+ }; \
} \
}
/// Utility for declaring that a std::vector of a particular type
+/// should be considered a YAML sequence.
+#define LLVM_YAML_IS_SEQUENCE_VECTOR(type) \
+ LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, false)
+
+/// Utility for declaring that a std::vector of a particular type
/// should be considered a YAML flow sequence.
-/// We need to do a partial specialization on the vector version, not a full.
-/// If this is a full specialization, the compiler is a bit too "smart" and
-/// decides to warn on -Wunused-const-variable. This workaround can be
-/// removed and we can do a full specialization on std::vector<T> once
-/// PR28878 is fixed.
-#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(_type) \
+#define LLVM_YAML_IS_FLOW_SEQUENCE_VECTOR(type) \
+ LLVM_YAML_IS_SEQUENCE_VECTOR_IMPL(type, true)
+
+#define LLVM_YAML_DECLARE_MAPPING_TRAITS(Type) \
namespace llvm { \
namespace yaml { \
- template <unsigned N> \
- struct SequenceTraits<SmallVector<_type, N>> \
- : public SequenceTraitsImpl<SmallVector<_type, N>> { \
- static const bool flow = true; \
+ template <> struct MappingTraits<Type> { \
+ static void mapping(IO &IO, Type &Obj); \
+ }; \
+ } \
+ }
+
+#define LLVM_YAML_DECLARE_ENUM_TRAITS(Type) \
+ namespace llvm { \
+ namespace yaml { \
+ template <> struct ScalarEnumerationTraits<Type> { \
+ static void enumeration(IO &io, Type &Value); \
+ }; \
+ } \
+ }
+
+#define LLVM_YAML_DECLARE_BITSET_TRAITS(Type) \
+ namespace llvm { \
+ namespace yaml { \
+ template <> struct ScalarBitSetTraits<Type> { \
+ static void bitset(IO &IO, Type &Options); \
}; \
- template <typename Allocator> \
- struct SequenceTraits<std::vector<_type, Allocator>> \
- : public SequenceTraitsImpl<std::vector<_type, Allocator>> { \
- static const bool flow = true; \
+ } \
+ }
+
+#define LLVM_YAML_DECLARE_SCALAR_TRAITS(Type, MustQuote) \
+ namespace llvm { \
+ namespace yaml { \
+ template <> struct ScalarTraits<Type> { \
+ static void output(const Type &Value, void *ctx, raw_ostream &Out); \
+ static StringRef input(StringRef Scalar, void *ctxt, Type &Value); \
+ static bool mustQuote(StringRef) { return MustQuote; } \
}; \
} \
}
@@ -1604,10 +1693,10 @@ template <typename T> struct StdMapStringCustomMappingTraitsImpl {
namespace yaml { \
template <unsigned N> \
struct DocumentListTraits<SmallVector<_type, N>> \
- : public SequenceTraitsImpl<SmallVector<_type, N>> {}; \
+ : public SequenceTraitsImpl<SmallVector<_type, N>, false> {}; \
template <> \
struct DocumentListTraits<std::vector<_type>> \
- : public SequenceTraitsImpl<std::vector<_type>> {}; \
+ : public SequenceTraitsImpl<std::vector<_type>, false> {}; \
} \
}
diff --git a/contrib/llvm/include/llvm/Support/raw_sha1_ostream.h b/contrib/llvm/include/llvm/Support/raw_sha1_ostream.h
index 329ef9f..bd55d98 100644
--- a/contrib/llvm/include/llvm/Support/raw_sha1_ostream.h
+++ b/contrib/llvm/include/llvm/Support/raw_sha1_ostream.h
@@ -14,9 +14,9 @@
#ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
#define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H
-#include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/SHA1.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/Support/SHA1.h"
+#include "llvm/Support/raw_ostream.h"
namespace llvm {
diff --git a/contrib/llvm/include/llvm/Support/thread.h b/contrib/llvm/include/llvm/Support/thread.h
index 9c45418..787a513 100644
--- a/contrib/llvm/include/llvm/Support/thread.h
+++ b/contrib/llvm/include/llvm/Support/thread.h
@@ -21,22 +21,8 @@
#if LLVM_ENABLE_THREADS
-#ifdef _MSC_VER
-// concrt.h depends on eh.h for __uncaught_exception declaration
-// even if we disable exceptions.
-#include <eh.h>
-
-// Suppress 'C++ exception handler used, but unwind semantics are not enabled.'
-#pragma warning(push)
-#pragma warning(disable:4530)
-#endif
-
#include <thread>
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
namespace llvm {
typedef std::thread thread;
}
diff --git a/contrib/llvm/include/llvm/Support/type_traits.h b/contrib/llvm/include/llvm/Support/type_traits.h
index 7706ff5..cc08783 100644
--- a/contrib/llvm/include/llvm/Support/type_traits.h
+++ b/contrib/llvm/include/llvm/Support/type_traits.h
@@ -14,11 +14,10 @@
#ifndef LLVM_SUPPORT_TYPE_TRAITS_H
#define LLVM_SUPPORT_TYPE_TRAITS_H
+#include "llvm/Support/Compiler.h"
#include <type_traits>
#include <utility>
-#include "llvm/Support/Compiler.h"
-
#ifndef __has_feature
#define LLVM_DEFINED_HAS_FEATURE
#define __has_feature(x) 0
@@ -51,7 +50,7 @@ struct isPodLike {
// std::pair's are pod-like if their elements are.
template<typename T, typename U>
-struct isPodLike<std::pair<T, U> > {
+struct isPodLike<std::pair<T, U>> {
static const bool value = isPodLike<T>::value && isPodLike<U>::value;
};
@@ -63,7 +62,7 @@ struct isPodLike<std::pair<T, U> > {
/// Also note that enum classes aren't implicitly convertible to integral types,
/// the value may therefore need to be explicitly converted before being used.
template <typename T> class is_integral_or_enum {
- typedef typename std::remove_reference<T>::type UnderlyingT;
+ using UnderlyingT = typename std::remove_reference<T>::type;
public:
static const bool value =
@@ -76,26 +75,36 @@ public:
/// \brief If T is a pointer, just return it. If it is not, return T&.
template<typename T, typename Enable = void>
-struct add_lvalue_reference_if_not_pointer { typedef T &type; };
+struct add_lvalue_reference_if_not_pointer { using type = T &; };
template <typename T>
struct add_lvalue_reference_if_not_pointer<
T, typename std::enable_if<std::is_pointer<T>::value>::type> {
- typedef T type;
+ using type = T;
};
/// \brief If T is a pointer to X, return a pointer to const X. If it is not,
/// return const T.
template<typename T, typename Enable = void>
-struct add_const_past_pointer { typedef const T type; };
+struct add_const_past_pointer { using type = const T; };
template <typename T>
struct add_const_past_pointer<
T, typename std::enable_if<std::is_pointer<T>::value>::type> {
- typedef const typename std::remove_pointer<T>::type *type;
+ using type = const typename std::remove_pointer<T>::type *;
};
-}
+template <typename T, typename Enable = void>
+struct const_pointer_or_const_ref {
+ using type = const T &;
+};
+template <typename T>
+struct const_pointer_or_const_ref<
+ T, typename std::enable_if<std::is_pointer<T>::value>::type> {
+ using type = typename add_const_past_pointer<T>::type;
+};
+
+} // end namespace llvm
// If the compiler supports detecting whether a class is final, define
// an LLVM_IS_FINAL macro. If it cannot be defined properly, this
@@ -110,4 +119,4 @@ struct add_const_past_pointer<
#undef __has_feature
#endif
-#endif
+#endif // LLVM_SUPPORT_TYPE_TRAITS_H
OpenPOWER on IntegriCloud