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>
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.
FunctionBuilder& addFunctionAttribute |
( |
const llvm::Attribute::AttrKind |
attr | ) |
|
|
inline |
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).
FunctionBuilder& addReturnAttribute |
( |
const llvm::Attribute::AttrKind |
attr | ) |
|
|
inline |
FunctionBuilder& addSignature |
( |
const Signature * |
ptr, |
|
|
const char * |
symbol = nullptr |
|
) |
| |
|
inline |
FunctionBuilder& setArgumentNames |
( |
const std::vector< const char * > & |
names | ) |
|
|
inline |