Talvos  0.1
SPIR-V interpreter and dynamic analysis framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | Static Public Member Functions | Private Attributes | Friends | List of all members
talvos::Object Class Reference

This class represents an instruction result. More...

#include <talvos/Object.h>

Public Member Functions

 Object ()
 Create an empty, uninitialized object. More...
 
 Object (const Type *Ty, const uint8_t *Data=nullptr)
 Allocate an object with type Ty. More...
 
template<typename T >
 Object (const Type *Ty, T Value)
 Allocate an object with type Ty, initializing it with Value. More...
 
 ~Object ()
 Destroy this object. More...
 
 Object (const Object &Src)
 Copy-construct a new object, cloning the data from Src. More...
 
Objectoperator= (const Object &Src)
 Copy-assign to this object, cloning the data from Src. More...
 
 Object (Object &&Src) noexcept
 Move-construct an object, taking the data from Src. More...
 
Object extract (const std::vector< uint32_t > &Indices) const
 Extract an element from a composite object. More...
 
template<typename T >
get (uint32_t Element=0) const
 Get the value of this object as a scalar of type T. More...
 
uint8_t * getData ()
 Returns a mutable pointer to the raw data backing this object. More...
 
const uint8_t * getData () const
 Returns an immutable pointer to the raw data backing this object. More...
 
const DescriptorElementgetDescriptorElements () const
 Returns the descriptor array element information. More...
 
const PtrMatrixLayoutgetMatrixLayout () const
 Get the matrix layout for this object. More...
 
const TypegetType () const
 Returns the type of this object. More...
 
void insert (const std::vector< uint32_t > &Indices, const Object &Element)
 Insert the value of Element into a composite object. More...
 
 operator bool () const
 Returns true if this object has been allocated. More...
 
template<typename T >
void set (T Value, uint32_t Element=0)
 Set the value of this object to a scalar of type T. More...
 
void setDescriptorElements (const DescriptorElement *DAE)
 Set the descriptor array elements for this object. More...
 
void setMatrixLayout (const PtrMatrixLayout &ML)
 Set the matrix layout for this object. More...
 
void store (Memory &Mem, uint64_t Address) const
 Store the value of this object to memory at Address. More...
 
void store (Memory &Mem, const Object &Pointer) const
 Store the value of this object to memory at the address in Pointer. More...
 
void zero ()
 Set all of the value bits in this object to zero. More...
 

Static Public Member Functions

static Object load (const Type *Ty, const Memory &Mem, uint64_t Address)
 Create an object of type Ty from the data at Address. More...
 
static Object load (const Type *Ty, const Memory &Mem, const Object &Pointer)
 Create an object of type Ty from the data at the address in Pointer. More...
 

Private Attributes

const TypeTy
 The type of this object. More...
 
uint8_t * Data
 The raw data backing this object. More...
 
PtrMatrixLayout MatrixLayout
 The memory layout of a matrix that this object points to. More...
 
const DescriptorElementDescriptorElements = nullptr
 Descriptor array element information. More...
 

Friends

std::ostream & operator<< (std::ostream &Stream, const Object &O)
 Allow an Object to be inserted into an output stream. More...
 

Detailed Description

This class represents an instruction result.

Instances of this class have a Type and a backing data store.

Definition at line 51 of file Object.h.

Constructor & Destructor Documentation

talvos::Object::Object ( )
inline

Create an empty, uninitialized object.

Definition at line 55 of file Object.h.

talvos::Object::Object ( const Type Ty,
const uint8_t *  Data = nullptr 
)

Allocate an object with type Ty.

If Data is nullptr, the object data will be left uninitialized. Otherwise, the object data will be copied from Data.

Definition at line 22 of file Object.cpp.

template<typename T >
talvos::Object::Object ( const Type Ty,
Value 
)

Allocate an object with type Ty, initializing it with Value.

Ty must be a scalar type, and its size must match sizeof(T).

Definition at line 31 of file Object.cpp.

talvos::Object::~Object ( )

Destroy this object.

Definition at line 38 of file Object.cpp.

talvos::Object::Object ( const Object Src)

Copy-construct a new object, cloning the data from Src.

Definition at line 40 of file Object.cpp.

talvos::Object::Object ( Object &&  Src)
noexcept

Move-construct an object, taking the data from Src.

Definition at line 66 of file Object.cpp.

Member Function Documentation

Object talvos::Object::extract ( const std::vector< uint32_t > &  Indices) const

Extract an element from a composite object.

Returns
a new object with the type and data of the target element.

Definition at line 75 of file Object.cpp.

template<typename T >
T talvos::Object::get ( uint32_t  Element = 0) const

Get the value of this object as a scalar of type T.

The type of this object must be either a scalar or a vector, and the size of the scalar type must match sizeof(T).

Definition at line 97 of file Object.cpp.

uint8_t* talvos::Object::getData ( )
inline

Returns a mutable pointer to the raw data backing this object.

Definition at line 88 of file Object.h.

const uint8_t* talvos::Object::getData ( ) const
inline

Returns an immutable pointer to the raw data backing this object.

Definition at line 91 of file Object.h.

const DescriptorElement * talvos::Object::getDescriptorElements ( ) const

Returns the descriptor array element information.

Definition at line 106 of file Object.cpp.

const PtrMatrixLayout & talvos::Object::getMatrixLayout ( ) const

Get the matrix layout for this object.

Only valid for objects that are pointers to matrix or vector types.

Definition at line 111 of file Object.cpp.

const Type* talvos::Object::getType ( ) const
inline

Returns the type of this object.

Definition at line 101 of file Object.h.

void talvos::Object::insert ( const std::vector< uint32_t > &  Indices,
const Object Element 
)

Insert the value of Element into a composite object.

Definition at line 118 of file Object.cpp.

Object talvos::Object::load ( const Type Ty,
const Memory Mem,
uint64_t  Address 
)
static

Create an object of type Ty from the data at Address.

Definition at line 137 of file Object.cpp.

Object talvos::Object::load ( const Type Ty,
const Memory Mem,
const Object Pointer 
)
static

Create an object of type Ty from the data at the address in Pointer.

Definition at line 146 of file Object.cpp.

talvos::Object::operator bool ( ) const
inline

Returns true if this object has been allocated.

Definition at line 107 of file Object.h.

Object & talvos::Object::operator= ( const Object Src)

Copy-assign to this object, cloning the data from Src.

Definition at line 53 of file Object.cpp.

template<typename T >
void talvos::Object::set ( Value,
uint32_t  Element = 0 
)

Set the value of this object to a scalar of type T.

The type of this object must be either a scalar or a vector, and the size of the scalar type must match sizeof(T).

Definition at line 295 of file Object.cpp.

void talvos::Object::setDescriptorElements ( const DescriptorElement DAE)

Set the descriptor array elements for this object.

Only valid for objects that are pointers to arrays.

Definition at line 304 of file Object.cpp.

void talvos::Object::setMatrixLayout ( const PtrMatrixLayout ML)

Set the matrix layout for this object.

Only valid for objects that are pointers to matrix or vector types.

Definition at line 310 of file Object.cpp.

void talvos::Object::store ( Memory Mem,
uint64_t  Address 
) const

Store the value of this object to memory at Address.

Definition at line 317 of file Object.cpp.

void talvos::Object::store ( Memory Mem,
const Object Pointer 
) const

Store the value of this object to memory at the address in Pointer.

Definition at line 323 of file Object.cpp.

void talvos::Object::zero ( )

Set all of the value bits in this object to zero.

Definition at line 367 of file Object.cpp.

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  Stream,
const Object O 
)
friend

Allow an Object to be inserted into an output stream.

Converts the value of this object to a human readable format.

Definition at line 283 of file Object.cpp.

Member Data Documentation

uint8_t* talvos::Object::Data
private

The raw data backing this object.

Definition at line 143 of file Object.h.

const DescriptorElement* talvos::Object::DescriptorElements = nullptr
private

Descriptor array element information.

Only valid for objects that are pointers to descriptor arrays.

Definition at line 151 of file Object.h.

PtrMatrixLayout talvos::Object::MatrixLayout
private

The memory layout of a matrix that this object points to.

Only valid for objects that are pointers to matrix or vector types.

Definition at line 147 of file Object.h.

const Type* talvos::Object::Ty
private

The type of this object.

Definition at line 142 of file Object.h.