docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
sdfg::types Namespace Reference

Namespaces

namespace  builder

Classes

class  Array
 Represents a c-style array type. More...
class  Function
 Represents a function type. More...
class  Pointer
 Represents a pointer type. More...
class  Scalar
 Represents a scalar primitive type. More...
class  Structure
 Represents a structure type (similar to C struct). More...
class  StructureDefinition
 Defines the layout and members of a structure type. More...
class  Tensor
class  StorageType
 Represents the storage location and management characteristics of data. More...
class  IType
 Abstract base interface for all types in the sdfglib type system. More...

Enumerations

enum  PrimitiveType {
  Void , Bool , Int8 , Int16 ,
  Int32 , Int64 , Int128 , UInt8 ,
  UInt16 , UInt32 , UInt64 , UInt128 ,
  Half , BFloat , Float , Double ,
  X86_FP80 , FP128 , PPC_FP128
}
 Enumeration of all primitive data types supported by sdfglib. More...
enum class  TypeID {
  Scalar , Array , Structure , Pointer ,
  Reference , Function , Tensor
}
 Enumeration of high-level type categories. More...

Functions

constexpr const char * primitive_type_to_string (PrimitiveType e)
 Converts a PrimitiveType to its string representation.
constexpr PrimitiveType primitive_type_from_string (std::string_view e)
 Converts a string to its corresponding PrimitiveType.
constexpr size_t bit_width (PrimitiveType e)
 Returns the bit width of a PrimitiveType.
constexpr bool is_floating_point (PrimitiveType e) noexcept
 Checks if a PrimitiveType is a floating-point type.
constexpr bool is_integer (PrimitiveType e) noexcept
 Checks if a PrimitiveType is an integer type.
constexpr bool is_signed (PrimitiveType e) noexcept
 Checks if a PrimitiveType is a signed integer type.
constexpr bool is_unsigned (PrimitiveType e) noexcept
 Checks if a PrimitiveType is an unsigned integer type.
constexpr PrimitiveType as_signed (PrimitiveType e) noexcept
 Converts an unsigned integer type to its signed equivalent.
constexpr PrimitiveType as_unsigned (PrimitiveType e) noexcept
 Converts a signed integer type to its unsigned equivalent.
std::unique_ptr< types::IType > infer_type (const sdfg::Function &function, const types::IType &type, const data_flow::Subset &subset)
 Infers the type resulting from accessing a subset of data.
std::unique_ptr< types::IType > recombine_array_type (const types::IType &type, uint depth, const types::IType &inner_type)
 Reconstructs an array type with a new inner element type.
const IType & peel_to_innermost_element (const IType &type, int follow_ptr=PEEL_TO_INNERMOST_ELEMENT_FOLLOW_ONLY_OUTER_PTR)
 Returns the innermost element type of a (potentially multi-dimensional) array.
symbolic::Expression get_contiguous_element_size (const types::IType &type, bool allow_comp_time_eval=true)
 Returns the size in bytes of one contiguous element.
symbolic::Expression get_type_size (const types::IType &type, bool allow_comp_time_eval=true)
 Returns the size of a type in bytes.
const types::IType * peel_to_next_element (const types::IType &type)
 Returns the next element type inside an array/pointer/reference.
bool is_contiguous_type (const types::IType &type, StructuredSDFG &sdfg)
 Checks if a type is contiguous in memory.
PrimitiveType get_primitive_type_to_hold_upper_bound (const symbolic::Expression &expr)
 Return a good primitive type that can hold the expressions maximum value.
PrimitiveType get_primitive_type_to_hold_lower_bound (const symbolic::Expression &expr)
 Return a good primitive type that can hold the expressions minimum value.
PrimitiveType get_primitive_type_to_hold (PrimitiveType a, PrimitiveType b)
 Return the primitive type that can hold the contents of both a and b without any risk of loss (respecting C-style signed-overflow is undefined and need not be considered.

Variables

constexpr int PEEL_TO_INNERMOST_ELEMENT_FOLLOW_ONLY_OUTER_PTR = -100
 Special value indicating to follow only an outermost pointer when peeling.

Enumeration Type Documentation

◆ PrimitiveType

Enumeration of all primitive data types supported by sdfglib.

This enum defines all the basic scalar types that can be used in the type system, including integer types (signed and unsigned), floating-point types, and void.

Enumerator
Void 

Void type (0 bits).

Bool 

Boolean type (1 bit).

Int8 

8-bit signed integer

Int16 

16-bit signed integer

Int32 

32-bit signed integer

Int64 

64-bit signed integer

Int128 

128-bit signed integer

UInt8 

8-bit unsigned integer

UInt16 

16-bit unsigned integer

UInt32 

32-bit unsigned integer

UInt64 

64-bit unsigned integer

UInt128 

128-bit unsigned integer

Half 

16-bit floating-point (IEEE 754 half precision)

BFloat 

16-bit brain floating-point

Float 

32-bit floating-point (IEEE 754 single precision)

Double 

64-bit floating-point (IEEE 754 double precision)

X86_FP80 

80-bit extended precision floating-point (x86)

FP128 

128-bit floating-point (IEEE 754 quadruple precision)

PPC_FP128 

128-bit floating-point (PowerPC double-double)

◆ TypeID

enum class sdfg::types::TypeID
strong

Enumeration of high-level type categories.

This enum is used for runtime type identification of IType-derived classes.

Enumerator
Scalar 

Scalar primitive type.

Array 

Array type (c-style arrays).

Structure 

Structure/record type.

Pointer 

Pointer type.

Reference 

Reference type.

Function 

Function type.

Tensor 

Tensor type (multi-dimensional arrays).

Function Documentation

◆ as_signed()

PrimitiveType sdfg::types::as_signed ( PrimitiveType e)
constexprnoexcept

Converts an unsigned integer type to its signed equivalent.

Parameters
eThe PrimitiveType to convert
Returns
The signed equivalent type, or the same type if not unsigned integer

◆ as_unsigned()

PrimitiveType sdfg::types::as_unsigned ( PrimitiveType e)
constexprnoexcept

Converts a signed integer type to its unsigned equivalent.

Parameters
eThe PrimitiveType to convert
Returns
The unsigned equivalent type, or the same type if not signed integer

◆ bit_width()

size_t sdfg::types::bit_width ( PrimitiveType e)
constexpr

Returns the bit width of a PrimitiveType.

Parameters
eThe PrimitiveType to query
Returns
The bit width of the type (0 for Void, 1 for Bool, etc.)
Exceptions
std::invalid_argumentif the primitive type is invalid

◆ get_contiguous_element_size()

symbolic::Expression sdfg::types::get_contiguous_element_size ( const types::IType & type,
bool allow_comp_time_eval = true )

Returns the size in bytes of one contiguous element.

This computes the size of a single element according to peel_to_innermost_element. This is useful for calculating strides and offsets in array indexing.

Parameters
typeThe type to query
allow_comp_time_evalWhether to emit compiler-time sizeof expressions if static size is unknown (default: true)
Returns
The element size as a symbolic expression (in bytes)

◆ get_primitive_type_to_hold()

PrimitiveType sdfg::types::get_primitive_type_to_hold ( PrimitiveType a,
PrimitiveType b )

Return the primitive type that can hold the contents of both a and b without any risk of loss (respecting C-style signed-overflow is undefined and need not be considered.

but unsigned overflow does)

Returns

◆ get_primitive_type_to_hold_lower_bound()

PrimitiveType sdfg::types::get_primitive_type_to_hold_lower_bound ( const symbolic::Expression & expr)

Return a good primitive type that can hold the expressions minimum value.

Current limited impl: will evaluate the expression. If result is immediate and fits into Int32, then that, otherwise falls back to Int64

Returns
For now Int32 or Int64 if not sure

◆ get_primitive_type_to_hold_upper_bound()

PrimitiveType sdfg::types::get_primitive_type_to_hold_upper_bound ( const symbolic::Expression & expr)

Return a good primitive type that can hold the expressions maximum value.

Current limited impl: will evaluate the expression. If result is immediate and fits into Int32, then that, otherwise falls back to Int64

Returns
For now Int32 or Int64 if not sure

◆ get_type_size()

symbolic::Expression sdfg::types::get_type_size ( const types::IType & type,
bool allow_comp_time_eval = true )

Returns the size of a type in bytes.

Computes the total size of the given type. For arrays, this includes all elements. For structures, this includes all members with padding.

Parameters
typeThe type to query
allow_comp_time_evalWhether to emit compiler-time sizeof expressions if static size is unknown (default: true)
Returns
The type size as a symbolic expression (in bytes), or empty RCP if unknown

◆ infer_type()

std::unique_ptr< types::IType > sdfg::types::infer_type ( const sdfg::Function & function,
const types::IType & type,
const data_flow::Subset & subset )

Infers the type resulting from accessing a subset of data.

Given a type and a subset (index expressions), this function determines what type results from that access. For example, accessing an element of an array returns the element type, while accessing a full array returns the array type.

Parameters
functionThe function context
typeThe type being accessed
subsetThe subset/index expressions defining the access
Returns
A const reference to the inferred type

◆ is_contiguous_type()

bool sdfg::types::is_contiguous_type ( const types::IType & type,
StructuredSDFG & sdfg )

Checks if a type is contiguous in memory.

This function determines if the given type represents a contiguous memory layout. Non-contiguous types include types with nested pointers. Outermost pointers are allowed as they can still point to contiguous memory.

Parameters
typeThe type to check
sdfgThe StructuredSDFG context, to access structure definitions if needed
Returns
True if the type is contiguous, false otherwise

◆ is_floating_point()

bool sdfg::types::is_floating_point ( PrimitiveType e)
constexprnoexcept

Checks if a PrimitiveType is a floating-point type.

Parameters
eThe PrimitiveType to check
Returns
true if the type is a floating-point type, false otherwise

◆ is_integer()

bool sdfg::types::is_integer ( PrimitiveType e)
constexprnoexcept

Checks if a PrimitiveType is an integer type.

Parameters
eThe PrimitiveType to check
Returns
true if the type is an integer type (including Bool), false otherwise

◆ is_signed()

bool sdfg::types::is_signed ( PrimitiveType e)
constexprnoexcept

Checks if a PrimitiveType is a signed integer type.

Parameters
eThe PrimitiveType to check
Returns
true if the type is a signed integer type, false otherwise

◆ is_unsigned()

bool sdfg::types::is_unsigned ( PrimitiveType e)
constexprnoexcept

Checks if a PrimitiveType is an unsigned integer type.

Parameters
eThe PrimitiveType to check
Returns
true if the type is an unsigned integer type, false otherwise

◆ peel_to_innermost_element()

const IType & sdfg::types::peel_to_innermost_element ( const IType & type,
int follow_ptr = PEEL_TO_INNERMOST_ELEMENT_FOLLOW_ONLY_OUTER_PTR )

Returns the innermost element type of a (potentially multi-dimensional) array.

This function recursively unwraps array and pointer types to find the innermost element type. The follow_ptr parameter controls how pointers are handled during unwrapping.

Parameters
typeThe type to unwrap
follow_ptrControls pointer following behavior:
  • PEEL_TO_INNERMOST_ELEMENT_FOLLOW_ONLY_OUTER_PTR (default): Only follow an outermost pointer
  • Positive count: Follow that many pointers
  • -1: Follow infinite pointers
Returns
A const reference to the innermost element type

◆ peel_to_next_element()

const types::IType * sdfg::types::peel_to_next_element ( const types::IType & type)

Returns the next element type inside an array/pointer/reference.

This function unwraps one level of array, pointer, or reference type to get the type of the element it contains or points to.

Parameters
typeThe type to peel
Returns
A pointer to the next element type, or nullptr if there is none

◆ primitive_type_from_string()

PrimitiveType sdfg::types::primitive_type_from_string ( std::string_view e)
constexpr

Converts a string to its corresponding PrimitiveType.

Parameters
eThe string representation of the primitive type
Returns
The corresponding PrimitiveType enum value
Exceptions
std::invalid_argumentif the string does not match any primitive type

◆ primitive_type_to_string()

const char * sdfg::types::primitive_type_to_string ( PrimitiveType e)
constexpr

Converts a PrimitiveType to its string representation.

Parameters
eThe PrimitiveType to convert
Returns
The string name of the primitive type
Exceptions
std::invalid_argumentif the primitive type is invalid

◆ recombine_array_type()

std::unique_ptr< types::IType > sdfg::types::recombine_array_type ( const types::IType & type,
uint depth,
const types::IType & inner_type )

Reconstructs an array type with a new inner element type.

This function is used to rebuild array types after transformations. It reconstructs the array type hierarchy to a specified depth with a new innermost element type.

Parameters
typeThe original type
depthThe depth to which to reconstruct the array type
inner_typeThe new innermost element type
Returns
A unique pointer to the reconstructed type

Variable Documentation

◆ PEEL_TO_INNERMOST_ELEMENT_FOLLOW_ONLY_OUTER_PTR

int sdfg::types::PEEL_TO_INNERMOST_ELEMENT_FOLLOW_ONLY_OUTER_PTR = -100
inlineconstexpr

Special value indicating to follow only an outermost pointer when peeling.