A group of functions which all have the same name but different signatures. For example: float abs(float) double abs(double) As well as serving as a way of grouping common functions, this class provides an API for selecting the best possible function signature, should a match exist, against a provided set of argument types.
More...
#include <openvdb_ax/codegen/FunctionTypes.h>
|
| FunctionGroup (const char *name, const char *doc, const FunctionList &list) |
|
| ~FunctionGroup ()=default |
|
bool | HasUniqueTypeSignatures (llvm::LLVMContext &C) const |
| Verify the function signatures in this group. More...
|
|
std::pair< const Function *, Function::SignatureMatch > | match (const ArgInfoVector &args, llvm::LLVMContext &C) const |
| Given a vector of llvm types, automatically returns the best possible function declaration from the stored function list. The 'best' declaration is determined by the provided types compatibility to each functions signature. More...
|
|
Value | execute (const Arguments &args, llvm::IRBuilder<> &B) const |
| Given a set of Arguments, find an EXPLICIT signature match, generate and execute the function body. If no explicit match exists, Value::Invalid() is returned. More...
|
|
Value | execute (const NativeArguments &args, llvm::IRBuilder<> &B) const |
| Given a set of NativeArguments, find the best possible function signature, generate and execute the function body. Returns the return value of the function or Value::Invalid() if no Explicit or Implicit match is found. More...
|
|
const FunctionList & | list () const |
| Accessor to the underlying function signature list. More...
|
|
const char * | name () const |
|
const char * | doc () const |
|
const Function * | match (const std::vector< llvm::Type * > &types, llvm::LLVMContext &C, Function::SignatureMatch *type=nullptr) const |
|
llvm::Value * | execute (const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B) const |
|
const Function * | execute (const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, llvm::Value *&result) const |
| Given a vector of llvm values, find the best possible function signature, generate and execute the function body. Returns the Function that was selected and executed or a nullptr if no valid match was found. Sets the result variable to the return value of the function (nullptr if void). If no match is found, the result variable if left unset. More...
|
|
A group of functions which all have the same name but different signatures. For example: float abs(float) double abs(double) As well as serving as a way of grouping common functions, this class provides an API for selecting the best possible function signature, should a match exist, against a provided set of argument types.
const char* doc |
( |
| ) |
const |
|
inline |
Given a set of Arguments, find an EXPLICIT signature match, generate and execute the function body. If no explicit match exists, Value::Invalid() is returned.
- Note
- To ensure something is matched/executed, consider calling match() and Function::call instead. This method should only be used by internal methods that can assert an explicit match exists.
- Parameters
-
args | Function arguments |
B | The current llvm IRBuilder |
Given a set of NativeArguments, find the best possible function signature, generate and execute the function body. Returns the return value of the function or Value::Invalid() if no Explicit or Implicit match is found.
- Note
- This function will throw if no valid return is provided by the matched declaration implementation.
- Parameters
-
args | Natively supported function arguments |
B | The current llvm IRBuilder |
llvm::Value* execute |
( |
const std::vector< llvm::Value * > & |
args, |
|
|
llvm::IRBuilder<> & |
B |
|
) |
| const |
- Deprecated:
- "FunctionGroup::execute which takes llvm::Value's and " "supports argument matching/casting is incompatible with LLVM 16+ and will be " "removed."
const Function* execute |
( |
const std::vector< llvm::Value * > & |
args, |
|
|
llvm::IRBuilder<> & |
B, |
|
|
llvm::Value *& |
result |
|
) |
| const |
Given a vector of llvm values, find the best possible function signature, generate and execute the function body. Returns the Function that was selected and executed or a nullptr if no valid match was found. Sets the result variable to the return value of the function (nullptr if void). If no match is found, the result variable if left unset.
- Note
- This function will throw if no valid return is provided by the matched declaration implementation.
- Parameters
-
args | A vector of values representing the function arguments |
B | The current llvm IRBuilder |
result | The result to set. nullptr on void return. |
- Returns
- The matched function. nullptr if no match was found
- Deprecated:
- "FunctionGroup::execute which takes llvm::Value's and " "supports argument matching/casting is incompatible with LLVM 16+ and will be " "removed."
bool HasUniqueTypeSignatures |
( |
llvm::LLVMContext & |
C | ) |
const |
Verify the function signatures in this group.
Accessor to the underlying function signature list.
Given a vector of llvm types, automatically returns the best possible function declaration from the stored function list. The 'best' declaration is determined by the provided types compatibility to each functions signature.
- Note
- Returns a nullptr if no compatible match was found or if the function list is empty. A compatible match is defined as an Explicit, Implicit or Ambiguous match (where the latter returns the first matched implicit function where other implicit matches exist).
-
If multiple implicit matches are found, the first match is returned and 'type' is set to Ambiguous (if provided).
- Warning
- All funcions in this group must implement the types(ArgInfo) virtual function, which is optional in LLVM 15 but required from LLVM 16.
- Parameters
-
types | A vector of types representing the function argument types |
C | The llvm context |
type | If provided, type is set to the type of match that occurred |
- Warning
- Does not support detecting Ambiguous functions (returns Implicit in these cases).
- Deprecated:
- "Switch to AX's internal ArgInfo types for LLVM 16 onwards"
const char* name |
( |
| ) |
const |
|
inline |