Halide 19.0.0
Halide compiler and libraries
Loading...
Searching...
No Matches
Type.h
Go to the documentation of this file.
1#ifndef HALIDE_TYPE_H
2#define HALIDE_TYPE_H
3
4#include "Error.h"
5#include "Float16.h"
6#include "Util.h"
8#include <cstdint>
9
10/** \file
11 * Defines halide types
12 */
13
14/** A set of types to represent a C++ function signature. This allows
15 * two things. First, proper prototypes can be provided for Halide
16 * generated functions, giving better compile time type
17 * checking. Second, C++ name mangling can be done to provide link
18 * time type checking for both Halide generated functions and calls
19 * from Halide to external functions.
20 *
21 * These are intended to be constexpr producable.
22 *
23 * halide_handle_traits has to go outside the Halide namespace due to template
24 * resolution rules. TODO(zalman): Do all types need to be in global namespace?
25 */
26//@{
27
28/** A structure to represent the (unscoped) name of a C++ composite type for use
29 * as a single argument (or return value) in a function signature.
30 *
31 * Currently does not support the restrict qualifier, references, or
32 * r-value references. These features cannot be used in extern
33 * function calls from Halide or in the generated function from
34 * Halide, but their applicability seems limited anyway.
35 *
36 * Although this is in the global namespace, it should be considered "Halide Internal"
37 * and subject to change; code outside Halide should avoid referencing it.
38 */
40 /// An enum to indicate whether a C++ type is non-composite, a struct, class, or union
42 Simple, ///< "int"
43 Struct, ///< "struct Foo"
44 Class, ///< "class Foo"
45 Union, ///< "union Foo"
46 Enum, ///< "enum Foo"
47 } cpp_type_type; // Note: order is reflected in map_to_name table in CPlusPlusMangle.cpp
48
49 std::string name;
50
54
55 bool operator==(const halide_cplusplus_type_name &rhs) const {
56 return cpp_type_type == rhs.cpp_type_type &&
57 name == rhs.name;
58 }
59
60 bool operator!=(const halide_cplusplus_type_name &rhs) const {
61 return !(*this == rhs);
62 }
63
64 bool operator<(const halide_cplusplus_type_name &rhs) const {
65 return cpp_type_type < rhs.cpp_type_type ||
67 name < rhs.name);
68 }
69};
70
71/** A structure to represent the fully scoped name of a C++ composite
72 * type for use in generating function signatures that use that type.
73 *
74 * This is intended to be a constexpr usable type.
75 *
76 * Although this is in the global namespace, it should be considered "Halide Internal"
77 * and subject to change; code outside Halide should avoid referencing it.
78 */
81 std::vector<std::string> namespaces;
82 std::vector<halide_cplusplus_type_name> enclosing_types;
83
84 /// One set of modifiers on a type.
85 /// The const/volatile/restrict properties are "inside" the pointer property.
87 Const = 1 << 0, ///< Bitmask flag for "const"
88 Volatile = 1 << 1, ///< Bitmask flag for "volatile"
89 Restrict = 1 << 2, ///< Bitmask flag for "restrict"
90 Pointer = 1 << 3, ///< Bitmask flag for a pointer "*"
91 FunctionTypedef = 1 << 4, ///< Bitmask flag for a function typedef; when this is set, Pointer should also always be set
92 };
93
94 /// Qualifiers and indirections on type. 0 is innermost.
95 std::vector<uint8_t> cpp_type_modifiers;
96
97 /// References are separate because they only occur at the outermost level.
98 /// No modifiers are needed for references as they are not allowed to apply
99 /// to the reference itself. (This isn't true for restrict, but that is a C++
100 /// extension anyway.) If modifiers are needed, the last entry in the above
101 /// array would be the modifers for the reference.
104 LValueReference = 1, // "&"
105 RValueReference = 2, // "&&"
106 };
108
110 const std::vector<std::string> &namespaces = {},
111 const std::vector<halide_cplusplus_type_name> &enclosing_types = {},
112 const std::vector<uint8_t> &modifiers = {},
117 cpp_type_modifiers(modifiers),
119 }
120
121 template<typename T>
123};
124//@}
125
126/** halide_c_type_to_name is a utility class used to provide a user-extensible
127 * way of naming Handle types.
128 *
129 * Although this is in the global namespace, it should be considered "Halide Internal"
130 * and subject to change; code outside Halide should avoid referencing it
131 * directly (use the HALIDE_DECLARE_EXTERN_xxx macros instead).
132 */
133template<typename T>
135 static constexpr bool known_type = false;
139};
140
141#define HALIDE_DECLARE_EXTERN_TYPE(TypeType, Type) \
142 template<> \
143 struct halide_c_type_to_name<Type> { \
144 static constexpr bool known_type = true; \
145 static halide_cplusplus_type_name name() { \
146 return {halide_cplusplus_type_name::TypeType, #Type}; \
147 } \
148 }
149
150#define HALIDE_DECLARE_EXTERN_SIMPLE_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Simple, T)
151#define HALIDE_DECLARE_EXTERN_STRUCT_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Struct, T)
152#define HALIDE_DECLARE_EXTERN_CLASS_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Class, T)
153#define HALIDE_DECLARE_EXTERN_UNION_TYPE(T) HALIDE_DECLARE_EXTERN_TYPE(Union, T)
154
169#ifdef HALIDE_CPP_COMPILER_HAS_FLOAT16
171#endif
181
182// You can make arbitrary user-defined types be "Known" using the
183// macro above. This is useful for making Param<> arguments for
184// Generators type safe. e.g.,
185//
186// struct MyFunStruct { ... };
187//
188// ...
189//
190// HALIDE_DECLARE_EXTERN_STRUCT_TYPE(MyFunStruct);
191//
192// ...
193//
194// class MyGenerator : public Generator<MyGenerator> {
195// Param<const MyFunStruct *> my_struct_ptr;
196// ...
197// };
198
199template<typename T>
201 constexpr bool is_ptr = std::is_pointer<T>::value;
202 constexpr bool is_lvalue_reference = std::is_lvalue_reference<T>::value;
203 constexpr bool is_rvalue_reference = std::is_rvalue_reference<T>::value;
204
205 using TNoRef = typename std::remove_reference<T>::type;
206 using TNoRefNoPtr = typename std::remove_pointer<TNoRef>::type;
207 constexpr bool is_function_pointer = std::is_pointer<TNoRef>::value &&
208 std::is_function<TNoRefNoPtr>::value;
209
210 // Don't remove the pointer-ness from a function pointer.
211 using TBase = typename std::conditional<is_function_pointer, TNoRef, TNoRefNoPtr>::type;
212 constexpr bool is_const = std::is_const<TBase>::value;
213 constexpr bool is_volatile = std::is_volatile<TBase>::value;
214
215 constexpr uint8_t modifiers = static_cast<uint8_t>(
216 (is_function_pointer ? halide_handle_cplusplus_type::FunctionTypedef : 0) |
218 (is_const ? halide_handle_cplusplus_type::Const : 0) |
219 (is_volatile ? halide_handle_cplusplus_type::Volatile : 0));
220
221 // clang-format off
223 (is_lvalue_reference ? halide_handle_cplusplus_type::LValueReference :
226 // clang-format on
227
228 using TNonCVBase = typename std::remove_cv<TBase>::type;
229 constexpr bool known_type = halide_c_type_to_name<TNonCVBase>::known_type;
230 static_assert(!(!known_type && !is_ptr), "Unknown types must be pointers");
231
234 {},
235 {},
236 {modifiers},
237 ref_type};
238 // Pull off any namespaces
240 return info;
241}
242
243/** A type traits template to provide a halide_handle_cplusplus_type
244 * value from a C++ type.
245 *
246 * Note the type represented is implicitly a pointer.
247 *
248 * A NULL pointer of type halide_handle_traits represents "void *".
249 * This is chosen for compactness or representation as Type is a very
250 * widely used data structure.
251 *
252 * Although this is in the global namespace, it should be considered "Halide Internal"
253 * and subject to change; code outside Halide should avoid referencing it directly.
254 */
255template<typename T>
257 // This trait must return a pointer to a global structure. I.e. it should never be freed.
258 // A return value of nullptr here means "void *".
260 if (std::is_pointer<T>::value ||
261 std::is_lvalue_reference<T>::value ||
262 std::is_rvalue_reference<T>::value) {
264 return &the_info;
265 }
266 return nullptr;
267 }
268};
269
270namespace Halide {
271
272namespace Internal {
273struct ConstantInterval;
274}
275
276struct Expr;
277
278/** Types in the halide type system. They can be ints, unsigned ints,
279 * or floats of various bit-widths (the 'bits' field). They can also
280 * be vectors of the same (by setting the 'lanes' field to something
281 * larger than one). Front-end code shouldn't use vector
282 * types. Instead vectorize a function. */
283struct Type {
284private:
285 halide_type_t type;
286
287public:
288 /** Aliases for halide_type_code_t values for legacy compatibility
289 * and to match the Halide internal C++ style. */
290 // @{
296 // @}
297
298 /** The number of bytes required to store a single scalar value of this type. Ignores vector lanes. */
299 int bytes() const {
300 return (bits() + 7) / 8;
301 }
302
303 // Default ctor initializes everything to predictable-but-unlikely values
305 : type(Handle, 0, 0) {
306 }
307
308 /** Construct a runtime representation of a Halide type from:
309 * code: The fundamental type from an enum.
310 * bits: The bit size of one element.
311 * lanes: The number of vector elements in the type. */
314 user_assert(lanes == type.lanes)
315 << "Halide only supports vector types with up to 65535 lanes. " << lanes << " lanes requested.";
316 user_assert(bits == type.bits)
317 << "Halide only supports types with up to 255 bits. " << bits << " bits requested.";
318 }
319
320 /** Trivial copy constructor. */
321 Type(const Type &that) = default;
322
323 /** Trivial copy assignment operator. */
324 Type &operator=(const Type &that) = default;
325
326 /** Type is a wrapper around halide_type_t with more methods for use
327 * inside the compiler. This simply constructs the wrapper around
328 * the runtime value. */
331 : type(that), handle_type(handle_type) {
332 }
333
334 /** Unwrap the runtime halide_type_t for use in runtime calls, etc.
335 * Representation is exactly equivalent. */
337 operator halide_type_t() const {
338 return type;
339 }
340
341 /** Return the underlying data type of an element as an enum value. */
344 return (halide_type_code_t)type.code;
345 }
346
347 /** Return the bit size of a single element of this type. */
349 int bits() const {
350 return type.bits;
351 }
352
353 /** Return the number of vector elements in this type. */
355 int lanes() const {
356 return type.lanes;
357 }
358
359 /** Return Type with same number of bits and lanes, but new_code for a type code. */
361 return Type(new_code, bits(), lanes(),
362 (new_code == code()) ? handle_type : nullptr);
363 }
364
365 /** Return Type with same type code and lanes, but new_bits for the number of bits. */
366 Type with_bits(int new_bits) const {
367 return Type(code(), new_bits, lanes(),
368 (new_bits == bits()) ? handle_type : nullptr);
369 }
370
371 /** Return Type with same type code and number of bits,
372 * but new_lanes for the number of vector lanes. */
373 Type with_lanes(int new_lanes) const {
374 return Type(code(), bits(), new_lanes, handle_type);
375 }
376
377 /** Return Type with the same type code and number of lanes, but with at least twice as many bits. */
378 Type widen() const {
379 if (bits() == 1) {
380 // Widening a 1-bit type should produce an 8-bit type.
381 return with_bits(8);
382 } else {
383 return with_bits(bits() * 2);
384 }
385 }
386
387 /** Return Type with the same type code and number of lanes, but with at most half as many bits. */
388 Type narrow() const {
389 internal_assert(bits() != 1) << "Attempting to narrow a 1-bit type\n";
390 if (bits() == 8) {
391 // Narrowing an 8-bit type should produce a 1-bit type.
392 return with_bits(1);
393 } else {
394 return with_bits(bits() / 2);
395 }
396 }
397
398 /** Type to be printed when declaring handles of this type. */
400
401 /** Is this type boolean (represented as UInt(1))? */
403 bool is_bool() const {
404 return code() == UInt && bits() == 1;
405 }
406
407 /** Is this type a vector type? (lanes() != 1).
408 * TODO(abadams): Decide what to do for lanes() == 0. */
410 bool is_vector() const {
411 return lanes() != 1;
412 }
413
414 /** Is this type a scalar type? (lanes() == 1).
415 * TODO(abadams): Decide what to do for lanes() == 0. */
417 bool is_scalar() const {
418 return lanes() == 1;
419 }
420
421 /** Is this type a floating point type (float or double). */
423 bool is_float() const {
424 return code() == Float || code() == BFloat;
425 }
426
427 /** Is this type a floating point type (float or double). */
429 bool is_bfloat() const {
430 return code() == BFloat;
431 }
432
433 /** Is this type a signed integer type? */
435 bool is_int() const {
436 return code() == Int;
437 }
438
439 /** Is this type an unsigned integer type? */
441 bool is_uint() const {
442 return code() == UInt;
443 }
444
445 /** Is this type an integer type of any sort? */
447 bool is_int_or_uint() const {
448 return code() == Int || code() == UInt;
449 }
450
451 /** Is this type an opaque handle type (void *) */
453 bool is_handle() const {
454 return code() == Handle;
455 }
456
457 // Returns true iff type is a signed integral type where overflow is defined.
459 bool can_overflow_int() const {
460 return is_int() && bits() <= 16;
461 }
462
463 // Returns true iff type does have a well-defined overflow behavior.
465 bool can_overflow() const {
466 return is_uint() || can_overflow_int();
467 }
468
469 /** Check that the type name of two handles matches. */
470 bool same_handle_type(const Type &other) const;
471
472 /** Compare two types for equality */
473 bool operator==(const Type &other) const {
474 return type == other.type && (code() != Handle || same_handle_type(other));
475 }
476
477 /** Compare two types for inequality */
478 bool operator!=(const Type &other) const {
479 return type != other.type || (code() == Handle && !same_handle_type(other));
480 }
481
482 /** Compare two types for equality */
483 bool operator==(const halide_type_t &other) const {
484 return type == other;
485 }
486
487 /** Compare two types for inequality */
488 bool operator!=(const halide_type_t &other) const {
489 return type != other;
490 }
491
492 /** Compare ordering of two types so they can be used in certain containers and algorithms */
493 bool operator<(const Type &other) const {
494 if (type < other.type) {
495 return true;
496 }
497 if (code() == Handle) {
498 return handle_type < other.handle_type;
499 }
500 return false;
501 }
502
503 /** Produce the scalar type (that of a single element) of this vector type */
504 Type element_of() const {
505 return with_lanes(1);
506 }
507
508 /** Can this type represent all values of another type? */
509 bool can_represent(Type other) const;
510
511 /** Can this type represent exactly all integer values of some constant
512 * integer range? */
514
515 /** Can this type represent a particular constant? */
516 // @{
517 bool can_represent(double x) const;
518 bool can_represent(int64_t x) const;
519 bool can_represent(uint64_t x) const;
520 // @}
521
522 /** Check if an integer constant value is the maximum or minimum
523 * representable value for this type. */
524 // @{
525 bool is_max(uint64_t) const;
526 bool is_max(int64_t) const;
527 bool is_min(uint64_t) const;
528 bool is_min(int64_t) const;
529 // @}
530
531 /** Return an expression which is the maximum value of this type.
532 * Returns infinity for types which can represent it. */
533 Expr max() const;
534
535 /** Return an expression which is the minimum value of this type.
536 * Returns -infinity for types which can represent it. */
537 Expr min() const;
538};
539
540/** Constructing a signed integer type */
541inline Type Int(int bits, int lanes = 1) {
542 return Type(Type::Int, bits, lanes);
543}
544
545/** Constructing an unsigned integer type */
546inline Type UInt(int bits, int lanes = 1) {
547 return Type(Type::UInt, bits, lanes);
548}
549
550/** Construct a floating-point type */
551inline Type Float(int bits, int lanes = 1) {
552 return Type(Type::Float, bits, lanes);
553}
554
555/** Construct a floating-point type in the bfloat format. Only 16-bit currently supported. */
556inline Type BFloat(int bits, int lanes = 1) {
557 return Type(Type::BFloat, bits, lanes);
558}
559
560/** Construct a boolean type */
561inline Type Bool(int lanes = 1) {
562 return UInt(1, lanes);
563}
564
565/** Construct a handle type */
566inline Type Handle(int lanes = 1, const halide_handle_cplusplus_type *handle_type = nullptr) {
567 return Type(Type::Handle, 64, lanes, handle_type);
568}
569
570/** Construct the halide equivalent of a C type */
571template<typename T>
572inline Type type_of() {
573 return Type(halide_type_of<T>(), halide_handle_traits<T>::type_info());
574}
575
576/** Halide type to a C++ type */
577std::string type_to_c_type(Type type, bool include_space, bool c_plus_plus = true);
578
579} // namespace Halide
580
581#endif
#define internal_assert(c)
Definition Errors.h:19
This file declares the routines used by Halide internally in its runtime.
int(* halide_task_t)(void *user_context, int task_number, uint8_t *closure)
Define halide_do_par_for to replace the default thread pool implementation.
halide_type_code_t
Types in the halide type system.
@ halide_type_float
IEEE floating point numbers.
@ halide_type_handle
opaque pointer type (void *)
@ halide_type_bfloat
floating point numbers in the bfloat format
@ halide_type_int
signed integers
@ halide_type_uint
unsigned integers
int(* halide_loop_task_t)(void *user_context, int min, int extent, uint8_t *closure, void *task_parent)
A task representing a serial for loop evaluated over some range.
#define HALIDE_ALWAYS_INLINE
#define HALIDE_DECLARE_EXTERN_STRUCT_TYPE(T)
Definition Type.h:151
#define HALIDE_DECLARE_EXTERN_SIMPLE_TYPE(T)
Definition Type.h:150
Various utility functions used internally Halide.
std::string extract_namespaces(const std::string &name, std::vector< std::string > &namespaces)
Returns base name and fills in namespaces, outermost one first in vector.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
std::string type_to_c_type(Type type, bool include_space, bool c_plus_plus=true)
Halide type to a C++ type.
Type BFloat(int bits, int lanes=1)
Construct a floating-point type in the bfloat format.
Definition Type.h:556
Type UInt(int bits, int lanes=1)
Constructing an unsigned integer type.
Definition Type.h:546
Type Float(int bits, int lanes=1)
Construct a floating-point type.
Definition Type.h:551
@ Internal
Not visible externally, similar to 'static' linkage in C.
Type type_of()
Construct the halide equivalent of a C type.
Definition Type.h:572
Type Int(int bits, int lanes=1)
Constructing a signed integer type.
Definition Type.h:541
Type Handle(int lanes=1, const halide_handle_cplusplus_type *handle_type=nullptr)
Construct a handle type.
Definition Type.h:566
Type Bool(int lanes=1)
Construct a boolean type.
Definition Type.h:561
unsigned __INT64_TYPE__ uint64_t
signed __INT64_TYPE__ int64_t
signed __INT32_TYPE__ int32_t
unsigned __INT8_TYPE__ uint8_t
unsigned __INT16_TYPE__ uint16_t
unsigned __INT32_TYPE__ uint32_t
signed __INT16_TYPE__ int16_t
signed __INT8_TYPE__ int8_t
A fragment of Halide syntax.
Definition Expr.h:258
A class to represent ranges of integers.
Types in the halide type system.
Definition Type.h:283
HALIDE_ALWAYS_INLINE halide_type_code_t code() const
Return the underlying data type of an element as an enum value.
Definition Type.h:343
static const halide_type_code_t Float
Definition Type.h:293
Type widen() const
Return Type with the same type code and number of lanes, but with at least twice as many bits.
Definition Type.h:378
Type(halide_type_code_t code, int bits, int lanes, const halide_handle_cplusplus_type *handle_type=nullptr)
Construct a runtime representation of a Halide type from: code: The fundamental type from an enum.
Definition Type.h:312
Type element_of() const
Produce the scalar type (that of a single element) of this vector type.
Definition Type.h:504
bool is_max(uint64_t) const
Check if an integer constant value is the maximum or minimum representable value for this type.
static const halide_type_code_t Int
Aliases for halide_type_code_t values for legacy compatibility and to match the Halide internal C++ s...
Definition Type.h:291
Type with_bits(int new_bits) const
Return Type with same type code and lanes, but new_bits for the number of bits.
Definition Type.h:366
HALIDE_ALWAYS_INLINE bool is_int() const
Is this type a signed integer type?
Definition Type.h:435
bool can_represent(const Internal::ConstantInterval &in) const
Can this type represent exactly all integer values of some constant integer range?
Expr min() const
Return an expression which is the minimum value of this type.
bool operator!=(const Type &other) const
Compare two types for inequality.
Definition Type.h:478
HALIDE_ALWAYS_INLINE int lanes() const
Return the number of vector elements in this type.
Definition Type.h:355
HALIDE_ALWAYS_INLINE bool is_uint() const
Is this type an unsigned integer type?
Definition Type.h:441
HALIDE_ALWAYS_INLINE bool is_bool() const
Is this type boolean (represented as UInt(1))?
Definition Type.h:403
Type with_lanes(int new_lanes) const
Return Type with same type code and number of bits, but new_lanes for the number of vector lanes.
Definition Type.h:373
HALIDE_ALWAYS_INLINE Type(const halide_type_t &that, const halide_handle_cplusplus_type *handle_type=nullptr)
Type is a wrapper around halide_type_t with more methods for use inside the compiler.
Definition Type.h:330
static const halide_type_code_t BFloat
Definition Type.h:294
bool operator<(const Type &other) const
Compare ordering of two types so they can be used in certain containers and algorithms.
Definition Type.h:493
Type(const Type &that)=default
Trivial copy constructor.
HALIDE_ALWAYS_INLINE int bits() const
Return the bit size of a single element of this type.
Definition Type.h:349
HALIDE_ALWAYS_INLINE bool can_overflow_int() const
Definition Type.h:459
bool operator!=(const halide_type_t &other) const
Compare two types for inequality.
Definition Type.h:488
bool same_handle_type(const Type &other) const
Check that the type name of two handles matches.
HALIDE_ALWAYS_INLINE bool is_int_or_uint() const
Is this type an integer type of any sort?
Definition Type.h:447
static const halide_type_code_t UInt
Definition Type.h:292
HALIDE_ALWAYS_INLINE bool is_vector() const
Is this type a vector type? (lanes() != 1).
Definition Type.h:410
HALIDE_ALWAYS_INLINE bool is_bfloat() const
Is this type a floating point type (float or double).
Definition Type.h:429
const halide_handle_cplusplus_type * handle_type
Type to be printed when declaring handles of this type.
Definition Type.h:399
int bytes() const
The number of bytes required to store a single scalar value of this type.
Definition Type.h:299
bool is_max(int64_t) const
bool can_represent(Type other) const
Can this type represent all values of another type?
bool is_min(int64_t) const
bool operator==(const Type &other) const
Compare two types for equality.
Definition Type.h:473
HALIDE_ALWAYS_INLINE bool can_overflow() const
Definition Type.h:465
Type with_code(halide_type_code_t new_code) const
Return Type with same number of bits and lanes, but new_code for a type code.
Definition Type.h:360
Type & operator=(const Type &that)=default
Trivial copy assignment operator.
static const halide_type_code_t Handle
Definition Type.h:295
bool can_represent(double x) const
Can this type represent a particular constant?
Type narrow() const
Return Type with the same type code and number of lanes, but with at most half as many bits.
Definition Type.h:388
HALIDE_ALWAYS_INLINE bool is_handle() const
Is this type an opaque handle type (void *)
Definition Type.h:453
bool can_represent(int64_t x) const
bool is_min(uint64_t) const
bool can_represent(uint64_t x) const
bool operator==(const halide_type_t &other) const
Compare two types for equality.
Definition Type.h:483
HALIDE_ALWAYS_INLINE bool is_scalar() const
Is this type a scalar type? (lanes() == 1).
Definition Type.h:417
Expr max() const
Return an expression which is the maximum value of this type.
HALIDE_ALWAYS_INLINE bool is_float() const
Is this type a floating point type (float or double).
Definition Type.h:423
Class that provides a type that implements half precision floating point using the bfloat16 format.
Definition Float16.h:158
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
Definition Float16.h:17
The raw representation of an image passed around by generated Halide code.
halide_c_type_to_name is a utility class used to provide a user-extensible way of naming Handle types...
Definition Type.h:134
static constexpr bool known_type
Definition Type.h:135
static halide_cplusplus_type_name name()
Definition Type.h:136
A set of types to represent a C++ function signature.
Definition Type.h:39
bool operator<(const halide_cplusplus_type_name &rhs) const
Definition Type.h:64
bool operator==(const halide_cplusplus_type_name &rhs) const
Definition Type.h:55
enum halide_cplusplus_type_name::CPPTypeType cpp_type_type
halide_cplusplus_type_name(CPPTypeType cpp_type_type, const std::string &name)
Definition Type.h:51
bool operator!=(const halide_cplusplus_type_name &rhs) const
Definition Type.h:60
CPPTypeType
An enum to indicate whether a C++ type is non-composite, a struct, class, or union.
Definition Type.h:41
@ Class
"class Foo"
Definition Type.h:44
@ Union
"union Foo"
Definition Type.h:45
@ Struct
"struct Foo"
Definition Type.h:43
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
A structure to represent the fully scoped name of a C++ composite type for use in generating function...
Definition Type.h:79
ReferenceType reference_type
Definition Type.h:107
halide_cplusplus_type_name inner_name
Definition Type.h:80
static halide_handle_cplusplus_type make()
Definition Type.h:200
ReferenceType
References are separate because they only occur at the outermost level.
Definition Type.h:102
halide_handle_cplusplus_type(const halide_cplusplus_type_name &inner_name, const std::vector< std::string > &namespaces={}, const std::vector< halide_cplusplus_type_name > &enclosing_types={}, const std::vector< uint8_t > &modifiers={}, ReferenceType reference_type=NotReference)
Definition Type.h:109
std::vector< std::string > namespaces
Definition Type.h:81
std::vector< halide_cplusplus_type_name > enclosing_types
Definition Type.h:82
Modifier
One set of modifiers on a type.
Definition Type.h:86
@ Const
Bitmask flag for "const".
Definition Type.h:87
@ Restrict
Bitmask flag for "restrict".
Definition Type.h:89
@ FunctionTypedef
Bitmask flag for a function typedef; when this is set, Pointer should also always be set.
Definition Type.h:91
@ Volatile
Bitmask flag for "volatile".
Definition Type.h:88
@ Pointer
Bitmask flag for a pointer "*".
Definition Type.h:90
std::vector< uint8_t > cpp_type_modifiers
Qualifiers and indirections on type. 0 is innermost.
Definition Type.h:95
A type traits template to provide a halide_handle_cplusplus_type value from a C++ type.
Definition Type.h:256
static HALIDE_ALWAYS_INLINE const halide_handle_cplusplus_type * type_info()
Definition Type.h:259
A parallel task to be passed to halide_do_parallel_tasks.
A struct representing a semaphore and a number of items that must be acquired from it.
An opaque struct representing a semaphore.
A runtime tag for a type in the halide type system.
uint8_t bits
The number of bits of precision of a single scalar value of this type.
uint16_t lanes
How many elements in a vector.
uint8_t code
The basic type code: signed integer, unsigned integer, or floating point.
#define user_assert(c)
Definition test.h:10