Represents a concrete C function binding with the first argument as its return type.
More...
#include <FunctionTypes.h>
Inherits SRetFunction< SignatureT, CFunction< SignatureT > >.
|
| CFunctionSRet (const std::string &symbol, const SignatureT function) |
|
| ~CFunctionSRet () override=default |
|
Function::SignatureMatch | match (const std::vector< llvm::Type * > &args, llvm::LLVMContext &C) const override |
| Override of match which inserts the SRET type such that the base class methods ignore it. More...
|
|
llvm::Value * | call (const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const override |
| Override of call which allocates the required SRET llvm::Value for this function. More...
|
|
void | print (llvm::LLVMContext &C, std::ostream &os, const char *name=nullptr, const bool axTypes=true) const override |
| Override of print to avoid printing out the SRET type. More...
|
|
llvm::Type * | types (std::vector< llvm::Type * > &types, llvm::LLVMContext &C) const override |
| Populate a vector of llvm::Types which describe this function signature. This method is used by Function::create, Function::print and Function::match. More...
|
|
uint64_t | address () const override final |
| Returns the global address of this function. More...
|
|
llvm::Value * | fold (const std::vector< llvm::Value * > &args, llvm::LLVMContext &C) const override final |
|
void | setConstantFold (bool on) |
|
bool | hasConstantFold () const |
|
virtual llvm::Function * | create (llvm::LLVMContext &C, llvm::Module *M=nullptr) const |
| Converts and creates this AX function into a llvm Function. More...
|
|
llvm::Function * | create (llvm::Module &M) const |
| Convenience method which always uses the provided module to find the function or insert it if necessary. More...
|
|
size_t | size () const |
| The number of arguments that this function has. More...
|
|
const char * | symbol () const |
| The function symbol name. More...
|
|
const char * | argName (const size_t idx) const |
| Returns the descriptive name of the given argument index. More...
|
|
bool | hasParamAttribute (const size_t i, const llvm::Attribute::AttrKind &kind) const |
| Builder methods. More...
|
|
void | setArgumentNames (std::vector< const char * > names) |
|
const std::vector< const char * > & | dependencies () const |
|
void | setDependencies (std::vector< const char * > deps) |
|
void | setFnAttributes (const std::vector< llvm::Attribute::AttrKind > &in) |
|
void | setRetAttributes (const std::vector< llvm::Attribute::AttrKind > &in) |
|
void | setParamAttributes (const size_t i, const std::vector< llvm::Attribute::AttrKind > &in) |
|
|
static void | cast (std::vector< llvm::Value * > &args, const std::vector< llvm::Type * > &types, llvm::IRBuilder<> &B) |
| Cast the provided arguments to the given type as supported by implicit casting of function types. If the types already match OR if a cast cannot be performed, nothing is done to the argument. More...
|
|
template<typename SignatureT>
struct openvdb::v7_2::ax::codegen::CFunctionSRet< SignatureT >
Represents a concrete C function binding with the first argument as its return type.
◆ BaseT
◆ CFunctionT
◆ Ptr
◆ Traits
◆ SignatureMatch
The result type from calls to Function::match.
Enumerator |
---|
None | |
Size | |
Implicit | |
Explicit | |
◆ CFunctionSRet()
CFunctionSRet |
( |
const std::string & |
symbol, |
|
|
const SignatureT |
function |
|
) |
| |
|
inline |
◆ ~CFunctionSRet()
◆ address()
uint64_t address |
( |
| ) |
const |
|
inlinefinaloverridevirtualinherited |
Returns the global address of this function.
- Note
- This is only required for C bindings.
Implements CFunctionBase.
◆ argName()
const char* argName |
( |
const size_t |
idx | ) |
const |
|
inlineinherited |
Returns the descriptive name of the given argument index.
If the index is greater than the number of arguments, an empty string is returned.
- Parameters
-
idx | The index of the argument |
◆ call()
llvm::Value* call |
( |
const std::vector< llvm::Value * > & |
args, |
|
|
llvm::IRBuilder<> & |
B, |
|
|
const bool |
cast |
|
) |
| const |
|
inlineoverridevirtualinherited |
Override of call which allocates the required SRET llvm::Value for this function.
- Note
- Unlike other function where the returned llvm::Value* is a llvm::CallInst (which also represents the return value), SRET functions return the allocated 1st argument i.e. not a llvm::CallInst
Reimplemented from CFunction< SignatureT >.
◆ cast()
static void cast |
( |
std::vector< llvm::Value * > & |
args, |
|
|
const std::vector< llvm::Type * > & |
types, |
|
|
llvm::IRBuilder<> & |
B |
|
) |
| |
|
staticprotectedinherited |
Cast the provided arguments to the given type as supported by implicit casting of function types. If the types already match OR if a cast cannot be performed, nothing is done to the argument.
◆ create() [1/2]
virtual llvm::Function* create |
( |
llvm::LLVMContext & |
C, |
|
|
llvm::Module * |
M = nullptr |
|
) |
| const |
|
virtualinherited |
Converts and creates this AX function into a llvm Function.
This method uses the result from Function::types() to construct a llvm::FunctionType and a subsequent a llvm::Function. Any parameter, return or function attributes are also added to the function. If a module is provided, the module if first checked to see if the function already exists. If it does, it is immediately returned. If the function doesn't exist in the module, its prototype is created and also inserted into the end of the modules function list. If no module is provided, the function is left detached and must be added to a valid Module to be callable.
- Note
- The body of the function is left to derived classes to implement. As you need a Module to generate the prototype/body, this function serves two purposes. The first is to return the detached function signature if only a context is provided. The second is to ensure the function prototype and body (if required) is inserted into the module prior to returning.
-
It is possible to end up with function symbol collisions if you do not have unique function symbols in your module
- Parameters
-
C | The LLVM Context |
M | The Module to write the function to |
Reimplemented in IRFunctionBase.
◆ create() [2/2]
llvm::Function* create |
( |
llvm::Module & |
M | ) |
const |
|
inlineinherited |
Convenience method which always uses the provided module to find the function or insert it if necessary.
- Parameters
-
◆ dependencies()
const std::vector<const char*>& dependencies |
( |
| ) |
const |
|
inlineinherited |
◆ fold()
llvm::Value* fold |
( |
const std::vector< llvm::Value * > & |
args, |
|
|
llvm::LLVMContext & |
C |
|
) |
| const |
|
inlinefinaloverridevirtualinherited |
◆ hasConstantFold()
bool hasConstantFold |
( |
| ) |
const |
|
inlineinherited |
◆ hasParamAttribute()
bool hasParamAttribute |
( |
const size_t |
i, |
|
|
const llvm::Attribute::AttrKind & |
kind |
|
) |
| const |
|
inlineinherited |
◆ match()
|
inlineoverridevirtualinherited |
Override of match which inserts the SRET type such that the base class methods ignore it.
Reimplemented from Function.
◆ print()
void print |
( |
llvm::LLVMContext & |
C, |
|
|
std::ostream & |
os, |
|
|
const char * |
name = nullptr , |
|
|
const bool |
axTypes = true |
|
) |
| const |
|
inlineoverridevirtualinherited |
Override of print to avoid printing out the SRET type.
Reimplemented from Function.
◆ setArgumentNames()
void setArgumentNames |
( |
std::vector< const char * > |
names | ) |
|
|
inlineinherited |
◆ setConstantFold()
void setConstantFold |
( |
bool |
on | ) |
|
|
inlineinherited |
◆ setDependencies()
void setDependencies |
( |
std::vector< const char * > |
deps | ) |
|
|
inlineinherited |
◆ setFnAttributes()
void setFnAttributes |
( |
const std::vector< llvm::Attribute::AttrKind > & |
in | ) |
|
|
inlineinherited |
◆ setParamAttributes()
void setParamAttributes |
( |
const size_t |
i, |
|
|
const std::vector< llvm::Attribute::AttrKind > & |
in |
|
) |
| |
|
inlineinherited |
◆ setRetAttributes()
void setRetAttributes |
( |
const std::vector< llvm::Attribute::AttrKind > & |
in | ) |
|
|
inlineinherited |
◆ size()
The number of arguments that this function has.
◆ symbol()
const char* symbol |
( |
| ) |
const |
|
inlineinherited |
The function symbol name.
This will be used as its identifier in IR and must be unique.
◆ types()
llvm::Type* types |
( |
std::vector< llvm::Type * > & |
, |
|
|
llvm::LLVMContext & |
|
|
) |
| const |
|
inlineoverridevirtualinherited |
The documentation for this struct was generated from the following file: