OpenVDB: FunctionBuilder Struct Reference

OpenVDB 11.0.0

Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | List of all members
FunctionBuilder Struct Reference

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

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

## Classes
struct | Settings

## Public Types
enum | DeclPreferrence { C , IR , Any }

## Public Member Functions
| FunctionBuilder (const char *name)
template<typename Signature , bool SRet = false>
FunctionBuilder & | addSignature (const IRFunctionBase::GeneratorCb &cb, const char *symbol=nullptr)
template<typename Signature , bool SRet = false>
FunctionBuilder & | addSignature (const Signature *ptr, const char *symbol=nullptr)
template<typename Signature , bool SRet = false>
FunctionBuilder & | addSignature (const IRFunctionBase::GeneratorCb &cb, const Signature *ptr, const char *symbol=nullptr)
FunctionBuilder & | addDependency (const char *name)
FunctionBuilder & | setEmbedIR (bool on)
FunctionBuilder & | setConstantFold (bool on)
FunctionBuilder & | setArgumentNames (const std::vector< const char * > &names)
FunctionBuilder & | addParameterAttribute (const size_t idx, const llvm::Attribute::AttrKind attr)
FunctionBuilder & | addReturnAttribute (const llvm::Attribute::AttrKind attr)
FunctionBuilder & | addFunctionAttribute (const llvm::Attribute::AttrKind attr)
FunctionBuilder & | setDocumentation (const char *doc)
FunctionBuilder & | setPreferredImpl (DeclPreferrence pref)
FunctionGroup::UniquePtr | get () const

## Detailed Description

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.

Use the FunctionBuilder::addSignature methods to append function signatures. Finalize the group of functions with FunctionBuilder::get.

## Member Enumeration Documentation

## ◆ DeclPreferrence

enum DeclPreferrence

Enumerator
C |
IR |
Any |

## Constructor & Destructor Documentation

## ◆ FunctionBuilder()

FunctionBuilder | ( | const char * | name | ) |
| inline

## Member Function Documentation

## ◆ addDependency()

FunctionBuilder & addDependency | ( | const char * | name | ) |
| inline

## ◆ addFunctionAttribute()

FunctionBuilder & addFunctionAttribute | ( | const llvm::Attribute::AttrKind | attr | ) |
| inline

## ◆ addParameterAttribute()

FunctionBuilder & addParameterAttribute | ( | const size_t | idx,
|  | const llvm::Attribute::AttrKind | attr )
| inline

Parameter and Function Attributes. When designing a C binding, llvm will be unable to assign parameter markings to the return type, function body or parameter attributes due to there not being any visibility on the function itself during codegen. The best way to ensure performant C bindings is to ensure that the function is marked with the required llvm parameters. Some of the heavy hitters (which can have the most impact) are below:

Functions:

- norecurse This function attribute indicates that the function does not call itself either directly or indirectly down any possible call path.
- willreturn This function attribute indicates that a call of this function will either exhibit undefined behavior or comes back and continues execution at a point in the existing call stack that includes the current invocation.
- nounwind This function attribute indicates that the function never raises an exception.
- readnone On a function, this attribute indicates that the function computes its result (or decides to unwind an exception) based strictly on its arguments, without dereferencing any pointer arguments or otherwise accessing any mutable state (e.g. memory, control registers, etc) visible to caller functions.
- readonly On a function, this attribute indicates that the function does not write through any pointer arguments (including byval arguments) or otherwise modify any state (e.g. memory, control registers, etc) visible to caller functions. control registers, etc) visible to caller functions.
- writeonly On a function, this attribute indicates that the function may write to but does not read from memory.

Parameters:

- noalias This indicates that objects accessed via pointer values based on the argument or return value are not also accessed, during the execution of the function, via pointer values not based on the argument or return value.
- nonnull This indicates that the parameter or return pointer is not null.
- readonly Indicates that the function does not write through this pointer argument, even though it may write to the memory that the pointer points to.
- writeonly Indicates that the function may write to but does not read through this pointer argument (even though it may read from the memory that the pointer points to).

## ◆ addReturnAttribute()

FunctionBuilder & addReturnAttribute | ( | const llvm::Attribute::AttrKind | attr | ) |
| inline

## ◆ addSignature() [1/3]

template<typename Signature , bool SRet = false>

FunctionBuilder & addSignature | ( | const IRFunctionBase::GeneratorCb & | cb,
|  | const char * | symbol = nullptr )
| inline

## ◆ addSignature() [2/3]

template<typename Signature , bool SRet = false>

FunctionBuilder & addSignature | ( | const IRFunctionBase::GeneratorCb & | cb,
|  | const Signature * | ptr,
|  | const char * | symbol = nullptr )
| inline

## ◆ addSignature() [3/3]

template<typename Signature , bool SRet = false>

FunctionBuilder & addSignature | ( | const Signature * | ptr,
|  | const char * | symbol = nullptr )
| inline

## ◆ get()

FunctionGroup::UniquePtr get | ( |  | ) | const
| inline

## ◆ setArgumentNames()

FunctionBuilder & setArgumentNames | ( | const std::vector< const char * > & | names | ) |
| inline

## ◆ setConstantFold()

FunctionBuilder & setConstantFold | ( | bool | on | ) |
| inline

## ◆ setDocumentation()

FunctionBuilder & setDocumentation | ( | const char * | doc | ) |
| inline

## ◆ setEmbedIR()

FunctionBuilder & setEmbedIR | ( | bool | on | ) |
| inline

## ◆ setPreferredImpl()

FunctionBuilder & setPreferredImpl | ( | DeclPreferrence | pref | ) |
| inline