OpenVDB: openvdb_ax/codegen/Utils.h File Reference

OpenVDB 12.1.1

Loading...
Searching...
No Matches
Utils.h File Reference

Utility code generation methods for performing various llvm operations. More...

`#include "Types.h"`
`#include "../ast/Tokens.h"`
`#include "../Exceptions.h"`
`#include <openvdb/version.h>`
`#include <openvdb/util/Assert.h>`
`#include <llvm/IR/IRBuilder.h>`
`#include <llvm/IR/LLVMContext.h>`
`#include <llvm/Support/raw_ostream.h>`

Go to the source code of this file.

## Namespaces
namespace | openvdb
namespace | openvdb::v12_1
namespace | openvdb::v12_1::ax
namespace | openvdb::v12_1::ax::codegen

## Macros
#define | BIND_ARITHMETIC_CAST_OP(Function, Twine)
#define | BIND_ARITHMETIC_CAST_OP_TRUNC(Function, Twine)
#define | BIND_ARITHMETIC_CAST_OP_UIFP(Function, Twine)
#define | BIND_ARITHMETIC_CAST_OP_ZEXT(Function, Twine)
#define | BIND_ARITHMETIC_CAST_OP_FP(Function, Twine)
#define | BIND_BINARY_OP(Function)

## Typedefs
using | CastFunction
using | BinaryFunction

## Functions
bool | AssertOpaquePtrs (llvm::Value *opaque, llvm::Type *type)
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.
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.
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)

## Detailed Description

Utility code generation methods for performing various llvm operations.

Authors
  Nick Avramoussis

## Macro Definition Documentation

## ◆ BIND_ARITHMETIC_CAST_OP

#define BIND_ARITHMETIC_CAST_OP | ( |  | Function,
|  |  | Twine )

Value:
std::bind(&Function, \
std::placeholders::_1, \
std::placeholders::_2, \
std::placeholders::_3, \
Twine)

## ◆ BIND_ARITHMETIC_CAST_OP_FP

#define BIND_ARITHMETIC_CAST_OP_FP | ( |  | Function,
|  |  | Twine )

Value:
std::bind(&Function, \
std::placeholders::_1, \
std::placeholders::_2, \
std::placeholders::_3, \
Twine)

## ◆ BIND_ARITHMETIC_CAST_OP_TRUNC

#define BIND_ARITHMETIC_CAST_OP_TRUNC | ( |  | Function,
|  |  | Twine )

Value:
std::bind(&Function, \
std::placeholders::_1, \
std::placeholders::_2, \
std::placeholders::_3, \
Twine)

## ◆ BIND_ARITHMETIC_CAST_OP_UIFP

#define BIND_ARITHMETIC_CAST_OP_UIFP | ( |  | Function,
|  |  | Twine )

Value:
std::bind(&Function, \
std::placeholders::_1, \
std::placeholders::_2, \
std::placeholders::_3, \
Twine)

## ◆ BIND_ARITHMETIC_CAST_OP_ZEXT

#define BIND_ARITHMETIC_CAST_OP_ZEXT | ( |  | Function,
|  |  | Twine )

Value:
std::bind(&Function, \
std::placeholders::_1, \
std::placeholders::_2, \
std::placeholders::_3, \
Twine)

## ◆ BIND_BINARY_OP

#define BIND_BINARY_OP | ( |  | Function | ) |

Value:
[twine](llvm::IRBuilder<>& B, llvm::Value* L, llvm::Value* R) \
-> llvm::Value* { return B.Function(L, R, twine); }