├── .gitignore ├── ArrayTypes.h ├── CMakeLists.txt ├── LICENSE ├── README.md ├── data_structure_benchmarks.cpp ├── data_types.h ├── lib └── llvm │ ├── include │ ├── llvm-c │ │ ├── Analysis.h │ │ ├── BitReader.h │ │ ├── BitWriter.h │ │ ├── Core.h │ │ ├── DebugInfo.h │ │ ├── Disassembler.h │ │ ├── ErrorHandling.h │ │ ├── ExecutionEngine.h │ │ ├── IRReader.h │ │ ├── Initialization.h │ │ ├── LinkTimeOptimizer.h │ │ ├── Linker.h │ │ ├── Object.h │ │ ├── OrcBindings.h │ │ ├── Support.h │ │ ├── Target.h │ │ ├── TargetMachine.h │ │ ├── Transforms │ │ │ ├── IPO.h │ │ │ ├── PassManagerBuilder.h │ │ │ ├── Scalar.h │ │ │ └── Vectorize.h │ │ ├── Types.h │ │ ├── lto.h │ │ └── module.modulemap │ └── llvm │ │ ├── ADT │ │ ├── APFloat.h │ │ ├── APInt.h │ │ ├── APSInt.h │ │ ├── AllocatorList.h │ │ ├── ArrayRef.h │ │ ├── BitVector.h │ │ ├── BitmaskEnum.h │ │ ├── BreadthFirstIterator.h │ │ ├── CachedHashString.h │ │ ├── DAGDeltaAlgorithm.h │ │ ├── DeltaAlgorithm.h │ │ ├── DenseMap.h │ │ ├── DenseMapInfo.h │ │ ├── DenseSet.h │ │ ├── DepthFirstIterator.h │ │ ├── EpochTracker.h │ │ ├── EquivalenceClasses.h │ │ ├── FoldingSet.h │ │ ├── GraphTraits.h │ │ ├── Hashing.h │ │ ├── ImmutableList.h │ │ ├── ImmutableMap.h │ │ ├── ImmutableSet.h │ │ ├── IndexedMap.h │ │ ├── IntEqClasses.h │ │ ├── IntervalMap.h │ │ ├── IntrusiveRefCntPtr.h │ │ ├── MapVector.h │ │ ├── None.h │ │ ├── Optional.h │ │ ├── PackedVector.h │ │ ├── PointerEmbeddedInt.h │ │ ├── PointerIntPair.h │ │ ├── PointerSumType.h │ │ ├── PointerUnion.h │ │ ├── PostOrderIterator.h │ │ ├── PriorityQueue.h │ │ ├── PriorityWorklist.h │ │ ├── SCCIterator.h │ │ ├── STLExtras.h │ │ ├── ScopeExit.h │ │ ├── ScopedHashTable.h │ │ ├── Sequence.h │ │ ├── SetOperations.h │ │ ├── SetVector.h │ │ ├── SmallBitVector.h │ │ ├── SmallPtrSet.h │ │ ├── SmallSet.h │ │ ├── SmallString.h │ │ ├── SmallVector.h │ │ ├── SparseBitVector.h │ │ ├── SparseMultiSet.h │ │ ├── SparseSet.h │ │ ├── Statistic.h │ │ ├── StringExtras.h │ │ ├── StringMap.h │ │ ├── StringRef.h │ │ ├── StringSet.h │ │ ├── StringSwitch.h │ │ ├── TinyPtrVector.h │ │ ├── Triple.h │ │ ├── Twine.h │ │ ├── UniqueVector.h │ │ ├── VariadicFunction.h │ │ ├── edit_distance.h │ │ ├── ilist.h │ │ ├── ilist_base.h │ │ ├── ilist_iterator.h │ │ ├── ilist_node.h │ │ ├── ilist_node_base.h │ │ ├── ilist_node_options.h │ │ ├── iterator.h │ │ ├── iterator_range.h │ │ └── simple_ilist.h │ │ ├── Config │ │ ├── AsmParsers.def.in │ │ ├── AsmPrinters.def.in │ │ ├── Disassemblers.def.in │ │ ├── Targets.def.in │ │ ├── abi-breaking.h │ │ ├── abi-breaking.h.cmake │ │ ├── config.h.cmake │ │ ├── llvm-config.h │ │ └── llvm-config.h.cmake │ │ └── Support │ │ ├── AArch64TargetParser.def │ │ ├── AMDGPUKernelDescriptor.h │ │ ├── AMDGPUMetadata.h │ │ ├── ARMAttributeParser.h │ │ ├── ARMBuildAttributes.h │ │ ├── ARMEHABI.h │ │ ├── ARMTargetParser.def │ │ ├── ARMWinEH.h │ │ ├── AlignOf.h │ │ ├── Allocator.h │ │ ├── ArrayRecycler.h │ │ ├── Atomic.h │ │ ├── AtomicOrdering.h │ │ ├── BinaryByteStream.h │ │ ├── BinaryItemStream.h │ │ ├── BinaryStream.h │ │ ├── BinaryStreamArray.h │ │ ├── BinaryStreamError.h │ │ ├── BinaryStreamReader.h │ │ ├── BinaryStreamRef.h │ │ ├── BinaryStreamWriter.h │ │ ├── BlockFrequency.h │ │ ├── BranchProbability.h │ │ ├── CBindingWrapping.h │ │ ├── CMakeLists.txt │ │ ├── COM.h │ │ ├── CachePruning.h │ │ ├── Capacity.h │ │ ├── Casting.h │ │ ├── Chrono.h │ │ ├── CodeGen.h │ │ ├── CodeGenCWrappers.h │ │ ├── CodeGenCoverage.h │ │ ├── CommandLine.h │ │ ├── Compiler.h │ │ ├── Compression.h │ │ ├── ConvertUTF.h │ │ ├── CrashRecoveryContext.h │ │ ├── DJB.h │ │ ├── DOTGraphTraits.h │ │ ├── DataExtractor.h │ │ ├── DataTypes.h │ │ ├── DataTypes.h.cmake │ │ ├── Debug.h │ │ ├── DebugCounter.h │ │ ├── DynamicLibrary.h │ │ ├── Endian.h │ │ ├── EndianStream.h │ │ ├── Errc.h │ │ ├── Errno.h │ │ ├── Error.h │ │ ├── ErrorHandling.h │ │ ├── ErrorOr.h │ │ ├── FileOutputBuffer.h │ │ ├── FileSystem.h │ │ ├── FileUtilities.h │ │ ├── Format.h │ │ ├── FormatAdapters.h │ │ ├── FormatCommon.h │ │ ├── FormatProviders.h │ │ ├── FormatVariadic.h │ │ ├── FormatVariadicDetails.h │ │ ├── FormattedStream.h │ │ ├── GenericDomTree.h │ │ ├── GenericDomTreeConstruction.h │ │ ├── GlobPattern.h │ │ ├── GraphWriter.h │ │ ├── Host.h │ │ ├── JamCRC.h │ │ ├── KnownBits.h │ │ ├── LEB128.h │ │ ├── LICENSE.TXT │ │ ├── LineIterator.h │ │ ├── Locale.h │ │ ├── LockFileManager.h │ │ ├── LowLevelTypeImpl.h │ │ ├── MD5.h │ │ ├── ManagedStatic.h │ │ ├── MathExtras.h │ │ ├── Memory.h │ │ ├── MemoryBuffer.h │ │ ├── MipsABIFlags.h │ │ ├── Mutex.h │ │ ├── MutexGuard.h │ │ ├── NativeFormatting.h │ │ ├── OnDiskHashTable.h │ │ ├── Options.h │ │ ├── Parallel.h │ │ ├── Path.h │ │ ├── PluginLoader.h │ │ ├── PointerLikeTypeTraits.h │ │ ├── PrettyStackTrace.h │ │ ├── Printable.h │ │ ├── Process.h │ │ ├── Program.h │ │ ├── RWMutex.h │ │ ├── RandomNumberGenerator.h │ │ ├── Recycler.h │ │ ├── RecyclingAllocator.h │ │ ├── Regex.h │ │ ├── Registry.h │ │ ├── ReverseIteration.h │ │ ├── SHA1.h │ │ ├── SMLoc.h │ │ ├── SaveAndRestore.h │ │ ├── ScaledNumber.h │ │ ├── ScopedPrinter.h │ │ ├── Signals.h │ │ ├── Solaris │ │ └── sys │ │ │ └── regset.h │ │ ├── SourceMgr.h │ │ ├── SpecialCaseList.h │ │ ├── StringPool.h │ │ ├── StringSaver.h │ │ ├── SwapByteOrder.h │ │ ├── SystemUtils.h │ │ ├── TarWriter.h │ │ ├── TargetParser.h │ │ ├── TargetRegistry.h │ │ ├── TargetSelect.h │ │ ├── ThreadLocal.h │ │ ├── ThreadPool.h │ │ ├── Threading.h │ │ ├── Timer.h │ │ ├── ToolOutputFile.h │ │ ├── TrailingObjects.h │ │ ├── TrigramIndex.h │ │ ├── TypeName.h │ │ ├── Unicode.h │ │ ├── UnicodeCharRanges.h │ │ ├── UniqueLock.h │ │ ├── Valgrind.h │ │ ├── Watchdog.h │ │ ├── Win64EH.h │ │ ├── WindowsError.h │ │ ├── X86TargetParser.def │ │ ├── YAMLParser.h │ │ ├── YAMLTraits.h │ │ ├── circular_raw_ostream.h │ │ ├── raw_os_ostream.h │ │ ├── raw_ostream.h │ │ ├── raw_sha1_ostream.h │ │ ├── thread.h │ │ ├── type_traits.h │ │ └── xxhash.h │ └── support │ └── Error.cpp └── scripts ├── benchmark_and_graph.py ├── graph_results.py ├── llvm_data_structure_benchmark_results.txt └── package_requirements.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | 34 | cmake-build-*/ 35 | scripts/env/ 36 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.9) 2 | project(llvm_data_structure_benchmarks) 3 | 4 | set(CMAKE_CXX_STANDARD 11) 5 | 6 | 7 | add_executable(llvm_data_structure_benchmarks 8 | data_structure_benchmarks.cpp 9 | lib/llvm/support/Error.cpp) 10 | target_include_directories(llvm_data_structure_benchmarks SYSTEM PRIVATE 11 | "/usr/local/Cellar/google-benchmark/1.3.0/include/" # Get this on Mac from $ brew install google-benchmark 12 | "${CMAKE_CURRENT_SOURCE_DIR}/lib/llvm/include") 13 | find_library(GOOGLE_BENCHMARK benchmark) 14 | target_link_libraries(llvm_data_structure_benchmarks 15 | ${GOOGLE_BENCHMARK}) 16 | 17 | target_compile_options(llvm_data_structure_benchmarks PRIVATE 18 | -march=haswell) # May want to try with -march=native as well 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Tyler A. Young 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # llvm-data-structure-benchmarks 2 | 3 | A benchmark for cache efficient data structures. 4 | 5 | Full writeup (explaining the data structures being examined, as well as a discussion of the results) can be [found on my blog](https://tylerayoung.com/?p=1277). 6 | 7 | ## Compiling & running the easy way 8 | 9 | `scripts` contains a Python script that can automate the entire process of building, running, and graphing the output. To use it, you'll need to (once) set up a Python virtual environment like so: 10 | 11 | 1. `$ cd /scripts` 12 | 2. `$ virtualenv env -p python3` 13 | 3. `$ env/bin/pip3 install -r package_requirements.txt` 14 | 15 | Then, run the script via: 16 | `$ env/bin/python3 benchmark_and_graph.py` 17 | 18 | After the program churns for a few minutes, you'll get a new `graphs` directory full of PNGs. 19 | 20 | ## Compiling & running the hard way 21 | 22 | 1. `$ cmake CMakeLists.txt` 23 | 2. `$ make` 24 | 3. `./data_structure_benchmarks > my_output_file.txt` 25 | 4. Set up a Python virtual environment in your `scripts` directory as above 26 | 5. `$ cd scripts` 27 | 6. `$ env/bin/python3 graph_results.py --file my_output_file.txt [--min-elements=N] [--max-elements=M]` 28 | -------------------------------------------------------------------------------- /data_types.h: -------------------------------------------------------------------------------- 1 | /** 2 | * Simple utilities for the data types we'll benchmark 3 | */ 4 | 5 | #ifndef LLVM_DATA_STRUCTURE_BENCHMARKS_DATA_TYPES_H 6 | #define LLVM_DATA_STRUCTURE_BENCHMARKS_DATA_TYPES_H 7 | 8 | /* A generic struct whose sizeof == 16 bytes */ 9 | struct size_16 { 10 | size_16() : a(0), b(0) { } 11 | size_16(double a, double b) : a(a), b(b) { } 12 | bool operator<(const size_16 &other) const { return a < other.a && b < other.b; } 13 | bool operator==(const size_16 &other) const { return a == other.a && b == other.b; } 14 | double a; 15 | double b; 16 | }; 17 | 18 | /* A generic struct whose sizeof == 64 bytes */ 19 | struct size_64 { 20 | size_64() { } 21 | size_64(const size_16 &a, const size_16 &b, const size_16 &c, const size_16 &d) : a(a), b(b), c(c), d(d) { } 22 | bool operator<(const size_64 &other) const { return a < other.a && b < other.b && c < other.c && d < other.d; } 23 | bool operator==(const size_64 &other) const { return a == other.a && b == other.b && c == other.c && d == other.d; } 24 | size_16 a; 25 | size_16 b; 26 | size_16 c; 27 | size_16 d; 28 | }; 29 | 30 | // Template method to generate unique values for the data types we'll be testing. 31 | // This lets us write *one* test function that covers *all* our types, rather than 32 | // having separate methods for test_int(), test_size_16(), test_size_64(), etc. 33 | template T generate_value (int iteration); 34 | template<> int generate_value (int iteration) { return iteration; } 35 | template<> size_16 generate_value(int iteration) { return size_16(iteration, iteration + 1); } 36 | template<> size_64 generate_value(int iteration) { return size_64(size_16(iteration, iteration + 1), size_16(iteration + 2, iteration + 3), size_16(iteration + 4, iteration + 5), size_16(iteration + 6, iteration + 7)); } 37 | 38 | 39 | #endif //LLVM_DATA_STRUCTURE_BENCHMARKS_DATA_TYPES_H 40 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Analysis.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/Analysis.h - Analysis Library C Interface --------*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to libLLVMAnalysis.a, which *| 11 | |* implements various analyses of the LLVM IR. *| 12 | |* *| 13 | |* Many exotic languages can interoperate with C code but have a harder time *| 14 | |* with C++ due to name mangling. So in addition to C, this interface enables *| 15 | |* tools written in such languages. *| 16 | |* *| 17 | \*===----------------------------------------------------------------------===*/ 18 | 19 | #ifndef LLVM_C_ANALYSIS_H 20 | #define LLVM_C_ANALYSIS_H 21 | 22 | #include "llvm-c/Types.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * @defgroup LLVMCAnalysis Analysis 30 | * @ingroup LLVMC 31 | * 32 | * @{ 33 | */ 34 | 35 | typedef enum { 36 | LLVMAbortProcessAction, /* verifier will print to stderr and abort() */ 37 | LLVMPrintMessageAction, /* verifier will print to stderr and return 1 */ 38 | LLVMReturnStatusAction /* verifier will just return 1 */ 39 | } LLVMVerifierFailureAction; 40 | 41 | 42 | /* Verifies that a module is valid, taking the specified action if not. 43 | Optionally returns a human-readable description of any invalid constructs. 44 | OutMessage must be disposed with LLVMDisposeMessage. */ 45 | LLVMBool LLVMVerifyModule(LLVMModuleRef M, LLVMVerifierFailureAction Action, 46 | char **OutMessage); 47 | 48 | /* Verifies that a single function is valid, taking the specified action. Useful 49 | for debugging. */ 50 | LLVMBool LLVMVerifyFunction(LLVMValueRef Fn, LLVMVerifierFailureAction Action); 51 | 52 | /* Open up a ghostview window that displays the CFG of the current function. 53 | Useful for debugging. */ 54 | void LLVMViewFunctionCFG(LLVMValueRef Fn); 55 | void LLVMViewFunctionCFGOnly(LLVMValueRef Fn); 56 | 57 | /** 58 | * @} 59 | */ 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/BitWriter.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/BitWriter.h - BitWriter Library C Interface ------*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to libLLVMBitWriter.a, which *| 11 | |* implements output of the LLVM bitcode format. *| 12 | |* *| 13 | |* Many exotic languages can interoperate with C code but have a harder time *| 14 | |* with C++ due to name mangling. So in addition to C, this interface enables *| 15 | |* tools written in such languages. *| 16 | |* *| 17 | \*===----------------------------------------------------------------------===*/ 18 | 19 | #ifndef LLVM_C_BITWRITER_H 20 | #define LLVM_C_BITWRITER_H 21 | 22 | #include "llvm-c/Types.h" 23 | 24 | #ifdef __cplusplus 25 | extern "C" { 26 | #endif 27 | 28 | /** 29 | * @defgroup LLVMCBitWriter Bit Writer 30 | * @ingroup LLVMC 31 | * 32 | * @{ 33 | */ 34 | 35 | /*===-- Operations on modules ---------------------------------------------===*/ 36 | 37 | /** Writes a module to the specified path. Returns 0 on success. */ 38 | int LLVMWriteBitcodeToFile(LLVMModuleRef M, const char *Path); 39 | 40 | /** Writes a module to an open file descriptor. Returns 0 on success. */ 41 | int LLVMWriteBitcodeToFD(LLVMModuleRef M, int FD, int ShouldClose, 42 | int Unbuffered); 43 | 44 | /** Deprecated for LLVMWriteBitcodeToFD. Writes a module to an open file 45 | descriptor. Returns 0 on success. Closes the Handle. */ 46 | int LLVMWriteBitcodeToFileHandle(LLVMModuleRef M, int Handle); 47 | 48 | /** Writes a module to a new memory buffer and returns it. */ 49 | LLVMMemoryBufferRef LLVMWriteBitcodeToMemoryBuffer(LLVMModuleRef M); 50 | 51 | /** 52 | * @} 53 | */ 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/ErrorHandling.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/ErrorHandling.h - Error Handling C Interface -------*- C -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to LLVM's error handling mechanism. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_ERROR_HANDLING_H 15 | #define LLVM_C_ERROR_HANDLING_H 16 | 17 | #ifdef __cplusplus 18 | extern "C" { 19 | #endif 20 | 21 | typedef void (*LLVMFatalErrorHandler)(const char *Reason); 22 | 23 | /** 24 | * Install a fatal error handler. By default, if LLVM detects a fatal error, it 25 | * will call exit(1). This may not be appropriate in many contexts. For example, 26 | * doing exit(1) will bypass many crash reporting/tracing system tools. This 27 | * function allows you to install a callback that will be invoked prior to the 28 | * call to exit(1). 29 | */ 30 | void LLVMInstallFatalErrorHandler(LLVMFatalErrorHandler Handler); 31 | 32 | /** 33 | * Reset the fatal error handler. This resets LLVM's fatal error handling 34 | * behavior to the default. 35 | */ 36 | void LLVMResetFatalErrorHandler(void); 37 | 38 | /** 39 | * Enable LLVM's built-in stack trace code. This intercepts the OS's crash 40 | * signals and prints which component of LLVM you were in at the time if the 41 | * crash. 42 | */ 43 | void LLVMEnablePrettyStackTrace(void); 44 | 45 | #ifdef __cplusplus 46 | } 47 | #endif 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/IRReader.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/IRReader.h - IR Reader C Interface -----------------*- C -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to the IR Reader. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_IRREADER_H 15 | #define LLVM_C_IRREADER_H 16 | 17 | #include "llvm-c/Types.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** 24 | * Read LLVM IR from a memory buffer and convert it into an in-memory Module 25 | * object. Returns 0 on success. 26 | * Optionally returns a human-readable description of any errors that 27 | * occurred during parsing IR. OutMessage must be disposed with 28 | * LLVMDisposeMessage. 29 | * 30 | * @see llvm::ParseIR() 31 | */ 32 | LLVMBool LLVMParseIRInContext(LLVMContextRef ContextRef, 33 | LLVMMemoryBufferRef MemBuf, LLVMModuleRef *OutM, 34 | char **OutMessage); 35 | 36 | #ifdef __cplusplus 37 | } 38 | #endif 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Initialization.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/Initialization.h - Initialization C Interface ------*- C -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to LLVM initialization routines, *| 11 | |* which must be called before you can use the functionality provided by *| 12 | |* the corresponding LLVM library. *| 13 | |* *| 14 | \*===----------------------------------------------------------------------===*/ 15 | 16 | #ifndef LLVM_C_INITIALIZATION_H 17 | #define LLVM_C_INITIALIZATION_H 18 | 19 | #include "llvm-c/Types.h" 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * @defgroup LLVMCInitialization Initialization Routines 27 | * @ingroup LLVMC 28 | * 29 | * This module contains routines used to initialize the LLVM system. 30 | * 31 | * @{ 32 | */ 33 | 34 | void LLVMInitializeCore(LLVMPassRegistryRef R); 35 | void LLVMInitializeTransformUtils(LLVMPassRegistryRef R); 36 | void LLVMInitializeScalarOpts(LLVMPassRegistryRef R); 37 | void LLVMInitializeObjCARCOpts(LLVMPassRegistryRef R); 38 | void LLVMInitializeVectorization(LLVMPassRegistryRef R); 39 | void LLVMInitializeInstCombine(LLVMPassRegistryRef R); 40 | void LLVMInitializeIPO(LLVMPassRegistryRef R); 41 | void LLVMInitializeInstrumentation(LLVMPassRegistryRef R); 42 | void LLVMInitializeAnalysis(LLVMPassRegistryRef R); 43 | void LLVMInitializeIPA(LLVMPassRegistryRef R); 44 | void LLVMInitializeCodeGen(LLVMPassRegistryRef R); 45 | void LLVMInitializeTarget(LLVMPassRegistryRef R); 46 | 47 | /** 48 | * @} 49 | */ 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | #endif 56 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/LinkTimeOptimizer.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/LinkTimeOptimizer.h - LTO Public C Interface -------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This header provides a C API to use the LLVM link time optimization 11 | // library. This is intended to be used by linkers which are C-only in 12 | // their implementation for performing LTO. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_C_LINKTIMEOPTIMIZER_H 17 | #define LLVM_C_LINKTIMEOPTIMIZER_H 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /** 24 | * @defgroup LLVMCLinkTimeOptimizer Link Time Optimization 25 | * @ingroup LLVMC 26 | * 27 | * @{ 28 | */ 29 | 30 | /// This provides a dummy type for pointers to the LTO object. 31 | typedef void* llvm_lto_t; 32 | 33 | /// This provides a C-visible enumerator to manage status codes. 34 | /// This should map exactly onto the C++ enumerator LTOStatus. 35 | typedef enum llvm_lto_status { 36 | LLVM_LTO_UNKNOWN, 37 | LLVM_LTO_OPT_SUCCESS, 38 | LLVM_LTO_READ_SUCCESS, 39 | LLVM_LTO_READ_FAILURE, 40 | LLVM_LTO_WRITE_FAILURE, 41 | LLVM_LTO_NO_TARGET, 42 | LLVM_LTO_NO_WORK, 43 | LLVM_LTO_MODULE_MERGE_FAILURE, 44 | LLVM_LTO_ASM_FAILURE, 45 | 46 | // Added C-specific error codes 47 | LLVM_LTO_NULL_OBJECT 48 | } llvm_lto_status_t; 49 | 50 | /// This provides C interface to initialize link time optimizer. This allows 51 | /// linker to use dlopen() interface to dynamically load LinkTimeOptimizer. 52 | /// extern "C" helps, because dlopen() interface uses name to find the symbol. 53 | extern llvm_lto_t llvm_create_optimizer(void); 54 | extern void llvm_destroy_optimizer(llvm_lto_t lto); 55 | 56 | extern llvm_lto_status_t llvm_read_object_file 57 | (llvm_lto_t lto, const char* input_filename); 58 | extern llvm_lto_status_t llvm_optimize_modules 59 | (llvm_lto_t lto, const char* output_filename); 60 | 61 | /** 62 | * @} 63 | */ 64 | 65 | #ifdef __cplusplus 66 | } 67 | #endif 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Linker.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/Linker.h - Module Linker C Interface -------------*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to the module/file/archive linker. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_LINKER_H 15 | #define LLVM_C_LINKER_H 16 | 17 | #include "llvm-c/Types.h" 18 | 19 | #ifdef __cplusplus 20 | extern "C" { 21 | #endif 22 | 23 | /* This enum is provided for backwards-compatibility only. It has no effect. */ 24 | typedef enum { 25 | LLVMLinkerDestroySource = 0, /* This is the default behavior. */ 26 | LLVMLinkerPreserveSource_Removed = 1 /* This option has been deprecated and 27 | should not be used. */ 28 | } LLVMLinkerMode; 29 | 30 | /* Links the source module into the destination module. The source module is 31 | * destroyed. 32 | * The return value is true if an error occurred, false otherwise. 33 | * Use the diagnostic handler to get any diagnostic message. 34 | */ 35 | LLVMBool LLVMLinkModules2(LLVMModuleRef Dest, LLVMModuleRef Src); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Support.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/Support.h - Support C Interface --------------------*- C -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file defines the C interface to the LLVM support library. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_SUPPORT_H 15 | #define LLVM_C_SUPPORT_H 16 | 17 | #include "llvm-c/Types.h" 18 | #include "llvm/Support/DataTypes.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * This function permanently loads the dynamic library at the given path. 26 | * It is safe to call this function multiple times for the same library. 27 | * 28 | * @see sys::DynamicLibrary::LoadLibraryPermanently() 29 | */ 30 | LLVMBool LLVMLoadLibraryPermanently(const char* Filename); 31 | 32 | /** 33 | * This function parses the given arguments using the LLVM command line parser. 34 | * Note that the only stable thing about this function is its signature; you 35 | * cannot rely on any particular set of command line arguments being interpreted 36 | * the same way across LLVM versions. 37 | * 38 | * @see llvm::cl::ParseCommandLineOptions() 39 | */ 40 | void LLVMParseCommandLineOptions(int argc, const char *const *argv, 41 | const char *Overview); 42 | 43 | /** 44 | * This function will search through all previously loaded dynamic 45 | * libraries for the symbol \p symbolName. If it is found, the address of 46 | * that symbol is returned. If not, null is returned. 47 | * 48 | * @see sys::DynamicLibrary::SearchForAddressOfSymbol() 49 | */ 50 | void *LLVMSearchForAddressOfSymbol(const char *symbolName); 51 | 52 | /** 53 | * This functions permanently adds the symbol \p symbolName with the 54 | * value \p symbolValue. These symbols are searched before any 55 | * libraries. 56 | * 57 | * @see sys::DynamicLibrary::AddSymbol() 58 | */ 59 | void LLVMAddSymbol(const char *symbolName, void *symbolValue); 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Transforms/IPO.h: -------------------------------------------------------------------------------- 1 | /*===-- IPO.h - Interprocedural Transformations C Interface -----*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to libLLVMIPO.a, which implements *| 11 | |* various interprocedural transformations of the LLVM IR. *| 12 | |* *| 13 | \*===----------------------------------------------------------------------===*/ 14 | 15 | #ifndef LLVM_C_TRANSFORMS_IPO_H 16 | #define LLVM_C_TRANSFORMS_IPO_H 17 | 18 | #include "llvm-c/Types.h" 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | /** 25 | * @defgroup LLVMCTransformsIPO Interprocedural transformations 26 | * @ingroup LLVMCTransforms 27 | * 28 | * @{ 29 | */ 30 | 31 | /** See llvm::createArgumentPromotionPass function. */ 32 | void LLVMAddArgumentPromotionPass(LLVMPassManagerRef PM); 33 | 34 | /** See llvm::createConstantMergePass function. */ 35 | void LLVMAddConstantMergePass(LLVMPassManagerRef PM); 36 | 37 | /** See llvm::createCalledValuePropagationPass function. */ 38 | void LLVMAddCalledValuePropagationPass(LLVMPassManagerRef PM); 39 | 40 | /** See llvm::createDeadArgEliminationPass function. */ 41 | void LLVMAddDeadArgEliminationPass(LLVMPassManagerRef PM); 42 | 43 | /** See llvm::createFunctionAttrsPass function. */ 44 | void LLVMAddFunctionAttrsPass(LLVMPassManagerRef PM); 45 | 46 | /** See llvm::createFunctionInliningPass function. */ 47 | void LLVMAddFunctionInliningPass(LLVMPassManagerRef PM); 48 | 49 | /** See llvm::createAlwaysInlinerPass function. */ 50 | void LLVMAddAlwaysInlinerPass(LLVMPassManagerRef PM); 51 | 52 | /** See llvm::createGlobalDCEPass function. */ 53 | void LLVMAddGlobalDCEPass(LLVMPassManagerRef PM); 54 | 55 | /** See llvm::createGlobalOptimizerPass function. */ 56 | void LLVMAddGlobalOptimizerPass(LLVMPassManagerRef PM); 57 | 58 | /** See llvm::createIPConstantPropagationPass function. */ 59 | void LLVMAddIPConstantPropagationPass(LLVMPassManagerRef PM); 60 | 61 | /** See llvm::createPruneEHPass function. */ 62 | void LLVMAddPruneEHPass(LLVMPassManagerRef PM); 63 | 64 | /** See llvm::createIPSCCPPass function. */ 65 | void LLVMAddIPSCCPPass(LLVMPassManagerRef PM); 66 | 67 | /** See llvm::createInternalizePass function. */ 68 | void LLVMAddInternalizePass(LLVMPassManagerRef, unsigned AllButMain); 69 | 70 | /** See llvm::createStripDeadPrototypesPass function. */ 71 | void LLVMAddStripDeadPrototypesPass(LLVMPassManagerRef PM); 72 | 73 | /** See llvm::createStripSymbolsPass function. */ 74 | void LLVMAddStripSymbolsPass(LLVMPassManagerRef PM); 75 | 76 | /** 77 | * @} 78 | */ 79 | 80 | #ifdef __cplusplus 81 | } 82 | #endif /* defined(__cplusplus) */ 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Transforms/PassManagerBuilder.h: -------------------------------------------------------------------------------- 1 | /*===-- llvm-c/Transform/PassManagerBuilder.h - PMB C Interface ---*- C -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This header declares the C interface to the PassManagerBuilder class. *| 11 | |* *| 12 | \*===----------------------------------------------------------------------===*/ 13 | 14 | #ifndef LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H 15 | #define LLVM_C_TRANSFORMS_PASSMANAGERBUILDER_H 16 | 17 | #include "llvm-c/Types.h" 18 | 19 | typedef struct LLVMOpaquePassManagerBuilder *LLVMPassManagerBuilderRef; 20 | 21 | #ifdef __cplusplus 22 | extern "C" { 23 | #endif 24 | 25 | /** 26 | * @defgroup LLVMCTransformsPassManagerBuilder Pass manager builder 27 | * @ingroup LLVMCTransforms 28 | * 29 | * @{ 30 | */ 31 | 32 | /** See llvm::PassManagerBuilder. */ 33 | LLVMPassManagerBuilderRef LLVMPassManagerBuilderCreate(void); 34 | void LLVMPassManagerBuilderDispose(LLVMPassManagerBuilderRef PMB); 35 | 36 | /** See llvm::PassManagerBuilder::OptLevel. */ 37 | void 38 | LLVMPassManagerBuilderSetOptLevel(LLVMPassManagerBuilderRef PMB, 39 | unsigned OptLevel); 40 | 41 | /** See llvm::PassManagerBuilder::SizeLevel. */ 42 | void 43 | LLVMPassManagerBuilderSetSizeLevel(LLVMPassManagerBuilderRef PMB, 44 | unsigned SizeLevel); 45 | 46 | /** See llvm::PassManagerBuilder::DisableUnitAtATime. */ 47 | void 48 | LLVMPassManagerBuilderSetDisableUnitAtATime(LLVMPassManagerBuilderRef PMB, 49 | LLVMBool Value); 50 | 51 | /** See llvm::PassManagerBuilder::DisableUnrollLoops. */ 52 | void 53 | LLVMPassManagerBuilderSetDisableUnrollLoops(LLVMPassManagerBuilderRef PMB, 54 | LLVMBool Value); 55 | 56 | /** See llvm::PassManagerBuilder::DisableSimplifyLibCalls */ 57 | void 58 | LLVMPassManagerBuilderSetDisableSimplifyLibCalls(LLVMPassManagerBuilderRef PMB, 59 | LLVMBool Value); 60 | 61 | /** See llvm::PassManagerBuilder::Inliner. */ 62 | void 63 | LLVMPassManagerBuilderUseInlinerWithThreshold(LLVMPassManagerBuilderRef PMB, 64 | unsigned Threshold); 65 | 66 | /** See llvm::PassManagerBuilder::populateFunctionPassManager. */ 67 | void 68 | LLVMPassManagerBuilderPopulateFunctionPassManager(LLVMPassManagerBuilderRef PMB, 69 | LLVMPassManagerRef PM); 70 | 71 | /** See llvm::PassManagerBuilder::populateModulePassManager. */ 72 | void 73 | LLVMPassManagerBuilderPopulateModulePassManager(LLVMPassManagerBuilderRef PMB, 74 | LLVMPassManagerRef PM); 75 | 76 | /** See llvm::PassManagerBuilder::populateLTOPassManager. */ 77 | void LLVMPassManagerBuilderPopulateLTOPassManager(LLVMPassManagerBuilderRef PMB, 78 | LLVMPassManagerRef PM, 79 | LLVMBool Internalize, 80 | LLVMBool RunInliner); 81 | 82 | /** 83 | * @} 84 | */ 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif 89 | 90 | #endif 91 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/Transforms/Vectorize.h: -------------------------------------------------------------------------------- 1 | /*===---------------------------Vectorize.h --------------------- -*- C -*-===*\ 2 | |*===----------- Vectorization Transformation Library C Interface ---------===*| 3 | |* *| 4 | |* The LLVM Compiler Infrastructure *| 5 | |* *| 6 | |* This file is distributed under the University of Illinois Open Source *| 7 | |* License. See LICENSE.TXT for details. *| 8 | |* *| 9 | |*===----------------------------------------------------------------------===*| 10 | |* *| 11 | |* This header declares the C interface to libLLVMVectorize.a, which *| 12 | |* implements various vectorization transformations of the LLVM IR. *| 13 | |* *| 14 | |* Many exotic languages can interoperate with C code but have a harder time *| 15 | |* with C++ due to name mangling. So in addition to C, this interface enables *| 16 | |* tools written in such languages. *| 17 | |* *| 18 | \*===----------------------------------------------------------------------===*/ 19 | 20 | #ifndef LLVM_C_TRANSFORMS_VECTORIZE_H 21 | #define LLVM_C_TRANSFORMS_VECTORIZE_H 22 | 23 | #include "llvm-c/Types.h" 24 | 25 | #ifdef __cplusplus 26 | extern "C" { 27 | #endif 28 | 29 | /** 30 | * @defgroup LLVMCTransformsVectorize Vectorization transformations 31 | * @ingroup LLVMCTransforms 32 | * 33 | * @{ 34 | */ 35 | 36 | /** DEPRECATED - Use LLVMAddSLPVectorizePass */ 37 | void LLVMAddBBVectorizePass(LLVMPassManagerRef PM); 38 | 39 | /** See llvm::createLoopVectorizePass function. */ 40 | void LLVMAddLoopVectorizePass(LLVMPassManagerRef PM); 41 | 42 | /** See llvm::createSLPVectorizerPass function. */ 43 | void LLVMAddSLPVectorizePass(LLVMPassManagerRef PM); 44 | 45 | /** 46 | * @} 47 | */ 48 | 49 | #ifdef __cplusplus 50 | } 51 | #endif /* defined(__cplusplus) */ 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm-c/module.modulemap: -------------------------------------------------------------------------------- 1 | module LLVM_C { 2 | umbrella "." 3 | module * { export * } 4 | } 5 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/DAGDeltaAlgorithm.h: -------------------------------------------------------------------------------- 1 | //===- DAGDeltaAlgorithm.h - A DAG Minimization Algorithm ------*- C++ -*--===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_ADT_DAGDELTAALGORITHM_H 10 | #define LLVM_ADT_DAGDELTAALGORITHM_H 11 | 12 | #include 13 | #include 14 | #include 15 | 16 | namespace llvm { 17 | 18 | /// DAGDeltaAlgorithm - Implements a "delta debugging" algorithm for minimizing 19 | /// directed acyclic graphs using a predicate function. 20 | /// 21 | /// The result of the algorithm is a subset of the input change set which is 22 | /// guaranteed to satisfy the predicate, assuming that the input set did. For 23 | /// well formed predicates, the result set is guaranteed to be such that 24 | /// removing any single element not required by the dependencies on the other 25 | /// elements would falsify the predicate. 26 | /// 27 | /// The DAG should be used to represent dependencies in the changes which are 28 | /// likely to hold across the predicate function. That is, for a particular 29 | /// changeset S and predicate P: 30 | /// 31 | /// P(S) => P(S union pred(S)) 32 | /// 33 | /// The minization algorithm uses this dependency information to attempt to 34 | /// eagerly prune large subsets of changes. As with \see DeltaAlgorithm, the DAG 35 | /// is not required to satisfy this property, but the algorithm will run 36 | /// substantially fewer tests with appropriate dependencies. \see DeltaAlgorithm 37 | /// for more information on the properties which the predicate function itself 38 | /// should satisfy. 39 | class DAGDeltaAlgorithm { 40 | virtual void anchor(); 41 | 42 | public: 43 | using change_ty = unsigned; 44 | using edge_ty = std::pair; 45 | 46 | // FIXME: Use a decent data structure. 47 | using changeset_ty = std::set; 48 | using changesetlist_ty = std::vector; 49 | 50 | public: 51 | virtual ~DAGDeltaAlgorithm() = default; 52 | 53 | /// Run - Minimize the DAG formed by the \p Changes vertices and the 54 | /// \p Dependencies edges by executing \see ExecuteOneTest() on subsets of 55 | /// changes and returning the smallest set which still satisfies the test 56 | /// predicate and the input \p Dependencies. 57 | /// 58 | /// \param Changes The list of changes. 59 | /// 60 | /// \param Dependencies The list of dependencies amongst changes. For each 61 | /// (x,y) in \p Dependencies, both x and y must be in \p Changes. The 62 | /// minimization algorithm guarantees that for each tested changed set S, 63 | /// \f$ x \in S \f$ implies \f$ y \in S \f$. It is an error to have cyclic 64 | /// dependencies. 65 | changeset_ty Run(const changeset_ty &Changes, 66 | const std::vector &Dependencies); 67 | 68 | /// UpdatedSearchState - Callback used when the search state changes. 69 | virtual void UpdatedSearchState(const changeset_ty &Changes, 70 | const changesetlist_ty &Sets, 71 | const changeset_ty &Required) {} 72 | 73 | /// ExecuteOneTest - Execute a single test predicate on the change set \p S. 74 | virtual bool ExecuteOneTest(const changeset_ty &S) = 0; 75 | }; 76 | 77 | } // end namespace llvm 78 | 79 | #endif // LLVM_ADT_DAGDELTAALGORITHM_H 80 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/DeltaAlgorithm.h: -------------------------------------------------------------------------------- 1 | //===- DeltaAlgorithm.h - A Set Minimization Algorithm ---------*- C++ -*--===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | //===----------------------------------------------------------------------===// 8 | 9 | #ifndef LLVM_ADT_DELTAALGORITHM_H 10 | #define LLVM_ADT_DELTAALGORITHM_H 11 | 12 | #include 13 | #include 14 | 15 | namespace llvm { 16 | 17 | /// DeltaAlgorithm - Implements the delta debugging algorithm (A. Zeller '99) 18 | /// for minimizing arbitrary sets using a predicate function. 19 | /// 20 | /// The result of the algorithm is a subset of the input change set which is 21 | /// guaranteed to satisfy the predicate, assuming that the input set did. For 22 | /// well formed predicates, the result set is guaranteed to be such that 23 | /// removing any single element would falsify the predicate. 24 | /// 25 | /// For best results the predicate function *should* (but need not) satisfy 26 | /// certain properties, in particular: 27 | /// (1) The predicate should return false on an empty set and true on the full 28 | /// set. 29 | /// (2) If the predicate returns true for a set of changes, it should return 30 | /// true for all supersets of that set. 31 | /// 32 | /// It is not an error to provide a predicate that does not satisfy these 33 | /// requirements, and the algorithm will generally produce reasonable 34 | /// results. However, it may run substantially more tests than with a good 35 | /// predicate. 36 | class DeltaAlgorithm { 37 | public: 38 | using change_ty = unsigned; 39 | // FIXME: Use a decent data structure. 40 | using changeset_ty = std::set; 41 | using changesetlist_ty = std::vector; 42 | 43 | private: 44 | /// Cache of failed test results. Successful test results are never cached 45 | /// since we always reduce following a success. 46 | std::set FailedTestsCache; 47 | 48 | /// GetTestResult - Get the test result for the \p Changes from the 49 | /// cache, executing the test if necessary. 50 | /// 51 | /// \param Changes - The change set to test. 52 | /// \return - The test result. 53 | bool GetTestResult(const changeset_ty &Changes); 54 | 55 | /// Split - Partition a set of changes \p S into one or two subsets. 56 | void Split(const changeset_ty &S, changesetlist_ty &Res); 57 | 58 | /// Delta - Minimize a set of \p Changes which has been partioned into 59 | /// smaller sets, by attempting to remove individual subsets. 60 | changeset_ty Delta(const changeset_ty &Changes, 61 | const changesetlist_ty &Sets); 62 | 63 | /// Search - Search for a subset (or subsets) in \p Sets which can be 64 | /// removed from \p Changes while still satisfying the predicate. 65 | /// 66 | /// \param Res - On success, a subset of Changes which satisfies the 67 | /// predicate. 68 | /// \return - True on success. 69 | bool Search(const changeset_ty &Changes, const changesetlist_ty &Sets, 70 | changeset_ty &Res); 71 | 72 | protected: 73 | /// UpdatedSearchState - Callback used when the search state changes. 74 | virtual void UpdatedSearchState(const changeset_ty &Changes, 75 | const changesetlist_ty &Sets) {} 76 | 77 | /// ExecuteOneTest - Execute a single test predicate on the change set \p S. 78 | virtual bool ExecuteOneTest(const changeset_ty &S) = 0; 79 | 80 | DeltaAlgorithm& operator=(const DeltaAlgorithm&) = default; 81 | 82 | public: 83 | virtual ~DeltaAlgorithm(); 84 | 85 | /// Run - Minimize the set \p Changes by executing \see ExecuteOneTest() on 86 | /// subsets of changes and returning the smallest set which still satisfies 87 | /// the test predicate. 88 | changeset_ty Run(const changeset_ty &Changes); 89 | }; 90 | 91 | } // end namespace llvm 92 | 93 | #endif // LLVM_ADT_DELTAALGORITHM_H 94 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/EpochTracker.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/EpochTracker.h - ADT epoch tracking --------------*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the DebugEpochBase and DebugEpochBase::HandleBase classes. 11 | // These can be used to write iterators that are fail-fast when LLVM is built 12 | // with asserts enabled. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_ADT_EPOCH_TRACKER_H 17 | #define LLVM_ADT_EPOCH_TRACKER_H 18 | 19 | #include "llvm/Config/abi-breaking.h" 20 | #include "llvm/Config/llvm-config.h" 21 | 22 | #include 23 | 24 | namespace llvm { 25 | 26 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS 27 | 28 | /// \brief A base class for data structure classes wishing to make iterators 29 | /// ("handles") pointing into themselves fail-fast. When building without 30 | /// asserts, this class is empty and does nothing. 31 | /// 32 | /// DebugEpochBase does not by itself track handles pointing into itself. The 33 | /// expectation is that routines touching the handles will poll on 34 | /// isHandleInSync at appropriate points to assert that the handle they're using 35 | /// is still valid. 36 | /// 37 | class DebugEpochBase { 38 | uint64_t Epoch; 39 | 40 | public: 41 | DebugEpochBase() : Epoch(0) {} 42 | 43 | /// \brief Calling incrementEpoch invalidates all handles pointing into the 44 | /// calling instance. 45 | void incrementEpoch() { ++Epoch; } 46 | 47 | /// \brief The destructor calls incrementEpoch to make use-after-free bugs 48 | /// more likely to crash deterministically. 49 | ~DebugEpochBase() { incrementEpoch(); } 50 | 51 | /// \brief A base class for iterator classes ("handles") that wish to poll for 52 | /// iterator invalidating modifications in the underlying data structure. 53 | /// When LLVM is built without asserts, this class is empty and does nothing. 54 | /// 55 | /// HandleBase does not track the parent data structure by itself. It expects 56 | /// the routines modifying the data structure to call incrementEpoch when they 57 | /// make an iterator-invalidating modification. 58 | /// 59 | class HandleBase { 60 | const uint64_t *EpochAddress; 61 | uint64_t EpochAtCreation; 62 | 63 | public: 64 | HandleBase() : EpochAddress(nullptr), EpochAtCreation(UINT64_MAX) {} 65 | 66 | explicit HandleBase(const DebugEpochBase *Parent) 67 | : EpochAddress(&Parent->Epoch), EpochAtCreation(Parent->Epoch) {} 68 | 69 | /// \brief Returns true if the DebugEpochBase this Handle is linked to has 70 | /// not called incrementEpoch on itself since the creation of this 71 | /// HandleBase instance. 72 | bool isHandleInSync() const { return *EpochAddress == EpochAtCreation; } 73 | 74 | /// \brief Returns a pointer to the epoch word stored in the data structure 75 | /// this handle points into. Can be used to check if two iterators point 76 | /// into the same data structure. 77 | const void *getEpochAddress() const { return EpochAddress; } 78 | }; 79 | }; 80 | 81 | #else 82 | 83 | class DebugEpochBase { 84 | public: 85 | void incrementEpoch() {} 86 | 87 | class HandleBase { 88 | public: 89 | HandleBase() = default; 90 | explicit HandleBase(const DebugEpochBase *) {} 91 | bool isHandleInSync() const { return true; } 92 | const void *getEpochAddress() const { return nullptr; } 93 | }; 94 | }; 95 | 96 | #endif // LLVM_ENABLE_ABI_BREAKING_CHECKS 97 | 98 | } // namespace llvm 99 | 100 | #endif 101 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/IndexedMap.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/IndexedMap.h - An index map implementation ------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements an indexed map. The index map template takes two 11 | // types. The first is the mapped type and the second is a functor 12 | // that maps its argument to a size_t. On instantiation a "null" value 13 | // can be provided to be used as a "does not exist" indicator in the 14 | // map. A member function grow() is provided that given the value of 15 | // the maximally indexed key (the argument of the functor) makes sure 16 | // the map has enough space for it. 17 | // 18 | //===----------------------------------------------------------------------===// 19 | 20 | #ifndef LLVM_ADT_INDEXEDMAP_H 21 | #define LLVM_ADT_INDEXEDMAP_H 22 | 23 | #include "llvm/ADT/SmallVector.h" 24 | #include "llvm/ADT/STLExtras.h" 25 | #include 26 | 27 | namespace llvm { 28 | 29 | template > 30 | class IndexedMap { 31 | using IndexT = typename ToIndexT::argument_type; 32 | // Prefer SmallVector with zero inline storage over std::vector. IndexedMaps 33 | // can grow very large and SmallVector grows more efficiently as long as T 34 | // is trivially copyable. 35 | using StorageT = SmallVector; 36 | 37 | StorageT storage_; 38 | T nullVal_; 39 | ToIndexT toIndex_; 40 | 41 | public: 42 | IndexedMap() : nullVal_(T()) {} 43 | 44 | explicit IndexedMap(const T& val) : nullVal_(val) {} 45 | 46 | typename StorageT::reference operator[](IndexT n) { 47 | assert(toIndex_(n) < storage_.size() && "index out of bounds!"); 48 | return storage_[toIndex_(n)]; 49 | } 50 | 51 | typename StorageT::const_reference operator[](IndexT n) const { 52 | assert(toIndex_(n) < storage_.size() && "index out of bounds!"); 53 | return storage_[toIndex_(n)]; 54 | } 55 | 56 | void reserve(typename StorageT::size_type s) { 57 | storage_.reserve(s); 58 | } 59 | 60 | void resize(typename StorageT::size_type s) { 61 | storage_.resize(s, nullVal_); 62 | } 63 | 64 | void clear() { 65 | storage_.clear(); 66 | } 67 | 68 | void grow(IndexT n) { 69 | unsigned NewSize = toIndex_(n) + 1; 70 | if (NewSize > storage_.size()) 71 | resize(NewSize); 72 | } 73 | 74 | bool inBounds(IndexT n) const { 75 | return toIndex_(n) < storage_.size(); 76 | } 77 | 78 | typename StorageT::size_type size() const { 79 | return storage_.size(); 80 | } 81 | }; 82 | 83 | } // end namespace llvm 84 | 85 | #endif // LLVM_ADT_INDEXEDMAP_H 86 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/IntEqClasses.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/ADT/IntEqClasses.h - Equiv. Classes of Integers ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Equivalence classes for small integers. This is a mapping of the integers 11 | // 0 .. N-1 into M equivalence classes numbered 0 .. M-1. 12 | // 13 | // Initially each integer has its own equivalence class. Classes are joined by 14 | // passing a representative member of each class to join(). 15 | // 16 | // Once the classes are built, compress() will number them 0 .. M-1 and prevent 17 | // further changes. 18 | // 19 | //===----------------------------------------------------------------------===// 20 | 21 | #ifndef LLVM_ADT_INTEQCLASSES_H 22 | #define LLVM_ADT_INTEQCLASSES_H 23 | 24 | #include "llvm/ADT/SmallVector.h" 25 | 26 | namespace llvm { 27 | 28 | class IntEqClasses { 29 | /// EC - When uncompressed, map each integer to a smaller member of its 30 | /// equivalence class. The class leader is the smallest member and maps to 31 | /// itself. 32 | /// 33 | /// When compressed, EC[i] is the equivalence class of i. 34 | SmallVector EC; 35 | 36 | /// NumClasses - The number of equivalence classes when compressed, or 0 when 37 | /// uncompressed. 38 | unsigned NumClasses; 39 | 40 | public: 41 | /// IntEqClasses - Create an equivalence class mapping for 0 .. N-1. 42 | IntEqClasses(unsigned N = 0) : NumClasses(0) { grow(N); } 43 | 44 | /// grow - Increase capacity to hold 0 .. N-1, putting new integers in unique 45 | /// equivalence classes. 46 | /// This requires an uncompressed map. 47 | void grow(unsigned N); 48 | 49 | /// clear - Clear all classes so that grow() will assign a unique class to 50 | /// every integer. 51 | void clear() { 52 | EC.clear(); 53 | NumClasses = 0; 54 | } 55 | 56 | /// Join the equivalence classes of a and b. After joining classes, 57 | /// findLeader(a) == findLeader(b). This requires an uncompressed map. 58 | /// Returns the new leader. 59 | unsigned join(unsigned a, unsigned b); 60 | 61 | /// findLeader - Compute the leader of a's equivalence class. This is the 62 | /// smallest member of the class. 63 | /// This requires an uncompressed map. 64 | unsigned findLeader(unsigned a) const; 65 | 66 | /// compress - Compress equivalence classes by numbering them 0 .. M. 67 | /// This makes the equivalence class map immutable. 68 | void compress(); 69 | 70 | /// getNumClasses - Return the number of equivalence classes after compress() 71 | /// was called. 72 | unsigned getNumClasses() const { return NumClasses; } 73 | 74 | /// operator[] - Return a's equivalence class number, 0 .. getNumClasses()-1. 75 | /// This requires a compressed map. 76 | unsigned operator[](unsigned a) const { 77 | assert(NumClasses && "operator[] called before compress()"); 78 | return EC[a]; 79 | } 80 | 81 | /// uncompress - Change back to the uncompressed representation that allows 82 | /// editing. 83 | void uncompress(); 84 | }; 85 | 86 | } // End llvm namespace 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/None.h: -------------------------------------------------------------------------------- 1 | //===-- None.h - Simple null value for implicit construction ------*- C++ -*-=// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file provides None, an enumerator for use in implicit constructors 11 | // of various (usually templated) types to make such construction more 12 | // terse. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_ADT_NONE_H 17 | #define LLVM_ADT_NONE_H 18 | 19 | namespace llvm { 20 | /// \brief A simple null object to allow implicit construction of Optional 21 | /// and similar types without having to spell out the specialization's name. 22 | // (constant value 1 in an attempt to workaround MSVC build issue... ) 23 | enum class NoneType { None = 1 }; 24 | const NoneType None = NoneType::None; 25 | } 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/PriorityQueue.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/PriorityQueue.h - Priority queues ---------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the PriorityQueue class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_ADT_PRIORITYQUEUE_H 15 | #define LLVM_ADT_PRIORITYQUEUE_H 16 | 17 | #include 18 | #include 19 | 20 | namespace llvm { 21 | 22 | /// PriorityQueue - This class behaves like std::priority_queue and 23 | /// provides a few additional convenience functions. 24 | /// 25 | template, 27 | class Compare = std::less > 28 | class PriorityQueue : public std::priority_queue { 29 | public: 30 | explicit PriorityQueue(const Compare &compare = Compare(), 31 | const Sequence &sequence = Sequence()) 32 | : std::priority_queue(compare, sequence) 33 | {} 34 | 35 | template 36 | PriorityQueue(Iterator begin, Iterator end, 37 | const Compare &compare = Compare(), 38 | const Sequence &sequence = Sequence()) 39 | : std::priority_queue(begin, end, compare, sequence) 40 | {} 41 | 42 | /// erase_one - Erase one element from the queue, regardless of its 43 | /// position. This operation performs a linear search to find an element 44 | /// equal to t, but then uses all logarithmic-time algorithms to do 45 | /// the erase operation. 46 | /// 47 | void erase_one(const T &t) { 48 | // Linear-search to find the element. 49 | typename Sequence::size_type i = find(this->c, t) - this->c.begin(); 50 | 51 | // Logarithmic-time heap bubble-up. 52 | while (i != 0) { 53 | typename Sequence::size_type parent = (i - 1) / 2; 54 | this->c[i] = this->c[parent]; 55 | i = parent; 56 | } 57 | 58 | // The element we want to remove is now at the root, so we can use 59 | // priority_queue's plain pop to remove it. 60 | this->pop(); 61 | } 62 | 63 | /// reheapify - If an element in the queue has changed in a way that 64 | /// affects its standing in the comparison function, the queue's 65 | /// internal state becomes invalid. Calling reheapify() resets the 66 | /// queue's state, making it valid again. This operation has time 67 | /// complexity proportional to the number of elements in the queue, 68 | /// so don't plan to use it a lot. 69 | /// 70 | void reheapify() { 71 | std::make_heap(this->c.begin(), this->c.end(), this->comp); 72 | } 73 | 74 | /// clear - Erase all elements from the queue. 75 | /// 76 | void clear() { 77 | this->c.clear(); 78 | } 79 | }; 80 | 81 | } // End llvm namespace 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/ScopeExit.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/ScopeExit.h - Execute code at scope exit --------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the make_scope_exit function, which executes user-defined 11 | // cleanup logic at scope exit. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_ADT_SCOPE_EXIT_H 16 | #define LLVM_ADT_SCOPE_EXIT_H 17 | 18 | #include "llvm/Support/Compiler.h" 19 | 20 | #include 21 | #include 22 | 23 | namespace llvm { 24 | namespace detail { 25 | 26 | template class scope_exit { 27 | Callable ExitFunction; 28 | bool Engaged = true; // False once moved-from or release()d. 29 | 30 | public: 31 | template 32 | explicit scope_exit(Fp &&F) : ExitFunction(std::forward(F)) {} 33 | 34 | scope_exit(scope_exit &&Rhs) 35 | : ExitFunction(std::move(Rhs.ExitFunction)), Engaged(Rhs.Engaged) { 36 | Rhs.release(); 37 | } 38 | scope_exit(const scope_exit &) = delete; 39 | scope_exit &operator=(scope_exit &&) = delete; 40 | scope_exit &operator=(const scope_exit &) = delete; 41 | 42 | void release() { Engaged = false; } 43 | 44 | ~scope_exit() { 45 | if (Engaged) 46 | ExitFunction(); 47 | } 48 | }; 49 | 50 | } // end namespace detail 51 | 52 | // Keeps the callable object that is passed in, and execute it at the 53 | // destruction of the returned object (usually at the scope exit where the 54 | // returned object is kept). 55 | // 56 | // Interface is specified by p0052r2. 57 | template 58 | LLVM_NODISCARD detail::scope_exit::type> 59 | make_scope_exit(Callable &&F) { 60 | return detail::scope_exit::type>( 61 | std::forward(F)); 62 | } 63 | 64 | } // end namespace llvm 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/Sequence.h: -------------------------------------------------------------------------------- 1 | //===- Sequence.h - Utility for producing sequences of values ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// \file 10 | /// This routine provides some synthesis utilities to produce sequences of 11 | /// values. The names are intentionally kept very short as they tend to occur 12 | /// in common and widely used contexts. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_ADT_SEQUENCE_H 17 | #define LLVM_ADT_SEQUENCE_H 18 | 19 | #include "llvm/ADT/iterator.h" 20 | #include "llvm/ADT/iterator_range.h" 21 | #include 22 | #include 23 | #include 24 | 25 | namespace llvm { 26 | 27 | namespace detail { 28 | 29 | template 30 | class value_sequence_iterator 31 | : public iterator_facade_base, 32 | std::random_access_iterator_tag, 33 | const ValueT> { 34 | using BaseT = typename value_sequence_iterator::iterator_facade_base; 35 | 36 | ValueT Value; 37 | 38 | public: 39 | using difference_type = typename BaseT::difference_type; 40 | using reference = typename BaseT::reference; 41 | 42 | value_sequence_iterator() = default; 43 | value_sequence_iterator(const value_sequence_iterator &) = default; 44 | value_sequence_iterator(value_sequence_iterator &&Arg) 45 | : Value(std::move(Arg.Value)) {} 46 | 47 | template ()))> 48 | value_sequence_iterator(U &&Value) : Value(std::forward(Value)) {} 49 | 50 | value_sequence_iterator &operator+=(difference_type N) { 51 | Value += N; 52 | return *this; 53 | } 54 | value_sequence_iterator &operator-=(difference_type N) { 55 | Value -= N; 56 | return *this; 57 | } 58 | using BaseT::operator-; 59 | difference_type operator-(const value_sequence_iterator &RHS) const { 60 | return Value - RHS.Value; 61 | } 62 | 63 | bool operator==(const value_sequence_iterator &RHS) const { 64 | return Value == RHS.Value; 65 | } 66 | bool operator<(const value_sequence_iterator &RHS) const { 67 | return Value < RHS.Value; 68 | } 69 | 70 | reference operator*() const { return Value; } 71 | }; 72 | 73 | } // end namespace detail 74 | 75 | template 76 | iterator_range> seq(ValueT Begin, 77 | ValueT End) { 78 | return make_range(detail::value_sequence_iterator(Begin), 79 | detail::value_sequence_iterator(End)); 80 | } 81 | 82 | } // end namespace llvm 83 | 84 | #endif // LLVM_ADT_SEQUENCE_H 85 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/SetOperations.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/ADT/SetOperations.h - Generic Set Operations -------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines generic set operations that may be used on set's of 11 | // different types, and different element types. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_ADT_SETOPERATIONS_H 16 | #define LLVM_ADT_SETOPERATIONS_H 17 | 18 | namespace llvm { 19 | 20 | /// set_union(A, B) - Compute A := A u B, return whether A changed. 21 | /// 22 | template 23 | bool set_union(S1Ty &S1, const S2Ty &S2) { 24 | bool Changed = false; 25 | 26 | for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end(); 27 | SI != SE; ++SI) 28 | if (S1.insert(*SI).second) 29 | Changed = true; 30 | 31 | return Changed; 32 | } 33 | 34 | /// set_intersect(A, B) - Compute A := A ^ B 35 | /// Identical to set_intersection, except that it works on set<>'s and 36 | /// is nicer to use. Functionally, this iterates through S1, removing 37 | /// elements that are not contained in S2. 38 | /// 39 | template 40 | void set_intersect(S1Ty &S1, const S2Ty &S2) { 41 | for (typename S1Ty::iterator I = S1.begin(); I != S1.end();) { 42 | const auto &E = *I; 43 | ++I; 44 | if (!S2.count(E)) S1.erase(E); // Erase element if not in S2 45 | } 46 | } 47 | 48 | /// set_difference(A, B) - Return A - B 49 | /// 50 | template 51 | S1Ty set_difference(const S1Ty &S1, const S2Ty &S2) { 52 | S1Ty Result; 53 | for (typename S1Ty::const_iterator SI = S1.begin(), SE = S1.end(); 54 | SI != SE; ++SI) 55 | if (!S2.count(*SI)) // if the element is not in set2 56 | Result.insert(*SI); 57 | return Result; 58 | } 59 | 60 | /// set_subtract(A, B) - Compute A := A - B 61 | /// 62 | template 63 | void set_subtract(S1Ty &S1, const S2Ty &S2) { 64 | for (typename S2Ty::const_iterator SI = S2.begin(), SE = S2.end(); 65 | SI != SE; ++SI) 66 | S1.erase(*SI); 67 | } 68 | 69 | } // End llvm namespace 70 | 71 | #endif 72 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/StringSet.h: -------------------------------------------------------------------------------- 1 | //===- StringSet.h - The LLVM Compiler Driver -------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open 6 | // Source License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // StringSet - A set-like wrapper for the StringMap. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_ADT_STRINGSET_H 15 | #define LLVM_ADT_STRINGSET_H 16 | 17 | #include "llvm/ADT/StringMap.h" 18 | #include "llvm/ADT/StringRef.h" 19 | #include "llvm/Support/Allocator.h" 20 | #include 21 | #include 22 | #include 23 | 24 | namespace llvm { 25 | 26 | /// StringSet - A wrapper for StringMap that provides set-like functionality. 27 | template 28 | class StringSet : public StringMap { 29 | using base = StringMap; 30 | 31 | public: 32 | StringSet() = default; 33 | StringSet(std::initializer_list S) { 34 | for (StringRef X : S) 35 | insert(X); 36 | } 37 | 38 | std::pair insert(StringRef Key) { 39 | assert(!Key.empty()); 40 | return base::insert(std::make_pair(Key, '\0')); 41 | } 42 | 43 | template 44 | void insert(const InputIt &Begin, const InputIt &End) { 45 | for (auto It = Begin; It != End; ++It) 46 | base::insert(std::make_pair(*It, '\0')); 47 | } 48 | }; 49 | 50 | } // end namespace llvm 51 | 52 | #endif // LLVM_ADT_STRINGSET_H 53 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/UniqueVector.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/UniqueVector.h ----------------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_ADT_UNIQUEVECTOR_H 11 | #define LLVM_ADT_UNIQUEVECTOR_H 12 | 13 | #include 14 | #include 15 | #include 16 | #include 17 | 18 | namespace llvm { 19 | 20 | //===----------------------------------------------------------------------===// 21 | /// UniqueVector - This class produces a sequential ID number (base 1) for each 22 | /// unique entry that is added. T is the type of entries in the vector. This 23 | /// class should have an implementation of operator== and of operator<. 24 | /// Entries can be fetched using operator[] with the entry ID. 25 | template class UniqueVector { 26 | public: 27 | using VectorType = typename std::vector; 28 | using iterator = typename VectorType::iterator; 29 | using const_iterator = typename VectorType::const_iterator; 30 | 31 | private: 32 | // Map - Used to handle the correspondence of entry to ID. 33 | std::map Map; 34 | 35 | // Vector - ID ordered vector of entries. Entries can be indexed by ID - 1. 36 | VectorType Vector; 37 | 38 | public: 39 | /// insert - Append entry to the vector if it doesn't already exist. Returns 40 | /// the entry's index + 1 to be used as a unique ID. 41 | unsigned insert(const T &Entry) { 42 | // Check if the entry is already in the map. 43 | unsigned &Val = Map[Entry]; 44 | 45 | // See if entry exists, if so return prior ID. 46 | if (Val) return Val; 47 | 48 | // Compute ID for entry. 49 | Val = static_cast(Vector.size()) + 1; 50 | 51 | // Insert in vector. 52 | Vector.push_back(Entry); 53 | return Val; 54 | } 55 | 56 | /// idFor - return the ID for an existing entry. Returns 0 if the entry is 57 | /// not found. 58 | unsigned idFor(const T &Entry) const { 59 | // Search for entry in the map. 60 | typename std::map::const_iterator MI = Map.find(Entry); 61 | 62 | // See if entry exists, if so return ID. 63 | if (MI != Map.end()) return MI->second; 64 | 65 | // No luck. 66 | return 0; 67 | } 68 | 69 | /// operator[] - Returns a reference to the entry with the specified ID. 70 | const T &operator[](unsigned ID) const { 71 | assert(ID-1 < size() && "ID is 0 or out of range!"); 72 | return Vector[ID - 1]; 73 | } 74 | 75 | /// \brief Return an iterator to the start of the vector. 76 | iterator begin() { return Vector.begin(); } 77 | 78 | /// \brief Return an iterator to the start of the vector. 79 | const_iterator begin() const { return Vector.begin(); } 80 | 81 | /// \brief Return an iterator to the end of the vector. 82 | iterator end() { return Vector.end(); } 83 | 84 | /// \brief Return an iterator to the end of the vector. 85 | const_iterator end() const { return Vector.end(); } 86 | 87 | /// size - Returns the number of entries in the vector. 88 | size_t size() const { return Vector.size(); } 89 | 90 | /// empty - Returns true if the vector is empty. 91 | bool empty() const { return Vector.empty(); } 92 | 93 | /// reset - Clears all the entries. 94 | void reset() { 95 | Map.clear(); 96 | Vector.resize(0, 0); 97 | } 98 | }; 99 | 100 | } // end namespace llvm 101 | 102 | #endif // LLVM_ADT_UNIQUEVECTOR_H 103 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/ilist_base.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/ilist_base.h - Intrusive List Base --------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_ADT_ILIST_BASE_H 11 | #define LLVM_ADT_ILIST_BASE_H 12 | 13 | #include "llvm/ADT/ilist_node_base.h" 14 | #include 15 | 16 | namespace llvm { 17 | 18 | /// Implementations of list algorithms using ilist_node_base. 19 | template class ilist_base { 20 | public: 21 | using node_base_type = ilist_node_base; 22 | 23 | static void insertBeforeImpl(node_base_type &Next, node_base_type &N) { 24 | node_base_type &Prev = *Next.getPrev(); 25 | N.setNext(&Next); 26 | N.setPrev(&Prev); 27 | Prev.setNext(&N); 28 | Next.setPrev(&N); 29 | } 30 | 31 | static void removeImpl(node_base_type &N) { 32 | node_base_type *Prev = N.getPrev(); 33 | node_base_type *Next = N.getNext(); 34 | Next->setPrev(Prev); 35 | Prev->setNext(Next); 36 | 37 | // Not strictly necessary, but helps catch a class of bugs. 38 | N.setPrev(nullptr); 39 | N.setNext(nullptr); 40 | } 41 | 42 | static void removeRangeImpl(node_base_type &First, node_base_type &Last) { 43 | node_base_type *Prev = First.getPrev(); 44 | node_base_type *Final = Last.getPrev(); 45 | Last.setPrev(Prev); 46 | Prev->setNext(&Last); 47 | 48 | // Not strictly necessary, but helps catch a class of bugs. 49 | First.setPrev(nullptr); 50 | Final->setNext(nullptr); 51 | } 52 | 53 | static void transferBeforeImpl(node_base_type &Next, node_base_type &First, 54 | node_base_type &Last) { 55 | if (&Next == &Last || &First == &Last) 56 | return; 57 | 58 | // Position cannot be contained in the range to be transferred. 59 | assert(&Next != &First && 60 | // Check for the most common mistake. 61 | "Insertion point can't be one of the transferred nodes"); 62 | 63 | node_base_type &Final = *Last.getPrev(); 64 | 65 | // Detach from old list/position. 66 | First.getPrev()->setNext(&Last); 67 | Last.setPrev(First.getPrev()); 68 | 69 | // Splice [First, Final] into its new list/position. 70 | node_base_type &Prev = *Next.getPrev(); 71 | Final.setNext(&Next); 72 | First.setPrev(&Prev); 73 | Prev.setNext(&First); 74 | Next.setPrev(&Final); 75 | } 76 | 77 | template static void insertBefore(T &Next, T &N) { 78 | insertBeforeImpl(Next, N); 79 | } 80 | 81 | template static void remove(T &N) { removeImpl(N); } 82 | template static void removeRange(T &First, T &Last) { 83 | removeRangeImpl(First, Last); 84 | } 85 | 86 | template static void transferBefore(T &Next, T &First, T &Last) { 87 | transferBeforeImpl(Next, First, Last); 88 | } 89 | }; 90 | 91 | } // end namespace llvm 92 | 93 | #endif // LLVM_ADT_ILIST_BASE_H 94 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/ilist_node_base.h: -------------------------------------------------------------------------------- 1 | //===- llvm/ADT/ilist_node_base.h - Intrusive List Node Base -----*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_ADT_ILIST_NODE_BASE_H 11 | #define LLVM_ADT_ILIST_NODE_BASE_H 12 | 13 | #include "llvm/ADT/PointerIntPair.h" 14 | 15 | namespace llvm { 16 | 17 | /// Base class for ilist nodes. 18 | /// 19 | /// Optionally tracks whether this node is the sentinel. 20 | template class ilist_node_base; 21 | 22 | template <> class ilist_node_base { 23 | ilist_node_base *Prev = nullptr; 24 | ilist_node_base *Next = nullptr; 25 | 26 | public: 27 | void setPrev(ilist_node_base *Prev) { this->Prev = Prev; } 28 | void setNext(ilist_node_base *Next) { this->Next = Next; } 29 | ilist_node_base *getPrev() const { return Prev; } 30 | ilist_node_base *getNext() const { return Next; } 31 | 32 | bool isKnownSentinel() const { return false; } 33 | void initializeSentinel() {} 34 | }; 35 | 36 | template <> class ilist_node_base { 37 | PointerIntPair PrevAndSentinel; 38 | ilist_node_base *Next = nullptr; 39 | 40 | public: 41 | void setPrev(ilist_node_base *Prev) { PrevAndSentinel.setPointer(Prev); } 42 | void setNext(ilist_node_base *Next) { this->Next = Next; } 43 | ilist_node_base *getPrev() const { return PrevAndSentinel.getPointer(); } 44 | ilist_node_base *getNext() const { return Next; } 45 | 46 | bool isSentinel() const { return PrevAndSentinel.getInt(); } 47 | bool isKnownSentinel() const { return isSentinel(); } 48 | void initializeSentinel() { PrevAndSentinel.setInt(true); } 49 | }; 50 | 51 | } // end namespace llvm 52 | 53 | #endif // LLVM_ADT_ILIST_NODE_BASE_H 54 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/ADT/iterator_range.h: -------------------------------------------------------------------------------- 1 | //===- iterator_range.h - A range adaptor for iterators ---------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// \file 10 | /// This provides a very simple, boring adaptor for a begin and end iterator 11 | /// into a range type. This should be used to build range views that work well 12 | /// with range based for loops and range based constructors. 13 | /// 14 | /// Note that code here follows more standards-based coding conventions as it 15 | /// is mirroring proposed interfaces for standardization. 16 | /// 17 | //===----------------------------------------------------------------------===// 18 | 19 | #ifndef LLVM_ADT_ITERATOR_RANGE_H 20 | #define LLVM_ADT_ITERATOR_RANGE_H 21 | 22 | #include 23 | #include 24 | 25 | namespace llvm { 26 | 27 | /// \brief A range adaptor for a pair of iterators. 28 | /// 29 | /// This just wraps two iterators into a range-compatible interface. Nothing 30 | /// fancy at all. 31 | template 32 | class iterator_range { 33 | IteratorT begin_iterator, end_iterator; 34 | 35 | public: 36 | //TODO: Add SFINAE to test that the Container's iterators match the range's 37 | // iterators. 38 | template 39 | iterator_range(Container &&c) 40 | //TODO: Consider ADL/non-member begin/end calls. 41 | : begin_iterator(c.begin()), end_iterator(c.end()) {} 42 | iterator_range(IteratorT begin_iterator, IteratorT end_iterator) 43 | : begin_iterator(std::move(begin_iterator)), 44 | end_iterator(std::move(end_iterator)) {} 45 | 46 | IteratorT begin() const { return begin_iterator; } 47 | IteratorT end() const { return end_iterator; } 48 | }; 49 | 50 | /// \brief Convenience function for iterating over sub-ranges. 51 | /// 52 | /// This provides a bit of syntactic sugar to make using sub-ranges 53 | /// in for loops a bit easier. Analogous to std::make_pair(). 54 | template iterator_range make_range(T x, T y) { 55 | return iterator_range(std::move(x), std::move(y)); 56 | } 57 | 58 | template iterator_range make_range(std::pair p) { 59 | return iterator_range(std::move(p.first), std::move(p.second)); 60 | } 61 | 62 | template 63 | iterator_range()))> drop_begin(T &&t, int n) { 64 | return make_range(std::next(begin(t), n), end(t)); 65 | } 66 | } 67 | 68 | #endif 69 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/AsmParsers.def.in: -------------------------------------------------------------------------------- 1 | /*===- llvm/Config/AsmParsers.def - LLVM Assembly Parsers -------*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file enumerates all of the assembly-language parsers *| 11 | |* supported by this build of LLVM. Clients of this file should define *| 12 | |* the LLVM_ASM_PARSER macro to be a function-like macro with a *| 13 | |* single parameter (the name of the target whose assembly can be *| 14 | |* generated); including this file will then enumerate all of the *| 15 | |* targets with assembly parsers. *| 16 | |* *| 17 | |* The set of targets supported by LLVM is generated at configuration *| 18 | |* time, at which point this header is generated. Do not modify this *| 19 | |* header directly. *| 20 | |* *| 21 | \*===----------------------------------------------------------------------===*/ 22 | 23 | #ifndef LLVM_ASM_PARSER 24 | # error Please define the macro LLVM_ASM_PARSER(TargetName) 25 | #endif 26 | 27 | @LLVM_ENUM_ASM_PARSERS@ 28 | 29 | #undef LLVM_ASM_PARSER 30 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/AsmPrinters.def.in: -------------------------------------------------------------------------------- 1 | /*===- llvm/Config/AsmPrinters.def - LLVM Assembly Printers -----*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file enumerates all of the assembly-language printers *| 11 | |* supported by this build of LLVM. Clients of this file should define *| 12 | |* the LLVM_ASM_PRINTER macro to be a function-like macro with a *| 13 | |* single parameter (the name of the target whose assembly can be *| 14 | |* generated); including this file will then enumerate all of the *| 15 | |* targets with assembly printers. *| 16 | |* *| 17 | |* The set of targets supported by LLVM is generated at configuration *| 18 | |* time, at which point this header is generated. Do not modify this *| 19 | |* header directly. *| 20 | |* *| 21 | \*===----------------------------------------------------------------------===*/ 22 | 23 | #ifndef LLVM_ASM_PRINTER 24 | # error Please define the macro LLVM_ASM_PRINTER(TargetName) 25 | #endif 26 | 27 | @LLVM_ENUM_ASM_PRINTERS@ 28 | 29 | #undef LLVM_ASM_PRINTER 30 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/Disassemblers.def.in: -------------------------------------------------------------------------------- 1 | /*===- llvm/Config/Disassemblers.def - LLVM Assembly Parsers ----*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file enumerates all of the assembly-language parsers *| 11 | |* supported by this build of LLVM. Clients of this file should define *| 12 | |* the LLVM_DISASSEMBLER macro to be a function-like macro with a *| 13 | |* single parameter (the name of the target whose assembly can be *| 14 | |* generated); including this file will then enumerate all of the *| 15 | |* targets with assembly parsers. *| 16 | |* *| 17 | |* The set of targets supported by LLVM is generated at configuration *| 18 | |* time, at which point this header is generated. Do not modify this *| 19 | |* header directly. *| 20 | |* *| 21 | \*===----------------------------------------------------------------------===*/ 22 | 23 | #ifndef LLVM_DISASSEMBLER 24 | # error Please define the macro LLVM_DISASSEMBLER(TargetName) 25 | #endif 26 | 27 | @LLVM_ENUM_DISASSEMBLERS@ 28 | 29 | #undef LLVM_DISASSEMBLER 30 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/Targets.def.in: -------------------------------------------------------------------------------- 1 | /*===- llvm/Config/Targets.def - LLVM Target Architectures ------*- C++ -*-===*\ 2 | |* *| 3 | |* The LLVM Compiler Infrastructure *| 4 | |* *| 5 | |* This file is distributed under the University of Illinois Open Source *| 6 | |* License. See LICENSE.TXT for details. *| 7 | |* *| 8 | |*===----------------------------------------------------------------------===*| 9 | |* *| 10 | |* This file enumerates all of the target architectures supported by *| 11 | |* this build of LLVM. Clients of this file should define the *| 12 | |* LLVM_TARGET macro to be a function-like macro with a single *| 13 | |* parameter (the name of the target); including this file will then *| 14 | |* enumerate all of the targets. *| 15 | |* *| 16 | |* The set of targets supported by LLVM is generated at configuration *| 17 | |* time, at which point this header is generated. Do not modify this *| 18 | |* header directly. *| 19 | |* *| 20 | \*===----------------------------------------------------------------------===*/ 21 | 22 | #ifndef LLVM_TARGET 23 | # error Please define the macro LLVM_TARGET(TargetName) 24 | #endif 25 | 26 | @LLVM_ENUM_TARGETS@ 27 | 28 | #undef LLVM_TARGET 29 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/abi-breaking.h: -------------------------------------------------------------------------------- 1 | /* hacked for X-Plane by Tyler */ 2 | 3 | /* This file controls the C++ ABI break introduced in LLVM public header. */ 4 | 5 | #ifndef LLVM_ABI_BREAKING_CHECKS_H 6 | #define LLVM_ABI_BREAKING_CHECKS_H 7 | 8 | /* Define to enable checks that alter the LLVM C++ ABI */ 9 | #define LLVM_ENABLE_ABI_BREAKING_CHECKS 0 10 | 11 | /* Define to enable reverse iteration of unordered llvm containers */ 12 | #define LLVM_ENABLE_REVERSE_ITERATION 0 13 | 14 | /* Allow selectively disabling link-time mismatch checking so that header-only 15 | ADT content from LLVM can be used without linking libSupport. */ 16 | #if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING 17 | 18 | // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build 19 | // mismatch with LLVM 20 | #if defined(_MSC_VER) 21 | // Use pragma with MSVC 22 | #define LLVM_XSTR(s) LLVM_STR(s) 23 | #define LLVM_STR(s) #s 24 | #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS)) 25 | #undef LLVM_XSTR 26 | #undef LLVM_STR 27 | #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch 28 | // FIXME: Implement checks without weak. 29 | #elif defined(__cplusplus) 30 | namespace llvm { 31 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS 32 | extern int EnableABIBreakingChecks; 33 | __attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks; 34 | #else 35 | extern int DisableABIBreakingChecks; 36 | __attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks; 37 | #endif 38 | } 39 | #endif // _MSC_VER 40 | 41 | #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/abi-breaking.h.cmake: -------------------------------------------------------------------------------- 1 | /*===------- llvm/Config/abi-breaking.h - llvm configuration -------*- C -*-===*/ 2 | /* */ 3 | /* The LLVM Compiler Infrastructure */ 4 | /* */ 5 | /* This file is distributed under the University of Illinois Open Source */ 6 | /* License. See LICENSE.TXT for details. */ 7 | /* */ 8 | /*===----------------------------------------------------------------------===*/ 9 | 10 | /* This file controls the C++ ABI break introduced in LLVM public header. */ 11 | 12 | #ifndef LLVM_ABI_BREAKING_CHECKS_H 13 | #define LLVM_ABI_BREAKING_CHECKS_H 14 | 15 | /* Define to enable checks that alter the LLVM C++ ABI */ 16 | #cmakedefine01 LLVM_ENABLE_ABI_BREAKING_CHECKS 17 | 18 | /* Define to enable reverse iteration of unordered llvm containers */ 19 | #cmakedefine01 LLVM_ENABLE_REVERSE_ITERATION 20 | 21 | /* Allow selectively disabling link-time mismatch checking so that header-only 22 | ADT content from LLVM can be used without linking libSupport. */ 23 | #if !LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING 24 | 25 | // ABI_BREAKING_CHECKS protection: provides link-time failure when clients build 26 | // mismatch with LLVM 27 | #if defined(_MSC_VER) 28 | // Use pragma with MSVC 29 | #define LLVM_XSTR(s) LLVM_STR(s) 30 | #define LLVM_STR(s) #s 31 | #pragma detect_mismatch("LLVM_ENABLE_ABI_BREAKING_CHECKS", LLVM_XSTR(LLVM_ENABLE_ABI_BREAKING_CHECKS)) 32 | #undef LLVM_XSTR 33 | #undef LLVM_STR 34 | #elif defined(_WIN32) || defined(__CYGWIN__) // Win32 w/o #pragma detect_mismatch 35 | // FIXME: Implement checks without weak. 36 | #elif defined(__cplusplus) 37 | namespace llvm { 38 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS 39 | extern int EnableABIBreakingChecks; 40 | __attribute__((weak, visibility ("hidden"))) int *VerifyEnableABIBreakingChecks = &EnableABIBreakingChecks; 41 | #else 42 | extern int DisableABIBreakingChecks; 43 | __attribute__((weak, visibility ("hidden"))) int *VerifyDisableABIBreakingChecks = &DisableABIBreakingChecks; 44 | #endif 45 | } 46 | #endif // _MSC_VER 47 | 48 | #endif // LLVM_DISABLE_ABI_BREAKING_CHECKS_ENFORCING 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/llvm-config.h: -------------------------------------------------------------------------------- 1 | /* Hacked by Tyler to match X-Plane's config! */ 2 | 3 | #ifndef LLVM_CONFIG_H 4 | #define LLVM_CONFIG_H 5 | 6 | /* Define if LLVM_ENABLE_DUMP is enabled */ 7 | #define LLVM_ENABLE_DUMP 0 8 | 9 | /* Define if we link Polly to the tools */ 10 | #define LINK_POLLY_INTO_TOOLS 0 11 | 12 | /* Target triple LLVM will generate code for by default */ 13 | #define LLVM_DEFAULT_TARGET_TRIPLE 0 14 | 15 | /* Define if this is Unixish platform */ 16 | #define LLVM_ON_UNIX (APL||LIN) 17 | 18 | /* Define if this is Win32ish platform */ 19 | #define LLVM_ON_WIN32 IBM 20 | 21 | /* Major version of the LLVM API */ 22 | #define LLVM_VERSION_MAJOR 7 23 | 24 | /* Minor version of the LLVM API */ 25 | #define LLVM_VERSION_MINOR 0 26 | 27 | /* Patch version of the LLVM API */ 28 | #define LLVM_VERSION_PATCH 0 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Config/llvm-config.h.cmake: -------------------------------------------------------------------------------- 1 | /*===------- llvm/Config/llvm-config.h - llvm configuration -------*- C -*-===*/ 2 | /* */ 3 | /* The LLVM Compiler Infrastructure */ 4 | /* */ 5 | /* This file is distributed under the University of Illinois Open Source */ 6 | /* License. See LICENSE.TXT for details. */ 7 | /* */ 8 | /*===----------------------------------------------------------------------===*/ 9 | 10 | /* This file enumerates variables from the LLVM configuration so that they 11 | can be in exported headers and won't override package specific directives. 12 | This is a C header that can be included in the llvm-c headers. */ 13 | 14 | #ifndef LLVM_CONFIG_H 15 | #define LLVM_CONFIG_H 16 | 17 | /* Define if LLVM_ENABLE_DUMP is enabled */ 18 | #cmakedefine LLVM_ENABLE_DUMP 19 | 20 | /* Define if we link Polly to the tools */ 21 | #cmakedefine LINK_POLLY_INTO_TOOLS 22 | 23 | /* Target triple LLVM will generate code for by default */ 24 | #cmakedefine LLVM_DEFAULT_TARGET_TRIPLE "${LLVM_DEFAULT_TARGET_TRIPLE}" 25 | 26 | /* Define if threads enabled */ 27 | #cmakedefine01 LLVM_ENABLE_THREADS 28 | 29 | /* Has gcc/MSVC atomic intrinsics */ 30 | #cmakedefine01 LLVM_HAS_ATOMICS 31 | 32 | /* Host triple LLVM will be executed on */ 33 | #cmakedefine LLVM_HOST_TRIPLE "${LLVM_HOST_TRIPLE}" 34 | 35 | /* LLVM architecture name for the native architecture, if available */ 36 | #cmakedefine LLVM_NATIVE_ARCH ${LLVM_NATIVE_ARCH} 37 | 38 | /* LLVM name for the native AsmParser init function, if available */ 39 | #cmakedefine LLVM_NATIVE_ASMPARSER LLVMInitialize${LLVM_NATIVE_ARCH}AsmParser 40 | 41 | /* LLVM name for the native AsmPrinter init function, if available */ 42 | #cmakedefine LLVM_NATIVE_ASMPRINTER LLVMInitialize${LLVM_NATIVE_ARCH}AsmPrinter 43 | 44 | /* LLVM name for the native Disassembler init function, if available */ 45 | #cmakedefine LLVM_NATIVE_DISASSEMBLER LLVMInitialize${LLVM_NATIVE_ARCH}Disassembler 46 | 47 | /* LLVM name for the native Target init function, if available */ 48 | #cmakedefine LLVM_NATIVE_TARGET LLVMInitialize${LLVM_NATIVE_ARCH}Target 49 | 50 | /* LLVM name for the native TargetInfo init function, if available */ 51 | #cmakedefine LLVM_NATIVE_TARGETINFO LLVMInitialize${LLVM_NATIVE_ARCH}TargetInfo 52 | 53 | /* LLVM name for the native target MC init function, if available */ 54 | #cmakedefine LLVM_NATIVE_TARGETMC LLVMInitialize${LLVM_NATIVE_ARCH}TargetMC 55 | 56 | /* Define if this is Unixish platform */ 57 | #cmakedefine LLVM_ON_UNIX ${LLVM_ON_UNIX} 58 | 59 | /* Define if this is Win32ish platform */ 60 | #cmakedefine LLVM_ON_WIN32 ${LLVM_ON_WIN32} 61 | 62 | /* Define if we have the Intel JIT API runtime support library */ 63 | #cmakedefine01 LLVM_USE_INTEL_JITEVENTS 64 | 65 | /* Define if we have the oprofile JIT-support library */ 66 | #cmakedefine01 LLVM_USE_OPROFILE 67 | 68 | /* Major version of the LLVM API */ 69 | #define LLVM_VERSION_MAJOR ${LLVM_VERSION_MAJOR} 70 | 71 | /* Minor version of the LLVM API */ 72 | #define LLVM_VERSION_MINOR ${LLVM_VERSION_MINOR} 73 | 74 | /* Patch version of the LLVM API */ 75 | #define LLVM_VERSION_PATCH ${LLVM_VERSION_PATCH} 76 | 77 | /* LLVM version string */ 78 | #define LLVM_VERSION_STRING "${PACKAGE_VERSION}" 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Atomic.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Atomic.h - Atomic Operations -----------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the llvm::sys atomic operations. 11 | // 12 | // DO NOT USE IN NEW CODE! 13 | // 14 | // New code should always rely on the std::atomic facilities in C++11. 15 | // 16 | //===----------------------------------------------------------------------===// 17 | 18 | #ifndef LLVM_SUPPORT_ATOMIC_H 19 | #define LLVM_SUPPORT_ATOMIC_H 20 | 21 | #include "llvm/Support/DataTypes.h" 22 | 23 | // Windows will at times define MemoryFence. 24 | #ifdef MemoryFence 25 | #undef MemoryFence 26 | #endif 27 | 28 | namespace llvm { 29 | namespace sys { 30 | void MemoryFence(); 31 | 32 | #ifdef _MSC_VER 33 | typedef long cas_flag; 34 | #else 35 | typedef uint32_t cas_flag; 36 | #endif 37 | cas_flag CompareAndSwap(volatile cas_flag* ptr, 38 | cas_flag new_value, 39 | cas_flag old_value); 40 | } 41 | } 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/BinaryStreamError.h: -------------------------------------------------------------------------------- 1 | //===- BinaryStreamError.h - Error extensions for Binary Streams *- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_BINARYSTREAMERROR_H 11 | #define LLVM_SUPPORT_BINARYSTREAMERROR_H 12 | 13 | #include "llvm/ADT/StringRef.h" 14 | #include "llvm/Support/Error.h" 15 | 16 | #include 17 | 18 | namespace llvm { 19 | enum class stream_error_code { 20 | unspecified, 21 | stream_too_short, 22 | invalid_array_size, 23 | invalid_offset, 24 | filesystem_error 25 | }; 26 | 27 | /// Base class for errors originating when parsing raw PDB files 28 | class BinaryStreamError : public ErrorInfo { 29 | public: 30 | static char ID; 31 | explicit BinaryStreamError(stream_error_code C); 32 | explicit BinaryStreamError(StringRef Context); 33 | BinaryStreamError(stream_error_code C, StringRef Context); 34 | 35 | void log(raw_ostream &OS) const override; 36 | std::error_code convertToErrorCode() const override; 37 | 38 | StringRef getErrorMessage() const; 39 | 40 | stream_error_code getErrorCode() const { return Code; } 41 | 42 | private: 43 | std::string ErrMsg; 44 | stream_error_code Code; 45 | }; 46 | } // namespace llvm 47 | 48 | #endif // LLVM_SUPPORT_BINARYSTREAMERROR_H 49 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/BlockFrequency.h: -------------------------------------------------------------------------------- 1 | //===-------- BlockFrequency.h - Block Frequency Wrapper --------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements Block Frequency class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_BLOCKFREQUENCY_H 15 | #define LLVM_SUPPORT_BLOCKFREQUENCY_H 16 | 17 | #include "llvm/Support/BranchProbability.h" 18 | #include "llvm/Support/DataTypes.h" 19 | 20 | namespace llvm { 21 | 22 | class raw_ostream; 23 | 24 | // This class represents Block Frequency as a 64-bit value. 25 | class BlockFrequency { 26 | uint64_t Frequency; 27 | 28 | public: 29 | BlockFrequency(uint64_t Freq = 0) : Frequency(Freq) { } 30 | 31 | /// \brief Returns the maximum possible frequency, the saturation value. 32 | static uint64_t getMaxFrequency() { return -1ULL; } 33 | 34 | /// \brief Returns the frequency as a fixpoint number scaled by the entry 35 | /// frequency. 36 | uint64_t getFrequency() const { return Frequency; } 37 | 38 | /// \brief Multiplies with a branch probability. The computation will never 39 | /// overflow. 40 | BlockFrequency &operator*=(BranchProbability Prob); 41 | BlockFrequency operator*(BranchProbability Prob) const; 42 | 43 | /// \brief Divide by a non-zero branch probability using saturating 44 | /// arithmetic. 45 | BlockFrequency &operator/=(BranchProbability Prob); 46 | BlockFrequency operator/(BranchProbability Prob) const; 47 | 48 | /// \brief Adds another block frequency using saturating arithmetic. 49 | BlockFrequency &operator+=(BlockFrequency Freq); 50 | BlockFrequency operator+(BlockFrequency Freq) const; 51 | 52 | /// \brief Subtracts another block frequency using saturating arithmetic. 53 | BlockFrequency &operator-=(BlockFrequency Freq); 54 | BlockFrequency operator-(BlockFrequency Freq) const; 55 | 56 | /// \brief Shift block frequency to the right by count digits saturating to 1. 57 | BlockFrequency &operator>>=(const unsigned count); 58 | 59 | bool operator<(BlockFrequency RHS) const { 60 | return Frequency < RHS.Frequency; 61 | } 62 | 63 | bool operator<=(BlockFrequency RHS) const { 64 | return Frequency <= RHS.Frequency; 65 | } 66 | 67 | bool operator>(BlockFrequency RHS) const { 68 | return Frequency > RHS.Frequency; 69 | } 70 | 71 | bool operator>=(BlockFrequency RHS) const { 72 | return Frequency >= RHS.Frequency; 73 | } 74 | 75 | bool operator==(BlockFrequency RHS) const { 76 | return Frequency == RHS.Frequency; 77 | } 78 | }; 79 | 80 | } 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/CBindingWrapping.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/CBindingWrapph.h - C Interface Wrapping -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the wrapping macros for the C interface. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_CBINDINGWRAPPING_H 15 | #define LLVM_SUPPORT_CBINDINGWRAPPING_H 16 | 17 | #include "llvm-c/Types.h" 18 | #include "llvm/Support/Casting.h" 19 | 20 | #define DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 21 | inline ty *unwrap(ref P) { \ 22 | return reinterpret_cast(P); \ 23 | } \ 24 | \ 25 | inline ref wrap(const ty *P) { \ 26 | return reinterpret_cast(const_cast(P)); \ 27 | } 28 | 29 | #define DEFINE_ISA_CONVERSION_FUNCTIONS(ty, ref) \ 30 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 31 | \ 32 | template \ 33 | inline T *unwrap(ref P) { \ 34 | return cast(unwrap(P)); \ 35 | } 36 | 37 | #define DEFINE_STDCXX_CONVERSION_FUNCTIONS(ty, ref) \ 38 | DEFINE_SIMPLE_CONVERSION_FUNCTIONS(ty, ref) \ 39 | \ 40 | template \ 41 | inline T *unwrap(ref P) { \ 42 | T *Q = (T*)unwrap(P); \ 43 | assert(Q && "Invalid cast!"); \ 44 | return Q; \ 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_first_existing_vc_file(llvm_vc "${LLVM_MAIN_SRC_DIR}") 2 | 3 | # The VC revision include that we want to generate. 4 | set(version_inc "${CMAKE_CURRENT_BINARY_DIR}/VCSRevision.h") 5 | 6 | set(get_svn_script "${LLVM_CMAKE_PATH}/GenerateVersionFromCVS.cmake") 7 | 8 | file(WRITE "${version_inc}.undef" "#undef LLVM_REVISION\n") 9 | if((DEFINED llvm_vc) AND LLVM_APPEND_VC_REV) 10 | 11 | execute_process(COMMAND ${CMAKE_COMMAND} -E compare_files 12 | "${version_inc}.undef" "${version_inc}" 13 | RESULT_VARIABLE files_not_equal 14 | OUTPUT_QUIET 15 | ERROR_QUIET) 16 | # Remove ${version_inc} if it doesn't define a revision. This will force it 17 | # to be regenerated when toggling LLVM_APPEND_VC_REV from OFF to ON. 18 | if(NOT files_not_equal) 19 | file(REMOVE "${version_inc}") 20 | endif() 21 | 22 | # Create custom target to generate the VC revision include. 23 | add_custom_command(OUTPUT "${version_inc}" 24 | DEPENDS "${llvm_vc}" "${get_svn_script}" 25 | COMMAND 26 | ${CMAKE_COMMAND} "-DSOURCE_DIR=${LLVM_MAIN_SRC_DIR}" 27 | "-DNAME=LLVM_REVISION" 28 | "-DHEADER_FILE=${version_inc}" 29 | -P "${get_svn_script}") 30 | else() 31 | # Make sure ${version_inc} doesn't define a revision 32 | execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different 33 | "${version_inc}.undef" "${version_inc}") 34 | endif() 35 | file(REMOVE "${version_inc}.undef") 36 | 37 | # Mark the generated header as being generated. 38 | set_source_files_properties("${version_inc}" 39 | PROPERTIES GENERATED TRUE 40 | HEADER_FILE_ONLY TRUE) 41 | 42 | add_custom_target(llvm_vcsrevision_h DEPENDS "${version_inc}") 43 | set_target_properties(llvm_vcsrevision_h PROPERTIES FOLDER "Misc") 44 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/COM.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/COM.h ---------------------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// \file 10 | /// 11 | /// Provides a library for accessing COM functionality of the Host OS. 12 | /// 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_COM_H 16 | #define LLVM_SUPPORT_COM_H 17 | 18 | namespace llvm { 19 | namespace sys { 20 | 21 | enum class COMThreadingMode { SingleThreaded, MultiThreaded }; 22 | 23 | class InitializeCOMRAII { 24 | public: 25 | explicit InitializeCOMRAII(COMThreadingMode Threading, 26 | bool SpeedOverMemory = false); 27 | ~InitializeCOMRAII(); 28 | 29 | private: 30 | InitializeCOMRAII(const InitializeCOMRAII &) = delete; 31 | void operator=(const InitializeCOMRAII &) = delete; 32 | }; 33 | } 34 | } 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/CachePruning.h: -------------------------------------------------------------------------------- 1 | //=- CachePruning.h - Helper to manage the pruning of a cache dir -*- C++ -*-=// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements pruning of a directory intended for cache storage, using 11 | // various policies. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_CACHE_PRUNING_H 16 | #define LLVM_SUPPORT_CACHE_PRUNING_H 17 | 18 | #include "llvm/ADT/StringRef.h" 19 | #include 20 | 21 | namespace llvm { 22 | 23 | template class Expected; 24 | 25 | /// Policy for the pruneCache() function. A default constructed 26 | /// CachePruningPolicy provides a reasonable default policy. 27 | struct CachePruningPolicy { 28 | /// The pruning interval. This is intended to be used to avoid scanning the 29 | /// directory too often. It does not impact the decision of which file to 30 | /// prune. A value of 0 forces the scan to occur. A value of None disables 31 | /// pruning. 32 | llvm::Optional Interval = std::chrono::seconds(1200); 33 | 34 | /// The expiration for a file. When a file hasn't been accessed for Expiration 35 | /// seconds, it is removed from the cache. A value of 0 disables the 36 | /// expiration-based pruning. 37 | std::chrono::seconds Expiration = std::chrono::hours(7 * 24); // 1w 38 | 39 | /// The maximum size for the cache directory, in terms of percentage of the 40 | /// available space on the disk. Set to 100 to indicate no limit, 50 to 41 | /// indicate that the cache size will not be left over half the available disk 42 | /// space. A value over 100 will be reduced to 100. A value of 0 disables the 43 | /// percentage size-based pruning. 44 | unsigned MaxSizePercentageOfAvailableSpace = 75; 45 | 46 | /// The maximum size for the cache directory in bytes. A value over the amount 47 | /// of available space on the disk will be reduced to the amount of available 48 | /// space. A value of 0 disables the absolute size-based pruning. 49 | uint64_t MaxSizeBytes = 0; 50 | 51 | /// The maximum number of files in the cache directory. A value of 0 disables 52 | /// the number of files based pruning. 53 | /// 54 | /// This defaults to 1000000 because with that many files there are 55 | /// diminishing returns on the effectiveness of the cache, and some file 56 | /// systems have a limit on how many files can be contained in a directory 57 | /// (notably ext4, which is limited to around 6000000 files). 58 | uint64_t MaxSizeFiles = 1000000; 59 | }; 60 | 61 | /// Parse the given string as a cache pruning policy. Defaults are taken from a 62 | /// default constructed CachePruningPolicy object. 63 | /// For example: "prune_interval=30s:prune_after=24h:cache_size=50%" 64 | /// which means a pruning interval of 30 seconds, expiration time of 24 hours 65 | /// and maximum cache size of 50% of available disk space. 66 | Expected parseCachePruningPolicy(StringRef PolicyStr); 67 | 68 | /// Peform pruning using the supplied policy, returns true if pruning 69 | /// occurred, i.e. if Policy.Interval was expired. 70 | /// 71 | /// As a safeguard against data loss if the user specifies the wrong directory 72 | /// as their cache directory, this function will ignore files not matching the 73 | /// pattern "llvmcache-*". 74 | bool pruneCache(StringRef Path, CachePruningPolicy Policy); 75 | 76 | } // namespace llvm 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Capacity.h: -------------------------------------------------------------------------------- 1 | //===--- Capacity.h - Generic computation of ADT memory use -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the capacity function that computes the amount of 11 | // memory used by an ADT. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_CAPACITY_H 16 | #define LLVM_SUPPORT_CAPACITY_H 17 | 18 | #include 19 | 20 | namespace llvm { 21 | 22 | template 23 | static inline size_t capacity_in_bytes(const T &x) { 24 | // This default definition of capacity should work for things like std::vector 25 | // and friends. More specialized versions will work for others. 26 | return x.capacity() * sizeof(typename T::value_type); 27 | } 28 | 29 | } // end namespace llvm 30 | 31 | #endif 32 | 33 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/CodeGen.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/CodeGen.h - CodeGen Concepts ---------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file define some types which define code generation concepts. For 11 | // example, relocation model. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_CODEGEN_H 16 | #define LLVM_SUPPORT_CODEGEN_H 17 | 18 | namespace llvm { 19 | 20 | // Relocation model types. 21 | namespace Reloc { 22 | enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI }; 23 | } 24 | 25 | // Code model types. 26 | namespace CodeModel { 27 | // Sync changes with CodeGenCWrappers.h. 28 | enum Model { Small, Kernel, Medium, Large }; 29 | } 30 | 31 | namespace PICLevel { 32 | // This is used to map -fpic/-fPIC. 33 | enum Level { NotPIC=0, SmallPIC=1, BigPIC=2 }; 34 | } 35 | 36 | namespace PIELevel { 37 | enum Level { Default=0, Small=1, Large=2 }; 38 | } 39 | 40 | // TLS models. 41 | namespace TLSModel { 42 | enum Model { 43 | GeneralDynamic, 44 | LocalDynamic, 45 | InitialExec, 46 | LocalExec 47 | }; 48 | } 49 | 50 | // Code generation optimization level. 51 | namespace CodeGenOpt { 52 | enum Level { 53 | None, // -O0 54 | Less, // -O1 55 | Default, // -O2, -Os 56 | Aggressive // -O3 57 | }; 58 | } 59 | 60 | } // end llvm namespace 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/CodeGenCWrappers.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/CodeGenCWrappers.h - CodeGen C Wrappers -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines C bindings wrappers for enums in llvm/Support/CodeGen.h 11 | // that need them. The wrappers are separated to avoid adding an indirect 12 | // dependency on llvm/Config/Targets.def to CodeGen.h. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_CODEGENCWRAPPERS_H 17 | #define LLVM_SUPPORT_CODEGENCWRAPPERS_H 18 | 19 | #include "llvm-c/TargetMachine.h" 20 | #include "llvm/ADT/Optional.h" 21 | #include "llvm/Support/CodeGen.h" 22 | #include "llvm/Support/ErrorHandling.h" 23 | 24 | namespace llvm { 25 | 26 | inline Optional unwrap(LLVMCodeModel Model, bool &JIT) { 27 | JIT = false; 28 | switch (Model) { 29 | case LLVMCodeModelJITDefault: 30 | JIT = true; 31 | LLVM_FALLTHROUGH; 32 | case LLVMCodeModelDefault: 33 | return None; 34 | case LLVMCodeModelSmall: 35 | return CodeModel::Small; 36 | case LLVMCodeModelKernel: 37 | return CodeModel::Kernel; 38 | case LLVMCodeModelMedium: 39 | return CodeModel::Medium; 40 | case LLVMCodeModelLarge: 41 | return CodeModel::Large; 42 | } 43 | return CodeModel::Small; 44 | } 45 | 46 | inline LLVMCodeModel wrap(CodeModel::Model Model) { 47 | switch (Model) { 48 | case CodeModel::Small: 49 | return LLVMCodeModelSmall; 50 | case CodeModel::Kernel: 51 | return LLVMCodeModelKernel; 52 | case CodeModel::Medium: 53 | return LLVMCodeModelMedium; 54 | case CodeModel::Large: 55 | return LLVMCodeModelLarge; 56 | } 57 | llvm_unreachable("Bad CodeModel!"); 58 | } 59 | 60 | } // end llvm namespace 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/CodeGenCoverage.h: -------------------------------------------------------------------------------- 1 | //== llvm/Support/CodeGenCoverage.h ------------------------------*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// \file This file provides rule coverage tracking for tablegen-erated CodeGen. 10 | //===----------------------------------------------------------------------===// 11 | 12 | #ifndef LLVM_SUPPORT_CODEGENCOVERAGE_H 13 | #define LLVM_SUPPORT_CODEGENCOVERAGE_H 14 | 15 | #include "llvm/ADT/BitVector.h" 16 | 17 | namespace llvm { 18 | class LLVMContext; 19 | class MemoryBuffer; 20 | 21 | class CodeGenCoverage { 22 | protected: 23 | BitVector RuleCoverage; 24 | 25 | public: 26 | CodeGenCoverage(); 27 | 28 | void setCovered(uint64_t RuleID); 29 | bool isCovered(uint64_t RuleID); 30 | 31 | bool parse(MemoryBuffer &Buffer, StringRef BackendName); 32 | bool emit(StringRef FilePrefix, StringRef BackendName) const; 33 | void reset(); 34 | }; 35 | } // end namespace llvm 36 | 37 | #endif // ifndef LLVM_SUPPORT_CODEGENCOVERAGE_H 38 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Compression.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/Compression.h ---Compression----------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains basic functions for compression/uncompression. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_COMPRESSION_H 15 | #define LLVM_SUPPORT_COMPRESSION_H 16 | 17 | #include "llvm/Support/DataTypes.h" 18 | 19 | namespace llvm { 20 | template class SmallVectorImpl; 21 | class Error; 22 | class StringRef; 23 | 24 | namespace zlib { 25 | 26 | enum CompressionLevel { 27 | NoCompression, 28 | DefaultCompression, 29 | BestSpeedCompression, 30 | BestSizeCompression 31 | }; 32 | 33 | bool isAvailable(); 34 | 35 | Error compress(StringRef InputBuffer, SmallVectorImpl &CompressedBuffer, 36 | CompressionLevel Level = DefaultCompression); 37 | 38 | Error uncompress(StringRef InputBuffer, char *UncompressedBuffer, 39 | size_t &UncompressedSize); 40 | 41 | Error uncompress(StringRef InputBuffer, 42 | SmallVectorImpl &UncompressedBuffer, 43 | size_t UncompressedSize); 44 | 45 | uint32_t crc32(StringRef Buffer); 46 | 47 | } // End of namespace zlib 48 | 49 | } // End of namespace llvm 50 | 51 | #endif 52 | 53 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/DJB.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/DJB.h ---DJB Hash --------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains support for the DJ Bernstein hash function. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_DJB_H 15 | #define LLVM_SUPPORT_DJB_H 16 | 17 | #include "llvm/ADT/StringRef.h" 18 | 19 | namespace llvm { 20 | 21 | /// The Bernstein hash function used by the DWARF accelerator tables. 22 | uint32_t djbHash(StringRef Buffer, uint32_t H = 5381); 23 | } // namespace llvm 24 | 25 | #endif // LLVM_SUPPORT_DJB_H 26 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/DataTypes.h: -------------------------------------------------------------------------------- 1 | /* Hacked by Tyler to match X-Plane's config */ 2 | 3 | /* Please leave this file C-compatible. */ 4 | 5 | #ifndef SUPPORT_DATATYPES_H 6 | #define SUPPORT_DATATYPES_H 7 | 8 | #define HAVE_INTTYPES_H 1 9 | #define HAVE_STDINT_H 1 10 | #define HAVE_UINT64_T 1 11 | #define HAVE_U_INT64_T 1 12 | 13 | #ifdef __cplusplus 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | #ifdef __cplusplus 20 | #include 21 | #else 22 | #ifdef HAVE_INTTYPES_H 23 | #include 24 | #endif 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | #include 29 | #else 30 | #ifdef HAVE_STDINT_H 31 | #include 32 | #else 33 | #error "Compiler must provide an implementation of stdint.h" 34 | #endif 35 | #endif 36 | 37 | #ifndef _MSC_VER 38 | 39 | #if !defined(UINT32_MAX) 40 | # error "The standard header is not C++11 compliant. Must #define "\ 41 | "__STDC_LIMIT_MACROS before #including Support/DataTypes.h" 42 | #endif 43 | 44 | #if !defined(UINT32_C) 45 | # error "The standard header is not C++11 compliant. Must #define "\ 46 | "__STDC_CONSTANT_MACROS before #including Support/DataTypes.h" 47 | #endif 48 | 49 | /* Note that includes , if this is a C99 system. */ 50 | #include 51 | 52 | #ifdef _AIX 53 | // GCC is strict about defining large constants: they must have LL modifier. 54 | #undef INT64_MAX 55 | #undef INT64_MIN 56 | #endif 57 | 58 | /* Handle incorrect definition of uint64_t as u_int64_t */ 59 | #ifndef HAVE_UINT64_T 60 | #ifdef HAVE_U_INT64_T 61 | typedef u_int64_t uint64_t; 62 | #else 63 | # error "Don't have a definition for uint64_t on this platform" 64 | #endif 65 | #endif 66 | 67 | #else /* _MSC_VER */ 68 | #ifdef __cplusplus 69 | #include 70 | #include 71 | #else 72 | #include 73 | #include 74 | #endif 75 | #include 76 | 77 | #if defined(_WIN64) 78 | typedef signed __int64 ssize_t; 79 | #else 80 | typedef signed int ssize_t; 81 | #endif /* _WIN64 */ 82 | 83 | #ifndef HAVE_INTTYPES_H 84 | #define PRId64 "I64d" 85 | #define PRIi64 "I64i" 86 | #define PRIo64 "I64o" 87 | #define PRIu64 "I64u" 88 | #define PRIx64 "I64x" 89 | #define PRIX64 "I64X" 90 | 91 | #define PRId32 "d" 92 | #define PRIi32 "i" 93 | #define PRIo32 "o" 94 | #define PRIu32 "u" 95 | #define PRIx32 "x" 96 | #define PRIX32 "X" 97 | #endif /* HAVE_INTTYPES_H */ 98 | 99 | #endif /* _MSC_VER */ 100 | 101 | /* Set defaults for constants which we cannot find. */ 102 | #if !defined(INT64_MAX) 103 | # define INT64_MAX 9223372036854775807LL 104 | #endif 105 | #if !defined(INT64_MIN) 106 | # define INT64_MIN ((-INT64_MAX)-1) 107 | #endif 108 | #if !defined(UINT64_MAX) 109 | # define UINT64_MAX 0xffffffffffffffffULL 110 | #endif 111 | 112 | #ifndef HUGE_VALF 113 | #define HUGE_VALF (float)HUGE_VAL 114 | #endif 115 | 116 | #endif /* SUPPORT_DATATYPES_H */ 117 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/DataTypes.h.cmake: -------------------------------------------------------------------------------- 1 | /* Hacked by Tyler to match X-Plane's config */ 2 | 3 | /* Please leave this file C-compatible. */ 4 | 5 | #ifndef SUPPORT_DATATYPES_H 6 | #define SUPPORT_DATATYPES_H 7 | 8 | #cmakedefine HAVE_INTTYPES_H ${HAVE_INTTYPES_H} 9 | #cmakedefine HAVE_STDINT_H ${HAVE_STDINT_H} 10 | #cmakedefine HAVE_UINT64_T ${HAVE_UINT64_T} 11 | #cmakedefine HAVE_U_INT64_T ${HAVE_U_INT64_T} 12 | 13 | #ifdef __cplusplus 14 | #include 15 | #else 16 | #include 17 | #endif 18 | 19 | #ifdef __cplusplus 20 | #include 21 | #else 22 | #ifdef HAVE_INTTYPES_H 23 | #include 24 | #endif 25 | #endif 26 | 27 | #ifdef __cplusplus 28 | #include 29 | #else 30 | #ifdef HAVE_STDINT_H 31 | #include 32 | #else 33 | #error "Compiler must provide an implementation of stdint.h" 34 | #endif 35 | #endif 36 | 37 | #ifndef _MSC_VER 38 | 39 | #if !defined(UINT32_MAX) 40 | # error "The standard header is not C++11 compliant. Must #define "\ 41 | "__STDC_LIMIT_MACROS before #including Support/DataTypes.h" 42 | #endif 43 | 44 | #if !defined(UINT32_C) 45 | # error "The standard header is not C++11 compliant. Must #define "\ 46 | "__STDC_CONSTANT_MACROS before #including Support/DataTypes.h" 47 | #endif 48 | 49 | /* Note that includes , if this is a C99 system. */ 50 | #include 51 | 52 | #ifdef _AIX 53 | // GCC is strict about defining large constants: they must have LL modifier. 54 | #undef INT64_MAX 55 | #undef INT64_MIN 56 | #endif 57 | 58 | /* Handle incorrect definition of uint64_t as u_int64_t */ 59 | #ifndef HAVE_UINT64_T 60 | #ifdef HAVE_U_INT64_T 61 | typedef u_int64_t uint64_t; 62 | #else 63 | # error "Don't have a definition for uint64_t on this platform" 64 | #endif 65 | #endif 66 | 67 | #else /* _MSC_VER */ 68 | #ifdef __cplusplus 69 | #include 70 | #include 71 | #else 72 | #include 73 | #include 74 | #endif 75 | #include 76 | 77 | #if defined(_WIN64) 78 | typedef signed __int64 ssize_t; 79 | #else 80 | typedef signed int ssize_t; 81 | #endif /* _WIN64 */ 82 | 83 | #ifndef HAVE_INTTYPES_H 84 | #define PRId64 "I64d" 85 | #define PRIi64 "I64i" 86 | #define PRIo64 "I64o" 87 | #define PRIu64 "I64u" 88 | #define PRIx64 "I64x" 89 | #define PRIX64 "I64X" 90 | 91 | #define PRId32 "d" 92 | #define PRIi32 "i" 93 | #define PRIo32 "o" 94 | #define PRIu32 "u" 95 | #define PRIx32 "x" 96 | #define PRIX32 "X" 97 | #endif /* HAVE_INTTYPES_H */ 98 | 99 | #endif /* _MSC_VER */ 100 | 101 | /* Set defaults for constants which we cannot find. */ 102 | #if !defined(INT64_MAX) 103 | # define INT64_MAX 9223372036854775807LL 104 | #endif 105 | #if !defined(INT64_MIN) 106 | # define INT64_MIN ((-INT64_MAX)-1) 107 | #endif 108 | #if !defined(UINT64_MAX) 109 | # define UINT64_MAX 0xffffffffffffffffULL 110 | #endif 111 | 112 | #ifndef HUGE_VALF 113 | #define HUGE_VALF (float)HUGE_VAL 114 | #endif 115 | 116 | #endif /* SUPPORT_DATATYPES_H */ 117 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/EndianStream.h: -------------------------------------------------------------------------------- 1 | //===- EndianStream.h - Stream ops with endian specific data ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines utilities for operating on streams that have endian 11 | // specific data. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_ENDIANSTREAM_H 16 | #define LLVM_SUPPORT_ENDIANSTREAM_H 17 | 18 | #include "llvm/ADT/ArrayRef.h" 19 | #include "llvm/Support/Endian.h" 20 | #include "llvm/Support/raw_ostream.h" 21 | 22 | namespace llvm { 23 | namespace support { 24 | 25 | namespace endian { 26 | /// Adapter to write values to a stream in a particular byte order. 27 | template struct Writer { 28 | raw_ostream &OS; 29 | Writer(raw_ostream &OS) : OS(OS) {} 30 | template void write(ArrayRef Vals) { 31 | for (value_type V : Vals) 32 | write(V); 33 | } 34 | template void write(value_type Val) { 35 | Val = byte_swap(Val); 36 | OS.write((const char *)&Val, sizeof(value_type)); 37 | } 38 | }; 39 | 40 | template <> 41 | template <> 42 | inline void Writer::write(float Val) { 43 | write(FloatToBits(Val)); 44 | } 45 | 46 | template <> 47 | template <> 48 | inline void Writer::write(double Val) { 49 | write(DoubleToBits(Val)); 50 | } 51 | 52 | template <> 53 | template <> 54 | inline void Writer::write(float Val) { 55 | write(FloatToBits(Val)); 56 | } 57 | 58 | template <> 59 | template <> 60 | inline void Writer::write(double Val) { 61 | write(DoubleToBits(Val)); 62 | } 63 | 64 | } // end namespace endian 65 | 66 | } // end namespace support 67 | } // end namespace llvm 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Errno.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Errno.h - Portable+convenient errno handling -*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares some portable and convenient functions to deal with errno. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_ERRNO_H 15 | #define LLVM_SUPPORT_ERRNO_H 16 | 17 | #include 18 | #include 19 | #include 20 | 21 | namespace llvm { 22 | namespace sys { 23 | 24 | /// Returns a string representation of the errno value, using whatever 25 | /// thread-safe variant of strerror() is available. Be sure to call this 26 | /// immediately after the function that set errno, or errno may have been 27 | /// overwritten by an intervening call. 28 | std::string StrError(); 29 | 30 | /// Like the no-argument version above, but uses \p errnum instead of errno. 31 | std::string StrError(int errnum); 32 | 33 | template 34 | inline auto RetryAfterSignal(const FailT &Fail, const Fun &F, 35 | const Args &... As) -> decltype(F(As...)) { 36 | decltype(F(As...)) Res; 37 | do 38 | Res = F(As...); 39 | while (Res == Fail && errno == EINTR); 40 | return Res; 41 | } 42 | 43 | } // namespace sys 44 | } // namespace llvm 45 | 46 | #endif // LLVM_SYSTEM_ERRNO_H 47 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/FileOutputBuffer.h: -------------------------------------------------------------------------------- 1 | //=== FileOutputBuffer.h - File Output Buffer -------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Utility for creating a in-memory buffer that will be written to a file. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_FILEOUTPUTBUFFER_H 15 | #define LLVM_SUPPORT_FILEOUTPUTBUFFER_H 16 | 17 | #include "llvm/ADT/SmallString.h" 18 | #include "llvm/ADT/StringRef.h" 19 | #include "llvm/Support/DataTypes.h" 20 | #include "llvm/Support/Error.h" 21 | #include "llvm/Support/FileSystem.h" 22 | 23 | namespace llvm { 24 | /// FileOutputBuffer - This interface provides simple way to create an in-memory 25 | /// buffer which will be written to a file. During the lifetime of these 26 | /// objects, the content or existence of the specified file is undefined. That 27 | /// is, creating an OutputBuffer for a file may immediately remove the file. 28 | /// If the FileOutputBuffer is committed, the target file's content will become 29 | /// the buffer content at the time of the commit. If the FileOutputBuffer is 30 | /// not committed, the file will be deleted in the FileOutputBuffer destructor. 31 | class FileOutputBuffer { 32 | public: 33 | enum { 34 | F_executable = 1 /// set the 'x' bit on the resulting file 35 | }; 36 | 37 | /// Factory method to create an OutputBuffer object which manages a read/write 38 | /// buffer of the specified size. When committed, the buffer will be written 39 | /// to the file at the specified path. 40 | static Expected> 41 | create(StringRef FilePath, size_t Size, unsigned Flags = 0); 42 | 43 | /// Returns a pointer to the start of the buffer. 44 | virtual uint8_t *getBufferStart() const = 0; 45 | 46 | /// Returns a pointer to the end of the buffer. 47 | virtual uint8_t *getBufferEnd() const = 0; 48 | 49 | /// Returns size of the buffer. 50 | virtual size_t getBufferSize() const = 0; 51 | 52 | /// Returns path where file will show up if buffer is committed. 53 | StringRef getPath() const { return FinalPath; } 54 | 55 | /// Flushes the content of the buffer to its file and deallocates the 56 | /// buffer. If commit() is not called before this object's destructor 57 | /// is called, the file is deleted in the destructor. The optional parameter 58 | /// is used if it turns out you want the file size to be smaller than 59 | /// initially requested. 60 | virtual Error commit() = 0; 61 | 62 | /// If this object was previously committed, the destructor just deletes 63 | /// this object. If this object was not committed, the destructor 64 | /// deallocates the buffer and the target file is never written. 65 | virtual ~FileOutputBuffer() {} 66 | 67 | protected: 68 | FileOutputBuffer(StringRef Path) : FinalPath(Path) {} 69 | 70 | std::string FinalPath; 71 | }; 72 | } // end namespace llvm 73 | 74 | #endif 75 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/FileUtilities.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/FileUtilities.h - File System Utilities -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a family of utility functions which are useful for doing 11 | // various things with files. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_FILEUTILITIES_H 16 | #define LLVM_SUPPORT_FILEUTILITIES_H 17 | 18 | #include "llvm/Support/FileSystem.h" 19 | #include "llvm/Support/Path.h" 20 | 21 | namespace llvm { 22 | 23 | /// DiffFilesWithTolerance - Compare the two files specified, returning 0 if 24 | /// the files match, 1 if they are different, and 2 if there is a file error. 25 | /// This function allows you to specify an absolute and relative FP error that 26 | /// is allowed to exist. If you specify a string to fill in for the error 27 | /// option, it will set the string to an error message if an error occurs, or 28 | /// if the files are different. 29 | /// 30 | int DiffFilesWithTolerance(StringRef FileA, 31 | StringRef FileB, 32 | double AbsTol, double RelTol, 33 | std::string *Error = nullptr); 34 | 35 | 36 | /// FileRemover - This class is a simple object meant to be stack allocated. 37 | /// If an exception is thrown from a region, the object removes the filename 38 | /// specified (if deleteIt is true). 39 | /// 40 | class FileRemover { 41 | SmallString<128> Filename; 42 | bool DeleteIt; 43 | public: 44 | FileRemover() : DeleteIt(false) {} 45 | 46 | explicit FileRemover(const Twine& filename, bool deleteIt = true) 47 | : DeleteIt(deleteIt) { 48 | filename.toVector(Filename); 49 | } 50 | 51 | ~FileRemover() { 52 | if (DeleteIt) { 53 | // Ignore problems deleting the file. 54 | sys::fs::remove(Filename); 55 | } 56 | } 57 | 58 | /// setFile - Give ownership of the file to the FileRemover so it will 59 | /// be removed when the object is destroyed. If the FileRemover already 60 | /// had ownership of a file, remove it first. 61 | void setFile(const Twine& filename, bool deleteIt = true) { 62 | if (DeleteIt) { 63 | // Ignore problems deleting the file. 64 | sys::fs::remove(Filename); 65 | } 66 | 67 | Filename.clear(); 68 | filename.toVector(Filename); 69 | DeleteIt = deleteIt; 70 | } 71 | 72 | /// releaseFile - Take ownership of the file away from the FileRemover so it 73 | /// will not be removed when the object is destroyed. 74 | void releaseFile() { DeleteIt = false; } 75 | }; 76 | } // End llvm namespace 77 | 78 | #endif 79 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/FormatAdapters.h: -------------------------------------------------------------------------------- 1 | //===- FormatAdapters.h - Formatters for common LLVM types -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_FORMATADAPTERS_H 11 | #define LLVM_SUPPORT_FORMATADAPTERS_H 12 | 13 | #include "llvm/ADT/SmallString.h" 14 | #include "llvm/ADT/StringRef.h" 15 | #include "llvm/Support/FormatCommon.h" 16 | #include "llvm/Support/FormatVariadicDetails.h" 17 | #include "llvm/Support/raw_ostream.h" 18 | 19 | namespace llvm { 20 | template class FormatAdapter : public detail::format_adapter { 21 | protected: 22 | explicit FormatAdapter(T &&Item) : Item(Item) {} 23 | 24 | T Item; 25 | }; 26 | 27 | namespace detail { 28 | template class AlignAdapter final : public FormatAdapter { 29 | AlignStyle Where; 30 | size_t Amount; 31 | char Fill; 32 | 33 | public: 34 | AlignAdapter(T &&Item, AlignStyle Where, size_t Amount, char Fill) 35 | : FormatAdapter(std::forward(Item)), Where(Where), Amount(Amount), 36 | Fill(Fill) {} 37 | 38 | void format(llvm::raw_ostream &Stream, StringRef Style) { 39 | auto Adapter = detail::build_format_adapter(std::forward(this->Item)); 40 | FmtAlign(Adapter, Where, Amount, Fill).format(Stream, Style); 41 | } 42 | }; 43 | 44 | template class PadAdapter final : public FormatAdapter { 45 | size_t Left; 46 | size_t Right; 47 | 48 | public: 49 | PadAdapter(T &&Item, size_t Left, size_t Right) 50 | : FormatAdapter(std::forward(Item)), Left(Left), Right(Right) {} 51 | 52 | void format(llvm::raw_ostream &Stream, StringRef Style) { 53 | auto Adapter = detail::build_format_adapter(std::forward(this->Item)); 54 | Stream.indent(Left); 55 | Adapter.format(Stream, Style); 56 | Stream.indent(Right); 57 | } 58 | }; 59 | 60 | template class RepeatAdapter final : public FormatAdapter { 61 | size_t Count; 62 | 63 | public: 64 | RepeatAdapter(T &&Item, size_t Count) 65 | : FormatAdapter(std::forward(Item)), Count(Count) {} 66 | 67 | void format(llvm::raw_ostream &Stream, StringRef Style) { 68 | auto Adapter = detail::build_format_adapter(std::forward(this->Item)); 69 | for (size_t I = 0; I < Count; ++I) { 70 | Adapter.format(Stream, Style); 71 | } 72 | } 73 | }; 74 | } 75 | 76 | template 77 | detail::AlignAdapter fmt_align(T &&Item, AlignStyle Where, size_t Amount, 78 | char Fill = ' ') { 79 | return detail::AlignAdapter(std::forward(Item), Where, Amount, Fill); 80 | } 81 | 82 | template 83 | detail::PadAdapter fmt_pad(T &&Item, size_t Left, size_t Right) { 84 | return detail::PadAdapter(std::forward(Item), Left, Right); 85 | } 86 | 87 | template 88 | detail::RepeatAdapter fmt_repeat(T &&Item, size_t Count) { 89 | return detail::RepeatAdapter(std::forward(Item), Count); 90 | } 91 | } 92 | 93 | #endif 94 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/FormatCommon.h: -------------------------------------------------------------------------------- 1 | //===- FormatAdapters.h - Formatters for common LLVM types -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_FORMATCOMMON_H 11 | #define LLVM_SUPPORT_FORMATCOMMON_H 12 | 13 | #include "llvm/ADT/SmallString.h" 14 | #include "llvm/Support/FormatVariadicDetails.h" 15 | #include "llvm/Support/raw_ostream.h" 16 | 17 | namespace llvm { 18 | enum class AlignStyle { Left, Center, Right }; 19 | 20 | struct FmtAlign { 21 | detail::format_adapter &Adapter; 22 | AlignStyle Where; 23 | size_t Amount; 24 | char Fill; 25 | 26 | FmtAlign(detail::format_adapter &Adapter, AlignStyle Where, size_t Amount, 27 | char Fill = ' ') 28 | : Adapter(Adapter), Where(Where), Amount(Amount), Fill(Fill) {} 29 | 30 | void format(raw_ostream &S, StringRef Options) { 31 | // If we don't need to align, we can format straight into the underlying 32 | // stream. Otherwise we have to go through an intermediate stream first 33 | // in order to calculate how long the output is so we can align it. 34 | // TODO: Make the format method return the number of bytes written, that 35 | // way we can also skip the intermediate stream for left-aligned output. 36 | if (Amount == 0) { 37 | Adapter.format(S, Options); 38 | return; 39 | } 40 | SmallString<64> Item; 41 | raw_svector_ostream Stream(Item); 42 | 43 | Adapter.format(Stream, Options); 44 | if (Amount <= Item.size()) { 45 | S << Item; 46 | return; 47 | } 48 | 49 | size_t PadAmount = Amount - Item.size(); 50 | switch (Where) { 51 | case AlignStyle::Left: 52 | S << Item; 53 | fill(S, PadAmount); 54 | break; 55 | case AlignStyle::Center: { 56 | size_t X = PadAmount / 2; 57 | fill(S, X); 58 | S << Item; 59 | fill(S, PadAmount - X); 60 | break; 61 | } 62 | default: 63 | fill(S, PadAmount); 64 | S << Item; 65 | break; 66 | } 67 | } 68 | 69 | private: 70 | void fill(llvm::raw_ostream &S, uint32_t Count) { 71 | for (uint32_t I = 0; I < Count; ++I) 72 | S << Fill; 73 | } 74 | }; 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/GlobPattern.h: -------------------------------------------------------------------------------- 1 | //===-- GlobPattern.h - glob pattern matcher implementation -*- C++ -*-----===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file implements a glob pattern matcher. The glob pattern is the 11 | // rule used by the shell. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_GLOB_PATTERN_H 16 | #define LLVM_SUPPORT_GLOB_PATTERN_H 17 | 18 | #include "llvm/ADT/BitVector.h" 19 | #include "llvm/ADT/Optional.h" 20 | #include "llvm/ADT/StringRef.h" 21 | #include "llvm/Support/Error.h" 22 | #include 23 | 24 | // This class represents a glob pattern. Supported metacharacters 25 | // are "*", "?", "[]" and "[^]". 26 | namespace llvm { 27 | class BitVector; 28 | template class ArrayRef; 29 | 30 | class GlobPattern { 31 | public: 32 | static Expected create(StringRef Pat); 33 | bool match(StringRef S) const; 34 | 35 | private: 36 | bool matchOne(ArrayRef Pat, StringRef S) const; 37 | 38 | // Parsed glob pattern. 39 | std::vector Tokens; 40 | 41 | // The following members are for optimization. 42 | Optional Exact; 43 | Optional Prefix; 44 | Optional Suffix; 45 | }; 46 | } 47 | 48 | #endif // LLVM_SUPPORT_GLOB_PATTERN_H 49 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Host.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Host.h - Host machine characteristics --------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Methods for querying the nature of the host machine. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_HOST_H 15 | #define LLVM_SUPPORT_HOST_H 16 | 17 | #include "llvm/ADT/StringMap.h" 18 | 19 | #if defined(__linux__) || defined(__GNU__) || defined(__HAIKU__) 20 | #include 21 | #elif defined(_AIX) 22 | #include 23 | #elif defined(__sun) 24 | /* Solaris provides _BIG_ENDIAN/_LITTLE_ENDIAN selector in sys/types.h */ 25 | #include 26 | #define BIG_ENDIAN 4321 27 | #define LITTLE_ENDIAN 1234 28 | #if defined(_BIG_ENDIAN) 29 | #define BYTE_ORDER BIG_ENDIAN 30 | #else 31 | #define BYTE_ORDER LITTLE_ENDIAN 32 | #endif 33 | #else 34 | #if !defined(BYTE_ORDER) && !defined(LLVM_ON_WIN32) 35 | #include 36 | #endif 37 | #endif 38 | 39 | #include 40 | 41 | namespace llvm { 42 | namespace sys { 43 | 44 | #if defined(BYTE_ORDER) && defined(BIG_ENDIAN) && BYTE_ORDER == BIG_ENDIAN 45 | constexpr bool IsBigEndianHost = true; 46 | #else 47 | constexpr bool IsBigEndianHost = false; 48 | #endif 49 | 50 | static const bool IsLittleEndianHost = !IsBigEndianHost; 51 | 52 | /// getDefaultTargetTriple() - Return the default target triple the compiler 53 | /// has been configured to produce code for. 54 | /// 55 | /// The target triple is a string in the format of: 56 | /// CPU_TYPE-VENDOR-OPERATING_SYSTEM 57 | /// or 58 | /// CPU_TYPE-VENDOR-KERNEL-OPERATING_SYSTEM 59 | std::string getDefaultTargetTriple(); 60 | 61 | /// getProcessTriple() - Return an appropriate target triple for generating 62 | /// code to be loaded into the current process, e.g. when using the JIT. 63 | std::string getProcessTriple(); 64 | 65 | /// getHostCPUName - Get the LLVM name for the host CPU. The particular format 66 | /// of the name is target dependent, and suitable for passing as -mcpu to the 67 | /// target which matches the host. 68 | /// 69 | /// \return - The host CPU name, or empty if the CPU could not be determined. 70 | StringRef getHostCPUName(); 71 | 72 | /// getHostCPUFeatures - Get the LLVM names for the host CPU features. 73 | /// The particular format of the names are target dependent, and suitable for 74 | /// passing as -mattr to the target which matches the host. 75 | /// 76 | /// \param Features - A string mapping feature names to either 77 | /// true (if enabled) or false (if disabled). This routine makes no guarantees 78 | /// about exactly which features may appear in this map, except that they are 79 | /// all valid LLVM feature names. 80 | /// 81 | /// \return - True on success. 82 | bool getHostCPUFeatures(StringMap &Features); 83 | 84 | /// Get the number of physical cores (as opposed to logical cores returned 85 | /// from thread::hardware_concurrency(), which includes hyperthreads). 86 | /// Returns -1 if unknown for the current host system. 87 | int getHostNumPhysicalCores(); 88 | 89 | namespace detail { 90 | /// Helper functions to extract HostCPUName from /proc/cpuinfo on linux. 91 | StringRef getHostCPUNameForPowerPC(const StringRef &ProcCpuinfoContent); 92 | StringRef getHostCPUNameForARM(const StringRef &ProcCpuinfoContent); 93 | StringRef getHostCPUNameForS390x(const StringRef &ProcCpuinfoContent); 94 | StringRef getHostCPUNameForBPF(); 95 | } 96 | } 97 | } 98 | 99 | #endif 100 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/JamCRC.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/JamCRC.h - Cyclic Redundancy Check ---------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains an implementation of JamCRC. 11 | // 12 | // We will use the "Rocksoft^tm Model CRC Algorithm" to describe the properties 13 | // of this CRC: 14 | // Width : 32 15 | // Poly : 04C11DB7 16 | // Init : FFFFFFFF 17 | // RefIn : True 18 | // RefOut : True 19 | // XorOut : 00000000 20 | // Check : 340BC6D9 (result of CRC for "123456789") 21 | // 22 | // N.B. We permit flexibility of the "Init" value. Some consumers of this need 23 | // it to be zero. 24 | // 25 | //===----------------------------------------------------------------------===// 26 | 27 | #ifndef LLVM_SUPPORT_JAMCRC_H 28 | #define LLVM_SUPPORT_JAMCRC_H 29 | 30 | #include "llvm/Support/DataTypes.h" 31 | 32 | namespace llvm { 33 | template class ArrayRef; 34 | 35 | class JamCRC { 36 | public: 37 | JamCRC(uint32_t Init = 0xFFFFFFFFU) : CRC(Init) {} 38 | 39 | // \brief Update the CRC calculation with Data. 40 | void update(ArrayRef Data); 41 | 42 | uint32_t getCRC() const { return CRC; } 43 | 44 | private: 45 | uint32_t CRC; 46 | }; 47 | } // End of namespace llvm 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/LICENSE.TXT: -------------------------------------------------------------------------------- 1 | LLVM System Interface Library 2 | ------------------------------------------------------------------------------- 3 | The LLVM System Interface Library is licensed under the Illinois Open Source 4 | License and has the following additional copyright: 5 | 6 | Copyright (C) 2004 eXtensible Systems, Inc. 7 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/LineIterator.h: -------------------------------------------------------------------------------- 1 | //===- LineIterator.h - Iterator to read a text buffer's lines --*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_LINEITERATOR_H 11 | #define LLVM_SUPPORT_LINEITERATOR_H 12 | 13 | #include "llvm/ADT/StringRef.h" 14 | #include "llvm/Support/DataTypes.h" 15 | #include 16 | 17 | namespace llvm { 18 | 19 | class MemoryBuffer; 20 | 21 | /// \brief A forward iterator which reads text lines from a buffer. 22 | /// 23 | /// This class provides a forward iterator interface for reading one line at 24 | /// a time from a buffer. When default constructed the iterator will be the 25 | /// "end" iterator. 26 | /// 27 | /// The iterator is aware of what line number it is currently processing. It 28 | /// strips blank lines by default, and comment lines given a comment-starting 29 | /// character. 30 | /// 31 | /// Note that this iterator requires the buffer to be nul terminated. 32 | class line_iterator 33 | : public std::iterator { 34 | const MemoryBuffer *Buffer; 35 | char CommentMarker; 36 | bool SkipBlanks; 37 | 38 | unsigned LineNumber; 39 | StringRef CurrentLine; 40 | 41 | public: 42 | /// \brief Default construct an "end" iterator. 43 | line_iterator() : Buffer(nullptr) {} 44 | 45 | /// \brief Construct a new iterator around some memory buffer. 46 | explicit line_iterator(const MemoryBuffer &Buffer, bool SkipBlanks = true, 47 | char CommentMarker = '\0'); 48 | 49 | /// \brief Return true if we've reached EOF or are an "end" iterator. 50 | bool is_at_eof() const { return !Buffer; } 51 | 52 | /// \brief Return true if we're an "end" iterator or have reached EOF. 53 | bool is_at_end() const { return is_at_eof(); } 54 | 55 | /// \brief Return the current line number. May return any number at EOF. 56 | int64_t line_number() const { return LineNumber; } 57 | 58 | /// \brief Advance to the next (non-empty, non-comment) line. 59 | line_iterator &operator++() { 60 | advance(); 61 | return *this; 62 | } 63 | line_iterator operator++(int) { 64 | line_iterator tmp(*this); 65 | advance(); 66 | return tmp; 67 | } 68 | 69 | /// \brief Get the current line as a \c StringRef. 70 | StringRef operator*() const { return CurrentLine; } 71 | const StringRef *operator->() const { return &CurrentLine; } 72 | 73 | friend bool operator==(const line_iterator &LHS, const line_iterator &RHS) { 74 | return LHS.Buffer == RHS.Buffer && 75 | LHS.CurrentLine.begin() == RHS.CurrentLine.begin(); 76 | } 77 | 78 | friend bool operator!=(const line_iterator &LHS, const line_iterator &RHS) { 79 | return !(LHS == RHS); 80 | } 81 | 82 | private: 83 | /// \brief Advance the iterator to the next line. 84 | void advance(); 85 | }; 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Locale.h: -------------------------------------------------------------------------------- 1 | #ifndef LLVM_SUPPORT_LOCALE_H 2 | #define LLVM_SUPPORT_LOCALE_H 3 | 4 | namespace llvm { 5 | class StringRef; 6 | 7 | namespace sys { 8 | namespace locale { 9 | 10 | int columnWidth(StringRef s); 11 | bool isPrint(int c); 12 | 13 | } 14 | } 15 | } 16 | 17 | #endif // LLVM_SUPPORT_LOCALE_H 18 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/LockFileManager.h: -------------------------------------------------------------------------------- 1 | //===--- LockFileManager.h - File-level locking utility ---------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | #ifndef LLVM_SUPPORT_LOCKFILEMANAGER_H 10 | #define LLVM_SUPPORT_LOCKFILEMANAGER_H 11 | 12 | #include "llvm/ADT/Optional.h" 13 | #include "llvm/ADT/SmallString.h" 14 | #include "llvm/Support/FileSystem.h" 15 | #include 16 | #include // for std::pair 17 | 18 | namespace llvm { 19 | class StringRef; 20 | 21 | /// \brief Class that manages the creation of a lock file to aid 22 | /// implicit coordination between different processes. 23 | /// 24 | /// The implicit coordination works by creating a ".lock" file alongside 25 | /// the file that we're coordinating for, using the atomicity of the file 26 | /// system to ensure that only a single process can create that ".lock" file. 27 | /// When the lock file is removed, the owning process has finished the 28 | /// operation. 29 | class LockFileManager { 30 | public: 31 | /// \brief Describes the state of a lock file. 32 | enum LockFileState { 33 | /// \brief The lock file has been created and is owned by this instance 34 | /// of the object. 35 | LFS_Owned, 36 | /// \brief The lock file already exists and is owned by some other 37 | /// instance. 38 | LFS_Shared, 39 | /// \brief An error occurred while trying to create or find the lock 40 | /// file. 41 | LFS_Error 42 | }; 43 | 44 | /// \brief Describes the result of waiting for the owner to release the lock. 45 | enum WaitForUnlockResult { 46 | /// \brief The lock was released successfully. 47 | Res_Success, 48 | /// \brief Owner died while holding the lock. 49 | Res_OwnerDied, 50 | /// \brief Reached timeout while waiting for the owner to release the lock. 51 | Res_Timeout 52 | }; 53 | 54 | private: 55 | SmallString<128> FileName; 56 | SmallString<128> LockFileName; 57 | Optional UniqueLockFile; 58 | 59 | Optional > Owner; 60 | std::error_code ErrorCode; 61 | std::string ErrorDiagMsg; 62 | 63 | LockFileManager(const LockFileManager &) = delete; 64 | LockFileManager &operator=(const LockFileManager &) = delete; 65 | 66 | static Optional > 67 | readLockFile(StringRef LockFileName); 68 | 69 | static bool processStillExecuting(StringRef Hostname, int PID); 70 | 71 | public: 72 | 73 | LockFileManager(StringRef FileName); 74 | ~LockFileManager(); 75 | 76 | /// \brief Determine the state of the lock file. 77 | LockFileState getState() const; 78 | 79 | operator LockFileState() const { return getState(); } 80 | 81 | /// \brief For a shared lock, wait until the owner releases the lock. 82 | WaitForUnlockResult waitForUnlock(); 83 | 84 | /// \brief Remove the lock file. This may delete a different lock file than 85 | /// the one previously read if there is a race. 86 | std::error_code unsafeRemoveLockFile(); 87 | 88 | /// \brief Get error message, or "" if there is no error. 89 | std::string getErrorMessage() const; 90 | 91 | /// \brief Set error and error message 92 | void setError(const std::error_code &EC, StringRef ErrorMsg = "") { 93 | ErrorCode = EC; 94 | ErrorDiagMsg = ErrorMsg.str(); 95 | } 96 | }; 97 | 98 | } // end namespace llvm 99 | 100 | #endif // LLVM_SUPPORT_LOCKFILEMANAGER_H 101 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/ManagedStatic.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/ManagedStatic.h - Static Global wrapper ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the ManagedStatic class and the llvm_shutdown() function. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_MANAGEDSTATIC_H 15 | #define LLVM_SUPPORT_MANAGEDSTATIC_H 16 | 17 | #include 18 | #include 19 | 20 | namespace llvm { 21 | 22 | /// object_creator - Helper method for ManagedStatic. 23 | template struct object_creator { 24 | static void *call() { return new C(); } 25 | }; 26 | 27 | /// object_deleter - Helper method for ManagedStatic. 28 | /// 29 | template struct object_deleter { 30 | static void call(void *Ptr) { delete (T *)Ptr; } 31 | }; 32 | template struct object_deleter { 33 | static void call(void *Ptr) { delete[](T *)Ptr; } 34 | }; 35 | 36 | /// ManagedStaticBase - Common base class for ManagedStatic instances. 37 | class ManagedStaticBase { 38 | protected: 39 | // This should only be used as a static variable, which guarantees that this 40 | // will be zero initialized. 41 | mutable std::atomic Ptr; 42 | mutable void (*DeleterFn)(void*); 43 | mutable const ManagedStaticBase *Next; 44 | 45 | void RegisterManagedStatic(void *(*creator)(), void (*deleter)(void*)) const; 46 | 47 | public: 48 | /// isConstructed - Return true if this object has not been created yet. 49 | bool isConstructed() const { return Ptr != nullptr; } 50 | 51 | void destroy() const; 52 | }; 53 | 54 | /// ManagedStatic - This transparently changes the behavior of global statics to 55 | /// be lazily constructed on demand (good for reducing startup times of dynamic 56 | /// libraries that link in LLVM components) and for making destruction be 57 | /// explicit through the llvm_shutdown() function call. 58 | /// 59 | template , 60 | class Deleter = object_deleter> 61 | class ManagedStatic : public ManagedStaticBase { 62 | public: 63 | // Accessors. 64 | C &operator*() { 65 | void *Tmp = Ptr.load(std::memory_order_acquire); 66 | if (!Tmp) 67 | RegisterManagedStatic(Creator::call, Deleter::call); 68 | 69 | return *static_cast(Ptr.load(std::memory_order_relaxed)); 70 | } 71 | 72 | C *operator->() { return &**this; } 73 | 74 | const C &operator*() const { 75 | void *Tmp = Ptr.load(std::memory_order_acquire); 76 | if (!Tmp) 77 | RegisterManagedStatic(Creator::call, Deleter::call); 78 | 79 | return *static_cast(Ptr.load(std::memory_order_relaxed)); 80 | } 81 | 82 | const C *operator->() const { return &**this; } 83 | }; 84 | 85 | /// llvm_shutdown - Deallocate and destroy all ManagedStatic variables. 86 | void llvm_shutdown(); 87 | 88 | /// llvm_shutdown_obj - This is a simple helper class that calls 89 | /// llvm_shutdown() when it is destroyed. 90 | struct llvm_shutdown_obj { 91 | llvm_shutdown_obj() = default; 92 | ~llvm_shutdown_obj() { llvm_shutdown(); } 93 | }; 94 | 95 | } // end namespace llvm 96 | 97 | #endif // LLVM_SUPPORT_MANAGEDSTATIC_H 98 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/MutexGuard.h: -------------------------------------------------------------------------------- 1 | //===-- Support/MutexGuard.h - Acquire/Release Mutex In Scope ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a guard for a block of code that ensures a Mutex is locked 11 | // upon construction and released upon destruction. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_MUTEXGUARD_H 16 | #define LLVM_SUPPORT_MUTEXGUARD_H 17 | 18 | #include "llvm/Support/Mutex.h" 19 | 20 | namespace llvm { 21 | /// Instances of this class acquire a given Mutex Lock when constructed and 22 | /// hold that lock until destruction. The intention is to instantiate one of 23 | /// these on the stack at the top of some scope to be assured that C++ 24 | /// destruction of the object will always release the Mutex and thus avoid 25 | /// a host of nasty multi-threading problems in the face of exceptions, etc. 26 | /// @brief Guard a section of code with a Mutex. 27 | class MutexGuard { 28 | sys::Mutex &M; 29 | MutexGuard(const MutexGuard &) = delete; 30 | void operator=(const MutexGuard &) = delete; 31 | public: 32 | MutexGuard(sys::Mutex &m) : M(m) { M.lock(); } 33 | ~MutexGuard() { M.unlock(); } 34 | /// holds - Returns true if this locker instance holds the specified lock. 35 | /// This is mostly used in assertions to validate that the correct mutex 36 | /// is held. 37 | bool holds(const sys::Mutex& lock) const { return &M == &lock; } 38 | }; 39 | } 40 | 41 | #endif // LLVM_SUPPORT_MUTEXGUARD_H 42 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/NativeFormatting.h: -------------------------------------------------------------------------------- 1 | //===- NativeFormatting.h - Low level formatting helpers ---------*- C++-*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_NATIVE_FORMATTING_H 11 | #define LLVM_SUPPORT_NATIVE_FORMATTING_H 12 | 13 | #include "llvm/ADT/Optional.h" 14 | #include "llvm/Support/raw_ostream.h" 15 | 16 | #include 17 | 18 | namespace llvm { 19 | enum class FloatStyle { Exponent, ExponentUpper, Fixed, Percent }; 20 | enum class IntegerStyle { 21 | Integer, 22 | Number, 23 | }; 24 | enum class HexPrintStyle { Upper, Lower, PrefixUpper, PrefixLower }; 25 | 26 | size_t getDefaultPrecision(FloatStyle Style); 27 | 28 | bool isPrefixedHexStyle(HexPrintStyle S); 29 | 30 | void write_integer(raw_ostream &S, unsigned int N, size_t MinDigits, 31 | IntegerStyle Style); 32 | void write_integer(raw_ostream &S, int N, size_t MinDigits, IntegerStyle Style); 33 | void write_integer(raw_ostream &S, unsigned long N, size_t MinDigits, 34 | IntegerStyle Style); 35 | void write_integer(raw_ostream &S, long N, size_t MinDigits, 36 | IntegerStyle Style); 37 | void write_integer(raw_ostream &S, unsigned long long N, size_t MinDigits, 38 | IntegerStyle Style); 39 | void write_integer(raw_ostream &S, long long N, size_t MinDigits, 40 | IntegerStyle Style); 41 | 42 | void write_hex(raw_ostream &S, uint64_t N, HexPrintStyle Style, 43 | Optional Width = None); 44 | void write_double(raw_ostream &S, double D, FloatStyle Style, 45 | Optional Precision = None); 46 | } 47 | 48 | #endif 49 | 50 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/PluginLoader.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/PluginLoader.h - Plugin Loader for Tools ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // A tool can #include this file to get a -load option that allows the user to 11 | // load arbitrary shared objects into the tool's address space. Note that this 12 | // header can only be included by a program ONCE, so it should never to used by 13 | // library authors. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef LLVM_SUPPORT_PLUGINLOADER_H 18 | #define LLVM_SUPPORT_PLUGINLOADER_H 19 | 20 | #include "llvm/Support/CommandLine.h" 21 | 22 | namespace llvm { 23 | struct PluginLoader { 24 | void operator=(const std::string &Filename); 25 | static unsigned getNumPlugins(); 26 | static std::string& getPlugin(unsigned num); 27 | }; 28 | 29 | #ifndef DONT_GET_PLUGIN_LOADER_OPTION 30 | // This causes operator= above to be invoked for every -load option. 31 | static cl::opt > 32 | LoadOpt("load", cl::ZeroOrMore, cl::value_desc("pluginfilename"), 33 | cl::desc("Load the specified plugin")); 34 | #endif 35 | } 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/PrettyStackTrace.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/PrettyStackTrace.h - Pretty Crash Handling --*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the PrettyStackTraceEntry class, which is used to make 11 | // crashes give more contextual information about what the program was doing 12 | // when it crashed. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_PRETTYSTACKTRACE_H 17 | #define LLVM_SUPPORT_PRETTYSTACKTRACE_H 18 | 19 | #include "llvm/ADT/SmallVector.h" 20 | #include "llvm/Support/Compiler.h" 21 | 22 | namespace llvm { 23 | class raw_ostream; 24 | 25 | void EnablePrettyStackTrace(); 26 | 27 | /// PrettyStackTraceEntry - This class is used to represent a frame of the 28 | /// "pretty" stack trace that is dumped when a program crashes. You can define 29 | /// subclasses of this and declare them on the program stack: when they are 30 | /// constructed and destructed, they will add their symbolic frames to a 31 | /// virtual stack trace. This gets dumped out if the program crashes. 32 | class PrettyStackTraceEntry { 33 | friend PrettyStackTraceEntry *ReverseStackTrace(PrettyStackTraceEntry *); 34 | 35 | PrettyStackTraceEntry *NextEntry; 36 | PrettyStackTraceEntry(const PrettyStackTraceEntry &) = delete; 37 | void operator=(const PrettyStackTraceEntry &) = delete; 38 | public: 39 | PrettyStackTraceEntry(); 40 | virtual ~PrettyStackTraceEntry(); 41 | 42 | /// print - Emit information about this stack frame to OS. 43 | virtual void print(raw_ostream &OS) const = 0; 44 | 45 | /// getNextEntry - Return the next entry in the list of frames. 46 | const PrettyStackTraceEntry *getNextEntry() const { return NextEntry; } 47 | }; 48 | 49 | /// PrettyStackTraceString - This object prints a specified string (which 50 | /// should not contain newlines) to the stream as the stack trace when a crash 51 | /// occurs. 52 | class PrettyStackTraceString : public PrettyStackTraceEntry { 53 | const char *Str; 54 | public: 55 | PrettyStackTraceString(const char *str) : Str(str) {} 56 | void print(raw_ostream &OS) const override; 57 | }; 58 | 59 | /// PrettyStackTraceFormat - This object prints a string (which may use 60 | /// printf-style formatting but should not contain newlines) to the stream 61 | /// as the stack trace when a crash occurs. 62 | class PrettyStackTraceFormat : public PrettyStackTraceEntry { 63 | llvm::SmallVector Str; 64 | public: 65 | PrettyStackTraceFormat(const char *Format, ...); 66 | void print(raw_ostream &OS) const override; 67 | }; 68 | 69 | /// PrettyStackTraceProgram - This object prints a specified program arguments 70 | /// to the stream as the stack trace when a crash occurs. 71 | class PrettyStackTraceProgram : public PrettyStackTraceEntry { 72 | int ArgC; 73 | const char *const *ArgV; 74 | public: 75 | PrettyStackTraceProgram(int argc, const char * const*argv) 76 | : ArgC(argc), ArgV(argv) { 77 | EnablePrettyStackTrace(); 78 | } 79 | void print(raw_ostream &OS) const override; 80 | }; 81 | 82 | /// Returns the topmost element of the "pretty" stack state. 83 | const void *SavePrettyStackState(); 84 | 85 | /// Restores the topmost element of the "pretty" stack state to State, which 86 | /// should come from a previous call to SavePrettyStackState(). This is 87 | /// useful when using a CrashRecoveryContext in code that also uses 88 | /// PrettyStackTraceEntries, to make sure the stack that's printed if a crash 89 | /// happens after a crash that's been recovered by CrashRecoveryContext 90 | /// doesn't have frames on it that were added in code unwound by the 91 | /// CrashRecoveryContext. 92 | void RestorePrettyStackState(const void *State); 93 | 94 | } // end namespace llvm 95 | 96 | #endif 97 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Printable.h: -------------------------------------------------------------------------------- 1 | //===--- Printable.h - Print function helpers -------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the Printable struct. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_PRINTABLE_H 15 | #define LLVM_SUPPORT_PRINTABLE_H 16 | 17 | #include 18 | 19 | namespace llvm { 20 | 21 | class raw_ostream; 22 | 23 | /// Simple wrapper around std::function. 24 | /// This class is useful to construct print helpers for raw_ostream. 25 | /// 26 | /// Example: 27 | /// Printable PrintRegister(unsigned Register) { 28 | /// return Printable([Register](raw_ostream &OS) { 29 | /// OS << getRegisterName(Register); 30 | /// } 31 | /// } 32 | /// ... OS << PrintRegister(Register); ... 33 | /// 34 | /// Implementation note: Ideally this would just be a typedef, but doing so 35 | /// leads to operator << being ambiguous as function has matching constructors 36 | /// in some STL versions. I have seen the problem on gcc 4.6 libstdc++ and 37 | /// microsoft STL. 38 | class Printable { 39 | public: 40 | std::function Print; 41 | Printable(std::function Print) 42 | : Print(std::move(Print)) {} 43 | }; 44 | 45 | inline raw_ostream &operator<<(raw_ostream &OS, const Printable &P) { 46 | P.Print(OS); 47 | return OS; 48 | } 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/RandomNumberGenerator.h: -------------------------------------------------------------------------------- 1 | //==- llvm/Support/RandomNumberGenerator.h - RNG for diversity ---*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines an abstraction for deterministic random number 11 | // generation (RNG). Note that the current implementation is not 12 | // cryptographically secure as it uses the C++11 facilities. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_RANDOMNUMBERGENERATOR_H_ 17 | #define LLVM_SUPPORT_RANDOMNUMBERGENERATOR_H_ 18 | 19 | #include "llvm/Support/Compiler.h" 20 | #include "llvm/Support/DataTypes.h" // Needed for uint64_t on Windows. 21 | #include 22 | #include 23 | 24 | namespace llvm { 25 | class StringRef; 26 | 27 | /// A random number generator. 28 | /// 29 | /// Instances of this class should not be shared across threads. The 30 | /// seed should be set by passing the -rng-seed= option. Use 31 | /// Module::createRNG to create a new RNG instance for use with that 32 | /// module. 33 | class RandomNumberGenerator { 34 | 35 | // 64-bit Mersenne Twister by Matsumoto and Nishimura, 2000 36 | // http://en.cppreference.com/w/cpp/numeric/random/mersenne_twister_engine 37 | // This RNG is deterministically portable across C++11 38 | // implementations. 39 | using generator_type = std::mt19937_64; 40 | 41 | public: 42 | using result_type = generator_type::result_type; 43 | 44 | /// Returns a random number in the range [0, Max). 45 | result_type operator()(); 46 | 47 | static constexpr result_type min() { return generator_type::min(); } 48 | static constexpr result_type max() { return generator_type::max(); } 49 | 50 | private: 51 | /// Seeds and salts the underlying RNG engine. 52 | /// 53 | /// This constructor should not be used directly. Instead use 54 | /// Module::createRNG to create a new RNG salted with the Module ID. 55 | RandomNumberGenerator(StringRef Salt); 56 | 57 | generator_type Generator; 58 | 59 | // Noncopyable. 60 | RandomNumberGenerator(const RandomNumberGenerator &other) = delete; 61 | RandomNumberGenerator &operator=(const RandomNumberGenerator &other) = delete; 62 | 63 | friend class Module; 64 | }; 65 | 66 | // Get random vector of specified size 67 | std::error_code getRandomBytes(void *Buffer, size_t Size); 68 | } 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/RecyclingAllocator.h: -------------------------------------------------------------------------------- 1 | //==- llvm/Support/RecyclingAllocator.h - Recycling Allocator ----*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the RecyclingAllocator class. See the doxygen comment for 11 | // RecyclingAllocator for more details on the implementation. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_RECYCLINGALLOCATOR_H 16 | #define LLVM_SUPPORT_RECYCLINGALLOCATOR_H 17 | 18 | #include "llvm/Support/Recycler.h" 19 | 20 | namespace llvm { 21 | 22 | /// RecyclingAllocator - This class wraps an Allocator, adding the 23 | /// functionality of recycling deleted objects. 24 | /// 25 | template 27 | class RecyclingAllocator { 28 | private: 29 | /// Base - Implementation details. 30 | /// 31 | Recycler Base; 32 | 33 | /// Allocator - The wrapped allocator. 34 | /// 35 | AllocatorType Allocator; 36 | 37 | public: 38 | ~RecyclingAllocator() { Base.clear(Allocator); } 39 | 40 | /// Allocate - Return a pointer to storage for an object of type 41 | /// SubClass. The storage may be either newly allocated or recycled. 42 | /// 43 | template 44 | SubClass *Allocate() { return Base.template Allocate(Allocator); } 45 | 46 | T *Allocate() { return Base.Allocate(Allocator); } 47 | 48 | /// Deallocate - Release storage for the pointed-to object. The 49 | /// storage will be kept track of and may be recycled. 50 | /// 51 | template 52 | void Deallocate(SubClass* E) { return Base.Deallocate(Allocator, E); } 53 | 54 | void PrintStats() { 55 | Allocator.PrintStats(); 56 | Base.PrintStats(); 57 | } 58 | }; 59 | 60 | } 61 | 62 | template 63 | inline void *operator new(size_t size, 64 | llvm::RecyclingAllocator &Allocator) { 66 | assert(size <= Size && "allocation size exceeded"); 67 | return Allocator.Allocate(); 68 | } 69 | 70 | template 71 | inline void operator delete(void *E, 72 | llvm::RecyclingAllocator &A) { 74 | A.Deallocate(E); 75 | } 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/ReverseIteration.h: -------------------------------------------------------------------------------- 1 | #ifndef LLVM_SUPPORT_REVERSEITERATION_H 2 | #define LLVM_SUPPORT_REVERSEITERATION_H 3 | 4 | #include "llvm/Config/abi-breaking.h" 5 | #include "llvm/Support/PointerLikeTypeTraits.h" 6 | 7 | namespace llvm { 8 | 9 | template 10 | bool shouldReverseIterate() { 11 | #if LLVM_ENABLE_REVERSE_ITERATION 12 | return detail::IsPointerLike::value; 13 | #else 14 | return false; 15 | #endif 16 | } 17 | 18 | } 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/SHA1.h: -------------------------------------------------------------------------------- 1 | //==- SHA1.h - SHA1 implementation for LLVM --*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // This code is taken from public domain 10 | // (http://oauth.googlecode.com/svn/code/c/liboauth/src/sha1.c) 11 | // and modified by wrapping it in a C++ interface for LLVM, 12 | // and removing unnecessary code. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_SHA1_H 17 | #define LLVM_SUPPORT_SHA1_H 18 | 19 | #include "llvm/ADT/ArrayRef.h" 20 | 21 | #include 22 | #include 23 | 24 | namespace llvm { 25 | template class ArrayRef; 26 | class StringRef; 27 | 28 | /// A class that wrap the SHA1 algorithm. 29 | class SHA1 { 30 | public: 31 | SHA1() { init(); } 32 | 33 | /// Reinitialize the internal state 34 | void init(); 35 | 36 | /// Digest more data. 37 | void update(ArrayRef Data); 38 | 39 | /// Digest more data. 40 | void update(StringRef Str) { 41 | update(ArrayRef((uint8_t *)const_cast(Str.data()), 42 | Str.size())); 43 | } 44 | 45 | /// Return a reference to the current raw 160-bits SHA1 for the digested data 46 | /// since the last call to init(). This call will add data to the internal 47 | /// state and as such is not suited for getting an intermediate result 48 | /// (see result()). 49 | StringRef final(); 50 | 51 | /// Return a reference to the current raw 160-bits SHA1 for the digested data 52 | /// since the last call to init(). This is suitable for getting the SHA1 at 53 | /// any time without invalidating the internal state so that more calls can be 54 | /// made into update. 55 | StringRef result(); 56 | 57 | /// Returns a raw 160-bit SHA1 hash for the given data. 58 | static std::array hash(ArrayRef Data); 59 | 60 | private: 61 | /// Define some constants. 62 | /// "static constexpr" would be cleaner but MSVC does not support it yet. 63 | enum { BLOCK_LENGTH = 64 }; 64 | enum { HASH_LENGTH = 20 }; 65 | 66 | // Internal State 67 | struct { 68 | union { 69 | uint8_t C[BLOCK_LENGTH]; 70 | uint32_t L[BLOCK_LENGTH / 4]; 71 | } Buffer; 72 | uint32_t State[HASH_LENGTH / 4]; 73 | uint32_t ByteCount; 74 | uint8_t BufferOffset; 75 | } InternalState; 76 | 77 | // Internal copy of the hash, populated and accessed on calls to result() 78 | uint32_t HashResult[HASH_LENGTH / 4]; 79 | 80 | // Helper 81 | void writebyte(uint8_t data); 82 | void hashBlock(); 83 | void addUncounted(uint8_t data); 84 | void pad(); 85 | }; 86 | 87 | } // end llvm namespace 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/SMLoc.h: -------------------------------------------------------------------------------- 1 | //===- SMLoc.h - Source location for use with diagnostics -------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the SMLoc class. This class encapsulates a location in 11 | // source code for use in diagnostics. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_SMLOC_H 16 | #define LLVM_SUPPORT_SMLOC_H 17 | 18 | #include "llvm/ADT/None.h" 19 | #include 20 | 21 | namespace llvm { 22 | 23 | /// Represents a location in source code. 24 | class SMLoc { 25 | const char *Ptr = nullptr; 26 | 27 | public: 28 | SMLoc() = default; 29 | 30 | bool isValid() const { return Ptr != nullptr; } 31 | 32 | bool operator==(const SMLoc &RHS) const { return RHS.Ptr == Ptr; } 33 | bool operator!=(const SMLoc &RHS) const { return RHS.Ptr != Ptr; } 34 | 35 | const char *getPointer() const { return Ptr; } 36 | 37 | static SMLoc getFromPointer(const char *Ptr) { 38 | SMLoc L; 39 | L.Ptr = Ptr; 40 | return L; 41 | } 42 | }; 43 | 44 | /// Represents a range in source code. 45 | /// 46 | /// SMRange is implemented using a half-open range, as is the convention in C++. 47 | /// In the string "abc", the range (1,3] represents the substring "bc", and the 48 | /// range (2,2] represents an empty range between the characters "b" and "c". 49 | class SMRange { 50 | public: 51 | SMLoc Start, End; 52 | 53 | SMRange() = default; 54 | SMRange(NoneType) {} 55 | SMRange(SMLoc St, SMLoc En) : Start(St), End(En) { 56 | assert(Start.isValid() == End.isValid() && 57 | "Start and end should either both be valid or both be invalid!"); 58 | } 59 | 60 | bool isValid() const { return Start.isValid(); } 61 | }; 62 | 63 | } // end namespace llvm 64 | 65 | #endif // LLVM_SUPPORT_SMLOC_H 66 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/SaveAndRestore.h: -------------------------------------------------------------------------------- 1 | //===-- SaveAndRestore.h - Utility -------------------------------*- C++ -*-=// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | /// 10 | /// \file 11 | /// This file provides utility classes that use RAII to save and restore 12 | /// values. 13 | /// 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_SAVEANDRESTORE_H 17 | #define LLVM_SUPPORT_SAVEANDRESTORE_H 18 | 19 | namespace llvm { 20 | 21 | /// A utility class that uses RAII to save and restore the value of a variable. 22 | template struct SaveAndRestore { 23 | SaveAndRestore(T &X) : X(X), OldValue(X) {} 24 | SaveAndRestore(T &X, const T &NewValue) : X(X), OldValue(X) { 25 | X = NewValue; 26 | } 27 | ~SaveAndRestore() { X = OldValue; } 28 | T get() { return OldValue; } 29 | 30 | private: 31 | T &X; 32 | T OldValue; 33 | }; 34 | 35 | /// Similar to \c SaveAndRestore. Operates only on bools; the old value of a 36 | /// variable is saved, and during the dstor the old value is or'ed with the new 37 | /// value. 38 | struct SaveOr { 39 | SaveOr(bool &X) : X(X), OldValue(X) { X = false; } 40 | ~SaveOr() { X |= OldValue; } 41 | 42 | private: 43 | bool &X; 44 | const bool OldValue; 45 | }; 46 | 47 | } // namespace llvm 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Signals.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Signals.h - Signal Handling support ----------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines some helpful functions for dealing with the possibility of 11 | // unix signals occurring while your program is running. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_SIGNALS_H 16 | #define LLVM_SUPPORT_SIGNALS_H 17 | 18 | #include 19 | 20 | namespace llvm { 21 | class StringRef; 22 | class raw_ostream; 23 | 24 | namespace sys { 25 | 26 | /// This function runs all the registered interrupt handlers, including the 27 | /// removal of files registered by RemoveFileOnSignal. 28 | void RunInterruptHandlers(); 29 | 30 | /// This function registers signal handlers to ensure that if a signal gets 31 | /// delivered that the named file is removed. 32 | /// @brief Remove a file if a fatal signal occurs. 33 | bool RemoveFileOnSignal(StringRef Filename, std::string* ErrMsg = nullptr); 34 | 35 | /// This function removes a file from the list of files to be removed on 36 | /// signal delivery. 37 | void DontRemoveFileOnSignal(StringRef Filename); 38 | 39 | /// When an error signal (such as SIGABRT or SIGSEGV) is delivered to the 40 | /// process, print a stack trace and then exit. 41 | /// \brief Print a stack trace if a fatal signal occurs. 42 | /// \param Argv0 the current binary name, used to find the symbolizer 43 | /// relative to the current binary before searching $PATH; can be 44 | /// StringRef(), in which case we will only search $PATH. 45 | /// \param DisableCrashReporting if \c true, disable the normal crash 46 | /// reporting mechanisms on the underlying operating system. 47 | void PrintStackTraceOnErrorSignal(StringRef Argv0, 48 | bool DisableCrashReporting = false); 49 | 50 | /// Disable all system dialog boxes that appear when the process crashes. 51 | void DisableSystemDialogsOnCrash(); 52 | 53 | /// \brief Print the stack trace using the given \c raw_ostream object. 54 | void PrintStackTrace(raw_ostream &OS); 55 | 56 | // Run all registered signal handlers. 57 | void RunSignalHandlers(); 58 | 59 | /// AddSignalHandler - Add a function to be called when an abort/kill signal 60 | /// is delivered to the process. The handler can have a cookie passed to it 61 | /// to identify what instance of the handler it is. 62 | void AddSignalHandler(void (*FnPtr)(void *), void *Cookie); 63 | 64 | /// This function registers a function to be called when the user "interrupts" 65 | /// the program (typically by pressing ctrl-c). When the user interrupts the 66 | /// program, the specified interrupt function is called instead of the program 67 | /// being killed, and the interrupt function automatically disabled. Note 68 | /// that interrupt functions are not allowed to call any non-reentrant 69 | /// functions. An null interrupt function pointer disables the current 70 | /// installed function. Note also that the handler may be executed on a 71 | /// different thread on some platforms. 72 | /// @brief Register a function to be called when ctrl-c is pressed. 73 | void SetInterruptFunction(void (*IF)()); 74 | } // End sys namespace 75 | } // End llvm namespace 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Solaris/sys/regset.h: -------------------------------------------------------------------------------- 1 | /*===- llvm/Support/Solaris/sys/regset.h ------------------------*- C++ -*-===* 2 | * 3 | * The LLVM Compiler Infrastructure 4 | * 5 | * This file is distributed under the University of Illinois Open Source 6 | * License. See LICENSE.TXT for details. 7 | * 8 | *===----------------------------------------------------------------------===* 9 | * 10 | * This file works around excessive name space pollution from the system header 11 | * on Solaris hosts. 12 | * 13 | *===----------------------------------------------------------------------===*/ 14 | 15 | #ifndef LLVM_SUPPORT_SOLARIS_SYS_REGSET_H 16 | 17 | #include_next 18 | 19 | #undef CS 20 | #undef DS 21 | #undef ES 22 | #undef FS 23 | #undef GS 24 | #undef SS 25 | #undef EAX 26 | #undef ECX 27 | #undef EDX 28 | #undef EBX 29 | #undef ESP 30 | #undef EBP 31 | #undef ESI 32 | #undef EDI 33 | #undef EIP 34 | #undef UESP 35 | #undef EFL 36 | #undef ERR 37 | #undef TRAPNO 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/StringSaver.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/StringSaver.h -------------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_STRINGSAVER_H 11 | #define LLVM_SUPPORT_STRINGSAVER_H 12 | 13 | #include "llvm/ADT/StringRef.h" 14 | #include "llvm/ADT/Twine.h" 15 | #include "llvm/Support/Allocator.h" 16 | 17 | namespace llvm { 18 | 19 | /// \brief Saves strings in the inheritor's stable storage and returns a 20 | /// StringRef with a stable character pointer. 21 | class StringSaver final { 22 | BumpPtrAllocator &Alloc; 23 | 24 | public: 25 | StringSaver(BumpPtrAllocator &Alloc) : Alloc(Alloc) {} 26 | StringRef save(const char *S) { return save(StringRef(S)); } 27 | StringRef save(StringRef S); 28 | StringRef save(const Twine &S) { return save(StringRef(S.str())); } 29 | StringRef save(const std::string &S) { return save(StringRef(S)); } 30 | }; 31 | } 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/SystemUtils.h: -------------------------------------------------------------------------------- 1 | //===- SystemUtils.h - Utilities to do low-level system stuff ---*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file contains functions used to do a variety of low-level, often 11 | // system-specific, tasks. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_SYSTEMUTILS_H 16 | #define LLVM_SUPPORT_SYSTEMUTILS_H 17 | 18 | namespace llvm { 19 | class raw_ostream; 20 | 21 | /// Determine if the raw_ostream provided is connected to a terminal. If so, 22 | /// generate a warning message to errs() advising against display of bitcode 23 | /// and return true. Otherwise just return false. 24 | /// @brief Check for output written to a console 25 | bool CheckBitcodeOutputToConsole( 26 | raw_ostream &stream_to_check, ///< The stream to be checked 27 | bool print_warning = true ///< Control whether warnings are printed 28 | ); 29 | 30 | } // End llvm namespace 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/TarWriter.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/TarWriter.h - Tar archive file creator -----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_TAR_WRITER_H 11 | #define LLVM_SUPPORT_TAR_WRITER_H 12 | 13 | #include "llvm/ADT/StringRef.h" 14 | #include "llvm/ADT/StringSet.h" 15 | #include "llvm/Support/Error.h" 16 | #include "llvm/Support/raw_ostream.h" 17 | 18 | namespace llvm { 19 | class TarWriter { 20 | public: 21 | static Expected> create(StringRef OutputPath, 22 | StringRef BaseDir); 23 | 24 | void append(StringRef Path, StringRef Data); 25 | 26 | private: 27 | TarWriter(int FD, StringRef BaseDir); 28 | raw_fd_ostream OS; 29 | std::string BaseDir; 30 | StringSet<> Files; 31 | }; 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/ThreadLocal.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/ThreadLocal.h - Thread Local Data ------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the llvm::sys::ThreadLocal class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_THREADLOCAL_H 15 | #define LLVM_SUPPORT_THREADLOCAL_H 16 | 17 | #include "llvm/Support/DataTypes.h" 18 | #include "llvm/Support/Threading.h" 19 | #include 20 | 21 | namespace llvm { 22 | namespace sys { 23 | // ThreadLocalImpl - Common base class of all ThreadLocal instantiations. 24 | // YOU SHOULD NEVER USE THIS DIRECTLY. 25 | class ThreadLocalImpl { 26 | typedef uint64_t ThreadLocalDataTy; 27 | /// \brief Platform-specific thread local data. 28 | /// 29 | /// This is embedded in the class and we avoid malloc'ing/free'ing it, 30 | /// to make this class more safe for use along with CrashRecoveryContext. 31 | union { 32 | char data[sizeof(ThreadLocalDataTy)]; 33 | ThreadLocalDataTy align_data; 34 | }; 35 | public: 36 | ThreadLocalImpl(); 37 | virtual ~ThreadLocalImpl(); 38 | void setInstance(const void* d); 39 | void *getInstance(); 40 | void removeInstance(); 41 | }; 42 | 43 | /// ThreadLocal - A class used to abstract thread-local storage. It holds, 44 | /// for each thread, a pointer a single object of type T. 45 | template 46 | class ThreadLocal : public ThreadLocalImpl { 47 | public: 48 | ThreadLocal() : ThreadLocalImpl() { } 49 | 50 | /// get - Fetches a pointer to the object associated with the current 51 | /// thread. If no object has yet been associated, it returns NULL; 52 | T* get() { return static_cast(getInstance()); } 53 | 54 | // set - Associates a pointer to an object with the current thread. 55 | void set(T* d) { setInstance(d); } 56 | 57 | // erase - Removes the pointer associated with the current thread. 58 | void erase() { removeInstance(); } 59 | }; 60 | } 61 | } 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/ThreadPool.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/ThreadPool.h - A ThreadPool implementation -*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a crude C++11 based thread pool. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_THREAD_POOL_H 15 | #define LLVM_SUPPORT_THREAD_POOL_H 16 | 17 | #include "llvm/Support/thread.h" 18 | 19 | #include 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | namespace llvm { 30 | 31 | /// A ThreadPool for asynchronous parallel execution on a defined number of 32 | /// threads. 33 | /// 34 | /// The pool keeps a vector of threads alive, waiting on a condition variable 35 | /// for some work to become available. 36 | class ThreadPool { 37 | public: 38 | using TaskTy = std::function; 39 | using PackagedTaskTy = std::packaged_task; 40 | 41 | /// Construct a pool with the number of threads found by 42 | /// hardware_concurrency(). 43 | ThreadPool(); 44 | 45 | /// Construct a pool of \p ThreadCount threads 46 | ThreadPool(unsigned ThreadCount); 47 | 48 | /// Blocking destructor: the pool will wait for all the threads to complete. 49 | ~ThreadPool(); 50 | 51 | /// Asynchronous submission of a task to the pool. The returned future can be 52 | /// used to wait for the task to finish and is *non-blocking* on destruction. 53 | template 54 | inline std::shared_future async(Function &&F, Args &&... ArgList) { 55 | auto Task = 56 | std::bind(std::forward(F), std::forward(ArgList)...); 57 | return asyncImpl(std::move(Task)); 58 | } 59 | 60 | /// Asynchronous submission of a task to the pool. The returned future can be 61 | /// used to wait for the task to finish and is *non-blocking* on destruction. 62 | template 63 | inline std::shared_future async(Function &&F) { 64 | return asyncImpl(std::forward(F)); 65 | } 66 | 67 | /// Blocking wait for all the threads to complete and the queue to be empty. 68 | /// It is an error to try to add new tasks while blocking on this call. 69 | void wait(); 70 | 71 | private: 72 | /// Asynchronous submission of a task to the pool. The returned future can be 73 | /// used to wait for the task to finish and is *non-blocking* on destruction. 74 | std::shared_future asyncImpl(TaskTy F); 75 | 76 | /// Threads in flight 77 | std::vector Threads; 78 | 79 | /// Tasks waiting for execution in the pool. 80 | std::queue Tasks; 81 | 82 | /// Locking and signaling for accessing the Tasks queue. 83 | std::mutex QueueLock; 84 | std::condition_variable QueueCondition; 85 | 86 | /// Locking and signaling for job completion 87 | std::mutex CompletionLock; 88 | std::condition_variable CompletionCondition; 89 | 90 | /// Keep track of the number of thread actually busy 91 | std::atomic ActiveThreads; 92 | 93 | #if LLVM_ENABLE_THREADS // avoids warning for unused variable 94 | /// Signal for the destruction of the pool, asking thread to exit. 95 | bool EnableFlag; 96 | #endif 97 | }; 98 | } 99 | 100 | #endif // LLVM_SUPPORT_THREAD_POOL_H 101 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/ToolOutputFile.h: -------------------------------------------------------------------------------- 1 | //===- ToolOutputFile.h - Output files for compiler-like tools -----------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the ToolOutputFile class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_TOOLOUTPUTFILE_H 15 | #define LLVM_SUPPORT_TOOLOUTPUTFILE_H 16 | 17 | #include "llvm/Support/raw_ostream.h" 18 | 19 | namespace llvm { 20 | 21 | /// This class contains a raw_fd_ostream and adds a few extra features commonly 22 | /// needed for compiler-like tool output files: 23 | /// - The file is automatically deleted if the process is killed. 24 | /// - The file is automatically deleted when the ToolOutputFile 25 | /// object is destroyed unless the client calls keep(). 26 | class ToolOutputFile { 27 | /// This class is declared before the raw_fd_ostream so that it is constructed 28 | /// before the raw_fd_ostream is constructed and destructed after the 29 | /// raw_fd_ostream is destructed. It installs cleanups in its constructor and 30 | /// uninstalls them in its destructor. 31 | class CleanupInstaller { 32 | /// The name of the file. 33 | std::string Filename; 34 | public: 35 | /// The flag which indicates whether we should not delete the file. 36 | bool Keep; 37 | 38 | explicit CleanupInstaller(StringRef ilename); 39 | ~CleanupInstaller(); 40 | } Installer; 41 | 42 | /// The contained stream. This is intentionally declared after Installer. 43 | raw_fd_ostream OS; 44 | 45 | public: 46 | /// This constructor's arguments are passed to raw_fd_ostream's 47 | /// constructor. 48 | ToolOutputFile(StringRef Filename, std::error_code &EC, 49 | sys::fs::OpenFlags Flags); 50 | 51 | ToolOutputFile(StringRef Filename, int FD); 52 | 53 | /// Return the contained raw_fd_ostream. 54 | raw_fd_ostream &os() { return OS; } 55 | 56 | /// Indicate that the tool's job wrt this output file has been successful and 57 | /// the file should not be deleted. 58 | void keep() { Installer.Keep = true; } 59 | }; 60 | 61 | } // end llvm namespace 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/TrigramIndex.h: -------------------------------------------------------------------------------- 1 | //===-- TrigramIndex.h - a heuristic for SpecialCaseList --------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | //===----------------------------------------------------------------------===// 8 | // 9 | // TrigramIndex implements a heuristic for SpecialCaseList that allows to 10 | // filter out ~99% incoming queries when all regular expressions in the 11 | // SpecialCaseList are simple wildcards with '*' and '.'. If rules are more 12 | // complicated, the check is defeated and it will always pass the queries to a 13 | // full regex. 14 | // 15 | // The basic idea is that in order for a wildcard to match a query, the query 16 | // needs to have all trigrams which occur in the wildcard. We create a trigram 17 | // index (trigram -> list of rules with it) and then count trigrams in the query 18 | // for each rule. If the count for one of the rules reaches the expected value, 19 | // the check passes the query to a regex. If none of the rules got enough 20 | // trigrams, the check tells that the query is definitely not matched by any 21 | // of the rules, and no regex matching is needed. 22 | // A similar idea was used in Google Code Search as described in the blog post: 23 | // https://swtch.com/~rsc/regexp/regexp4.html 24 | // 25 | //===----------------------------------------------------------------------===// 26 | 27 | #ifndef LLVM_SUPPORT_TRIGRAMINDEX_H 28 | #define LLVM_SUPPORT_TRIGRAMINDEX_H 29 | 30 | #include "llvm/ADT/SmallVector.h" 31 | #include "llvm/ADT/StringMap.h" 32 | 33 | #include 34 | #include 35 | #include 36 | 37 | namespace llvm { 38 | class StringRef; 39 | 40 | class TrigramIndex { 41 | public: 42 | /// Inserts a new Regex into the index. 43 | void insert(std::string Regex); 44 | 45 | /// Returns true, if special case list definitely does not have a line 46 | /// that matches the query. Returns false, if it's not sure. 47 | bool isDefinitelyOut(StringRef Query) const; 48 | 49 | /// Returned true, iff the heuristic is defeated and not useful. 50 | /// In this case isDefinitelyOut always returns false. 51 | bool isDefeated() { return Defeated; } 52 | private: 53 | // If true, the rules are too complicated for the check to work, and full 54 | // regex matching is needed for every rule. 55 | bool Defeated = false; 56 | // The minimum number of trigrams which should match for a rule to have a 57 | // chance to match the query. The number of elements equals the number of 58 | // regex rules in the SpecialCaseList. 59 | std::vector Counts; 60 | // Index holds a list of rules indices for each trigram. The same indices 61 | // are used in Counts to store per-rule limits. 62 | // If a trigram is too common (>4 rules with it), we stop tracking it, 63 | // which increases the probability for a need to match using regex, but 64 | // decreases the costs in the regular case. 65 | std::unordered_map> Index{256}; 66 | }; 67 | 68 | } // namespace llvm 69 | 70 | #endif // LLVM_SUPPORT_TRIGRAMINDEX_H 71 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/TypeName.h: -------------------------------------------------------------------------------- 1 | //===- TypeName.h -----------------------------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_TYPENAME_H 11 | #define LLVM_SUPPORT_TYPENAME_H 12 | 13 | #include "llvm/ADT/StringRef.h" 14 | 15 | namespace llvm { 16 | 17 | /// We provide a function which tries to compute the (demangled) name of a type 18 | /// statically. 19 | /// 20 | /// This routine may fail on some platforms or for particularly unusual types. 21 | /// Do not use it for anything other than logging and debugging aids. It isn't 22 | /// portable or dependendable in any real sense. 23 | /// 24 | /// The returned StringRef will point into a static storage duration string. 25 | /// However, it may not be null terminated and may be some strangely aligned 26 | /// inner substring of a larger string. 27 | template 28 | inline StringRef getTypeName() { 29 | #if defined(__clang__) || defined(__GNUC__) 30 | StringRef Name = __PRETTY_FUNCTION__; 31 | 32 | StringRef Key = "DesiredTypeName = "; 33 | Name = Name.substr(Name.find(Key)); 34 | assert(!Name.empty() && "Unable to find the template parameter!"); 35 | Name = Name.drop_front(Key.size()); 36 | 37 | assert(Name.endswith("]") && "Name doesn't end in the substitution key!"); 38 | return Name.drop_back(1); 39 | #elif defined(_MSC_VER) 40 | StringRef Name = __FUNCSIG__; 41 | 42 | StringRef Key = "getTypeName<"; 43 | Name = Name.substr(Name.find(Key)); 44 | assert(!Name.empty() && "Unable to find the function name!"); 45 | Name = Name.drop_front(Key.size()); 46 | 47 | for (StringRef Prefix : {"class ", "struct ", "union ", "enum "}) 48 | if (Name.startswith(Prefix)) { 49 | Name = Name.drop_front(Prefix.size()); 50 | break; 51 | } 52 | 53 | auto AnglePos = Name.rfind('>'); 54 | assert(AnglePos != StringRef::npos && "Unable to find the closing '>'!"); 55 | return Name.substr(0, AnglePos); 56 | #else 57 | // No known technique for statically extracting a type name on this compiler. 58 | // We return a string that is unlikely to look like any type in LLVM. 59 | return "UNKNOWN_TYPE"; 60 | #endif 61 | } 62 | 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Unicode.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Unicode.h - Unicode character properties -*- C++ -*-=====// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines functions that allow querying certain properties of Unicode 11 | // characters. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_UNICODE_H 16 | #define LLVM_SUPPORT_UNICODE_H 17 | 18 | namespace llvm { 19 | class StringRef; 20 | 21 | namespace sys { 22 | namespace unicode { 23 | 24 | enum ColumnWidthErrors { 25 | ErrorInvalidUTF8 = -2, 26 | ErrorNonPrintableCharacter = -1 27 | }; 28 | 29 | /// Determines if a character is likely to be displayed correctly on the 30 | /// terminal. Exact implementation would have to depend on the specific 31 | /// terminal, so we define the semantic that should be suitable for generic case 32 | /// of a terminal capable to output Unicode characters. 33 | /// 34 | /// All characters from the Unicode code point range are considered printable 35 | /// except for: 36 | /// * C0 and C1 control character ranges; 37 | /// * default ignorable code points as per 5.21 of 38 | /// http://www.unicode.org/versions/Unicode6.2.0/UnicodeStandard-6.2.pdf 39 | /// except for U+00AD SOFT HYPHEN, as it's actually displayed on most 40 | /// terminals; 41 | /// * format characters (category = Cf); 42 | /// * surrogates (category = Cs); 43 | /// * unassigned characters (category = Cn). 44 | /// \return true if the character is considered printable. 45 | bool isPrintable(int UCS); 46 | 47 | /// Gets the number of positions the UTF8-encoded \p Text is likely to occupy 48 | /// when output on a terminal ("character width"). This depends on the 49 | /// implementation of the terminal, and there's no standard definition of 50 | /// character width. 51 | /// 52 | /// The implementation defines it in a way that is expected to be compatible 53 | /// with a generic Unicode-capable terminal. 54 | /// 55 | /// \return Character width: 56 | /// * ErrorNonPrintableCharacter (-1) if \p Text contains non-printable 57 | /// characters (as identified by isPrintable); 58 | /// * 0 for each non-spacing and enclosing combining mark; 59 | /// * 2 for each CJK character excluding halfwidth forms; 60 | /// * 1 for each of the remaining characters. 61 | int columnWidthUTF8(StringRef Text); 62 | 63 | } // namespace unicode 64 | } // namespace sys 65 | } // namespace llvm 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/UnicodeCharRanges.h: -------------------------------------------------------------------------------- 1 | //===--- UnicodeCharRanges.h - Types and functions for character ranges ---===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | #ifndef LLVM_SUPPORT_UNICODECHARRANGES_H 10 | #define LLVM_SUPPORT_UNICODECHARRANGES_H 11 | 12 | #include "llvm/ADT/ArrayRef.h" 13 | #include "llvm/ADT/SmallPtrSet.h" 14 | #include "llvm/Support/Compiler.h" 15 | #include "llvm/Support/Debug.h" 16 | #include "llvm/Support/Mutex.h" 17 | #include "llvm/Support/MutexGuard.h" 18 | #include "llvm/Support/raw_ostream.h" 19 | #include 20 | 21 | #define DEBUG_TYPE "unicode" 22 | 23 | namespace llvm { 24 | namespace sys { 25 | 26 | /// \brief Represents a closed range of Unicode code points [Lower, Upper]. 27 | struct UnicodeCharRange { 28 | uint32_t Lower; 29 | uint32_t Upper; 30 | }; 31 | 32 | inline bool operator<(uint32_t Value, UnicodeCharRange Range) { 33 | return Value < Range.Lower; 34 | } 35 | inline bool operator<(UnicodeCharRange Range, uint32_t Value) { 36 | return Range.Upper < Value; 37 | } 38 | 39 | /// \brief Holds a reference to an ordered array of UnicodeCharRange and allows 40 | /// to quickly check if a code point is contained in the set represented by this 41 | /// array. 42 | class UnicodeCharSet { 43 | public: 44 | typedef ArrayRef CharRanges; 45 | 46 | /// \brief Constructs a UnicodeCharSet instance from an array of 47 | /// UnicodeCharRanges. 48 | /// 49 | /// Array pointed by \p Ranges should have the lifetime at least as long as 50 | /// the UnicodeCharSet instance, and should not change. Array is validated by 51 | /// the constructor, so it makes sense to create as few UnicodeCharSet 52 | /// instances per each array of ranges, as possible. 53 | #ifdef NDEBUG 54 | 55 | // FIXME: This could use constexpr + static_assert. This way we 56 | // may get rid of NDEBUG in this header. Unfortunately there are some 57 | // problems to get this working with MSVC 2013. Change this when 58 | // the support for MSVC 2013 is dropped. 59 | constexpr UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) {} 60 | #else 61 | UnicodeCharSet(CharRanges Ranges) : Ranges(Ranges) { 62 | assert(rangesAreValid()); 63 | } 64 | #endif 65 | 66 | /// \brief Returns true if the character set contains the Unicode code point 67 | /// \p C. 68 | bool contains(uint32_t C) const { 69 | return std::binary_search(Ranges.begin(), Ranges.end(), C); 70 | } 71 | 72 | private: 73 | /// \brief Returns true if each of the ranges is a proper closed range 74 | /// [min, max], and if the ranges themselves are ordered and non-overlapping. 75 | bool rangesAreValid() const { 76 | uint32_t Prev = 0; 77 | for (CharRanges::const_iterator I = Ranges.begin(), E = Ranges.end(); 78 | I != E; ++I) { 79 | if (I != Ranges.begin() && Prev >= I->Lower) { 80 | DEBUG(dbgs() << "Upper bound 0x"); 81 | DEBUG(dbgs().write_hex(Prev)); 82 | DEBUG(dbgs() << " should be less than succeeding lower bound 0x"); 83 | DEBUG(dbgs().write_hex(I->Lower) << "\n"); 84 | return false; 85 | } 86 | if (I->Upper < I->Lower) { 87 | DEBUG(dbgs() << "Upper bound 0x"); 88 | DEBUG(dbgs().write_hex(I->Lower)); 89 | DEBUG(dbgs() << " should not be less than lower bound 0x"); 90 | DEBUG(dbgs().write_hex(I->Upper) << "\n"); 91 | return false; 92 | } 93 | Prev = I->Upper; 94 | } 95 | 96 | return true; 97 | } 98 | 99 | const CharRanges Ranges; 100 | }; 101 | 102 | } // namespace sys 103 | } // namespace llvm 104 | 105 | #undef DEBUG_TYPE // "unicode" 106 | 107 | #endif // LLVM_SUPPORT_UNICODECHARRANGES_H 108 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/UniqueLock.h: -------------------------------------------------------------------------------- 1 | //===- Support/UniqueLock.h - Acquire/Release Mutex In Scope ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines a guard for a block of code that ensures a Mutex is locked 11 | // upon construction and released upon destruction. 12 | // 13 | //===----------------------------------------------------------------------===// 14 | 15 | #ifndef LLVM_SUPPORT_UNIQUE_LOCK_H 16 | #define LLVM_SUPPORT_UNIQUE_LOCK_H 17 | 18 | #include 19 | 20 | namespace llvm { 21 | 22 | /// A pared-down imitation of std::unique_lock from C++11. Contrary to the 23 | /// name, it's really more of a wrapper for a lock. It may or may not have 24 | /// an associated mutex, which is guaranteed to be locked upon creation 25 | /// and unlocked after destruction. unique_lock can also unlock the mutex 26 | /// and re-lock it freely during its lifetime. 27 | /// @brief Guard a section of code with a mutex. 28 | template 29 | class unique_lock { 30 | MutexT *M = nullptr; 31 | bool locked = false; 32 | 33 | public: 34 | unique_lock() = default; 35 | explicit unique_lock(MutexT &m) : M(&m), locked(true) { M->lock(); } 36 | unique_lock(const unique_lock &) = delete; 37 | unique_lock &operator=(const unique_lock &) = delete; 38 | 39 | void operator=(unique_lock &&o) { 40 | if (owns_lock()) 41 | M->unlock(); 42 | M = o.M; 43 | locked = o.locked; 44 | o.M = nullptr; 45 | o.locked = false; 46 | } 47 | 48 | ~unique_lock() { if (owns_lock()) M->unlock(); } 49 | 50 | void lock() { 51 | assert(!locked && "mutex already locked!"); 52 | assert(M && "no associated mutex!"); 53 | M->lock(); 54 | locked = true; 55 | } 56 | 57 | void unlock() { 58 | assert(locked && "unlocking a mutex that isn't locked!"); 59 | assert(M && "no associated mutex!"); 60 | M->unlock(); 61 | locked = false; 62 | } 63 | 64 | bool owns_lock() { return locked; } 65 | }; 66 | 67 | } // end namespace llvm 68 | 69 | #endif // LLVM_SUPPORT_UNIQUE_LOCK_H 70 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Valgrind.h: -------------------------------------------------------------------------------- 1 | //===- llvm/Support/Valgrind.h - Communication with Valgrind ----*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // Methods for communicating with a valgrind instance this program is running 11 | // under. These are all no-ops unless LLVM was configured on a system with the 12 | // valgrind headers installed and valgrind is controlling this process. 13 | // 14 | //===----------------------------------------------------------------------===// 15 | 16 | #ifndef LLVM_SUPPORT_VALGRIND_H 17 | #define LLVM_SUPPORT_VALGRIND_H 18 | 19 | #include 20 | 21 | namespace llvm { 22 | namespace sys { 23 | // True if Valgrind is controlling this process. 24 | bool RunningOnValgrind(); 25 | 26 | // Discard valgrind's translation of code in the range [Addr .. Addr + Len). 27 | // Otherwise valgrind may continue to execute the old version of the code. 28 | void ValgrindDiscardTranslations(const void *Addr, size_t Len); 29 | } // namespace sys 30 | } // end namespace llvm 31 | 32 | #endif // LLVM_SUPPORT_VALGRIND_H 33 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/Watchdog.h: -------------------------------------------------------------------------------- 1 | //===--- Watchdog.h - Watchdog timer ----------------------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file declares the llvm::sys::Watchdog class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_WATCHDOG_H 15 | #define LLVM_SUPPORT_WATCHDOG_H 16 | 17 | #include "llvm/Support/Compiler.h" 18 | 19 | namespace llvm { 20 | namespace sys { 21 | 22 | /// This class provides an abstraction for a timeout around an operation 23 | /// that must complete in a given amount of time. Failure to complete before 24 | /// the timeout is an unrecoverable situation and no mechanisms to attempt 25 | /// to handle it are provided. 26 | class Watchdog { 27 | public: 28 | Watchdog(unsigned int seconds); 29 | ~Watchdog(); 30 | private: 31 | // Noncopyable. 32 | Watchdog(const Watchdog &other) = delete; 33 | Watchdog &operator=(const Watchdog &other) = delete; 34 | }; 35 | } 36 | } 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/WindowsError.h: -------------------------------------------------------------------------------- 1 | //===-- WindowsError.h - Support for mapping windows errors to posix-------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | #ifndef LLVM_SUPPORT_WINDOWSERROR_H 11 | #define LLVM_SUPPORT_WINDOWSERROR_H 12 | 13 | #include 14 | 15 | namespace llvm { 16 | std::error_code mapWindowsError(unsigned EV); 17 | } 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/raw_os_ostream.h: -------------------------------------------------------------------------------- 1 | //===- raw_os_ostream.h - std::ostream adaptor for raw_ostream --*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the raw_os_ostream class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_RAW_OS_OSTREAM_H 15 | #define LLVM_SUPPORT_RAW_OS_OSTREAM_H 16 | 17 | #include "llvm/Support/raw_ostream.h" 18 | #include 19 | 20 | namespace llvm { 21 | 22 | /// raw_os_ostream - A raw_ostream that writes to an std::ostream. This is a 23 | /// simple adaptor class. It does not check for output errors; clients should 24 | /// use the underlying stream to detect errors. 25 | class raw_os_ostream : public raw_ostream { 26 | std::ostream &OS; 27 | 28 | /// write_impl - See raw_ostream::write_impl. 29 | void write_impl(const char *Ptr, size_t Size) override; 30 | 31 | /// current_pos - Return the current position within the stream, not 32 | /// counting the bytes currently in the buffer. 33 | uint64_t current_pos() const override; 34 | 35 | public: 36 | raw_os_ostream(std::ostream &O) : OS(O) {} 37 | ~raw_os_ostream() override; 38 | }; 39 | 40 | } // end llvm namespace 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/raw_sha1_ostream.h: -------------------------------------------------------------------------------- 1 | //==- raw_sha1_ostream.h - raw_ostream that compute SHA1 --*- C++ -*-==// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This file defines the raw_sha1_ostream class. 11 | // 12 | //===----------------------------------------------------------------------===// 13 | 14 | #ifndef LLVM_SUPPORT_RAW_SHA1_OSTREAM_H 15 | #define LLVM_SUPPORT_RAW_SHA1_OSTREAM_H 16 | 17 | #include "llvm/ADT/ArrayRef.h" 18 | #include "llvm/Support/SHA1.h" 19 | #include "llvm/Support/raw_ostream.h" 20 | 21 | namespace llvm { 22 | 23 | /// A raw_ostream that hash the content using the sha1 algorithm. 24 | class raw_sha1_ostream : public raw_ostream { 25 | SHA1 State; 26 | 27 | /// See raw_ostream::write_impl. 28 | void write_impl(const char *Ptr, size_t Size) override { 29 | State.update(ArrayRef((const uint8_t *)Ptr, Size)); 30 | } 31 | 32 | public: 33 | /// Return the current SHA1 hash for the content of the stream 34 | StringRef sha1() { 35 | flush(); 36 | return State.result(); 37 | } 38 | 39 | /// Reset the internal state to start over from scratch. 40 | void resetHash() { State.init(); } 41 | 42 | uint64_t current_pos() const override { return 0; } 43 | }; 44 | 45 | } // end llvm namespace 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/thread.h: -------------------------------------------------------------------------------- 1 | //===-- llvm/Support/thread.h - Wrapper for ------------*- C++ -*-===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | // 10 | // This header is a wrapper for that works around problems with the 11 | // MSVC headers when exceptions are disabled. It also provides llvm::thread, 12 | // which is either a typedef of std::thread or a replacement that calls the 13 | // function synchronously depending on the value of LLVM_ENABLE_THREADS. 14 | // 15 | //===----------------------------------------------------------------------===// 16 | 17 | #ifndef LLVM_SUPPORT_THREAD_H 18 | #define LLVM_SUPPORT_THREAD_H 19 | 20 | #include "llvm/Config/llvm-config.h" 21 | 22 | #if LLVM_ENABLE_THREADS 23 | 24 | #include 25 | 26 | namespace llvm { 27 | typedef std::thread thread; 28 | } 29 | 30 | #else // !LLVM_ENABLE_THREADS 31 | 32 | #include 33 | 34 | namespace llvm { 35 | 36 | struct thread { 37 | thread() {} 38 | thread(thread &&other) {} 39 | template 40 | explicit thread(Function &&f, Args &&... args) { 41 | f(std::forward(args)...); 42 | } 43 | thread(const thread &) = delete; 44 | 45 | void join() {} 46 | static unsigned hardware_concurrency() { return 1; }; 47 | }; 48 | 49 | } 50 | 51 | #endif // LLVM_ENABLE_THREADS 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /lib/llvm/include/llvm/Support/xxhash.h: -------------------------------------------------------------------------------- 1 | /* 2 | xxHash - Extremely Fast Hash algorithm 3 | Header File 4 | Copyright (C) 2012-2016, Yann Collet. 5 | 6 | BSD 2-Clause License (http://www.opensource.org/licenses/bsd-license.php) 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are 10 | met: 11 | 12 | * Redistributions of source code must retain the above copyright 13 | notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above 15 | copyright notice, this list of conditions and the following disclaimer 16 | in the documentation and/or other materials provided with the 17 | distribution. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 22 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 23 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 24 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 25 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 26 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 27 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | 31 | You can contact the author at : 32 | - xxHash source repository : https://github.com/Cyan4973/xxHash 33 | */ 34 | 35 | /* based on revision d2df04efcbef7d7f6886d345861e5dfda4edacc1 Removed 36 | * everything but a simple interface for computing XXh64. */ 37 | 38 | #ifndef LLVM_SUPPORT_XXHASH_H 39 | #define LLVM_SUPPORT_XXHASH_H 40 | 41 | #include "llvm/ADT/StringRef.h" 42 | 43 | namespace llvm { 44 | uint64_t xxHash64(llvm::StringRef Data); 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /lib/llvm/support/Error.cpp: -------------------------------------------------------------------------------- 1 | //===----- lib/Support/Error.cpp - Error and associated utilities ---------===// 2 | // 3 | // The LLVM Compiler Infrastructure 4 | // 5 | // This file is distributed under the University of Illinois Open Source 6 | // License. See LICENSE.TXT for details. 7 | // 8 | //===----------------------------------------------------------------------===// 9 | 10 | 11 | #ifndef _MSC_VER 12 | namespace llvm { 13 | 14 | // One of these two variables will be referenced by a symbol defined in 15 | // llvm-config.h. We provide a link-time (or load time for DSO) failure when 16 | // there is a mismatch in the build configuration of the API client and LLVM. 17 | #if LLVM_ENABLE_ABI_BREAKING_CHECKS 18 | int EnableABIBreakingChecks; 19 | #else 20 | int DisableABIBreakingChecks; 21 | #endif 22 | 23 | } // end namespace llvm 24 | #endif 25 | -------------------------------------------------------------------------------- /scripts/benchmark_and_graph.py: -------------------------------------------------------------------------------- 1 | import argparse 2 | import contextlib 3 | import os 4 | import subprocess 5 | from graph_results import parse_benchmark_results, graph_results 6 | 7 | 8 | 9 | 10 | def main(): 11 | argparser = argparse.ArgumentParser(description='Builds & runs the benchmarks, saves the output to a text file, and produces a number of graphs') 12 | argparser.add_argument('-f', '--file', type=str, default=None, help='true if you want to use previously saved output; otherwise, we\'ll build and run the benchmark "live"') 13 | args = argparser.parse_args() 14 | 15 | if args.file: 16 | with open(args.file) as results_file: 17 | results_raw = results_file.readlines() 18 | else: 19 | results_raw = build_and_run() 20 | with open('output.txt', 'w') as out_file: 21 | out_file.writelines([line + '\n' for line in results_raw]) 22 | 23 | for max_elements in [64, 256, 1024, 16384]: 24 | graph_results( 25 | parse_benchmark_results(results_raw, None, max_elements), 26 | os.path.join('graphs', "container_size_up_to_%d" % max_elements)) 27 | 28 | 29 | def build_and_run(): 30 | with friendly_cd_to_repo_root(): 31 | subprocess.check_call(['cmake', 'CMakeLists.txt']) 32 | subprocess.check_call(['make']) 33 | benchmark_output_bytes = subprocess.check_output(['./llvm_data_structure_benchmarks', '--benchmark_color=false']) 34 | return benchmark_output_bytes.decode('utf-8').splitlines() 35 | 36 | 37 | @contextlib.contextmanager 38 | def friendly_cd_to_repo_root(additional_path=None): 39 | """ 40 | A context manager for changing directories to some specific subdirectory 41 | of this repo. 42 | :type additional_path: str|None 43 | 44 | >>> prev_path = os.getcwd() 45 | >>> with friendly_cd_to_repo_root('scripts'): 46 | ... assert os.getcwd().endswith(os.path.join('llvm-data-structure-benchmarks', 'scripts')) 47 | >>> assert prev_path == os.getcwd() 48 | """ 49 | def _cd_up_until_file_path_exists(file_to_check_for, max_levels=3): 50 | for i in range(max_levels): 51 | if not file_to_check_for in os.listdir(os.getcwd()): 52 | os.chdir('..') 53 | assert file_to_check_for in os.listdir(os.getcwd()), 'It looks like you didn\'t run this script from an expected location' 54 | 55 | prev_dir = os.getcwd() 56 | try: 57 | _cd_up_until_file_path_exists('data_structure_benchmarks.cpp') 58 | if additional_path: 59 | os.chdir(additional_path) 60 | yield 61 | finally: 62 | os.chdir(prev_dir) 63 | 64 | 65 | if __name__ == "__main__": 66 | main() 67 | -------------------------------------------------------------------------------- /scripts/package_requirements.txt: -------------------------------------------------------------------------------- 1 | plotly==3.5.0 2 | psutil==5.5.0 3 | --------------------------------------------------------------------------------