OpenVDB 13.0.0

Loading...
Searching...
No Matches
Value Class Reference

Intermediate representation wrapper for supported value types in AX as immutable instances. More...

`#include <openvdb_ax/codegen/Value.h>`

## Public Member Functions
| Value (llvm::Value *val, llvm::Type *utype)
| Create a Value with a provided underlying type.
| Value (llvm::Constant *costant)
| Initialize from a constant value.
| Value (const Value &)=default
| Value (Value &&)=default
Value & | operator= (const Value &)=default
Value & | operator= (Value &&)=default
Value | Zero () const
| Create a new zero scalar Value using the underlying scalar precision of this Value. Does not generate IR, however will return an invalid constant if this Value is a string.
Value | One () const
| Create a new one scalar Value using the underlying scalar precision of this Value. Does not generate IR, however will return an invalid constant if this Value is a string.
| operator bool () const
| Check if this Value contains an active underlying llvm Value/Type. When asserts are enabled. This method strictly checks all possible valid combination types of a Value.
bool | operator! () const
| See bool operator.
bool | IsVoid () const
| Return true if this value represents a void type. This is typically only possible for void function returns.
bool | IsBool () const
| Return true if the underlying type is a bool type.
bool | IsScalar () const
| Return true if the underlying type is a scalar type (bool, int or float).
bool | IsInteger () const
| Return true if the underlying type is an integer type.
bool | IsFloat () const
| Return true if the underlying type is an floating point type (float or double).
bool | IsArray () const
| Return true if the underlying type is an array type.
bool | IsVector () const
| Return true if the underlying type is an vector 2/3/4 type.
bool | IsMatrix () const
| Return true if the underlying type is an matrix 3/4 type.
bool | IsString () const
| Return true if the underlying type is a string type.
bool | IsPtr () const
| Return true if this Value is a pointer type.
bool | IsConstant () const
| Return true if this Value is a constant.
size_t | GetArrayNumElements () const
| Return the number of elements in this array type.
Value | IsNan (llvm::IRBuilder<> &B) const
| Emit IR to check whether this value is NaN. Only works on Float types and will generate invalid IR if this Value is not a Float instance.
Value | Load (llvm::IRBuilder<> &B) const
| Emit IR to load the current value. Not typically required to call directly. Will generate invalid IR if this Value is not a Ptr.
Value | LoadIfPtr (llvm::IRBuilder<> &B) const
| Emit IR to load the current value if it is a ptr. Not typically required to call directly.
Value | GetArrayElement (llvm::IRBuilder<> &B, Value idx) const
| Emit IR to return a scalar at the provided index from this array value. Will generate invalid IR if this Value is not an array or if idx is not an integer.
Value | GetArrayElement (llvm::IRBuilder<> &B, uint64_t idx) const
| Emit IR to return a scalar at the provided index from this array value. Will generate invalid IR if this Value is not an array.
void | ArrayToScalars (llvm::IRBuilder<> &B, std::vector< Value > &elements, const bool load=false) const
| Emit IR to extract scalar values from the elements in this array and populate the provided vector with them. The scalars are additionally loaded if load is true. Will generate invalid IR if this is not an array.
Value | ScalarToArray (llvm::IRBuilder<> &B, size_t size) const
| Emit IR to broadcast this scalar to a new array. Will generated invalid IR if this is not a scalar or if size is zero.
Value | ScalarToIdentMatrix3 (llvm::IRBuilder<> &B) const
| Emit IR to create a new 3x3 matrix from this scalar value, adhering to scalar->matrix promotion rules. Will generate invalid IR if this is not a scalar value.
Value | ScalarToIdentMatrix4 (llvm::IRBuilder<> &B) const
| Emit IR to create a new 4x4 matrix from this scalar value, adhering to scalar->matrix promotion rules. Will generate invalid IR if this is not a scalar value.
Value | ScalarBoolComparison (llvm::IRBuilder<> &B) const
| Emit IR to perform standard boolean comparison on this scalar i.e. bool(scalar) or bool(scalar == 0). Returns a Value of type bool. Will return Value::Invalid() if this is not a bool/int/float.
Value | Select (llvm::IRBuilder<> &B, const Value &trueval, const Value &falseval) const
| Emit IR to select a value based on this boolean scalar value. Will generate invalid IR if this is not a boolean value, or if trueval and falseval have different types.
Value | CastToPrecision (llvm::IRBuilder<> &B, llvm::Type *precision) const
| Emit IR to cast this scalar or array to a new value of the provided scalar precision. Returns a new value of the same class type (scalar or array) but with a new precision. Will generate invalid IR if the precision is not an integer or floating point precision type. If this is not an array or scalar, no IR is emitted and Value::Invalid() is returned. Additionally, if the provided precision is the same as this scalar/array's underlying precision, no IR is emitted and no new value is created.
Value | Not (llvm::IRBuilder<> &B, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to create a unary not instruction on this scalar or integer array (i.e. !value). If the value is not a int/float/integer array, no IR is emitted, a warning is logged (if a logger is provided) and Value::Invalid is returned.
Value | BitNot (llvm::IRBuilder<> &B, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to create a unary not instruction on this integer or integer array (i.e. ~value). If the value is not a int/integer array, no IR is emitted, a warning is logged (if a logger is provided) and Value::Invalid is returned.
Value | Negate (llvm::IRBuilder<> &B, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to create a unary not instruction on this scalar or array (i.e. -value). If the value is not a int/float/array, no IR is is emitted, a warning is logged (if a logger is provided) and Value::Invalid is returned.
Value | Increment (llvm::IRBuilder<> &B, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to increment this scalar (i.e. value + 1). Will return Value::Invalid() and report a message to a logger (if provided) if this is not an integer (non-bool) or float scalar.
Value | Decrement (llvm::IRBuilder<> &B, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to increment this scalar (i.e. value - 1). Will return Value::Invalid() and report a message to a logger (if provided) if this is not an integer (non-bool) or float scalar.
Value | Binary (llvm::IRBuilder<> &B, Value rhs, const ast::tokens::OperatorToken &op, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a binary operation on this LHS value and a provided RHS value. If the operation is not a valid binary operation, Value::Invalid() is returned. Defer to the explicit binary methods on this class for more details.
Value | And (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a && operation on two scalars. Assumes both inputs are scalars (this checking is currently done in the ComputeGenerator) and will cause undefined behaviour if they are not.
Value | Or (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a || operation on two scalars. Assumes both inputs are scalars (this checking is currently done in the ComputeGenerator) and will cause undefined behaviour if they are not.
Value | Add (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a + operation on two values.
Value | Subtract (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a - operation on two values.
Value | Multiply (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a * operation on two values.
Value | Divide (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a / operation on two values If the denominator is constant and zero, returns Value::Invalid().
Value | Modulo (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a FLOORED % operation on two values.
Value | TruncatedModulo (llvm::IRBuilder<> &B, Value rhs) const
| Emit IR to perform a TRUNCATED % operation on two values.
Value | Equals (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a == operation on two values.
Value | NotEquals (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a != operation on two values.
Value | GreaterThan (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a > operation on two values.
Value | GreaterThanEquals (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a >= operation on two values.
Value | LessThan (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a < operation on two values.
Value | LessThanEquals (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a <= operation on two values.
Value | ShiftLeft (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a << operation. Both values must be integers.
Value | ShiftRight (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a >> operation. Both values must be integers.
Value | BitAnd (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a & operation. Both values must be integers.
Value | BitOr (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a | operation. Both values must be integers.
Value | BitXor (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to perform a ^ operation. Both values must be integers.
Value | Assign (llvm::IRBuilder<> &B, Value rhs, Logger *log=nullptr, const ax::ast::Node *node=nullptr) const
| Emit IR to assign the provided rhs to this value.
void | Print () const
| Dump this value/type to llvm::errs.
llvm::Value * | GetValue () const
| Access the underlying llvm Value.
llvm::Type * | GetUnderlyingType () const
| Access the underlying llvm Type.
llvm::Type * | GetUnderlyingScalarType () const
| Access the underlying scalar type. This method assumes the current value is a scalar or array.

## Static Public Member Functions
static Value | Invalid ()
| Return an invalid Value. This is used to represent various fail cases. Note that the operator bool(Value) will return false in for Value::Invalid.
template<typename ValueType>
static Value | Create (llvm::LLVMContext &C, const ValueType &value)
| Create an arithmetic literal.
static Value | Return (llvm::IRBuilder<> &B, Value *ret=nullptr)
| Create a value that represents a return value from a function. Really only intended to be used by the function framework. If ret is not provided, a void return is created.
static bool | Supports (llvm::Type *utype)
| Return true if the underlying type held by utype is supported via the interface of this Value class.
static Value | Alloc (llvm::IRBuilder<> &B, llvm::Type *type, llvm::Value *size=nullptr)
| Emit IR inserting an allocation at the front of the BasicBlock pointed to by the provided IRBuilder. The type is expected to be a supported utype.
static Value | ScalarsToArray (llvm::IRBuilder<> &B, const std::vector< Value > &values)
| Emit IR to create an array from a set of scalar values. Will generate invalid IR if the values are not all scalar or are of different precision. values cannot be empty.

## Detailed Description

Intermediate representation wrapper for supported value types in AX as immutable instances.

This class allows you to generate LLVM IR for common operations supported by the AX grammar whilst abstracting away a lot of the complexity of the underlying LLVM state. This class is not meant as a definitive representation of all possible LLVM IR instructions that can be emitted, more as a strict helper translation layer for some supported AX instructions to LLVM IR. More generally, this is intended to be used for all arithmetic operations and less so for program control flow (branches, loops, etc). Importantly, this class abstracts away the concept of ptr/loaded instructions. That is, users of this API usually do not need to worry about explicitly loading or querying the state of LLVM IR allocations when calling methods. Instances of Value types also ensure that the required underlying type information is retained, necessary from LLVM 15 onwards (due to the introduction of LLVM's opaque ptr changes).

The subset of possible types this class supports are

- void types (for function returns)
- AX scalar values (bool, ints, floats)
- AX array values (element types of ints or floats)
- AX string values

Note that a Value can have a variety of arithmetic type/precision states. The API of this class does not guaranteed compatibility between all states. Some failure cases may report a log message and return Value::Invalid() or generate invalid IR/result in undefined behaviour if the inputs are not correct. Refer to individual API methods for more details.

## Constructor & Destructor Documentation

## ◆ Value() [1/4]

Value | ( | llvm::Value * | val,
|  | llvm::Type * | utype )
| inline

Create a Value with a provided underlying type.

Warning
  This constructor assumes that the underlying type is correct. This cannot be asserted from LLVM 15 onwards. This should be used sparingly and currently only exists to support some holes in the compute generator. This constructor should eventually be removed as these get closed, in favour of the static create/alloc methods.

## ◆ Value() [2/4]

Value | ( | llvm::Constant * | costant | ) |
| inline explicit

Initialize from a constant value.

## ◆ Value() [3/4]

Value | ( | const Value & |  | ) |
| default

## ◆ Value() [4/4]

Value | ( | Value && |  | ) |
| default

## Member Function Documentation

## ◆ Add()

Value Add | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a + operation on two values.

## ◆ Alloc()

Value Alloc | ( | llvm::IRBuilder<> & | B,
|  | llvm::Type * | type,
|  | llvm::Value * | size = nullptr )
| inline static

Emit IR inserting an allocation at the front of the BasicBlock pointed to by the provided IRBuilder. The type is expected to be a supported utype.

## ◆ And()

Value And | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a && operation on two scalars. Assumes both inputs are scalars (this checking is currently done in the ComputeGenerator) and will cause undefined behaviour if they are not.

Warning
  This does not perform short circuiting. See: ComputeGenerator::visit(const ast::BinaryOperator*)

## ◆ ArrayToScalars()

void ArrayToScalars | ( | llvm::IRBuilder<> & | B,
|  | std::vector< Value > & | elements,
|  | const bool | load = false ) const
| inline

Emit IR to extract scalar values from the elements in this array and populate the provided vector with them. The scalars are additionally loaded if load is true. Will generate invalid IR if this is not an array.

## ◆ Assign()

Value Assign | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to assign the provided rhs to this value.

## ◆ Binary()

Value Binary | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | const ast::tokens::OperatorToken & | op,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a binary operation on this LHS value and a provided RHS value. If the operation is not a valid binary operation, Value::Invalid() is returned. Defer to the explicit binary methods on this class for more details.

Note
  For all methods, performing type promotion/casting where necessary or return Value::Invalid() on incompatible inputs and report a message to the log, if provided.

## ◆ BitAnd()

Value BitAnd | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a & operation. Both values must be integers.

## ◆ BitNot()

Value BitNot | ( | llvm::IRBuilder<> & | B,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to create a unary not instruction on this integer or integer array (i.e. ~value). If the value is not a int/integer array, no IR is emitted, a warning is logged (if a logger is provided) and Value::Invalid is returned.

## ◆ BitOr()

Value BitOr | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a | operation. Both values must be integers.

## ◆ BitXor()

Value BitXor | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a ^ operation. Both values must be integers.

## ◆ CastToPrecision()

Value CastToPrecision | ( | llvm::IRBuilder<> & | B,
|  | llvm::Type * | precision ) const

Emit IR to cast this scalar or array to a new value of the provided scalar precision. Returns a new value of the same class type (scalar or array) but with a new precision. Will generate invalid IR if the precision is not an integer or floating point precision type. If this is not an array or scalar, no IR is emitted and Value::Invalid() is returned. Additionally, if the provided precision is the same as this scalar/array's underlying precision, no IR is emitted and no new value is created.

## ◆ Create()

template<typename ValueType>

Value Create | ( | llvm::LLVMContext & | C,
|  | const ValueType & | value )
| inline static

Create an arithmetic literal.

## ◆ Decrement()

Value Decrement | ( | llvm::IRBuilder<> & | B,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to increment this scalar (i.e. value - 1). Will return Value::Invalid() and report a message to a logger (if provided) if this is not an integer (non-bool) or float scalar.

## ◆ Divide()

Value Divide | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a / operation on two values If the denominator is constant and zero, returns Value::Invalid().

## ◆ Equals()

Value Equals | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a == operation on two values.

## ◆ GetArrayElement() [1/2]

Value GetArrayElement | ( | llvm::IRBuilder<> & | B,
|  | uint64_t | idx ) const
| inline

Emit IR to return a scalar at the provided index from this array value. Will generate invalid IR if this Value is not an array.

## ◆ GetArrayElement() [2/2]

Value GetArrayElement | ( | llvm::IRBuilder<> & | B,
|  | Value | idx ) const
| inline

Emit IR to return a scalar at the provided index from this array value. Will generate invalid IR if this Value is not an array or if idx is not an integer.

## ◆ GetArrayNumElements()

size_t GetArrayNumElements | ( |  | ) | const
| inline

Return the number of elements in this array type.

## ◆ GetUnderlyingScalarType()

llvm::Type * GetUnderlyingScalarType | ( |  | ) | const
| inline

Access the underlying scalar type. This method assumes the current value is a scalar or array.

## ◆ GetUnderlyingType()

llvm::Type * GetUnderlyingType | ( |  | ) | const
| inline

Access the underlying llvm Type.

## ◆ GetValue()

llvm::Value * GetValue | ( |  | ) | const
| inline

Access the underlying llvm Value.

## ◆ GreaterThan()

Value GreaterThan | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a > operation on two values.

## ◆ GreaterThanEquals()

Value GreaterThanEquals | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a >= operation on two values.

## ◆ Increment()

Value Increment | ( | llvm::IRBuilder<> & | B,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to increment this scalar (i.e. value + 1). Will return Value::Invalid() and report a message to a logger (if provided) if this is not an integer (non-bool) or float scalar.

## ◆ Invalid()

Value Invalid | ( |  | ) |
| inline static

Return an invalid Value. This is used to represent various fail cases. Note that the operator bool(Value) will return false in for Value::Invalid.

## ◆ IsArray()

bool IsArray | ( |  | ) | const
| inline

Return true if the underlying type is an array type.

Note
  An array type's state is only ever a pointer to an array allocation

## ◆ IsBool()

bool IsBool | ( |  | ) | const
| inline

Return true if the underlying type is a bool type.

Note
  A bool's underlying state can be either as a pointer or loaded. This method returns true in both instances if the underlying type is a bool.

## ◆ IsConstant()

bool IsConstant | ( |  | ) | const
| inline

Return true if this Value is a constant.

## ◆ IsFloat()

bool IsFloat | ( |  | ) | const
| inline

Return true if the underlying type is an floating point type (float or double).

Note
  A float's underlying state can be either as a pointer or loaded. This method returns true in both instances if the underlying type is a float/double.

## ◆ IsInteger()

bool IsInteger | ( |  | ) | const
| inline

Return true if the underlying type is an integer type.

Note
  A integer's underlying state can be either as a pointer or loaded. This method returns true in both instances if the underlying type is a integer.

## ◆ IsMatrix()

bool IsMatrix | ( |  | ) | const
| inline

Return true if the underlying type is an matrix 3/4 type.

Note
  An matrix type's state is only ever a pointer to a matrix allocation

## ◆ IsNan()

Value IsNan | ( | llvm::IRBuilder<> & | B | ) | const
| inline

Emit IR to check whether this value is NaN. Only works on Float types and will generate invalid IR if this Value is not a Float instance.

## ◆ IsPtr()

bool IsPtr | ( |  | ) | const
| inline

Return true if this Value is a pointer type.

## ◆ IsScalar()

bool IsScalar | ( |  | ) | const
| inline

Return true if the underlying type is a scalar type (bool, int or float).

Note
  A scalar's underlying state can be either as a pointer or loaded. This method returns true in both instances if the underlying type is a scalar.

## ◆ IsString()

bool IsString | ( |  | ) | const
| inline

Return true if the underlying type is a string type.

Note
  An string type's state is only ever a pointer to a string allocation

## ◆ IsVector()

bool IsVector | ( |  | ) | const
| inline

Return true if the underlying type is an vector 2/3/4 type.

Note
  An vector type's state is only ever a pointer to a vector allocation

## ◆ IsVoid()

bool IsVoid | ( |  | ) | const
| inline

Return true if this value represents a void type. This is typically only possible for void function returns.

Note
  Void types are only ever explicitly void, never pointers to void

## ◆ LessThan()

Value LessThan | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a < operation on two values.

## ◆ LessThanEquals()

Value LessThanEquals | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a <= operation on two values.

## ◆ Load()

Value Load | ( | llvm::IRBuilder<> & | B | ) | const
| inline

Emit IR to load the current value. Not typically required to call directly. Will generate invalid IR if this Value is not a Ptr.

Warning
  Should only ever be called for ptrs to scalar types

## ◆ LoadIfPtr()

Value LoadIfPtr | ( | llvm::IRBuilder<> & | B | ) | const
| inline

Emit IR to load the current value if it is a ptr. Not typically required to call directly.

Warning
  Should only ever be called for ptrs to scalar types

## ◆ Modulo()

Value Modulo | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a FLOORED % operation on two values.

## ◆ Multiply()

Value Multiply | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a * operation on two values.

## ◆ Negate()

Value Negate | ( | llvm::IRBuilder<> & | B,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to create a unary not instruction on this scalar or array (i.e. -value). If the value is not a int/float/array, no IR is is emitted, a warning is logged (if a logger is provided) and Value::Invalid is returned.

## ◆ Not()

Value Not | ( | llvm::IRBuilder<> & | B,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to create a unary not instruction on this scalar or integer array (i.e. !value). If the value is not a int/float/integer array, no IR is emitted, a warning is logged (if a logger is provided) and Value::Invalid is returned.

## ◆ NotEquals()

Value NotEquals | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a != operation on two values.

## ◆ One()

Value One | ( |  | ) | const
| inline

Create a new one scalar Value using the underlying scalar precision of this Value. Does not generate IR, however will return an invalid constant if this Value is a string.

## ◆ operator bool()

operator bool | ( |  | ) | const

Check if this Value contains an active underlying llvm Value/Type. When asserts are enabled. This method strictly checks all possible valid combination types of a Value.

## ◆ operator!()

bool operator! | ( |  | ) | const
| inline

See bool operator.

## ◆ operator=() [1/2]

Value & operator= | ( | const Value & |  | ) |
| default

## ◆ operator=() [2/2]

Value & operator= | ( | Value && |  | ) |
| default

## ◆ Or()

Value Or | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a || operation on two scalars. Assumes both inputs are scalars (this checking is currently done in the ComputeGenerator) and will cause undefined behaviour if they are not.

Warning
  This does not perform short circuiting. See: ComputeGenerator::visit(const ast::BinaryOperator*)

## ◆ Print()

void Print | ( |  | ) | const

Dump this value/type to llvm::errs.

## ◆ Return()

Value Return | ( | llvm::IRBuilder<> & | B,
|  | Value * | ret = nullptr )
| inline static

Create a value that represents a return value from a function. Really only intended to be used by the function framework. If ret is not provided, a void return is created.

## ◆ ScalarBoolComparison()

Value ScalarBoolComparison | ( | llvm::IRBuilder<> & | B | ) | const

Emit IR to perform standard boolean comparison on this scalar i.e. bool(scalar) or bool(scalar == 0). Returns a Value of type bool. Will return Value::Invalid() if this is not a bool/int/float.

## ◆ ScalarsToArray()

Value ScalarsToArray | ( | llvm::IRBuilder<> & | B,
|  | const std::vector< Value > & | values )
| inline static

Emit IR to create an array from a set of scalar values. Will generate invalid IR if the values are not all scalar or are of different precision. values cannot be empty.

## ◆ ScalarToArray()

Value ScalarToArray | ( | llvm::IRBuilder<> & | B,
|  | size_t | size ) const
| inline

Emit IR to broadcast this scalar to a new array. Will generated invalid IR if this is not a scalar or if size is zero.

Warning
  This fills the array with the current scalar value. It does NOT do scalar->matrix promotion.

## ◆ ScalarToIdentMatrix3()

Value ScalarToIdentMatrix3 | ( | llvm::IRBuilder<> & | B | ) | const
| inline

Emit IR to create a new 3x3 matrix from this scalar value, adhering to scalar->matrix promotion rules. Will generate invalid IR if this is not a scalar value.

## ◆ ScalarToIdentMatrix4()

Value ScalarToIdentMatrix4 | ( | llvm::IRBuilder<> & | B | ) | const
| inline

Emit IR to create a new 4x4 matrix from this scalar value, adhering to scalar->matrix promotion rules. Will generate invalid IR if this is not a scalar value.

## ◆ Select()

Value Select | ( | llvm::IRBuilder<> & | B,
|  | const Value & | trueval,
|  | const Value & | falseval ) const

Emit IR to select a value based on this boolean scalar value. Will generate invalid IR if this is not a boolean value, or if trueval and falseval have different types.

## ◆ ShiftLeft()

Value ShiftLeft | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a << operation. Both values must be integers.

## ◆ ShiftRight()

Value ShiftRight | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const
| inline

Emit IR to perform a >> operation. Both values must be integers.

## ◆ Subtract()

Value Subtract | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs,
|  | Logger * | log = nullptr,
|  | const ax::ast::Node * | node = nullptr ) const

Emit IR to perform a - operation on two values.

## ◆ Supports()

bool Supports | ( | llvm::Type * | utype | ) |
| inline static

Return true if the underlying type held by utype is supported via the interface of this Value class.

## ◆ TruncatedModulo()

Value TruncatedModulo | ( | llvm::IRBuilder<> & | B,
|  | Value | rhs ) const

Emit IR to perform a TRUNCATED % operation on two values.

## ◆ Zero()

Value Zero | ( |  | ) | const
| inline

Create a new zero scalar Value using the underlying scalar precision of this Value. Does not generate IR, however will return an invalid constant if this Value is a string.