Halide
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 >= 140
5 // We're good to go
6 #else
7 #error "Compiling Halide requires LLVM 14.0 or newer"
8 #endif
9 
10 // No msvc warnings from llvm headers please
11 #ifdef _MSC_VER
12 #pragma warning(push, 0)
13 #endif
14 #ifdef __GNUC__
15 #pragma GCC system_header
16 #endif
17 #ifdef __clang__
18 #pragma clang system_header
19 #endif
20 
21 // IWYU pragma: begin_exports
22 
23 #if WITH_WABT || WITH_V8
24 #include <lld/Common/Driver.h>
25 #if LLVM_VERSION >= 170
26 #include <lld/Common/ErrorHandler.h>
27 #endif
28 #endif
29 #include <llvm/ADT/APFloat.h>
30 #include <llvm/ADT/ArrayRef.h>
31 #include <llvm/ADT/SmallVector.h>
32 #include <llvm/ADT/StringMap.h>
33 #include <llvm/ADT/StringRef.h>
34 #if LLVM_VERSION < 170
35 #include <llvm/ADT/Triple.h>
36 #endif
37 #include <llvm/ADT/Twine.h>
38 #include <llvm/Analysis/AliasAnalysis.h>
39 #include <llvm/Analysis/TargetLibraryInfo.h>
40 #include <llvm/Analysis/TargetTransformInfo.h>
41 #include <llvm/Bitcode/BitcodeReader.h>
42 #include <llvm/Bitcode/BitcodeWriter.h>
43 #include <llvm/ExecutionEngine/Orc/LLJIT.h>
44 #include <llvm/ExecutionEngine/Orc/ObjectLinkingLayer.h>
45 #include <llvm/ExecutionEngine/Orc/RTDyldObjectLinkingLayer.h>
46 #include <llvm/ExecutionEngine/SectionMemoryManager.h>
47 #include <llvm/IR/Constant.h>
48 #include <llvm/IR/Constants.h>
49 #include <llvm/IR/DataLayout.h>
50 #include <llvm/IR/DerivedTypes.h>
51 #include <llvm/IR/Function.h>
52 #include <llvm/IR/GlobalValue.h>
53 #include <llvm/IR/GlobalVariable.h>
54 #include <llvm/IR/IRBuilder.h>
55 #include <llvm/IR/InlineAsm.h>
56 #include <llvm/IR/Instructions.h>
57 #include <llvm/IR/Intrinsics.h>
58 #ifdef WITH_HEXAGON
59 #include <llvm/IR/IntrinsicsHexagon.h>
60 #endif
61 #include <llvm/IR/LegacyPassManager.h>
62 #include <llvm/IR/MDBuilder.h>
63 #include <llvm/IR/Metadata.h>
64 #include <llvm/IR/Module.h>
65 #include <llvm/IR/PassTimingInfo.h>
66 #include <llvm/IR/Type.h>
67 #include <llvm/IR/Value.h>
68 #include <llvm/IR/Verifier.h>
69 #include <llvm/Linker/Linker.h>
70 #include <llvm/MC/MCTargetOptions.h>
71 #include <llvm/MC/TargetRegistry.h>
72 #include <llvm/Object/ArchiveWriter.h>
73 #include <llvm/Object/ObjectFile.h>
74 #include <llvm/Passes/PassBuilder.h>
75 #include <llvm/Support/Casting.h>
76 #include <llvm/Support/CodeGen.h>
77 #include <llvm/Support/CommandLine.h>
78 #include <llvm/Support/DataExtractor.h>
79 #include <llvm/Support/DynamicLibrary.h>
80 #include <llvm/Support/ErrorHandling.h>
81 #include <llvm/Support/FileSystem.h>
82 #include <llvm/Support/FormattedStream.h>
83 #include <llvm/Support/TargetSelect.h>
84 #include <llvm/Support/TypeSize.h>
85 #include <llvm/Support/raw_os_ostream.h>
86 #include <llvm/Support/raw_ostream.h>
87 #include <llvm/Target/TargetMachine.h>
88 #include <llvm/Target/TargetOptions.h>
89 #if LLVM_VERSION >= 170
90 #include <llvm/TargetParser/Triple.h>
91 #endif
92 #include <llvm/Transforms/IPO.h>
93 #include <llvm/Transforms/IPO/AlwaysInliner.h>
94 #include <llvm/Transforms/IPO/Inliner.h>
95 #if LLVM_VERSION < 170
96 #include <llvm/Transforms/IPO/PassManagerBuilder.h>
97 #endif
98 #include <llvm/Transforms/Instrumentation.h>
99 #include <llvm/Transforms/Instrumentation/AddressSanitizer.h>
100 #include <llvm/Transforms/Instrumentation/SanitizerCoverage.h>
101 #include <llvm/Transforms/Instrumentation/ThreadSanitizer.h>
102 #include <llvm/Transforms/Scalar/GVN.h>
103 #include <llvm/Transforms/Utils/ModuleUtils.h>
104 #include <llvm/Transforms/Utils/SymbolRewriter.h>
105 
106 // IWYU pragma: end_exports
107 
108 // No msvc warnings from llvm headers please
109 #ifdef _MSC_VER
110 #pragma warning(pop)
111 #endif
112 
113 // llvm may sometimes define NDEBUG, which is annoying, because we always want asserts
114 #ifdef NDEBUG
115 #undef NDEBUG
116 #include <assert.h>
117 #define NDEBUG
118 #endif
119 
120 namespace Halide {
121 namespace Internal {
122 
123 template<typename T>
124 auto iterator_to_pointer(T iter) -> decltype(&*std::declval<T>()) {
125  return &*iter;
126 }
127 
128 inline std::string get_llvm_function_name(const llvm::Function *f) {
129  return f->getName().str();
130 }
131 
132 inline std::string get_llvm_function_name(const llvm::Function &f) {
133  return f.getName().str();
134 }
135 
136 inline llvm::StructType *get_llvm_struct_type_by_name(llvm::Module *module, const char *name) {
137  return llvm::StructType::getTypeByName(module->getContext(), name);
138 }
139 
140 } // namespace Internal
141 } // namespace Halide
142 
143 #endif
Halide::Internal::iterator_to_pointer
auto iterator_to_pointer(T iter) -> decltype(&*std::declval< T >())
Definition: LLVM_Headers.h:124
Halide
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
Definition: AbstractGenerator.h:19
Halide::LinkageType::Internal
@ Internal
Not visible externally, similar to 'static' linkage in C.
Halide::Internal::get_llvm_struct_type_by_name
llvm::StructType * get_llvm_struct_type_by_name(llvm::Module *module, const char *name)
Definition: LLVM_Headers.h:136
Halide::Internal::get_llvm_function_name
std::string get_llvm_function_name(const llvm::Function *f)
Definition: LLVM_Headers.h:128