Halide 22.0.0 Halide compiler and libraries

CodeGen_C.h
Go to the documentation of this file.
1#ifndef HALIDE_CODEGEN_C_H
2#define HALIDE_CODEGEN_C_H
3
4/** \file
5 *
6 * Defines an IRPrinter that emits C++ code equivalent to a halide stmt
7 */
8
9#include "IRPrinter.h"
10#include "Scope.h"
11#include "Target.h"
12
13#include <unordered_map>
14
15 namespace Halide {
16
17 struct Argument;
18 class Module;
19
20 namespace Internal {
21
22 struct LoweredFunc;
23
24/** This class emits C++ code equivalent to a halide Stmt. It's
25 * mostly the same as an IRPrinter, but it's wrapped in a function
26 * definition, and some things are handled differently to be valid
27 * C++.
28 */
29 class CodeGen_C : public IRPrinter {
30 public:
31 enum OutputKind {
32 CHeader,
33 CPlusPlusHeader,
34 CImplementation,
35 CPlusPlusImplementation,
36 CExternDecl,
37 CPlusPlusExternDecl,
38 CPlusPlusFunctionInfoHeader,
39 };
40
41 /** Initialize a C code generator pointing at a particular output
42 * stream (e.g. a file, or std::cout) */
43 CodeGen_C(std::ostream &dest,
44 const Target &target,
45 OutputKind output_kind = CImplementation,
46 const std::string &include_guard = "");
47 ~CodeGen_C() override;
48
49 /** Emit the declarations contained in the module as C code. */
50 void compile(const Module &module);
51
52 /** The target we're generating code for */
53 const Target &get_target() const {
54 return target;
55 }
56
57 static void test();
58
59 protected:
60 enum class IntegerSuffixStyle {
61 PlainC = 0,
62 OpenCL = 1,
63 HLSL = 2
64 };
65
66 /** How to emit 64-bit integer constants */
67 IntegerSuffixStyle integer_suffix_style = IntegerSuffixStyle::PlainC;
68
69 /** Emit a declaration. */
70 // @{
71 void compile(const LoweredFunc &func, const MetadataNameMap &metadata_name_map);
72 void compile(const Buffer<> &buffer);
73 // @}
74
75 /** This is a hook that subclasses can use to transform a function body
76 * just before it is emitted -- e.g., to transform the IR to code that
77 * is easier to recognize and emit. The default implementation simply
78 * returns the input unchanged.
79 *
80 * This hook will always be called after the function declaration and
81 * opening brace is emitted, so in addition to (possibly) returning
82 * a modified Stmt, this function may also emit C++ code to the default
83 * stream if it wishes to add some prologue at the start of the function.
84 */
85 virtual Stmt preprocess_function_body(const Stmt &stmt);
86
87 /** An ID for the most recently generated ssa variable */
88 std::string id;
89
90 /** The target being generated for. */
91 Target target;
92
93 /** Controls whether this instance is generating declarations or
94 * definitions and whether the interface us extern "C" or C++. */
95 OutputKind output_kind;
96
97 /** A cache of generated values in scope */
98 std::map<std::string, std::string> cache;
99
100 /** Emit an expression as an assignment, then return the id of the
101 * resulting var */
102 std::string print_expr(const Expr &);
103
104 /** Like print_expr, but cast the Expr to the given Type */
105 std::string print_cast_expr(const Type &, const Expr &);
106
107 /** Emit a statement */
108 void print_stmt(const Stmt &);
109
110 void create_assertion(const std::string &id_cond, const Expr &message);
111 void create_assertion(const Expr &cond, const Expr &message);
112
113 Expr scalarize_vector_reduce(const VectorReduce *op);
114 enum AppendSpaceIfNeeded {
115 DoNotAppendSpace,
116 AppendSpace,
117 };
118
119 /** Emit the C name for a halide type. If space_option is AppendSpace,
120 * and there should be a space between the type and the next token,
121 * one is appended. (This allows both "int foo" and "Foo *foo" to be
122 * formatted correctly. Otherwise the latter is "Foo * foo".)
123 */
124 virtual std::string print_type(Type, AppendSpaceIfNeeded space_option = DoNotAppendSpace);
125
126 /** Emit a statement to reinterpret an expression as another type */
127 virtual std::string print_reinterpret(Type, const Expr &);
128
129 /** Emit a version of a string that is a valid identifier in C (. is replaced with _) */
130 virtual std::string print_name(const std::string &);
131
132 /** Add platform specific prologue */
133 virtual void add_platform_prologue();
134
135 /** Add typedefs for vector types. Not needed for OpenCL, might
136 * use different syntax for other C-like languages. */
137 virtual void add_vector_typedefs(const std::set<Type> &vector_types);
138
139 std::unordered_map<std::string, std::string> extern_function_name_map;
140
141 /** Bottleneck to allow customization of calls to generic Extern/PureExtern calls. */
142 virtual std::string print_extern_call(const Call *op);
143
144 /** Convert a vector Expr into a series of scalar Exprs, then reassemble into vector of original type. */
145 std::string print_scalarized_expr(const Expr &e);
146
147 /** Emit an SSA-style assignment, and set id to the freshly generated name. Return id. */
148 virtual std::string print_assignment(Type t, const std::string &rhs);
149
150 /** Emit free for the heap allocation. **/
151 void print_heap_free(const std::string &alloc_name);
152
153 /** Return true if only generating an interface, which may be extern "C" or C++ */
154 bool is_header() {
155 return output_kind == CHeader ||
156 output_kind == CPlusPlusHeader ||
157 output_kind == CPlusPlusFunctionInfoHeader;
158 }
159
160 /** Return true if only generating an interface, which may be extern "C" or C++ */
161 bool is_extern_decl() {
162 return output_kind == CExternDecl ||
163 output_kind == CPlusPlusExternDecl;
164 }
165
166 /** Return true if only generating an interface, which may be extern "C" or C++ */
167 bool is_header_or_extern_decl() {
168 return is_header() || is_extern_decl();
169 }
170
171 /** Return true if generating C++ linkage. */
172 bool is_c_plus_plus_interface() {
173 return output_kind == CPlusPlusHeader ||
174 output_kind == CPlusPlusImplementation ||
175 output_kind == CPlusPlusExternDecl ||
176 output_kind == CPlusPlusFunctionInfoHeader;
177 }
178
179 /** Open a new C scope (i.e. throw in a brace, increase the indent) */
180 void open_scope();
181
182 /** Close a C scope (i.e. throw in an end brace, decrease the indent) */
183 void close_scope(const std::string &comment);
184
185 struct Allocation {
186 Type type;
187 };
188
189 /** Track the types of allocations to avoid unnecessary casts. */
190 Scope<Allocation> allocations;
191
192 /** Track which allocations actually went on the heap. */
193 Scope<> heap_allocations;
194
195 /** True if there is a void * __user_context parameter in the arguments. */
196 bool have_user_context;
197
198 /** Track current calling convention scope. */
199 bool extern_c_open = false;
200
201 /** True if at least one gpu-based for loop is used. */
202 bool uses_gpu_for_loops;
203
204 /** Track which handle types have been forward-declared already. */
205 std::set<const halide_handle_cplusplus_type *> forward_declared;
206
207 /** If the Type is a handle type, emit a forward-declaration for it
208 * if we haven't already. */
209 void forward_declare_type_if_needed(const Type &t);
210
211 void set_name_mangling_mode(NameMangling mode);
212
213 using IRPrinter::visit;
214
215 void visit(const Variable *) override;
216 void visit(const IntImm *) override;
217 void visit(const UIntImm *) override;
218 void visit(const StringImm *) override;
219 void visit(const FloatImm *) override;
220 void visit(const Cast *) override;
221 void visit(const Reinterpret *) override;
222 void visit(const Add *) override;
223 void visit(const Sub *) override;
224 void visit(const Mul *) override;
225 void visit(const Div *) override;
226 void visit(const Mod *) override;
227 void visit(const Max *) override;
228 void visit(const Min *) override;
229 void visit(const EQ *) override;
230 void visit(const NE *) override;
231 void visit(const LT *) override;
232 void visit(const LE *) override;
233 void visit(const GT *) override;
234 void visit(const GE *) override;
235 void visit(const And *) override;
236 void visit(const Or *) override;
237 void visit(const Not *) override;
238 void visit(const Call *) override;
239 void visit(const Select *) override;
240 void visit(const Load *) override;
241 void visit(const Store *) override;
242 void visit(const Let *) override;
243 void visit(const LetStmt *) override;
244 void visit(const AssertStmt *) override;
245 void visit(const ProducerConsumer *) override;
246 void visit(const For *) override;
247 void visit(const Ramp *) override;
248 void visit(const Broadcast *) override;
249 void visit(const Provide *) override;
250 void visit(const Allocate *) override;
251 void visit(const Free *) override;
252 void visit(const Realize *) override;
253 void visit(const IfThenElse *) override;
254 void visit(const Evaluate *) override;
255 void visit(const Shuffle *) override;
256 void visit(const Prefetch *) override;
257 void visit(const Fork *) override;
258 void visit(const Acquire *) override;
259 void visit(const Atomic *) override;
260 void visit(const VectorReduce *) override;
261
262 void visit_binop(Type t, const Expr &a, const Expr &b, const char *op);
263 void visit_relop(Type t, const Expr &a, const Expr &b, const char *scalar_op, const char *vector_op);
264
265 template<typename T>
266 static std::string with_sep(const std::vector<T> &v, const std::string &sep) {
267 std::ostringstream o;
268 for (size_t i = 0; i < v.size(); ++i) {
269 if (i > 0) {
270 o << sep;
271 }
272 o << v[i];
273 }
274 return o.str();
275 }
276
277 template<typename T>
278 static std::string with_commas(const std::vector<T> &v) {
279 return with_sep<T>(v, ", ");
280 }
281
282 /** Are we inside an atomic node that uses mutex locks?
283 This is used for detecting deadlocks from nested atomics. */
284 bool inside_atomic_mutex_node = false;
285
286 /** Emit atomic store instructions? */
287 bool emit_atomic_stores = false;
288
289 /** true if add_vector_typedefs() has been called. */
290 bool using_vector_typedefs = false;
291
292 /** Some architectures have private memory for the call stack; this
293 * means a thread cannot hand pointers to stack memory to another
294 * thread. Returning true here flag forces heap allocation of
295 * things that might be shared, such as closures and any buffer
296 * that may be used in a parallel context. */
297 virtual bool is_stack_private_to_thread() const;
298
299 void emit_argv_wrapper(const std::string &function_name,
300 const std::vector<LoweredArgument> &args);
301 void emit_metadata_getter(const std::string &function_name,
302 const std::vector<LoweredArgument> &args,
303 const MetadataNameMap &metadata_name_map);
304 void emit_constexpr_function_info(const std::string &function_name,
305 const std::vector<LoweredArgument> &args,
306 const MetadataNameMap &metadata_name_map);
307 void emit_halide_free_helper(const std::string &alloc_name, const std::string &free_function);
308};
309
310} // namespace Internal
311} // namespace Halide
312
313#endif
IRPrinter.h
This header file defines operators that let you dump a Halide expression, statement,...
Scope.h
Defines the Scope class, which is used for keeping track of names in a scope while traversing IR.
Target.h
Defines the structure that describes a Halide target.
Halide::Buffer<>
Halide::Internal::CodeGen_C
This class emits C++ code equivalent to a halide Stmt.
Definition: CodeGen_C.h:29
Halide::Internal::CodeGen_C::OutputKind
OutputKind
Definition: CodeGen_C.h:31
Halide::Internal::CodeGen_C::CPlusPlusHeader
@ CPlusPlusHeader
Definition: CodeGen_C.h:33
Halide::Internal::CodeGen_C::CPlusPlusFunctionInfoHeader
@ CPlusPlusFunctionInfoHeader
Definition: CodeGen_C.h:38
Halide::Internal::CodeGen_C::CPlusPlusImplementation
@ CPlusPlusImplementation
Definition: CodeGen_C.h:35
Halide::Internal::CodeGen_C::CPlusPlusExternDecl
@ CPlusPlusExternDecl
Definition: CodeGen_C.h:37
Halide::Internal::CodeGen_C::CHeader
@ CHeader
Definition: CodeGen_C.h:32
Halide::Internal::CodeGen_C::CExternDecl
@ CExternDecl
Definition: CodeGen_C.h:36
Halide::Internal::CodeGen_C::CImplementation
@ CImplementation
Definition: CodeGen_C.h:34
Halide::Internal::CodeGen_C::visit
void visit(const GE *) override
Halide::Internal::CodeGen_C::is_extern_decl
bool is_extern_decl()
Return true if only generating an interface, which may be extern "C" or C++.
Definition: CodeGen_C.h:161
Halide::Internal::CodeGen_C::visit
void visit(const Provide *) override
Halide::Internal::CodeGen_C::visit
void visit(const Evaluate *) override
Halide::Internal::CodeGen_C::print_type
virtual std::string print_type(Type, AppendSpaceIfNeeded space_option=DoNotAppendSpace)
Emit the C name for a halide type.
Halide::Internal::CodeGen_C::~CodeGen_C
~CodeGen_C() override
Halide::Internal::CodeGen_C::print_heap_free
void print_heap_free(const std::string &alloc_name)
Emit free for the heap allocation.
Halide::Internal::CodeGen_C::visit
void visit(const NE *) override
Halide::Internal::CodeGen_C::visit
void visit(const Realize *) override
Halide::Internal::CodeGen_C::CodeGen_C
CodeGen_C(std::ostream &dest, const Target &target, OutputKind output_kind=CImplementation, const std::string &include_guard="")
Initialize a C code generator pointing at a particular output stream (e.g.
Halide::Internal::CodeGen_C::visit
void visit(const Call *) override
Halide::Internal::CodeGen_C::visit
void visit(const UIntImm *) override
Halide::Internal::CodeGen_C::close_scope
void close_scope(const std::string &comment)
Close a C scope (i.e.
Halide::Internal::CodeGen_C::IntegerSuffixStyle
IntegerSuffixStyle
Definition: CodeGen_C.h:60
Halide::Internal::CodeGen_C::IntegerSuffixStyle::PlainC
@ PlainC
Halide::Internal::CodeGen_C::visit
void visit(const Or *) override
Halide::Internal::CodeGen_C::visit
void visit(const Sub *) override
Halide::Internal::CodeGen_C::create_assertion
void create_assertion(const std::string &id_cond, const Expr &message)
Halide::Internal::CodeGen_C::open_scope
void open_scope()
Open a new C scope (i.e.
Halide::Internal::CodeGen_C::is_stack_private_to_thread
virtual bool is_stack_private_to_thread() const
Some architectures have private memory for the call stack; this means a thread cannot hand pointers t...
Halide::Internal::CodeGen_C::output_kind
OutputKind output_kind
Controls whether this instance is generating declarations or definitions and whether the interface us...
Definition: CodeGen_C.h:95
Halide::Internal::CodeGen_C::is_header
bool is_header()
Return true if only generating an interface, which may be extern "C" or C++.
Definition: CodeGen_C.h:154
Halide::Internal::CodeGen_C::using_vector_typedefs
bool using_vector_typedefs
true if add_vector_typedefs() has been called.
Definition: CodeGen_C.h:290
Halide::Internal::CodeGen_C::visit
void visit(const Max *) override
Halide::Internal::CodeGen_C::visit
void visit(const Select *) override
Halide::Internal::CodeGen_C::visit
void visit(const Load *) override
Halide::Internal::CodeGen_C::visit
void visit(const FloatImm *) override
Halide::Internal::CodeGen_C::forward_declare_type_if_needed
void forward_declare_type_if_needed(const Type &t)
If the Type is a handle type, emit a forward-declaration for it if we haven't already.
Halide::Internal::CodeGen_C::visit
void visit(const LE *) override
Halide::Internal::CodeGen_C::visit
void visit(const Div *) override
Halide::Internal::CodeGen_C::scalarize_vector_reduce
Expr scalarize_vector_reduce(const VectorReduce *op)
Halide::Internal::CodeGen_C::visit
void visit(const Let *) override
Halide::Internal::CodeGen_C::visit
void visit(const And *) override
Halide::Internal::CodeGen_C::test
static void test()
Halide::Internal::CodeGen_C::visit
void visit(const Atomic *) override
Halide::Internal::CodeGen_C::forward_declared
std::set< const halide_handle_cplusplus_type * > forward_declared
Track which handle types have been forward-declared already.
Definition: CodeGen_C.h:205
Halide::Internal::CodeGen_C::is_header_or_extern_decl
bool is_header_or_extern_decl()
Return true if only generating an interface, which may be extern "C" or C++.
Definition: CodeGen_C.h:167
Halide::Internal::CodeGen_C::add_vector_typedefs
virtual void add_vector_typedefs(const std::set< Type > &vector_types)
Add typedefs for vector types.
Halide::Internal::CodeGen_C::visit
void visit(const For *) override
Halide::Internal::CodeGen_C::print_stmt
void print_stmt(const Stmt &)
Emit a statement.
Halide::Internal::CodeGen_C::compile
void compile(const LoweredFunc &func, const MetadataNameMap &metadata_name_map)
Emit a declaration.
Halide::Internal::CodeGen_C::preprocess_function_body
virtual Stmt preprocess_function_body(const Stmt &stmt)
This is a hook that subclasses can use to transform a function body just before it is emitted – e....
Halide::Internal::CodeGen_C::allocations
Scope< Allocation > allocations
Track the types of allocations to avoid unnecessary casts.
Definition: CodeGen_C.h:190
Halide::Internal::CodeGen_C::print_name
virtual std::string print_name(const std::string &)
Emit a version of a string that is a valid identifier in C (.
Halide::Internal::CodeGen_C::visit
void visit(const GT *) override
Halide::Internal::CodeGen_C::visit
void visit(const Free *) override
Halide::Internal::CodeGen_C::compile
void compile(const Buffer<> &buffer)
Halide::Internal::CodeGen_C::visit
void visit(const Store *) override
Halide::Internal::CodeGen_C::emit_atomic_stores
bool emit_atomic_stores
Emit atomic store instructions?
Definition: CodeGen_C.h:287
Halide::Internal::CodeGen_C::emit_halide_free_helper
void emit_halide_free_helper(const std::string &alloc_name, const std::string &free_function)
Halide::Internal::CodeGen_C::visit
void visit(const Prefetch *) override
Halide::Internal::CodeGen_C::visit
void visit(const Add *) override
Halide::Internal::CodeGen_C::heap_allocations
Scope heap_allocations
Track which allocations actually went on the heap.
Definition: CodeGen_C.h:193
Halide::Internal::CodeGen_C::target
Target target
The target being generated for.
Definition: CodeGen_C.h:91
Halide::Internal::CodeGen_C::print_extern_call
virtual std::string print_extern_call(const Call *op)
Bottleneck to allow customization of calls to generic Extern/PureExtern calls.
Halide::Internal::CodeGen_C::print_reinterpret
virtual std::string print_reinterpret(Type, const Expr &)
Emit a statement to reinterpret an expression as another type.
Halide::Internal::CodeGen_C::visit
void visit(const Reinterpret *) override
Halide::Internal::CodeGen_C::visit
void visit(const AssertStmt *) override
Halide::Internal::CodeGen_C::visit
void visit(const EQ *) override
Halide::Internal::CodeGen_C::get_target
const Target & get_target() const
The target we're generating code for.
Definition: CodeGen_C.h:53
Halide::Internal::CodeGen_C::create_assertion
void create_assertion(const Expr &cond, const Expr &message)
Halide::Internal::CodeGen_C::visit
void visit(const VectorReduce *) override
Halide::Internal::CodeGen_C::visit
void visit(const Ramp *) override
Halide::Internal::CodeGen_C::emit_argv_wrapper
void emit_argv_wrapper(const std::string &function_name, const std::vector< LoweredArgument > &args)
Halide::Internal::CodeGen_C::is_c_plus_plus_interface
bool is_c_plus_plus_interface()
Return true if generating C++ linkage.
Definition: CodeGen_C.h:172
Halide::Internal::CodeGen_C::visit
void visit(const Not *) override
Halide::Internal::CodeGen_C::emit_constexpr_function_info
void emit_constexpr_function_info(const std::string &function_name, const std::vector< LoweredArgument > &args, const MetadataNameMap &metadata_name_map)
Halide::Internal::CodeGen_C::id
std::string id
An ID for the most recently generated ssa variable.
Definition: CodeGen_C.h:88
Halide::Internal::CodeGen_C::visit_relop
void visit_relop(Type t, const Expr &a, const Expr &b, const char *scalar_op, const char *vector_op)
Halide::Internal::CodeGen_C::AppendSpaceIfNeeded
AppendSpaceIfNeeded
Definition: CodeGen_C.h:114
Halide::Internal::CodeGen_C::DoNotAppendSpace
@ DoNotAppendSpace
Definition: CodeGen_C.h:115
Halide::Internal::CodeGen_C::AppendSpace
@ AppendSpace
Definition: CodeGen_C.h:116
Halide::Internal::CodeGen_C::with_commas
static std::string with_commas(const std::vector< T > &v)
Definition: CodeGen_C.h:278
Halide::Internal::CodeGen_C::visit
void visit(const Min *) override
Halide::Internal::CodeGen_C::visit
void visit(const Variable *) override
Halide::Internal::CodeGen_C::emit_metadata_getter
void emit_metadata_getter(const std::string &function_name, const std::vector< LoweredArgument > &args, const MetadataNameMap &metadata_name_map)
Halide::Internal::CodeGen_C::set_name_mangling_mode
void set_name_mangling_mode(NameMangling mode)
Halide::Internal::CodeGen_C::visit
void visit(const Mul *) override
Halide::Internal::CodeGen_C::visit
void visit(const Mod *) override
Halide::Internal::CodeGen_C::visit
void visit(const Allocate *) override
Halide::Internal::CodeGen_C::have_user_context
bool have_user_context
True if there is a void * __user_context parameter in the arguments.
Definition: CodeGen_C.h:196
Halide::Internal::CodeGen_C::with_sep
static std::string with_sep(const std::vector< T > &v, const std::string &sep)
Definition: CodeGen_C.h:266
Halide::Internal::CodeGen_C::visit
void visit(const Cast *) override
Halide::Internal::CodeGen_C::print_assignment
virtual std::string print_assignment(Type t, const std::string &rhs)
Emit an SSA-style assignment, and set id to the freshly generated name.
Halide::Internal::CodeGen_C::extern_c_open
bool extern_c_open
Track current calling convention scope.
Definition: CodeGen_C.h:199
Halide::Internal::CodeGen_C::add_platform_prologue
virtual void add_platform_prologue()
Add platform specific prologue.
Halide::Internal::CodeGen_C::inside_atomic_mutex_node
bool inside_atomic_mutex_node
Are we inside an atomic node that uses mutex locks? This is used for detecting deadlocks from nested ...
Definition: CodeGen_C.h:284
Halide::Internal::CodeGen_C::visit
void visit(const IfThenElse *) override
Halide::Internal::CodeGen_C::extern_function_name_map
std::unordered_map< std::string, std::string > extern_function_name_map
Definition: CodeGen_C.h:139
Halide::Internal::CodeGen_C::visit
void visit(const Broadcast *) override
Halide::Internal::CodeGen_C::visit
void visit(const StringImm *) override
Halide::Internal::CodeGen_C::compile
void compile(const Module &module)
Emit the declarations contained in the module as C code.
Halide::Internal::CodeGen_C::visit
void visit(const Shuffle *) override
Halide::Internal::CodeGen_C::print_expr
std::string print_expr(const Expr &)
Emit an expression as an assignment, then return the id of the resulting var.
Halide::Internal::CodeGen_C::visit
void visit(const LT *) override
Halide::Internal::CodeGen_C::print_scalarized_expr
std::string print_scalarized_expr(const Expr &e)
Convert a vector Expr into a series of scalar Exprs, then reassemble into vector of original type.
Halide::Internal::CodeGen_C::visit
void visit(const LetStmt *) override
Halide::Internal::CodeGen_C::uses_gpu_for_loops
bool uses_gpu_for_loops
True if at least one gpu-based for loop is used.
Definition: CodeGen_C.h:202
Halide::Internal::CodeGen_C::visit
void visit(const Fork *) override
Halide::Internal::CodeGen_C::visit
void visit(const ProducerConsumer *) override
Halide::Internal::CodeGen_C::visit
void visit(const Acquire *) override
Halide::Internal::CodeGen_C::cache
std::map< std::string, std::string > cache
A cache of generated values in scope.
Definition: CodeGen_C.h:98
Halide::Internal::CodeGen_C::integer_suffix_style
IntegerSuffixStyle integer_suffix_style
How to emit 64-bit integer constants.
Definition: CodeGen_C.h:67
Halide::Internal::CodeGen_C::visit
void visit(const IntImm *) override
Halide::Internal::CodeGen_C::visit_binop
void visit_binop(Type t, const Expr &a, const Expr &b, const char *op)
Halide::Internal::CodeGen_C::print_cast_expr
std::string print_cast_expr(const Type &, const Expr &)
Like print_expr, but cast the Expr to the given Type.
Halide::Internal::IRPrinter
An IRVisitor that emits IR to the given output stream in a human readable form.
Definition: IRPrinter.h:144
Halide::Internal::IRPrinter::visit
void visit(const IntImm *) override
Halide::Internal::Scope
A common pattern when traversing Halide IR is that you need to keep track of stuff when you find a Le...
Definition: Scope.h:94
Halide::Module
A halide module.
Definition: Module.h:142
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::MetadataNameMap
std::map< std::string, std::string > MetadataNameMap
Definition: Module.h:138
Halide::NameMangling
NameMangling
An enum to specify calling convention for extern stages.
Definition: Function.h:26
Halide::DeviceAPI::OpenCL
@ OpenCL
Halide::Expr
A fragment of Halide syntax.
Definition: Expr.h:258
Halide::Internal::Acquire
Definition: IR.h:872
Halide::Internal::Add
The sum of two expressions.
Definition: IR.h:56
Halide::Internal::Allocate
Allocate a scratch area called with the given name, type, and size.
Definition: IR.h:371
Halide::Internal::And
Logical and - are both expressions true.
Definition: IR.h:175
Halide::Internal::AssertStmt
If the 'condition' is false, then evaluate and return the message, which should be a call to an error...
Definition: IR.h:294
Halide::Internal::Atomic
Lock all the Store nodes in the body statement.
Definition: IR.h:994
Halide::Internal::Broadcast
A vector with 'lanes' elements, in which every element is 'value'.
Definition: IR.h:259
Halide::Internal::Call
A function call.
Definition: IR.h:490
Halide::Internal::Cast
The actual IR nodes begin here.
Definition: IR.h:30
Halide::Internal::CodeGen_C::Allocation
Definition: CodeGen_C.h:185
Halide::Internal::CodeGen_C::Allocation::type
Type type
Definition: CodeGen_C.h:186
Halide::Internal::Div
The ratio of two expressions.
Definition: IR.h:83
Halide::Internal::EQ
Is the first expression equal to the second.
Definition: IR.h:121
Halide::Internal::Evaluate
Evaluate and discard an expression, presumably because it has some side-effect.
Definition: IR.h:476
Halide::Internal::FloatImm
Floating point constants.
Definition: Expr.h:236
Halide::Internal::For
A for loop.
Definition: IR.h:848
Halide::Internal::Fork
A pair of statements executed concurrently.
Definition: IR.h:457
Halide::Internal::Free
Free the resources associated with the given buffer.
Definition: IR.h:413
Halide::Internal::GE
Is the first expression greater than or equal to the second.
Definition: IR.h:166
Halide::Internal::GT
Is the first expression greater than the second.
Definition: IR.h:157
Halide::Internal::IfThenElse
An if-then-else block.
Definition: IR.h:466
Halide::Internal::IntImm
Integer constants.
Definition: Expr.h:218
Halide::Internal::LE
Is the first expression less than or equal to the second.
Definition: IR.h:148
Halide::Internal::LT
Is the first expression less than the second.
Definition: IR.h:139
Halide::Internal::Let
A let expression, like you might find in a functional language.
Definition: IR.h:271
Halide::Internal::LetStmt
The statement form of a let node.
Definition: IR.h:282
Halide::Internal::Load
Load a value from a named symbol if predicate is true.
Definition: IR.h:217
Halide::Internal::LoweredFunc
Definition of a lowered function.
Definition: Module.h:101
Halide::Internal::Max
The greater of two values.
Definition: IR.h:112
Halide::Internal::Min
The lesser of two values.
Definition: IR.h:103
Halide::Internal::Mod
The remainder of a / b.
Definition: IR.h:94
Halide::Internal::Mul
The product of two expressions.
Definition: IR.h:74
Halide::Internal::NE
Is the first expression not equal to the second.
Definition: IR.h:130
Halide::Internal::Not
Logical not - true if the expression false.
Definition: IR.h:193
Halide::Internal::Or
Logical or - is at least one of the expression true.
Definition: IR.h:184
Halide::Internal::Prefetch
Represent a multi-dimensional region of a Func or an ImageParam that needs to be prefetched.
Definition: IR.h:956
Halide::Internal::ProducerConsumer
This node is a helpful annotation to do with permissions.
Definition: IR.h:315
Halide::Internal::Provide
This defines the value of a function at a multi-dimensional location.
Definition: IR.h:354
Halide::Internal::Ramp
A linear ramp vector node.
Definition: IR.h:247
Halide::Internal::Realize
Allocate a multi-dimensional buffer of the given type and size.
Definition: IR.h:427
Halide::Internal::Reinterpret
Reinterpret value as another type, without affecting any of the bits (on little-endian systems).
Definition: IR.h:47
Halide::Internal::Select
A ternary operator.
Definition: IR.h:204
Halide::Internal::Shuffle
Construct a new vector by taking elements from another sequence of vectors.
Definition: IR.h:884
Halide::Internal::Stmt
A reference-counted handle to a statement node.
Definition: Expr.h:427
Halide::Internal::Store
Store a 'value' to the buffer called 'name' at a given 'index' if 'predicate' is true.
Definition: IR.h:333
Halide::Internal::StringImm
String constants.
Definition: Expr.h:245
Halide::Internal::Sub
The difference of two expressions.
Definition: IR.h:65
Halide::Internal::UIntImm
Unsigned integer constants.
Definition: Expr.h:227
Halide::Internal::Variable
A named variable.
Definition: IR.h:801
Halide::Internal::VectorReduce
Horizontally reduce a vector to a scalar or narrower vector using the given commutative and associati...
Definition: IR.h:1012
Halide::Internal::cond
Definition: Generator.h:380
Halide::Target
A struct representing a target machine and os to generate code for.
Definition: Target.h:19
Halide::Type
Types in the halide type system.
Definition: Type.h:283