Halide  12.0.1
Halide compiler and libraries
LLVM_Headers.h
Go to the documentation of this file.
1 #ifndef HALIDE_LLVM_HEADERS_H
2 #define HALIDE_LLVM_HEADERS_H
3 
4 #if LLVM_VERSION >= 110
5 // We're good to go
6 #else
7 #error "Compiling Halide requires LLVM 11.0 or newer"
8 #endif
9 
10 // This seems to be required by some LLVM header, which is likely an LLVM bug.
11 #include <cstddef>
12 
13 // No msvc warnings from llvm headers please
14 #ifdef _MSC_VER
15 #pragma warning(push, 0)
16 #endif
17 #ifdef __GNUC__
18 #pragma GCC system_header
19 #endif
20 #ifdef __clang__
21 #pragma clang system_header
22 #endif
23 
24 #if WITH_WABT
25 #include <lld/Common/Driver.h>
26 #endif
27 
28 #include <llvm/ExecutionEngine/JITEventListener.h>
29 #include <llvm/ExecutionEngine/MCJIT.h>
30 #include <llvm/ExecutionEngine/SectionMemoryManager.h>
31 
32 #include "llvm/ADT/APFloat.h"
33 #include "llvm/ADT/SmallVector.h"
34 #include "llvm/ADT/StringRef.h"
35 #include "llvm/Support/ErrorHandling.h"
36 #include <llvm/ADT/StringMap.h>
37 #if LLVM_VERSION >= 12
38 #include <llvm/Analysis/AliasAnalysis.h>
39 #endif
40 #include <llvm/Analysis/TargetLibraryInfo.h>
41 #include <llvm/Bitcode/BitcodeReader.h>
42 #include <llvm/Bitcode/BitcodeWriter.h>
43 #include <llvm/ExecutionEngine/ExecutionEngine.h>
44 #include <llvm/IR/LegacyPassManager.h>
45 #include <llvm/IR/PassTimingInfo.h>
46 #include <llvm/IR/Verifier.h>
47 #include <llvm/Linker/Linker.h>
48 #include <llvm/Object/ArchiveWriter.h>
49 #include <llvm/Object/ObjectFile.h>
50 #include <llvm/Passes/PassBuilder.h>
51 #include <llvm/Support/CodeGen.h>
52 #if LLVM_VERSION >= 12
53 #include <llvm/Support/CommandLine.h>
54 #endif
55 #include <llvm/Support/DataExtractor.h>
56 #include <llvm/Support/DynamicLibrary.h>
57 #include <llvm/Support/FileSystem.h>
58 #include <llvm/Support/FormattedStream.h>
59 #include <llvm/Support/TargetRegistry.h>
60 #include <llvm/Support/TargetSelect.h>
61 #include <llvm/Support/raw_os_ostream.h>
62 #include <llvm/Support/raw_ostream.h>
63 #include <llvm/Target/TargetMachine.h>
64 #include <llvm/Transforms/IPO.h>
65 #include <llvm/Transforms/IPO/Inliner.h>
66 #include <llvm/Transforms/IPO/PassManagerBuilder.h>
67 #include <llvm/Transforms/Instrumentation.h>
68 #include <llvm/Transforms/Instrumentation/AddressSanitizer.h>
69 #include <llvm/Transforms/Instrumentation/ThreadSanitizer.h>
70 #include <llvm/Transforms/Utils/ModuleUtils.h>
71 #include <llvm/Transforms/Utils/SymbolRewriter.h>
72 
73 #include <llvm/Transforms/Scalar/GVN.h>
74 
75 #include <llvm/Transforms/IPO/AlwaysInliner.h>
76 
77 #include <llvm/Analysis/TargetTransformInfo.h>
78 #include <llvm/IR/DataLayout.h>
79 #include <llvm/IR/Function.h>
80 #include <llvm/IR/IRBuilder.h>
81 #include <llvm/IR/Intrinsics.h>
82 #ifdef WITH_HEXAGON
83 #include <llvm/IR/IntrinsicsHexagon.h>
84 #endif
85 #include <llvm/IR/MDBuilder.h>
86 #include <llvm/IR/Module.h>
87 #include <llvm/IR/Value.h>
88 
89 // No msvc warnings from llvm headers please
90 #ifdef _MSC_VER
91 #pragma warning(pop)
92 #endif
93 
94 // llvm may sometimes define NDEBUG, which is annoying, because we always want asserts
95 #ifdef NDEBUG
96 #undef NDEBUG
97 #include <assert.h>
98 #define NDEBUG
99 #endif
100 
101 namespace Halide {
102 namespace Internal {
103 
104 template<typename T>
105 auto iterator_to_pointer(T iter) -> decltype(&*std::declval<T>()) {
106  return &*iter;
107 }
108 
109 inline std::string get_llvm_function_name(const llvm::Function *f) {
110  return f->getName().str();
111 }
112 
113 inline std::string get_llvm_function_name(const llvm::Function &f) {
114  return f.getName().str();
115 }
116 
117 inline llvm::StructType *get_llvm_struct_type_by_name(llvm::Module *module, const char *name) {
118 #if LLVM_VERSION >= 120
119  return llvm::StructType::getTypeByName(module->getContext(), name);
120 #else
121  return module->getTypeByName(name);
122 #endif
123 }
124 
125 } // namespace Internal
126 } // namespace Halide
127 
128 #endif
auto iterator_to_pointer(T iter) -> decltype(&*std::declval< T >())
Definition: LLVM_Headers.h:105
std::string get_llvm_function_name(const llvm::Function *f)
Definition: LLVM_Headers.h:109
llvm::StructType * get_llvm_struct_type_by_name(llvm::Module *module, const char *name)
Definition: LLVM_Headers.h:117
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
@ Internal
Not visible externally, similar to 'static' linkage in C.