docc 0.8.3 (0d44999b)
C++ API Reference
Loading...
Searching...
No Matches
structure.h
Go to the documentation of this file.
1
8
9#pragma once
10
11#include <cassert>
12#include <string>
13#include <vector>
14
15#include "sdfg/types/type.h"
16
17namespace sdfg {
18
19namespace types {
20
21class Scalar;
22
23namespace builder {
24class FunctionBuilder;
25} // namespace builder
26
37class Structure : public IType {
38private:
39 std::string name_;
40
41public:
46 Structure(const std::string& name);
47
55 Structure(StorageType storage_type, size_t alignment, const std::string& initializer, const std::string& name);
56
61 virtual PrimitiveType primitive_type() const override;
62
64 virtual TypeID type_id() const override;
65
70 virtual bool is_symbol() const override;
71
76 const std::string& name() const;
77
79 virtual bool operator==(const IType& other) const override;
80
82 virtual std::unique_ptr<IType> clone() const override;
83
85 virtual std::string print() const override;
86
94 bool is_pointer_like() const override;
95
103 virtual void
104 replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override {
105 }
106 virtual void replace_symbols(const symbolic::ExpressionMapping& replacements) override {
107 }
108};
109
121private:
122 std::string name_;
123 bool is_packed_;
124 std::vector<std::unique_ptr<IType>> members_;
125
126public:
132 StructureDefinition(const std::string& name, bool is_packed);
133
138 std::unique_ptr<StructureDefinition> clone() const;
139
144 const std::string& name() const;
145
150 bool is_packed() const;
151
156 size_t num_members() const;
157
164
170
179 bool is_vector() const;
180
187
193 const size_t vector_size() const;
194
202 static const Structure&
204
212 void replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression);
214};
215
216} // namespace types
217} // namespace sdfg
Definition function_builder.h:12
Abstract base interface for all types in the sdfglib type system.
Definition type.h:625
IType(StorageType storage_type=StorageType::CPU_Stack(), size_t alignment=0, const std::string &initializer="")
Constructs an IType with optional storage, alignment, and initializer.
Definition type.h:638
StorageType storage_type() const
Gets the storage type (const version).
Definition type.h:651
std::string initializer() const
Gets the initializer expression.
Definition type.h:683
size_t alignment() const
Gets the alignment requirement in bytes.
Definition type.h:673
Represents a scalar primitive type.
Definition scalar.h:27
Represents the storage location and management characteristics of data.
Definition type.h:64
size_t num_members() const
Gets the number of members in this structure.
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.
const IType & member_type(symbolic::Integer index) const
Gets the type of a member at the specified index.
bool is_packed() const
Checks if this structure is packed.
const std::string & name() const
Gets the name of this structure.
const size_t vector_size() const
Gets the size of a vector structure.
bool is_vector() const
Checks if this structure represents a SIMD vector type.
StructureDefinition(const std::string &name, bool is_packed)
Constructs a StructureDefinition with the specified name and packing.
void replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression)
Replace symbolic expressions on the members.
void add_member(const IType &member_type)
Adds a member to this structure.
std::unique_ptr< StructureDefinition > clone() const
Creates a deep copy of this structure definition.
const Scalar & vector_element_type() const
Gets the element type of a vector structure.
void replace_symbols(const symbolic::ExpressionMapping &replacements)
Represents a structure type (similar to C struct).
Definition structure.h:37
virtual std::string print() const override
Returns a string representation of this structure type.
Structure(const std::string &name)
Constructs a Structure with the specified name.
virtual bool operator==(const IType &other) const override
Compares this structure with another type for equality.
virtual std::unique_ptr< IType > clone() const override
Creates a deep copy of this structure type.
Structure(StorageType storage_type, size_t alignment, const std::string &initializer, const std::string &name)
Constructs a Structure with explicit storage, alignment, initializer, and name.
virtual bool is_symbol() const override
Structures are not symbolic types.
virtual TypeID type_id() const override
Returns TypeID::Structure.
virtual void replace_symbols(const symbolic::ExpressionMapping &replacements) override
Definition structure.h:106
const std::string & name() const
Gets the name of this structure type.
virtual void replace_symbols(const symbolic::Expression old_expression, const symbolic::Expression new_expression) override
Replace symbolic expressions on this type.
Definition structure.h:104
virtual PrimitiveType primitive_type() const override
Returns the primitive type (implementation-defined for structures).
bool is_pointer_like() const override
Checks if this structure behaves like a pointer.
SymEngine::RCP< const SymEngine::Basic > Expression
Reference-counted pointer to a symbolic expression (SymEngine Basic).
Definition symbolic.h:83
SymEngine::RCP< const SymEngine::Integer > Integer
Reference-counted pointer to a SymEngine Integer constant.
Definition symbolic.h:77
SymEngine::map_basic_basic ExpressionMapping
Definition symbolic.h:109
Definition structure.h:23
Definition symbolic.h:57
PrimitiveType
Enumeration of all primitive data types supported by sdfglib.
Definition type.h:35
TypeID
Enumeration of high-level type categories.
Definition type.h:607
Definition analysis.h:7
Core type system definitions for sdfglib.