Go to the documentation of this file.
61 return !(*
this == rhs);
110 const std::vector<std::string> &
namespaces = {},
112 const std::vector<uint8_t> &modifiers = {},
141 #define HALIDE_DECLARE_EXTERN_TYPE(TypeType, Type) \
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}; \
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)
198 constexpr
bool is_ptr = std::is_pointer<T>::value;
199 constexpr
bool is_lvalue_reference = std::is_lvalue_reference<T>::value;
200 constexpr
bool is_rvalue_reference = std::is_rvalue_reference<T>::value;
202 using TNoRef =
typename std::remove_reference<T>::type;
203 using TNoRefNoPtr =
typename std::remove_pointer<TNoRef>::type;
204 constexpr
bool is_function_pointer = std::is_pointer<TNoRef>::value &&
205 std::is_function<TNoRefNoPtr>::value;
208 using TBase =
typename std::conditional<is_function_pointer, TNoRef, TNoRefNoPtr>::type;
209 constexpr
bool is_const = std::is_const<TBase>::value;
210 constexpr
bool is_volatile = std::is_volatile<TBase>::value;
225 using TNonCVBase =
typename std::remove_cv<TBase>::type;
227 static_assert(!(!known_type && !is_ptr),
"Unknown types must be pointers");
257 if (std::is_pointer<T>::value ||
258 std::is_lvalue_reference<T>::value ||
259 std::is_rvalue_reference<T>::value) {
293 return (
bits() + 7) / 8;
473 return type == other;
478 return type != other;
483 if (type < other.type) {
547 return UInt(1, lanes);
562 std::string
type_to_c_type(Type type,
bool include_space,
bool c_plus_plus =
true);
signed __INT32_TYPE__ int32_t
@ FunctionTypedef
Bitmask flag for a function typedef; when this is set, Pointer should also always be set.
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.
std::vector< uint8_t > cpp_type_modifiers
Qualifiers and indirections on type. 0 is innermost.
HALIDE_ALWAYS_INLINE bool is_bool() const
Is this type boolean (represented as UInt(1))?
Type & operator=(const Type &that)=default
Trivial copy assignment operator.
std::vector< halide_cplusplus_type_name > enclosing_types
#define internal_assert(c)
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_handle
opaque pointer type (void *)
static halide_cplusplus_type_name name()
bool operator==(const Type &other) const
Compare two types for equality.
unsigned __INT8_TYPE__ uint8_t
@ halide_type_bfloat
floating point numbers in the bfloat format
bool operator<(const halide_cplusplus_type_name &rhs) const
unsigned __INT16_TYPE__ uint16_t
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.
static const halide_type_code_t Float
Type Float(int bits, int lanes=1)
Construct a floating-point type.
@ halide_type_float
IEEE floating point numbers.
@ Const
Bitmask flag for "const".
static halide_handle_cplusplus_type make()
int bytes() const
The number of bytes required to store a single scalar value of this type.
HALIDE_ALWAYS_INLINE int lanes() const
Return the number of vector elements in this type.
signed __INT8_TYPE__ int8_t
HALIDE_ALWAYS_INLINE bool is_float() const
Is this type a floating point type (float or double).
HALIDE_ALWAYS_INLINE bool is_uint() const
Is this type an unsigned integer type?
@ Pointer
Bitmask flag for a pointer "*".
uint8_t bits
The number of bits of precision of a single scalar value of this type.
HALIDE_ALWAYS_INLINE auto is_const(A &&a) noexcept -> IsConst< decltype(pattern_arg(a))>
bool same_handle_type(const Type &other) const
Check that the type name of two handles matches.
Type element_of() const
Produce the scalar type (that of a single element) of this vector type.
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.
A runtime tag for a type in the halide type system.
bool operator<(const Type &other) const
Compare ordering of two types so they can be used in certain containers and algorithms.
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.
HALIDE_ALWAYS_INLINE bool can_overflow_int() const
#define HALIDE_DECLARE_EXTERN_SIMPLE_TYPE(T)
Expr max() const
Return an expression which is the maximum value of this type.
unsigned __INT64_TYPE__ uint64_t
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...
HALIDE_ALWAYS_INLINE bool is_vector() const
Is this type a vector type? (lanes() != 1).
HALIDE_ALWAYS_INLINE bool is_bfloat() const
Is this type a floating point type (float or double).
Types in the halide type system.
Type with_bits(int new_bits) const
Return Type with same type code and lanes, but new_bits for the number of bits.
This file defines the class FunctionDAG, which is our representation of a Halide pipeline,...
HALIDE_ALWAYS_INLINE bool can_overflow() const
#define HALIDE_DECLARE_EXTERN_STRUCT_TYPE(T)
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)
Type Handle(int lanes=1, const halide_handle_cplusplus_type *handle_type=nullptr)
Construct a handle type.
Type narrow() const
Return Type with the same type code and number of lanes, but with at most half as many bits.
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.
ReferenceType reference_type
bool operator!=(const Type &other) const
Compare two types for inequality.
Type Bool(int lanes=1)
Construct a boolean type.
A struct representing a semaphore and a number of items that must be acquired from it.
halide_type_code_t
Types in the halide type system.
HALIDE_ALWAYS_INLINE bool is_handle() const
Is this type an opaque handle type (void *)
#define HALIDE_ALWAYS_INLINE
std::vector< std::string > namespaces
static const halide_type_code_t Handle
HALIDE_ALWAYS_INLINE bool is_int_or_uint() const
Is this type an integer type of any sort?
uint16_t lanes
How many elements in a vector.
HALIDE_ALWAYS_INLINE int bits() const
Return the bit size of a single element of this type.
ReferenceType
References are separate because they only occur at the outermost level.
const halide_handle_cplusplus_type * handle_type
Type to be printed when declaring handles of this type.
Type UInt(int bits, int lanes=1)
Constructing an unsigned integer type.
signed __INT64_TYPE__ int64_t
bool operator==(const halide_type_t &other) const
Compare two types for equality.
static const halide_type_code_t UInt
@ halide_type_uint
unsigned integers
Expr min() const
Return an expression which is the minimum value of this type.
bool operator!=(const halide_cplusplus_type_name &rhs) const
Type BFloat(int bits, int lanes=1)
Construct a floating-point type in the bfloat format.
halide_cplusplus_type_name inner_name
bool is_min(uint64_t) const
Class that provides a type that implements half precision floating point using the bfloat16 format.
HALIDE_ALWAYS_INLINE bool is_scalar() const
Is this type a scalar type? (lanes() == 1).
bool is_max(uint64_t) const
Check if an integer constant value is the maximum or minimum representable value for this type.
halide_c_type_to_name is a utility class used to provide a user-extensible way of naming Handle types...
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.
HALIDE_ALWAYS_INLINE bool is_int() const
Is this type a signed integer type?
A parallel task to be passed to halide_do_parallel_tasks.
The raw representation of an image passed around by generated Halide code.
bool operator==(const halide_cplusplus_type_name &rhs) const
A type traits template to provide a halide_handle_cplusplus_type value from a C++ type.
static const HALIDE_ALWAYS_INLINE halide_handle_cplusplus_type * type_info()
CPPTypeType
An enum to indicate whether a C++ type is non-composite, a struct, class, or union.
Type type_of()
Construct the halide equivalent of a C type.
Each GPU API provides a halide_device_interface_t struct pointing to the code that manages device all...
@ Restrict
Bitmask flag for "restrict".
A structure to represent the fully scoped name of a C++ composite type for use in generating function...
signed __INT16_TYPE__ int16_t
A fragment of Halide syntax.
@ halide_type_int
signed integers
Class that provides a type that implements half precision floating point (IEEE754 2008 binary16) in s...
An opaque struct representing a semaphore.
@ Volatile
Bitmask flag for "volatile".
halide_cplusplus_type_name(CPPTypeType cpp_type_type, const std::string &name)
static constexpr bool known_type
unsigned __INT32_TYPE__ uint32_t
Type widen() const
Return Type with the same type code and number of lanes, but with at least twice as many bits.
A set of types to represent a C++ function signature.
enum halide_cplusplus_type_name::CPPTypeType cpp_type_type
bool can_represent(Type other) const
Can this type represent all values of another type?
std::string type_to_c_type(Type type, bool include_space, bool c_plus_plus=true)
Halide type to a C++ type.
HALIDE_ALWAYS_INLINE halide_type_code_t code() const
Return the underlying data type of an element as an enum value.
static const halide_type_code_t BFloat
uint8_t code
The basic type code: signed integer, unsigned integer, or floating point.
Modifier
One set of modifiers on a type.
bool operator!=(const halide_type_t &other) const
Compare two types for inequality.
Type Int(int bits, int lanes=1)
Constructing a signed integer type.