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

Abstract base interface for all types in the sdfglib type system. More...

#include <sdfg/types/type.h>

Inheritance diagram for sdfg::types::IType:
[legend]

Public Member Functions

 IType (StorageType storage_type=StorageType::CPU_Stack(), size_t alignment=0, const std::string &initializer="")
 Constructs an IType with optional storage, alignment, and initializer.
virtual ~IType ()=default
 Virtual destructor for proper cleanup of derived classes.
virtual TypeID type_id () const =0
 Returns the TypeID for runtime type identification.
StorageType storage_type () const
 Gets the storage type (const version).
virtual bool is_pointer_like () const =0
 Checks if this is a pointer or a structure behaves like a pointer.
StorageType & storage_type ()
 Gets the storage type (mutable reference).
void storage_type (const StorageType &storage_type)
 Sets the storage type.
size_t alignment () const
 Gets the alignment requirement in bytes.
void alignment (size_t alignment)
 Sets the alignment requirement in bytes.
std::string initializer () const
 Gets the initializer expression.
void initializer (const std::string &initializer)
 Sets the initializer expression.
virtual PrimitiveType primitive_type () const =0
 Returns the primitive type for this type.
virtual bool is_symbol () const =0
 Checks if this type represents a symbolic/integer type.
virtual bool operator== (const IType &other) const =0
 Compares two types for equality.
virtual std::unique_ptr< IType > clone () const =0
 Creates a deep copy of this type.
virtual std::string print () const =0
 Returns a string representation of this type.
virtual void replace_symbols (const symbolic::Expression old_expression, const symbolic::Expression new_expression)=0
 Replace symbolic expressions on this type.
virtual void replace_symbols (const symbolic::ExpressionMapping &replacements)=0

Protected Attributes

StorageType storage_type_
 Where and how the data is stored.
size_t alignment_
 Memory alignment requirement in bytes.
std::string initializer_
 Optional initializer expression.

Friends

std::ostream & operator<< (std::ostream &os, const IType &type)
 Stream output operator for types.

Detailed Description

Abstract base interface for all types in the sdfglib type system.

IType provides the common interface and properties for all type representations in sdfglib. All concrete type classes (Scalar, Array, Pointer, etc.) inherit from this interface.

Constructor & Destructor Documentation

◆ IType()

sdfg::types::IType::IType ( StorageType storage_type = StorageType::CPU_Stack(),
size_t alignment = 0,
const std::string & initializer = "" )
inline

Constructs an IType with optional storage, alignment, and initializer.

Parameters
storage_typeThe storage location and management (default: CPU_Stack)
alignmentMemory alignment in bytes (default: 0 for natural alignment)
initializerOptional initializer expression (default: empty)

◆ ~IType()

virtual sdfg::types::IType::~IType ( )
virtualdefault

Virtual destructor for proper cleanup of derived classes.

Member Function Documentation

◆ alignment() [1/2]

size_t sdfg::types::IType::alignment ( ) const
inline

Gets the alignment requirement in bytes.

◆ alignment() [2/2]

void sdfg::types::IType::alignment ( size_t alignment)
inline

Sets the alignment requirement in bytes.

◆ clone()

virtual std::unique_ptr< IType > sdfg::types::IType::clone ( ) const
pure virtual

Creates a deep copy of this type.

Returns
A unique pointer to a new type object with the same properties

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ initializer() [1/2]

std::string sdfg::types::IType::initializer ( ) const
inline

Gets the initializer expression.

◆ initializer() [2/2]

void sdfg::types::IType::initializer ( const std::string & initializer)
inline

Sets the initializer expression.

◆ is_pointer_like()

virtual bool sdfg::types::IType::is_pointer_like ( ) const
pure virtual

Checks if this is a pointer or a structure behaves like a pointer.

Some structures may have pointer-like semantics in certain contexts.

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ is_symbol()

virtual bool sdfg::types::IType::is_symbol ( ) const
pure virtual

Checks if this type represents a symbolic/integer type.

Symbolic types are integer types that can be used in symbolic expressions and loop bounds.

Returns
true if this is a symbolic integer type, false otherwise

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ operator==()

virtual bool sdfg::types::IType::operator== ( const IType & other) const
pure virtual

Compares two types for equality.

Parameters
otherThe type to compare with
Returns
true if the types are equal, false otherwise

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ primitive_type()

virtual PrimitiveType sdfg::types::IType::primitive_type ( ) const
pure virtual

Returns the primitive type for this type.

For scalar types, this returns the actual primitive type. For composite types (arrays, pointers, etc.), this returns the primitive type of the innermost element.

Returns
The primitive type

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ print()

virtual std::string sdfg::types::IType::print ( ) const
pure virtual

Returns a string representation of this type.

Returns
A human-readable string describing this type

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ replace_symbols() [1/2]

virtual void sdfg::types::IType::replace_symbols ( const symbolic::Expression old_expression,
const symbolic::Expression new_expression )
pure virtual

Replace symbolic expressions on this type.

Parameters
old_expressionExpression to replace
new_expressionReplacement expression

Replaces occurrences of symbolic expressions on the type.

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ replace_symbols() [2/2]

virtual void sdfg::types::IType::replace_symbols ( const symbolic::ExpressionMapping & replacements)
pure virtual

◆ storage_type() [1/3]

StorageType & sdfg::types::IType::storage_type ( )
inline

Gets the storage type (mutable reference).

◆ storage_type() [2/3]

StorageType sdfg::types::IType::storage_type ( ) const
inline

Gets the storage type (const version).

◆ storage_type() [3/3]

void sdfg::types::IType::storage_type ( const StorageType & storage_type)
inline

Sets the storage type.

◆ type_id()

virtual TypeID sdfg::types::IType::type_id ( ) const
pure virtual

Returns the TypeID for runtime type identification.

Returns
The TypeID enum value for this type

Implemented in sdfg::codegen::Reference, sdfg::types::Array, sdfg::types::Function, sdfg::types::Pointer, sdfg::types::Scalar, sdfg::types::Structure, and sdfg::types::Tensor.

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const IType & type )
friend

Stream output operator for types.

Parameters
osThe output stream
typeThe type to output
Returns
The output stream

Member Data Documentation

◆ alignment_

size_t sdfg::types::IType::alignment_
protected

Memory alignment requirement in bytes.

◆ initializer_

std::string sdfg::types::IType::initializer_
protected

Optional initializer expression.

◆ storage_type_

StorageType sdfg::types::IType::storage_type_
protected

Where and how the data is stored.


The documentation for this class was generated from the following file:
  • sdfg/include/sdfg/types/type.h