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

Defines the layout and members of a structure type. More...

#include <sdfg/types/structure.h>

Public Member Functions

 StructureDefinition (const std::string &name, bool is_packed)
 Constructs a StructureDefinition with the specified name and packing.
std::unique_ptr< StructureDefinition > clone () const
 Creates a deep copy of this structure definition.
const std::string & name () const
 Gets the name of this structure.
bool is_packed () const
 Checks if this structure is packed.
size_t num_members () const
 Gets the number of members in this structure.
const IType & member_type (symbolic::Integer index) const
 Gets the type of a member at the specified index.
void add_member (const IType &member_type)
 Adds a member to this structure.
bool is_vector () const
 Checks if this structure represents a SIMD vector type.
const Scalar & vector_element_type () const
 Gets the element type of a vector structure.
const size_t vector_size () const
 Gets the size of a vector structure.
void replace_symbols (const symbolic::Expression old_expression, const symbolic::Expression new_expression)
 Replace symbolic expressions on the members.
void replace_symbols (const symbolic::ExpressionMapping &replacements)

Static Public Member Functions

static const Structure & create_vector_type (const builder::FunctionBuilder &builder, const Scalar &element_type, size_t vector_size)
 Creates or retrieves a vector type structure.

Detailed Description

Defines the layout and members of a structure type.

StructureDefinition contains the complete definition of a structure, including all member types in order and layout information (packed vs. unpacked).

This class also supports creating and identifying SIMD vector types, which are represented as structures with homogeneous scalar members.

Constructor & Destructor Documentation

◆ StructureDefinition()

sdfg::types::StructureDefinition::StructureDefinition ( const std::string & name,
bool is_packed )

Constructs a StructureDefinition with the specified name and packing.

Parameters
nameThe name of the structure
is_packedWhether the structure should be packed (no padding between members)

Member Function Documentation

◆ add_member()

void sdfg::types::StructureDefinition::add_member ( const IType & member_type)

Adds a member to this structure.

Parameters
member_typeThe type of the member to add

◆ clone()

std::unique_ptr< StructureDefinition > sdfg::types::StructureDefinition::clone ( ) const

Creates a deep copy of this structure definition.

Returns
A unique pointer to a new StructureDefinition with the same properties

◆ create_vector_type()

const Structure & sdfg::types::StructureDefinition::create_vector_type ( const builder::FunctionBuilder & builder,
const Scalar & element_type,
size_t vector_size )
static

Creates or retrieves a vector type structure.

Parameters
builderThe function builder context
element_typeThe scalar type of vector elements
vector_sizeThe number of elements in the vector
Returns
A const reference to the Structure representing the vector type

◆ is_packed()

bool sdfg::types::StructureDefinition::is_packed ( ) const

Checks if this structure is packed.

Returns
true if the structure is packed, false otherwise

◆ is_vector()

bool sdfg::types::StructureDefinition::is_vector ( ) const

Checks if this structure represents a SIMD vector type.

A structure is considered a vector if all its members are scalar types of the same primitive type.

Returns
true if this is a vector type, false otherwise

◆ member_type()

const IType & sdfg::types::StructureDefinition::member_type ( symbolic::Integer index) const

Gets the type of a member at the specified index.

Parameters
indexThe zero-based index of the member
Returns
A const reference to the member's type

◆ name()

const std::string & sdfg::types::StructureDefinition::name ( ) const

Gets the name of this structure.

Returns
A const reference to the structure name

◆ num_members()

size_t sdfg::types::StructureDefinition::num_members ( ) const

Gets the number of members in this structure.

Returns
The number of members

◆ replace_symbols() [1/2]

void sdfg::types::StructureDefinition::replace_symbols ( const symbolic::Expression old_expression,
const symbolic::Expression new_expression )

Replace symbolic expressions on the members.

Parameters
old_expressionExpression to replace
new_expressionReplacement expression

Replaces occurrences of symbolic expressions on the member types.

◆ replace_symbols() [2/2]

void sdfg::types::StructureDefinition::replace_symbols ( const symbolic::ExpressionMapping & replacements)

◆ vector_element_type()

const Scalar & sdfg::types::StructureDefinition::vector_element_type ( ) const

Gets the element type of a vector structure.

Returns
A const reference to the scalar element type
Precondition
is_vector() must return true

◆ vector_size()

const size_t sdfg::types::StructureDefinition::vector_size ( ) const

Gets the size of a vector structure.

Returns
The number of elements in the vector
Precondition
is_vector() must return true

The documentation for this class was generated from the following file: