Jlm
Public Member Functions | Static Public Member Functions | Private Attributes | List of all members
jlm::llvm::StructType Class Referencefinal

StructType class. More...

#include <types.hpp>

Inheritance diagram for jlm::llvm::StructType:
Inheritance graph
[legend]
Collaboration diagram for jlm::llvm::StructType:
Collaboration graph
[legend]

Public Member Functions

 ~StructType () noexcept override
 
 StructType (std::string name, std::vector< std::shared_ptr< const Type >> types, const bool isPacked, const bool isLiteral)
 
 StructType (const StructType &)=delete
 
 StructType (StructType &&)=delete
 
StructTypeoperator= (const StructType &)=delete
 
StructTypeoperator= (StructType &&)=delete
 
bool operator== (const Type &other) const noexcept override
 
std::size_t ComputeHash () const noexcept override
 
rvsdg::TypeKind Kind () const noexcept override
 Return the kind of this type. More...
 
size_t numElements () const noexcept
 
std::shared_ptr< const TypegetElementType (const size_t index) const noexcept
 
std::string debug_string () const override
 
bool HasName () const noexcept
 
const std::string & GetName () const noexcept
 
bool IsPacked () const noexcept
 
bool IsLiteral () const noexcept
 
size_t GetFieldOffset (size_t fieldIndex) const
 
- Public Member Functions inherited from jlm::rvsdg::Type
virtual ~Type () noexcept
 
virtual bool operator== (const jlm::rvsdg::Type &other) const noexcept=0
 
bool operator!= (const jlm::rvsdg::Type &other) const noexcept
 

Static Public Member Functions

static std::shared_ptr< const StructTypeCreateIdentified (const std::string &name, std::vector< std::shared_ptr< const Type >> types, bool isPacked)
 
static std::shared_ptr< const StructTypeCreateIdentified (std::vector< std::shared_ptr< const Type >> types, bool isPacked)
 
static std::shared_ptr< const StructTypeCreateLiteral (std::vector< std::shared_ptr< const Type >> types, bool isPacked)
 

Private Attributes

std::string name_
 
std::vector< std::shared_ptr< const Type > > types_ {}
 
bool isPacked_
 
bool isLiteral_
 

Additional Inherited Members

- Protected Member Functions inherited from jlm::rvsdg::Type
constexpr Type () noexcept
 

Detailed Description

StructType class.

This class is the equivalent of LLVM's StructType class. There are two different kinds of struct types: Literal structs and Identified structs. Literal struct types (e.g., { i32, i32 }) are uniqued structurally. Identified structs (e.g., foo or %42) may optionally have a name and are not uniqued.

Definition at line 183 of file types.hpp.

Constructor & Destructor Documentation

◆ ~StructType()

jlm::llvm::StructType::~StructType ( )
overridedefaultnoexcept

◆ StructType() [1/3]

jlm::llvm::StructType::StructType ( std::string  name,
std::vector< std::shared_ptr< const Type >>  types,
const bool  isPacked,
const bool  isLiteral 
)
inline

Definition at line 188 of file types.hpp.

◆ StructType() [2/3]

jlm::llvm::StructType::StructType ( const StructType )
delete

◆ StructType() [3/3]

jlm::llvm::StructType::StructType ( StructType &&  )
delete

Member Function Documentation

◆ ComputeHash()

std::size_t jlm::llvm::StructType::ComputeHash ( ) const
overridevirtualnoexcept

Computes a hash value for the instance of the type.

Returns
A hash value.

Implements jlm::rvsdg::Type.

Definition at line 206 of file types.cpp.

◆ CreateIdentified() [1/2]

static std::shared_ptr<const StructType> jlm::llvm::StructType::CreateIdentified ( const std::string &  name,
std::vector< std::shared_ptr< const Type >>  types,
bool  isPacked 
)
inlinestatic

Creates an identified struct, with a name. The name should be unique to this struct.

Parameters
namethe name of the struct, or an empty string if the struct is unnamed.
typesthe fields in the struct
isPackedtrue if the struct is packed (no padding or alignment), false otherwise
Returns
the created struct type

Definition at line 296 of file types.hpp.

◆ CreateIdentified() [2/2]

static std::shared_ptr<const StructType> jlm::llvm::StructType::CreateIdentified ( std::vector< std::shared_ptr< const Type >>  types,
bool  isPacked 
)
inlinestatic

Creates an identified struct, without a name.

Parameters
typesthe fields in the struct
isPackedtrue if the struct is packed (no padding or alignment), false otherwise
Returns
the created struct type

Definition at line 311 of file types.hpp.

◆ CreateLiteral()

static std::shared_ptr<const StructType> jlm::llvm::StructType::CreateLiteral ( std::vector< std::shared_ptr< const Type >>  types,
bool  isPacked 
)
inlinestatic

Creates a literal struct, which is anonymous and only identified through its fields.

Parameters
typesthe fields in the struct
isPackedtrue if the struct is packed (no padding or alignment), false otherwise
Returns
the created struct type

Definition at line 323 of file types.hpp.

◆ debug_string()

std::string jlm::llvm::StructType::debug_string ( ) const
overridevirtual

Implements jlm::rvsdg::Type.

Definition at line 229 of file types.cpp.

◆ getElementType()

std::shared_ptr<const Type> jlm::llvm::StructType::getElementType ( const size_t  index) const
inlinenoexcept

Definition at line 225 of file types.hpp.

◆ GetFieldOffset()

size_t jlm::llvm::StructType::GetFieldOffset ( size_t  fieldIndex) const

Gets the position of the given field, as a byte offset from the start of the struct. Non-packed structs use padding to respect the alignment of each field, just like in C. Packed structs have no padding, and no alignment.

Parameters
fieldIndexthe index of the field, must be valid
Returns
the byte offset of the given field

Definition at line 235 of file types.cpp.

◆ GetName()

const std::string& jlm::llvm::StructType::GetName ( ) const
inlinenoexcept

Returns the name of the identified struct. If the struct has no name, an empty string is returned. Must not be called on literal structs.

Precondition
the struct is an identified struct.
Returns
the name of the struct, or an empty string.

Definition at line 255 of file types.hpp.

◆ HasName()

bool jlm::llvm::StructType::HasName ( ) const
inlinenoexcept

Checks if the struct is an identified struct that has a name. Will always return false for literal structs.

Returns
true if the struct has a name, false otherwise.

Definition at line 240 of file types.hpp.

◆ IsLiteral()

bool jlm::llvm::StructType::IsLiteral ( ) const
inlinenoexcept

Struct types can either be literal or identified. Literal structs are defined only through their fields, and can not have names.

Returns
true if this struct type is literal, false if it is identified.

Definition at line 273 of file types.hpp.

◆ IsPacked()

bool jlm::llvm::StructType::IsPacked ( ) const
inlinenoexcept

Definition at line 262 of file types.hpp.

◆ Kind()

rvsdg::TypeKind jlm::llvm::StructType::Kind ( ) const
overridevirtualnoexcept

Return the kind of this type.

Implements jlm::rvsdg::Type.

Definition at line 223 of file types.cpp.

◆ numElements()

size_t jlm::llvm::StructType::numElements ( ) const
inlinenoexcept

Definition at line 219 of file types.hpp.

◆ operator=() [1/2]

StructType& jlm::llvm::StructType::operator= ( const StructType )
delete

◆ operator=() [2/2]

StructType& jlm::llvm::StructType::operator= ( StructType &&  )
delete

◆ operator==()

bool jlm::llvm::StructType::operator== ( const Type other) const
overridenoexcept

Definition at line 189 of file types.cpp.

Member Data Documentation

◆ isLiteral_

bool jlm::llvm::StructType::isLiteral_
private

Definition at line 333 of file types.hpp.

◆ isPacked_

bool jlm::llvm::StructType::isPacked_
private

Definition at line 332 of file types.hpp.

◆ name_

std::string jlm::llvm::StructType::name_
private

Definition at line 330 of file types.hpp.

◆ types_

std::vector<std::shared_ptr<const Type> > jlm::llvm::StructType::types_ {}
private

Definition at line 331 of file types.hpp.


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