OpenVDB  12.0.0
Namespaces | Classes | Typedefs | Functions
openvdb::v12_0::ax::codegen Namespace Reference

Namespaces

 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 = std::function< llvm::Value *(llvm::IRBuilder<> &, llvm::Value *, llvm::Type *)>
 
using BinaryFunction = std::function< llvm::Value *(llvm::IRBuilder<> &, llvm::Value *, llvm::Value *)>
 

Functions

OPENVDB_AX_API const CodecTypeMapgetCodecTypeMap ()
 Get the global codec map. More...
 
OPENVDB_AX_API const CodecgetCodec (const ast::tokens::CoreType type, const std::string &name)
 Get a specific codec. Returns a nullptr if no codec exists. More...
 
OPENVDB_AX_API const CodecNameMapgetTypeSupportedCodecs (const ast::tokens::CoreType type)
 Get a specific set of codecs which encode a given type. Returns a nullptr if no codec exists. More...
 
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. More...
 
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. More...
 
OPENVDB_AX_API void insertVDBPointFunctions (FunctionRegistry &reg, const FunctionOptions *options=nullptr)
 Populates a function registry with all available OpenVDB Point AX library function. More...
 
OPENVDB_AX_API void insertVDBVolumeFunctions (FunctionRegistry &reg, const FunctionOptions *options=nullptr)
 Populates a function registry with all available OpenVDB Volume AX library function. More...
 
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. More...
 
template<typename SignatureT >
llvm::FunctionType * llvmFunctionTypeFromSignature (llvm::LLVMContext &C)
 Generate an LLVM FunctionType from a function signature. More...
 
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. More...
 
template<typename T >
llvm::Constant * llvmConstant (const T t, llvm::Type *type)
 Returns an llvm Constant holding a scalar value. More...
 
OPENVDB_AX_API llvm::IntegerType * llvmIntType (const uint32_t size, llvm::LLVMContext &C)
 Returns an llvm IntegerType given a requested size and context. More...
 
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. More...
 
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. More...
 
OPENVDB_AX_API ast::tokens::CoreType tokenFromLLVMType (const llvm::Type *type)
 Return a corresponding AX token which represents the given LLVM Type. More...
 
auto ir_load (llvm::IRBuilder<> &B, llvm::Value *ptr, const char *Name="")
 Alias around IR load inst. More...
 
auto ir_gep (llvm::IRBuilder<> &B, llvm::Value *ptr, llvm::ArrayRef< llvm::Value * > IdxList, const char *Name="")
 Alias around IR gep inst. More...
 
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. More...
 
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. More...
 
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. More...
 
void llvmTypeToString (const llvm::Type *const type, std::string &str)
 Prints an llvm type to a std string. More...
 
llvm::Type * getBaseContainedType (llvm::Type *const type)
 Return the base llvm value which is being pointed to through any number of layered pointers. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
bool isValidCast (llvm::Type *from, llvm::Type *to)
 Returns true if the llvm Type 'from' can be safely cast to the llvm Type 'to'. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
llvm::Value * boolComparison (llvm::Value *value, llvm::IRBuilder<> &builder)
 Performs a C style boolean comparison from a given scalar LLVM value. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
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. More...
 
llvm::Value * scalarToMatrix (llvm::Value *scalar, llvm::IRBuilder<> &builder, const size_t dim=3)
 

Typedef Documentation

using BinaryFunction = std::function<llvm::Value* (llvm::IRBuilder<>&, llvm::Value*, llvm::Value*)>
using CastFunction = 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
using CodecNameMap = std::map<const std::string, const Codec*>
using Codecs = std::vector<const Codec*>
using M3D = ArgType<double, 9>
using M3F = ArgType<float, 9>
using M4D = ArgType<double, 16>
using M4F = ArgType<float, 16>
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>

Function Documentation

llvm::Value* openvdb::v12_0::ax::codegen::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
valueA llvm scalar value to convert
targetTypeThe target llvm scalar type to convert to
builderThe current llvm IRBuilder
void openvdb::v12_0::ax::codegen::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
valuesA vector of llvm scalar values to convert
targetElementTypeThe target llvm scalar type to convert each value of the input vector
builderThe current llvm IRBuilder
void openvdb::v12_0::ax::codegen::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
valuesA vector of llvm scalar values to convert
builderThe current llvm IRBuilder
void openvdb::v12_0::ax::codegen::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
valueAThe first llvm value
valueBThe second llvm value
builderThe current llvm IRBuilder
llvm::Value* openvdb::v12_0::ax::codegen::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
value1The first array value
value2The second array value
value3The third array value
builderThe current llvm IRBuilder
void openvdb::v12_0::ax::codegen::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
ptrToArrayA llvm value which is a pointer to a llvm array
value1The first array value
value2The second array value
value3The third array value
builderThe current llvm IRBuilder
llvm::Value* openvdb::v12_0::ax::codegen::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
ptrToArrayA llvm value which is a pointer to a llvm array
targetElementTypeThe target llvm scalar type to convert each element of the input array
builderThe current llvm IRBuilder
llvm::Value* openvdb::v12_0::ax::codegen::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
ptrToArrayA llvm value which is a pointer to a llvm array
indexThe index at which to access the array
builderThe current llvm IRBuilder
llvm::Value* openvdb::v12_0::ax::codegen::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
valueThe uniform scalar llvm value to pack into the array
builderThe current llvm IRBuilder
sizeThe size of the newly allocated array
llvm::Value* openvdb::v12_0::ax::codegen::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
valuesA vector of loaded llvm scalar values to pack
builderThe current llvm IRBuilder
llvm::Value* openvdb::v12_0::ax::codegen::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
valuesA vector of loaded llvm scalar values to pack
builderThe current llvm IRBuilder
void openvdb::v12_0::ax::codegen::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
ptrToArrayA llvm value which is a pointer to a llvm array
valuesA vector of llvm values where to store the array elements
builderThe current llvm IRBuilder
loadElementsWhether or not to load each array element into a register
llvm::Value* openvdb::v12_0::ax::codegen::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
lhsThe left hand side value of the binary operation
rhsThe right hand side value of the binary operation
tokenThe token representing the binary operation to perform
builderThe current llvm IRBuilder
llvm::Value* openvdb::v12_0::ax::codegen::boolComparison ( llvm::Value *  value,
llvm::IRBuilder<> &  builder 
)
inline

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

Parameters
valueThe scalar llvm value to convert to a boolean
builderThe current llvm IRBuilder
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
opThe current function options
llvm::Argument* openvdb::v12_0::ax::codegen::extractArgument ( llvm::Function *  F,
const size_t  idx 
)
inline
llvm::Argument* openvdb::v12_0::ax::codegen::extractArgument ( llvm::Function *  F,
const std::string &  name 
)
inline
llvm::Type* openvdb::v12_0::ax::codegen::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
typeA llvm pointer type to traverse
OPENVDB_AX_API const Codec* openvdb::v12_0::ax::codegen::getCodec ( const ast::tokens::CoreType  type,
const std::string &  name 
)

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

Parameters
typeThe type the codec encodes
nameThe name of the codec
OPENVDB_AX_API const CodecTypeMap& openvdb::v12_0::ax::codegen::getCodecTypeMap ( )

Get the global codec map.

OPENVDB_AX_API const CodecNameMap* openvdb::v12_0::ax::codegen::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
typeThe type the codecs encode
OPENVDB_AX_API void openvdb::v12_0::ax::codegen::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
regThe function registry to populate
optionsThe current function options
llvm::Value* openvdb::v12_0::ax::codegen::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
BThe IRBuilder
typeThe type to allocate
sizeOptional count of allocations. If nullptr, runs a single allocation
OPENVDB_AX_API void openvdb::v12_0::ax::codegen::insertVDBPointFunctions ( FunctionRegistry reg,
const FunctionOptions options = nullptr 
)

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

Parameters
regThe function registry to populate
optionsThe current function options
OPENVDB_AX_API void openvdb::v12_0::ax::codegen::insertVDBVolumeFunctions ( FunctionRegistry reg,
const FunctionOptions options = nullptr 
)

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

Parameters
regThe function registry to populate
optionsThe current function options
auto openvdb::v12_0::ax::codegen::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.

auto openvdb::v12_0::ax::codegen::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.

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

Alias around IR gep inst.

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

Alias around IR load inst.

bool openvdb::v12_0::ax::codegen::isValidCast ( llvm::Type *  from,
llvm::Type *  to 
)
inline

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

CastFunction openvdb::v12_0::ax::codegen::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
sourceTypeThe source type to cast
targetTypeThe target type to cast to
twineAn optional string description of the cast function. This can be used for for more verbose llvm information on IR compilation failure
BinaryFunction openvdb::v12_0::ax::codegen::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
typeThe type defining the precision of the binary operation
tokenThe token used to create the relative binary operation
twineAn optional string description of the binary function. This can be used for for more verbose llvm information on IR compilation failure
llvm::Constant* openvdb::v12_0::ax::codegen::llvmConstant ( const T  t,
llvm::Type *  type 
)
inline

Returns an llvm Constant holding a scalar value.

Parameters
tThe scalar constant
typeThe LLVM type. Can differ from the type of t, in which case the value will be cast to the llvm type
OPENVDB_AX_API llvm::Type* openvdb::v12_0::ax::codegen::llvmFloatType ( const uint32_t  size,
llvm::LLVMContext &  C 
)

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

Parameters
sizeThe size of the float to request, i.e. float - 32, double - 64 etc.
CThe LLVMContext to request the Type from.
llvm::FunctionType* openvdb::v12_0::ax::codegen::llvmFunctionTypeFromSignature ( llvm::LLVMContext &  C)
inline

Generate an LLVM FunctionType from a function signature.

Parameters
CThe llvm context
OPENVDB_AX_API llvm::IntegerType* openvdb::v12_0::ax::codegen::llvmIntType ( const uint32_t  size,
llvm::LLVMContext &  C 
)

Returns an llvm IntegerType given a requested size and context.

Parameters
sizeThe number of bits of the integer type
CThe LLVMContext to request the Type from.
llvm::Value* openvdb::v12_0::ax::codegen::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
ptrA pointer to a type of ValueT whose address will be computed and returned
builderThe current llvm IRBuilder
OPENVDB_AX_API llvm::Type* openvdb::v12_0::ax::codegen::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
typeThe AX token type
CThe LLVMContext to request the Type from.
llvm::Type* openvdb::v12_0::ax::codegen::llvmTypesFromSignature ( llvm::LLVMContext &  C,
std::vector< llvm::Type * > *  types = nullptr 
)
inline

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

Parameters
CThe llvm context
typesA vector of types to populate
void openvdb::v12_0::ax::codegen::llvmTypeToString ( const llvm::Type *const  type,
std::string &  str 
)
inline

Prints an llvm type to a std string.

Parameters
typeThe llvm type to convert
strThe string to store the type info to
OPENVDB_AX_API void openvdb::v12_0::ax::codegen::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
osThe stream to print to
typesThe function argument types
returnTypeThe return type of the function. Must not be a nullptr
nameThe name of the function. If not provided, the return type neighbours the first parenthesis
namesNames of the function parameters. If a name is nullptr, it skipped
axTypesWhether to try and convert the llvm::Types provided to AX types. If false, the llvm types are used.
llvm::Value* openvdb::v12_0::ax::codegen::scalarToMatrix ( llvm::Value *  scalar,
llvm::IRBuilder<> &  builder,
const size_t  dim = 3 
)
inline
OPENVDB_AX_API ast::tokens::CoreType openvdb::v12_0::ax::codegen::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
typea valid LLVM Type
llvm::Type* openvdb::v12_0::ax::codegen::typePrecedence ( llvm::Type *const  typeA,
llvm::Type *const  typeB 
)
inline

Returns the highest order type from two LLVM Scalar types.

Parameters
typeAThe first scalar llvm type
typeBThe second scalar llvm type
void openvdb::v12_0::ax::codegen::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
valuesA vector of llvm values to retrieve types from
typesA vector of llvm types to populate