OpenVDB: openvdb::v11_0::ax::codegen Namespace Reference

OpenVDB 11.0.0

Loading...
Searching...
No Matches
Namespaces | Classes | Typedefs | Functions
openvdb::v11_0::ax::codegen Namespace Reference

## Namespaces
namespace | codegen_internal

## Classes
struct | AliasTypeMap
| Alias mapping between two types, a frontend type T1 and a backend type T2. This class is the intended interface for binding objects which implement supported backend AX/IR types to this given backend type. More specifically, it's current and expected usage is limited to objects which hold a single member of a supported backend type and implements a StandardLayoutType as defined by the standard. Fundamentally, T1->T2 mapping should be supported by reinterpret_cast<> as defined by the type aliasing rules. More...
struct | ArgType
| Object to array conversion methods to allow functions to return vector types. These containers provided an interface for automatic conversion of C++ objects to LLVM types as array types. More...
struct | ArgumentIterator
| Templated argument iterator which implements various small functions per argument type, resolved at compile time. More...
struct | ArgumentIterator< SignatureT, 0 >
struct | CFunction
| Represents a concrete C function binding. More...
struct | CFunctionBase
| The base class for all C bindings. More...
struct | CFunctionSRet
| Represents a concrete C function binding with the first argument as its return type. More...
class | Codec
struct | ComputeKernel
| The function definition and signature which is built by the ComputeGenerator. More...
struct | ConstantFolder
| Constant folding support structure. More...
struct | ConstantFolder< SignatureT, 0 >
struct | Function
| The base/abstract representation of an AX function. Derived classes must implement the Function::types call to describe their signature. More...
struct | FunctionBuilder
| The FunctionBuilder class provides a builder pattern framework to allow easy and valid construction of AX functions. There are a number of complex tasks which may need to be performed during construction of C or IR function which are delegated to this builder, whilst ensuring that the constructed functions are guaranteed to be valid. More...
struct | FunctionGroup
| todo More...
class | FunctionRegistry
| The function registry which is used for function code generation. Each time a function is visited within the AST, its identifier is used as a key into this registry for the corresponding function retrieval and execution. Functions can be inserted into the registry using insert() with a given identifier and pointer. More...
struct | FunctionTraits
| Templated function traits which provides compile-time index access to the types of the function signature. More...
struct | FunctionTraits< R(&)(Args...)>
struct | FunctionTraits< R(*)(Args...)>
struct | FunctionTraits< ReturnT(Args...)>
struct | int_t
struct | int_t< 16 >
struct | int_t< 32 >
struct | int_t< 64 >
struct | int_t< 8 >
struct | IRFunction
| Represents a concrete IR function. More...
struct | IRFunctionBase
| The base/abstract definition for an IR function. More...
struct | IRFunctionSRet
| Represents a concrete IR function with the first argument as its return type. More...
struct | LLVMType
| LLVM type mapping from pod types. More...
struct | LLVMType< ArgType< T, S > >
struct | LLVMType< char >
struct | LLVMType< codegen::String >
struct | LLVMType< const T * >
struct | LLVMType< const T >
struct | LLVMType< openvdb::math::half >
struct | LLVMType< openvdb::math::Mat3< T > >
struct | LLVMType< openvdb::math::Mat4< T > >
struct | LLVMType< openvdb::math::Vec2< T > >
| Supported aliasing for VDB math types, allowing use in external function signatures. More...
struct | LLVMType< openvdb::math::Vec3< T > >
struct | LLVMType< openvdb::math::Vec4< T > >
struct | LLVMType< T * >
struct | LLVMType< T[S]>
struct | LLVMType< void * >
struct | LLVMType< void >
struct | PointKernelAttributeArray
struct | PointKernelBuffer
struct | PointKernelBufferRange
struct | PointKernelValue
struct | SRetFunction
| Templated interface class for SRET functions. This struct provides the interface for functions that wish to return arrays (vectors or matrices) by internally remapping the first argument for the user. As far as LLVM and any bindings are concerned, the function signature remains unchanged - however the first argument becomes "invisible" to the user and is instead allocated by LLVM before the function is executed. Importantly, the argument has no impact on the user facing AX signature and doesn't affect declaration selection. More...
struct | String
| An extremely basic but native representation of a string class with SSO support. This exists to provide an interface between the AX C++ API and backend IR string logic. It is not designed to fulfill any other use and should very rarely be used directly. More...
struct | SymbolTable
| A symbol table which can be used to represent a single scoped set of a programs variables. This is simply an unordered map of strings to llvm::Values. More...
struct | SymbolTableBlocks
| A map of unique ids to symbol tables which can be used to represent local variables within a program. New scopes can be added and erased where necessary and iterated through using find(). Find assumes that tables are added through parented ascending ids. More...
struct | TypeToSymbol
| Type to symbol conversions - these characters are used to build each functions unique signature. They differ from standard AX or LLVM syntax to be as short as possible i.e. vec4d, [4 x double] = d4. More...
struct | TypeToSymbol< ArgType< T, S > >
struct | TypeToSymbol< char >
struct | TypeToSymbol< codegen::String >
struct | TypeToSymbol< const T * >
struct | TypeToSymbol< const T >
struct | TypeToSymbol< double >
struct | TypeToSymbol< float >
struct | TypeToSymbol< int16_t >
struct | TypeToSymbol< int32_t >
struct | TypeToSymbol< int64_t >
struct | TypeToSymbol< int8_t >
struct | TypeToSymbol< math::Mat3< T > >
struct | TypeToSymbol< math::Mat4< T > >
struct | TypeToSymbol< math::Vec2< T > >
struct | TypeToSymbol< math::Vec3< T > >
struct | TypeToSymbol< math::Vec4< T > >
struct | TypeToSymbol< T * >
struct | TypeToSymbol< T[S]>
struct | TypeToSymbol< uint16_t >
struct | TypeToSymbol< uint32_t >
struct | TypeToSymbol< uint64_t >
struct | TypeToSymbol< uint8_t >
struct | TypeToSymbol< void >
struct | VolumeKernelBuffer
| The second volume kernel, responsible for providing the core layer of SIMD optimisations by invoking this kernel across a range of values. More...
struct | VolumeKernelNode
| The third volume kernel, providing an agnostic way to modify a single tile value without passing through the buffer states. Note that this kernel is mainly utility and one of the value kernels should almost always be preferred. More...
struct | VolumeKernelValue
| The primary volume kernel. This function holds the generated body of AX programs. More...

## Typedefs
using | CodecNameMap = std::map<const std::string, const Codec*>
using | CodecTypeMap = std::map<const ast::tokens::CoreType, CodecNameMap>
using | Codecs = std::vector<const Codec*>
using | V2D = ArgType<double, 2>
using | V2F = ArgType<float, 2>
using | V2I = ArgType<int32_t, 2>
using | V3D = ArgType<double, 3>
using | V3F = ArgType<float, 3>
using | V3I = ArgType<int32_t, 3>
using | V4D = ArgType<double, 4>
using | V4F = ArgType<float, 4>
using | V4I = ArgType<int32_t, 4>
using | M3D = ArgType<double, 9>
using | M3F = ArgType<float, 9>
using | M4D = ArgType<double, 16>
using | M4F = ArgType<float, 16>
using | CastFunction
using | BinaryFunction

## Functions
OPENVDB_AX_API const CodecTypeMap & | getCodecTypeMap ()
| Get the global codec map.
OPENVDB_AX_API const Codec * | getCodec (const ast::tokens::CoreType type, const std::string &name)
| Get a specific codec. Returns a nullptr if no codec exists.
OPENVDB_AX_API const CodecNameMap * | getTypeSupportedCodecs (const ast::tokens::CoreType type)
| Get a specific set of codecs which encode a given type. Returns a nullptr if no codec exists.
FunctionRegistry::UniquePtr | createDefaultRegistry (const FunctionOptions *op=nullptr)
| Creates a registry with the default set of registered functions including math functions, point functions and volume functions.
OPENVDB_AX_API void | insertStandardFunctions (FunctionRegistry &reg, const FunctionOptions *options=nullptr)
| Populates a function registry with all available "standard" AX library function. This primarily consists of all mathematical ops on AX containers (scalars, vectors, matrices) and other stl built-ins.
OPENVDB_AX_API void | insertVDBPointFunctions (FunctionRegistry &reg, const FunctionOptions *options=nullptr)
| Populates a function registry with all available OpenVDB Point AX library function.
OPENVDB_AX_API void | insertVDBVolumeFunctions (FunctionRegistry &reg, const FunctionOptions *options=nullptr)
| Populates a function registry with all available OpenVDB Volume AX library function.
template<typename SignatureT >
llvm::Type * | llvmTypesFromSignature (llvm::LLVMContext &C, std::vector< llvm::Type * > *types=nullptr)
| Populate a vector of llvm types from a function signature declaration.
template<typename SignatureT >
llvm::FunctionType * | llvmFunctionTypeFromSignature (llvm::LLVMContext &C)
| Generate an LLVM FunctionType from a function signature.
OPENVDB_AX_API void | printSignature (std::ostream &os, const std::vector< llvm::Type * > &types, const llvm::Type *returnType, const char *name=nullptr, const std::vector< const char * > &names={}, const bool axTypes=false)
| Print a function signature to the provided ostream.
template<typename T >
llvm::Constant * | llvmConstant (const T t, llvm::Type *type)
| Returns an llvm Constant holding a scalar value.
OPENVDB_AX_API llvm::IntegerType * | llvmIntType (const uint32_t size, llvm::LLVMContext &C)
| Returns an llvm IntegerType given a requested size and context.
OPENVDB_AX_API llvm::Type * | llvmFloatType (const uint32_t size, llvm::LLVMContext &C)
| Returns an llvm floating point Type given a requested size and context.
OPENVDB_AX_API llvm::Type * | llvmTypeFromToken (const ast::tokens::CoreType &type, llvm::LLVMContext &C)
| Returns an llvm type representing a type defined by a string.
OPENVDB_AX_API ast::tokens::CoreType | tokenFromLLVMType (const llvm::Type *type)
| Return a corresponding AX token which represents the given LLVM Type.
auto | ir_load (llvm::IRBuilder<> &B, llvm::Value *ptr, const char *Name="")
| Alias around IR load inst.
auto | ir_gep (llvm::IRBuilder<> &B, llvm::Value *ptr, llvm::ArrayRef< llvm::Value * > IdxList, const char *Name="")
| Alias around IR gep inst.
auto | ir_constgep2_64 (llvm::IRBuilder<> &B, llvm::Value *ptr, uint64_t Idx0, uint64_t Idx1, const char *Name="")
| Alias around IR gep2_64 inst.
auto | ir_constinboundsgep2_64 (llvm::IRBuilder<> &B, llvm::Value *ptr, uint64_t Idx0, uint64_t Idx1, const char *Name="")
| Alias around IR in bounds gep2_64 inst.
void | valuesToTypes (const std::vector< llvm::Value * > &values, std::vector< llvm::Type * > &types)
| Populate a vector of llvm Types from a vector of llvm values.
void | llvmTypeToString (const llvm::Type *const type, std::string &str)
| Prints an llvm type to a std string.
llvm::Type * | getBaseContainedType (llvm::Type *const type)
| Return the base llvm value which is being pointed to through any number of layered pointers.
template<typename ValueT >
llvm::Value * | llvmPointerFromAddress (const ValueT *const &ptr, llvm::IRBuilder<> &builder)
| Return an llvm value representing a pointer to the provided ptr builtin ValueT.
llvm::Value * | insertStaticAlloca (llvm::IRBuilder<> &B, llvm::Type *type, llvm::Value *size=nullptr)
| Insert a stack allocation at the beginning of the current function of the provided type and size. The IRBuilder's insertion point must be set to a BasicBlock with a valid Function parent.
llvm::Argument * | extractArgument (llvm::Function *F, const size_t idx)
llvm::Argument * | extractArgument (llvm::Function *F, const std::string &name)
llvm::Type * | typePrecedence (llvm::Type *const typeA, llvm::Type *const typeB)
| Returns the highest order type from two LLVM Scalar types.
CastFunction | llvmArithmeticConversion (const llvm::Type *const sourceType, const llvm::Type *const targetType, const std::string &twine="")
| Returns a CastFunction which represents the corresponding instruction to convert a source llvm Type to a target llvm Type. If the conversion is unsupported, throws an error.
BinaryFunction | llvmBinaryConversion (const llvm::Type *const type, const ast::tokens::OperatorToken &token, const std::string &twine="")
| Returns a BinaryFunction representing the corresponding instruction to perform on two scalar values, relative to a provided operator token. Note that not all operations are supported on floating point types! If the token is not supported, or the llvm type is not a scalar type, throws an error.
bool | isValidCast (llvm::Type *from, llvm::Type *to)
| Returns true if the llvm Type 'from' can be safely cast to the llvm Type 'to'.
llvm::Value * | arithmeticConversion (llvm::Value *value, llvm::Type *targetType, llvm::IRBuilder<> &builder)
| Casts a scalar llvm Value to a target scalar llvm Type. Returns the cast scalar value of type targetType.
llvm::Value * | arrayCast (llvm::Value *ptrToArray, llvm::Type *targetElementType, llvm::IRBuilder<> &builder)
| Casts an array to another array of equal size but of a different element type. Both source and target array element types must be scalar types. The source array llvm Value should be a pointer to the array to cast.
void | arithmeticConversion (std::vector< llvm::Value * > &values, llvm::Type *targetElementType, llvm::IRBuilder<> &builder)
| Converts a vector of loaded llvm scalar values of the same type to a target scalar type. Each value is converted individually and the loaded result stored in the same location within values.
void | arithmeticConversion (std::vector< llvm::Value * > &values, llvm::IRBuilder<> &builder)
| Converts a vector of loaded llvm scalar values to the highest precision type stored amongst them. Any values which are not scalar types are ignored.
void | arithmeticConversion (llvm::Value *&valueA, llvm::Value *&valueB, llvm::IRBuilder<> &builder)
| Chooses the highest order llvm Type as defined by typePrecedence from either of the two incoming values and casts the other value to the choosen type if it is not already. The types of valueA and valueB are guaranteed to match. Both values must be scalar LLVM types.
llvm::Value * | boolComparison (llvm::Value *value, llvm::IRBuilder<> &builder)
| Performs a C style boolean comparison from a given scalar LLVM value.
llvm::Value * | binaryOperator (llvm::Value *lhs, llvm::Value *rhs, const ast::tokens::OperatorToken &token, llvm::IRBuilder<> &builder)
llvm::Value * | arrayIndexUnpack (llvm::Value *ptrToArray, const int16_t index, llvm::IRBuilder<> &builder)
| Unpack a particular element of an array and return a pointer to that element The provided llvm Value is expected to be a pointer to an array.
void | arrayUnpack (llvm::Value *ptrToArray, std::vector< llvm::Value * > &values, llvm::IRBuilder<> &builder, const bool loadElements=false)
| Unpack an array type into llvm Values which represent all its elements The provided llvm Value is expected to be a pointer to an array If loadElements is true, values will store loaded llvm values instead of pointers to the array elements.
void | array3Unpack (llvm::Value *ptrToArray, llvm::Value *&value1, llvm::Value *&value2, llvm::Value *&value3, llvm::IRBuilder<> &builder)
| Unpack the first three elements of an array. The provided llvm Value is expected to be a pointer to an array.
llvm::Value * | array3Pack (llvm::Value *value1, llvm::Value *value2, llvm::Value *value3, llvm::IRBuilder<> &builder)
| Pack three values into a new array and return a pointer to the newly allocated array. If the values are of a mismatching type, the highets order type is uses, as defined by typePrecedence. All llvm values are expected to a be a loaded scalar type.
llvm::Value * | arrayPack (llvm::Value *value, llvm::IRBuilder<> &builder, const size_t size=3)
| Pack a loaded llvm scalar value into a new array of a specified size and return a pointer to the newly allocated array. Each element of the new array will have the value of the given scalar.
llvm::Value * | arrayPack (const std::vector< llvm::Value * > &values, llvm::IRBuilder<> &builder)
| Pack a vector of loaded llvm scalar values into a new array of equal size and return a pointer to the newly allocated array.
llvm::Value * | arrayPackCast (std::vector< llvm::Value * > &values, llvm::IRBuilder<> &builder)
| Pack a vector of loaded llvm scalar values into a new array of equal size and return a pointer to the newly allocated array. arrayPackCast first checks all the contained types in values and casts all types to the highest order type present. All llvm values in values are expected to be loaded scalar types.
llvm::Value * | scalarToMatrix (llvm::Value *scalar, llvm::IRBuilder<> &builder, const size_t dim=3)

## Typedef Documentation

## ◆ BinaryFunction

using BinaryFunction

Initial value:
std::function<llvm::Value*
(llvm::IRBuilder<>&, llvm::Value*, llvm::Value*)>

## ◆ CastFunction

using CastFunction

Initial value:
std::function<llvm::Value*
(llvm::IRBuilder<>&, llvm::Value*, llvm::Type*)>

Note
  Function definitions for some types returned from automatic token to llvm IR operations. See llvmArithmeticConversion and llvmBianryConversion

## ◆ CodecNameMap

using CodecNameMap = std::map<const std::string, const Codec*>

## ◆ Codecs

using Codecs = std::vector<const Codec*>

## ◆ CodecTypeMap

using CodecTypeMap = std::map<const ast::tokens::CoreType, CodecNameMap>

## ◆ M3D

using M3D = ArgType<double, 9>

## ◆ M3F

using M3F = ArgType<float, 9>

## ◆ M4D

using M4D = ArgType<double, 16>

## ◆ M4F

using M4F = ArgType<float, 16>

## ◆ V2D

using V2D = ArgType<double, 2>

## ◆ V2F

using V2F = ArgType<float, 2>

## ◆ V2I

using V2I = ArgType<int32_t, 2>

## ◆ V3D

using V3D = ArgType<double, 3>

## ◆ V3F

using V3F = ArgType<float, 3>

## ◆ V3I

using V3I = ArgType<int32_t, 3>

## ◆ V4D

using V4D = ArgType<double, 4>

## ◆ V4F

using V4F = ArgType<float, 4>

## ◆ V4I

using V4I = ArgType<int32_t, 4>

## Function Documentation

## ◆ arithmeticConversion() [1/4]

void arithmeticConversion | ( | llvm::Value *& | valueA,
|  | llvm::Value *& | valueB,
|  | llvm::IRBuilder<> & | builder )
| inline

Chooses the highest order llvm Type as defined by typePrecedence from either of the two incoming values and casts the other value to the choosen type if it is not already. The types of valueA and valueB are guaranteed to match. Both values must be scalar LLVM types.

Warning
  This assumes any integer types are signed.

Parameters

  valueA | The first llvm value
  valueB | The second llvm value
  builder | The current llvm IRBuilder

## ◆ arithmeticConversion() [2/4]

llvm::Value * arithmeticConversion | ( | llvm::Value * | value,
|  | llvm::Type * | targetType,
|  | llvm::IRBuilder<> & | builder )
| inline

Casts a scalar llvm Value to a target scalar llvm Type. Returns the cast scalar value of type targetType.

Warning
  This assumes any integer types are signed.

Parameters

  value | A llvm scalar value to convert
  targetType | The target llvm scalar type to convert to
  builder | The current llvm IRBuilder

## ◆ arithmeticConversion() [3/4]

void arithmeticConversion | ( | std::vector< llvm::Value * > & | values,
|  | llvm::IRBuilder<> & | builder )
| inline

Converts a vector of loaded llvm scalar values to the highest precision type stored amongst them. Any values which are not scalar types are ignored.

Warning
  This assumes any integer types are signed.

Parameters

  values | A vector of llvm scalar values to convert
  builder | The current llvm IRBuilder

## ◆ arithmeticConversion() [4/4]

void arithmeticConversion | ( | std::vector< llvm::Value * > & | values,
|  | llvm::Type * | targetElementType,
|  | llvm::IRBuilder<> & | builder )
| inline

Converts a vector of loaded llvm scalar values of the same type to a target scalar type. Each value is converted individually and the loaded result stored in the same location within values.

Warning
  This assumes any integer types are signed.

Parameters

  values | A vector of llvm scalar values to convert
  targetElementType | The target llvm scalar type to convert each value of the input vector
  builder | The current llvm IRBuilder

## ◆ array3Pack()

llvm::Value * array3Pack | ( | llvm::Value * | value1,
|  | llvm::Value * | value2,
|  | llvm::Value * | value3,
|  | llvm::IRBuilder<> & | builder )
| inline

Pack three values into a new array and return a pointer to the newly allocated array. If the values are of a mismatching type, the highets order type is uses, as defined by typePrecedence. All llvm values are expected to a be a loaded scalar type.

Parameters

  value1 | The first array value
  value2 | The second array value
  value3 | The third array value
  builder | The current llvm IRBuilder

## ◆ array3Unpack()

void array3Unpack | ( | llvm::Value * | ptrToArray,
|  | llvm::Value *& | value1,
|  | llvm::Value *& | value2,
|  | llvm::Value *& | value3,
|  | llvm::IRBuilder<> & | builder )
| inline

Unpack the first three elements of an array. The provided llvm Value is expected to be a pointer to an array.

Note
  The elements are note loaded

Parameters

  ptrToArray | A llvm value which is a pointer to a llvm array
  value1 | The first array value
  value2 | The second array value
  value3 | The third array value
  builder | The current llvm IRBuilder

## ◆ arrayCast()

llvm::Value * arrayCast | ( | llvm::Value * | ptrToArray,
|  | llvm::Type * | targetElementType,
|  | llvm::IRBuilder<> & | builder )
| inline

Casts an array to another array of equal size but of a different element type. Both source and target array element types must be scalar types. The source array llvm Value should be a pointer to the array to cast.

Parameters

  ptrToArray | A llvm value which is a pointer to a llvm array
  targetElementType | The target llvm scalar type to convert each element of the input array
  builder | The current llvm IRBuilder

## ◆ arrayIndexUnpack()

llvm::Value * arrayIndexUnpack | ( | llvm::Value * | ptrToArray,
|  | const int16_t | index,
|  | llvm::IRBuilder<> & | builder )
| inline

Unpack a particular element of an array and return a pointer to that element The provided llvm Value is expected to be a pointer to an array.

Parameters

  ptrToArray | A llvm value which is a pointer to a llvm array
  index | The index at which to access the array
  builder | The current llvm IRBuilder

## ◆ arrayPack() [1/2]

llvm::Value * arrayPack | ( | const std::vector< llvm::Value * > & | values,
|  | llvm::IRBuilder<> & | builder )
| inline

Pack a vector of loaded llvm scalar values into a new array of equal size and return a pointer to the newly allocated array.

Parameters

  values | A vector of loaded llvm scalar values to pack
  builder | The current llvm IRBuilder

## ◆ arrayPack() [2/2]

llvm::Value * arrayPack | ( | llvm::Value * | value,
|  | llvm::IRBuilder<> & | builder,
|  | const size_t | size = 3 )
| inline

Pack a loaded llvm scalar value into a new array of a specified size and return a pointer to the newly allocated array. Each element of the new array will have the value of the given scalar.

Parameters

  value | The uniform scalar llvm value to pack into the array
  builder | The current llvm IRBuilder
  size | The size of the newly allocated array

## ◆ arrayPackCast()

llvm::Value * arrayPackCast | ( | std::vector< llvm::Value * > & | values,
|  | llvm::IRBuilder<> & | builder )
| inline

Pack a vector of loaded llvm scalar values into a new array of equal size and return a pointer to the newly allocated array. arrayPackCast first checks all the contained types in values and casts all types to the highest order type present. All llvm values in values are expected to be loaded scalar types.

Parameters

  values | A vector of loaded llvm scalar values to pack
  builder | The current llvm IRBuilder

## ◆ arrayUnpack()

void arrayUnpack | ( | llvm::Value * | ptrToArray,
|  | std::vector< llvm::Value * > & | values,
|  | llvm::IRBuilder<> & | builder,
|  | const bool | loadElements = false )
| inline

Unpack an array type into llvm Values which represent all its elements The provided llvm Value is expected to be a pointer to an array If loadElements is true, values will store loaded llvm values instead of pointers to the array elements.

Parameters

  ptrToArray | A llvm value which is a pointer to a llvm array
  values | A vector of llvm values where to store the array elements
  builder | The current llvm IRBuilder
  loadElements | Whether or not to load each array element into a register

## ◆ binaryOperator()

llvm::Value * binaryOperator | ( | llvm::Value * | lhs,
|  | llvm::Value * | rhs,
|  | const ast::tokens::OperatorToken & | token,
|  | llvm::IRBuilder<> & | builder )
| inline

@ brief Performs a binary operation on two loaded llvm scalar values of the same type. The type of operation performed is defined by the token (see the list of supported tokens in ast/Tokens.h. Returns a loaded llvm scalar result

Parameters

  lhs | The left hand side value of the binary operation
  rhs | The right hand side value of the binary operation
  token | The token representing the binary operation to perform
  builder | The current llvm IRBuilder

## ◆ boolComparison()

llvm::Value * boolComparison | ( | llvm::Value * | value,
|  | llvm::IRBuilder<> & | builder )
| inline

Performs a C style boolean comparison from a given scalar LLVM value.

Parameters

  value | The scalar llvm value to convert to a boolean
  builder | The current llvm IRBuilder

## ◆ createDefaultRegistry()

FunctionRegistry::UniquePtr createDefaultRegistry | ( | const FunctionOptions * | op = nullptr | ) |
| inline

Creates a registry with the default set of registered functions including math functions, point functions and volume functions.

Parameters

  op | The current function options

## ◆ extractArgument() [1/2]

llvm::Argument * extractArgument | ( | llvm::Function * | F,
|  | const size_t | idx )
| inline

## ◆ extractArgument() [2/2]

llvm::Argument * extractArgument | ( | llvm::Function * | F,
|  | const std::string & | name )
| inline

## ◆ getBaseContainedType()

llvm::Type * getBaseContainedType | ( | llvm::Type *const | type | ) |
| inline

Return the base llvm value which is being pointed to through any number of layered pointers.

Note
  This function does not check for cyclical pointer dependencies

Parameters

  type | A llvm pointer type to traverse

## ◆ getCodec()

OPENVDB_AX_API const Codec * getCodec | ( | const ast::tokens::CoreType | type,
|  | const std::string & | name )

Get a specific codec. Returns a nullptr if no codec exists.

Parameters

  type | The type the codec encodes
  name | The name of the codec

## ◆ getCodecTypeMap()

OPENVDB_AX_API const CodecTypeMap & getCodecTypeMap | ( |  | ) |

Get the global codec map.

## ◆ getTypeSupportedCodecs()

OPENVDB_AX_API const CodecNameMap * getTypeSupportedCodecs | ( | const ast::tokens::CoreType | type | ) |

Get a specific set of codecs which encode a given type. Returns a nullptr if no codec exists.

Parameters

  type | The type the codecs encode

## ◆ insertStandardFunctions()

OPENVDB_AX_API void insertStandardFunctions | ( | FunctionRegistry & | reg,
|  | const FunctionOptions * | options = nullptr )

Populates a function registry with all available "standard" AX library function. This primarily consists of all mathematical ops on AX containers (scalars, vectors, matrices) and other stl built-ins.

Parameters

  reg | The function registry to populate
  options | The current function options

## ◆ insertStaticAlloca()

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

Insert a stack allocation at the beginning of the current function of the provided type and size. The IRBuilder's insertion point must be set to a BasicBlock with a valid Function parent.

Note
  If a size is provided, the size must not depend on any other instructions. If it does, invalid LLVM IR will bb generated.

Parameters

  B | The IRBuilder
  type | The type to allocate
  size | Optional count of allocations. If nullptr, runs a single allocation

## ◆ insertVDBPointFunctions()

OPENVDB_AX_API void insertVDBPointFunctions | ( | FunctionRegistry & | reg,
|  | const FunctionOptions * | options = nullptr )

Populates a function registry with all available OpenVDB Point AX library function.

Parameters

  reg | The function registry to populate
  options | The current function options

## ◆ insertVDBVolumeFunctions()

OPENVDB_AX_API void insertVDBVolumeFunctions | ( | FunctionRegistry & | reg,
|  | const FunctionOptions * | options = nullptr )

Populates a function registry with all available OpenVDB Volume AX library function.

Parameters

  reg | The function registry to populate
  options | The current function options

## ◆ ir_constgep2_64()

auto ir_constgep2_64 | ( | llvm::IRBuilder<> & | B,
|  | llvm::Value * | ptr,
|  | uint64_t | Idx0,
|  | uint64_t | Idx1,
|  | const char * | Name = "" )
| inline

Alias around IR gep2_64 inst.

## ◆ ir_constinboundsgep2_64()

auto ir_constinboundsgep2_64 | ( | llvm::IRBuilder<> & | B,
|  | llvm::Value * | ptr,
|  | uint64_t | Idx0,
|  | uint64_t | Idx1,
|  | const char * | Name = "" )
| inline

Alias around IR in bounds gep2_64 inst.

## ◆ ir_gep()

auto ir_gep | ( | llvm::IRBuilder<> & | B,
|  | llvm::Value * | ptr,
|  | llvm::ArrayRef< llvm::Value * > | IdxList,
|  | const char * | Name = "" )
| inline

Alias around IR gep inst.

## ◆ ir_load()

auto ir_load | ( | llvm::IRBuilder<> & | B,
|  | llvm::Value * | ptr,
|  | const char * | Name = "" )
| inline

Alias around IR load inst.

## ◆ isValidCast()

bool isValidCast | ( | llvm::Type * | from,
|  | llvm::Type * | to )
| inline

Returns true if the llvm Type 'from' can be safely cast to the llvm Type 'to'.

## ◆ llvmArithmeticConversion()

CastFunction llvmArithmeticConversion | ( | const llvm::Type *const | sourceType,
|  | const llvm::Type *const | targetType,
|  | const std::string & | twine = "" )
| inline

Returns a CastFunction which represents the corresponding instruction to convert a source llvm Type to a target llvm Type. If the conversion is unsupported, throws an error.

Warning
  This assumes any integer types are signed.

Parameters

  sourceType | The source type to cast
  targetType | The target type to cast to
  twine | An optional string description of the cast function. This can be used for for more verbose llvm information on IR compilation failure

## ◆ llvmBinaryConversion()

BinaryFunction llvmBinaryConversion | ( | const llvm::Type *const | type,
|  | const ast::tokens::OperatorToken & | token,
|  | const std::string & | twine = "" )
| inline

Returns a BinaryFunction representing the corresponding instruction to perform on two scalar values, relative to a provided operator token. Note that not all operations are supported on floating point types! If the token is not supported, or the llvm type is not a scalar type, throws an error.

Note
  Various default arguments are bound to provide a simple function call signature. For floating point operations, this includes a null pointer to the optional metadata node. For integer operations, this includes disabling all overflow/rounding optimisations

Parameters

  type | The type defining the precision of the binary operation
  token | The token used to create the relative binary operation
  twine | An optional string description of the binary function. This can be used for for more verbose llvm information on IR compilation failure

## ◆ llvmConstant()

template<typename T >

llvm::Constant * llvmConstant | ( | const T | t,
|  | llvm::Type * | type )
| inline

Returns an llvm Constant holding a scalar value.

Parameters

  t | The scalar constant
  type | The LLVM type. Can differ from the type of t, in which case the value will be cast to the llvm type

## ◆ llvmFloatType()

OPENVDB_AX_API llvm::Type * llvmFloatType | ( | const uint32_t | size,
|  | llvm::LLVMContext & | C )

Returns an llvm floating point Type given a requested size and context.

Parameters

  size | The size of the float to request, i.e. float - 32, double - 64 etc.
  C | The LLVMContext to request the Type from.

## ◆ llvmFunctionTypeFromSignature()

template<typename SignatureT >

llvm::FunctionType * llvmFunctionTypeFromSignature | ( | llvm::LLVMContext & | C | ) |
| inline

Generate an LLVM FunctionType from a function signature.

Parameters

  C | The llvm context

## ◆ llvmIntType()

OPENVDB_AX_API llvm::IntegerType * llvmIntType | ( | const uint32_t | size,
|  | llvm::LLVMContext & | C )

Returns an llvm IntegerType given a requested size and context.

Parameters

  size | The number of bits of the integer type
  C | The LLVMContext to request the Type from.

## ◆ llvmPointerFromAddress()

template<typename ValueT >

llvm::Value * llvmPointerFromAddress | ( | const ValueT *const & | ptr,
|  | llvm::IRBuilder<> & | builder )
| inline

Return an llvm value representing a pointer to the provided ptr builtin ValueT.

Note
  This is probably not a suitable solution for anything other than POD types and should be used with caution.

Parameters

  ptr | A pointer to a type of ValueT whose address will be computed and returned
  builder | The current llvm IRBuilder

## ◆ llvmTypeFromToken()

OPENVDB_AX_API llvm::Type * llvmTypeFromToken | ( | const ast::tokens::CoreType & | type,
|  | llvm::LLVMContext & | C )

Returns an llvm type representing a type defined by a string.

Note
  For string types, this function returns the element type, not the object type! The llvm type representing a char block of memory is LLVMType<char*>::get(C);

Parameters

  type | The AX token type
  C | The LLVMContext to request the Type from.

## ◆ llvmTypesFromSignature()

template<typename SignatureT >

llvm::Type * llvmTypesFromSignature | ( | llvm::LLVMContext & | C,
|  | std::vector< llvm::Type * > * | types = nullptr )
| inline

Populate a vector of llvm types from a function signature declaration.

Parameters

  C | The llvm context
  types | A vector of types to populate

## ◆ llvmTypeToString()

void llvmTypeToString | ( | const llvm::Type *const | type,
|  | std::string & | str )
| inline

Prints an llvm type to a std string.

Parameters

  type | The llvm type to convert
  str | The string to store the type info to

## ◆ printSignature()

OPENVDB_AX_API void printSignature | ( | std::ostream & | os,
|  | const std::vector< llvm::Type * > & | types,
|  | const llvm::Type * | returnType,
|  | const char * | name = nullptr,
|  | const std::vector< const char * > & | names = {},
|  | const bool | axTypes = false )

Print a function signature to the provided ostream.

Parameters

  os | The stream to print to
  types | The function argument types
  returnType | The return type of the function. Must not be a nullptr
  name | The name of the function. If not provided, the return type neighbours the first parenthesis
  names | Names of the function parameters. If a name is nullptr, it skipped
  axTypes | Whether to try and convert the llvm::Types provided to AX types. If false, the llvm types are used.

## ◆ scalarToMatrix()

llvm::Value * scalarToMatrix | ( | llvm::Value * | scalar,
|  | llvm::IRBuilder<> & | builder,
|  | const size_t | dim = 3 )
| inline

## ◆ tokenFromLLVMType()

OPENVDB_AX_API ast::tokens::CoreType tokenFromLLVMType | ( | const llvm::Type * | type | ) |

Return a corresponding AX token which represents the given LLVM Type.

Note
  If the type does not exist in AX, ast::tokens::UNKNOWN is returned. Must not be a nullptr.

Parameters

  type | a valid LLVM Type

## ◆ typePrecedence()

llvm::Type * typePrecedence | ( | llvm::Type *const | typeA,
|  | llvm::Type *const | typeB )
| inline

Returns the highest order type from two LLVM Scalar types.

Parameters

  typeA | The first scalar llvm type
  typeB | The second scalar llvm type

## ◆ valuesToTypes()

void valuesToTypes | ( | const std::vector< llvm::Value * > & | values,
|  | std::vector< llvm::Type * > & | types )
| inline

Populate a vector of llvm Types from a vector of llvm values.

Parameters

  values | A vector of llvm values to retrieve types from
  types | A vector of llvm types to populate