OpenVDB 13.0.0

Loading...
Searching...
No Matches
CFunctionSRet< SignatureT > Struct Template Reference

Represents a concrete C function binding with the first argument as its return type. More...

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

Inheritance diagram for CFunctionSRet< SignatureT >:

## Public Types
using | BaseT = SRetFunction<SignatureT, CFunction<SignatureT>>
using | Ptr
using | Traits
using | CFunctionT = CFunction<SignatureT>
enum | SignatureMatch { None = 0 , Size , Implicit , Ambiguous , Explicit }
| The result type from calls to Function::match. More...

## Public Member Functions
| CFunctionSRet (const std::string &symbol, const SignatureT function)
| ~CFunctionSRet () override=default
ArgInfo | types (ArgInfoVector &args, llvm::LLVMContext &C) const override
| Overide the ArgInfo type method. This does NOT change the arg order, it simply marks the first argument as a return argument. Note that the void ret type is also left as a return type.
virtual llvm::Type * | types (std::vector< llvm::Type * > &, llvm::LLVMContext &) const =0
Function::SignatureMatch | match (const ArgInfoVector &args, llvm::LLVMContext &C) const override
| Override of match which inserts the SRET type such that the base class methods ignore it.
Function::SignatureMatch | match (const std::vector< llvm::Type * > &args, llvm::LLVMContext &C) const override
llvm::Value * | call (const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B) const override
| Override of call which allocates the required SRET llvm::Value for this function.
Value | call (const Arguments &args, llvm::IRBuilder<> &B) const override
llvm::Value * | call (const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const override
Value | call (const NativeArguments &args, llvm::IRBuilder<> &B) const
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.
uint64_t | address () const override final
| Returns the global address of this function.
llvm::Constant * | 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.
llvm::Function * | create (llvm::Module &M) const
| Convenience method which always uses the provided module to find the function or insert it if necessary.
llvm::Function * | get (const llvm::Module &M) const
| Convenience method for calling M.getFunction(symbol). Returns a nullptr if the function has not yet been created or if it is embedded IR.
size_t | size () const
| The number of arguments that this function has.
const char * | symbol () const
| The function symbol name.
const char * | argName (const size_t idx) const
| Returns the descriptive name of the given argument index.
const SmallArgumentVector< const char * > & | dependencies () const
bool | hasParamAttribute (const size_t i, const llvm::Attribute::AttrKind &kind) const
| Deprecated builder methods, no longer public.
void | setArgumentNames (std::vector< const char * > names)
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 Protected Member Functions
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.

## Detailed Description

template<typename SignatureT>
struct openvdb::v13_0::ax::codegen::CFunctionSRet< SignatureT >

Represents a concrete C function binding with the first argument as its return type.

## Member Typedef Documentation

## ◆ BaseT

template<typename SignatureT>

using BaseT = SRetFunction<SignatureT, CFunction<SignatureT>>

## ◆ CFunctionT

template<typename SignatureT>

using CFunctionT = CFunction<SignatureT>
| inherited

## ◆ Ptr

using Ptr
| inherited

## ◆ Traits

using Traits
| inherited

## Member Enumeration Documentation

## ◆ SignatureMatch

enum SignatureMatch
| inherited

The result type from calls to Function::match.

Note
  Function::match cannot return Ambiguous - this is only returned by the FunctionGroup API.

Enumerator
None |
Size |
Implicit |
Ambiguous |
Explicit |

## Constructor & Destructor Documentation

## ◆ CFunctionSRet()

template<typename SignatureT>

CFunctionSRet | ( | const std::string & | symbol,
|  | const SignatureT | function )
| inline

## ◆ ~CFunctionSRet()

template<typename SignatureT>

~CFunctionSRet | ( |  | ) |
| override default

## Member Function Documentation

## ◆ address()

template<typename SignatureT>

uint64_t address | ( |  | ) | const
| inline final override virtual inherited

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
| inline inherited

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() [1/4]

Value call | ( | const NativeArguments & | args,
|  | llvm::IRBuilder<> & | B ) const
| inline inherited

## ◆ call() [2/4]

Value call | ( | const Arguments & | args,
|  | llvm::IRBuilder<> & | B ) const
| inline override virtual inherited

Reimplemented from CFunction< SignatureT >.

## ◆ call() [3/4]

llvm::Value * call | ( | const std::vector< llvm::Value * > & | args,
|  | llvm::IRBuilder<> & | B ) const
| inline override virtual inherited

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

## ◆ call() [4/4]

llvm::Value * call | ( | const std::vector< llvm::Value * > & | args,
|  | llvm::IRBuilder<> & | B,
|  | const bool | cast ) const
| inline override virtual inherited

Note
  This is deprecated! Omitting the warning as it invokes the parent function which is also deprecated. Use NativeArguments to perform argument casting

Reimplemented from CFunction< SignatureT >.

## ◆ cast()

void cast | ( | std::vector< llvm::Value * > & | args,
|  | const std::vector< llvm::Type * > & | types,
|  | llvm::IRBuilder<> & | B )
| static protected inherited

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
| virtual inherited

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.

Warning
  If a module is not provided, the caller takes ownership of the returned function and is responsible for deallocating it.

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
| inline inherited

Convenience method which always uses the provided module to find the function or insert it if necessary.

Parameters

  M | The llvm::Module to use

## ◆ dependencies()

const SmallArgumentVector< const char * > & dependencies | ( |  | ) | const
| inline inherited

## ◆ fold()

template<typename SignatureT>

llvm::Constant * fold | ( | const std::vector< llvm::Value * > & | ,
|  | llvm::LLVMContext & | ) const
| inline final override virtual inherited

Deprecated

Reimplemented from CFunctionBase.

## ◆ get()

llvm::Function * get | ( | const llvm::Module & | M | ) | const
| inherited

Convenience method for calling M.getFunction(symbol). Returns a nullptr if the function has not yet been created or if it is embedded IR.

Parameters

  M | The llvm::Module to use

## ◆ hasConstantFold()

bool hasConstantFold | ( |  | ) | const
| inline inherited

## ◆ hasParamAttribute()

bool hasParamAttribute | ( | const size_t | i,
|  | const llvm::Attribute::AttrKind & | kind ) const
| inline inherited

Deprecated builder methods, no longer public.

Deprecated
  "This method incorrectly returns the attributes " "of the function set by the FunctionBuilder, not by the codegen. To " "inspect function attributes, retrieve the created function from the " "llvm::Module."

## ◆ match() [1/2]

Function::SignatureMatch match | ( | const ArgInfoVector & | args,
|  | llvm::LLVMContext & | C ) const
| inline override virtual inherited

Override of match which inserts the SRET type such that the base class methods ignore it.

Reimplemented from Function.

## ◆ match() [2/2]

Function::SignatureMatch match | ( | const std::vector< llvm::Type * > & | args,
|  | llvm::LLVMContext & | C ) const
| inline override virtual inherited

Note
  This is deprecated! Omitting the warning as it invokes the parent function which is also deprecated. Use NativeArguments to perform argument casting

Reimplemented from Function.

## ◆ print()

void print | ( | llvm::LLVMContext & | C,
|  | std::ostream & | os,
|  | const char * | name = nullptr,
|  | const bool | axTypes = true ) const
| inline override virtual inherited

Override of print to avoid printing out the SRET type.

Reimplemented from Function.

## ◆ setArgumentNames()

void setArgumentNames | ( | std::vector< const char * > | names | ) |
| inline inherited

Deprecated
  "Use the FunctionBuilder to construct Functions"

## ◆ setConstantFold()

void setConstantFold | ( | bool | on | ) |
| inline inherited

## ◆ setDependencies()

void setDependencies | ( | std::vector< const char * > | deps | ) |
| inline inherited

Deprecated
  "Use the FunctionBuilder to construct Functions"

## ◆ setFnAttributes()

void setFnAttributes | ( | const std::vector< llvm::Attribute::AttrKind > & | in | ) |
| inline inherited

Deprecated
  "Use the FunctionBuilder to construct Functions"

## ◆ setParamAttributes()

void setParamAttributes | ( | const size_t | i,
|  | const std::vector< llvm::Attribute::AttrKind > & | in )
| inline inherited

Deprecated
  "Use the FunctionBuilder to construct Functions"

## ◆ setRetAttributes()

void setRetAttributes | ( | const std::vector< llvm::Attribute::AttrKind > & | in | ) |
| inline inherited

Deprecated
  "Use the FunctionBuilder to construct Functions"

## ◆ size()

size_t size | ( |  | ) | const
| inline inherited

The number of arguments that this function has.

## ◆ symbol()

const char * symbol | ( |  | ) | const
| inline inherited

The function symbol name.

This will be used as its identifier in IR and must be unique.

## ◆ types() [1/2]

ArgInfo types | ( | ArgInfoVector & | args,
|  | llvm::LLVMContext & | C ) const
| inline override virtual inherited

Overide the ArgInfo type method. This does NOT change the arg order, it simply marks the first argument as a return argument. Note that the void ret type is also left as a return type.

Reimplemented from CFunction< SignatureT >.

## ◆ types() [2/2]

| ( | std::vector< llvm::Type * > & | ,
|  | llvm::LLVMContext & | ) const
| virtual inherited

Note
  Bring in deprecated type methods

Reimplemented from CFunction< SignatureT >.