OpenVDB  12.1.0
Public Member Functions | Static Public Member Functions | List of all members
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. More...
 
 Value (llvm::Constant *costant)
 Initialize from a constant value. More...
 
 Value (const Value &)=default
 
 Value (Value &&)=default
 
Valueoperator= (const Value &)=default
 
Valueoperator= (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. More...
 
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. More...
 
 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. More...
 
bool operator! () const
 See bool operator. More...
 
bool IsVoid () const
 Return true if this value represents a void type. This is typically only possible for void function returns. More...
 
bool IsBool () const
 Return true if the underlying type is a bool type. More...
 
bool IsScalar () const
 Return true if the underlying type is a scalar type (bool, int or float). More...
 
bool IsInteger () const
 Return true if the underlying type is an integer type. More...
 
bool IsFloat () const
 Return true if the underlying type is an floating point type (float or double). More...
 
bool IsArray () const
 Return true if the underlying type is an array type. More...
 
bool IsVector () const
 Return true if the underlying type is an vector 2/3/4 type. More...
 
bool IsMatrix () const
 Return true if the underlying type is an matrix 3/4 type. More...
 
bool IsString () const
 Return true if the underlying type is a string type. More...
 
bool IsPtr () const
 Return true if this Value is a pointer type. More...
 
bool IsConstant () const
 Return true if this Value is a constant. More...
 
size_t GetArrayNumElements () const
 Return the number of elements in this array type. More...
 
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. More...
 
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. More...
 
Value LoadIfPtr (llvm::IRBuilder<> &B) const
 Emit IR to load the current value if it is a ptr. Not typically required to call directly. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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() More...
 
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. More...
 
Value TruncatedModulo (llvm::IRBuilder<> &B, Value rhs) const
 Emit IR to perform a TRUNCATED % operation on two values. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
void Print () const
 Dump this value/type to llvm::errs. More...
 
llvm::Value * GetValue () const
 Access the underlying llvm Value. More...
 
llvm::Type * GetUnderlyingType () const
 Access the underlying llvm Type. More...
 
llvm::Type * GetUnderlyingScalarType () const
 Access the underlying scalar type. This method assumes the current value is a scalar or array. More...
 

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. More...
 
template<typename ValueType >
static Value Create (llvm::LLVMContext &C, const ValueType &value)
 Create an arithmetic literal. More...
 
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. More...
 
static bool Supports (llvm::Type *utype)
 Return true if the underlying type held by utype is supported via the interface of this Value class. More...
 
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. More...
 
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. More...
 

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

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 ( 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 ( llvm::Constant *  costant)
inlineexplicit

Initialize from a constant value.

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

Member Function Documentation

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.

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

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.

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*)
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.

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.

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.
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.

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 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.

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.

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.

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

Create an arithmetic literal.

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 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 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 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.

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.

size_t GetArrayNumElements ( ) const
inline

Return the number of elements in this array type.

llvm::Type* GetUnderlyingScalarType ( ) const
inline

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

llvm::Type* GetUnderlyingType ( ) const
inline

Access the underlying llvm Type.

llvm::Value* GetValue ( ) const
inline

Access the underlying llvm Value.

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.

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.

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.

static Value Invalid ( )
inlinestatic

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.

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
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.
bool IsConstant ( ) const
inline

Return true if this Value is a constant.

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.
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.
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
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.

bool IsPtr ( ) const
inline

Return true if this Value is a pointer type.

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.
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
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
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
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.

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.

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
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
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 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 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 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 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 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 ( ) 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
inline

See bool operator.

Value& operator= ( const Value )
default
Value& operator= ( Value &&  )
default
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*)
void Print ( ) const

Dump this value/type to llvm::errs.

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

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.

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.

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

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.

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.
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.

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.

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 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.

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.

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.

static bool Supports ( llvm::Type *  utype)
inlinestatic

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

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

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

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.