OpenVDB 13.0.0

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

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

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

Inheritance diagram for IRFunctionSRet< SignatureT >:

## Public Types
using | BaseT = SRetFunction<SignatureT, IRFunction<SignatureT>>
using | Ptr
using | Traits
using | GeneratorNativeCb
| The IR callback function which will write the LLVM IR for this function's body.
using | GeneratorArgumentsCb
using | GeneratorCb
| Legacy callback, will eventually be deprecated in favour of using the GeneratorArgumentsCb.
enum | SignatureMatch { None = 0 , Size , Implicit , Ambiguous , Explicit }
| The result type from calls to Function::match. More...

## Public Member Functions
| IRFunctionSRet (const std::string &symbol, const IRFunctionBase::GeneratorCb &gen)
| IRFunctionSRet (const std::string &symbol, const IRFunctionBase::GeneratorNativeCb &gen)
| IRFunctionSRet (const std::string &symbol, const IRFunctionBase::GeneratorArgumentsCb &gen)
| ~IRFunctionSRet () 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.
void | setEmbedIR (bool on)
| Enable or disable the embedding of IR. Embedded IR is currently required for function which use parent function parameters.
bool | hasEmbedIR () const
llvm::Function * | create (llvm::LLVMContext &C, llvm::Module *M) const override
| Override for the creation of an IR function. This ensures that the body and prototype of the function are generated if a Module is provided.
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)

## Protected Member Functions
void | verifyResultType (const llvm::Type *result, const llvm::Type *expected) const

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

## Protected Attributes
const GeneratorArgumentsCb | mGen
bool | mEmbedIR

## Detailed Description

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

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

## Member Typedef Documentation

## ◆ BaseT

template<typename SignatureT>

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

## ◆ GeneratorArgumentsCb

using GeneratorArgumentsCb
| inherited

Initial value:
std::function<Value
(const Arguments&, llvm::IRBuilder<>&)>
openvdb::v13_0::ax::codegen::Value
Intermediate representation wrapper for supported value types in AX as immutable instances.
Definition Value.h:63
openvdb::v13_0::ax::codegen::Arguments
Arbitrary, potentially "non-native" arguments. This wrapper struct can be used when generating functi...
Definition FunctionTypes.h:382

## ◆ GeneratorCb

using GeneratorCb
| inherited

Initial value:
std::function<llvm::Value*
(const std::vector<llvm::Value*>&,
llvm::IRBuilder<>&)>

Legacy callback, will eventually be deprecated in favour of using the GeneratorArgumentsCb.

## ◆ GeneratorNativeCb

using GeneratorNativeCb
| inherited

Initial value:
std::function<Value
(const NativeArguments&, llvm::IRBuilder<>&)>
openvdb::v13_0::ax::codegen::NativeArguments
Wrapper struct to represent "native" function arguments; that is, the set of Value type that the AX g...
Definition FunctionTypes.h:349

The IR callback function which will write the LLVM IR for this function's body.

The first argument is the vector of functional arguments. i.e. a representation of the value that the callback has been invoked with. The last argument is the IR builder which should be used to generate the function body IR.

Note
  You can return a ret void instruction, an actual value or Value::Invalid() which will cause the function framework to insert a ret void if necessary.

## ◆ 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

## ◆ IRFunctionSRet() [1/3]

template<typename SignatureT>

IRFunctionSRet | ( | const std::string & | symbol,
|  | const IRFunctionBase::GeneratorCb & | gen )
| inline

## ◆ IRFunctionSRet() [2/3]

template<typename SignatureT>

IRFunctionSRet | ( | const std::string & | symbol,
|  | const IRFunctionBase::GeneratorNativeCb & | gen )
| inline

## ◆ IRFunctionSRet() [3/3]

template<typename SignatureT>

IRFunctionSRet | ( | const std::string & | symbol,
|  | const IRFunctionBase::GeneratorArgumentsCb & | gen )
| inline

## ◆ ~IRFunctionSRet()

template<typename SignatureT>

~IRFunctionSRet | ( |  | ) |
| override default

## Member Function Documentation

## ◆ 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 IRFunctionBase.

## ◆ 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 IRFunctionBase.

## ◆ 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 IRFunctionBase.

## ◆ 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]

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

## ◆ create() [2/2]

llvm::Function * create | ( | llvm::LLVMContext & | C,
|  | llvm::Module * | M ) const
| override virtual inherited

Override for the creation of an IR function. This ensures that the body and prototype of the function are generated if a Module is provided.

Note
  A nullptr is returned if mEmbedIR is true and no action is performed.
  Throws if this function has been initialized with a nullptr generator callback. In this case, the function prototype will be created, but not the function body.
  Throws if the return type of the generator callback does not match the function prototype. In this case, both the prototype and the function body will be created and inserted, but the IR will be invalid.

Reimplemented from Function.

## ◆ dependencies()

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

## ◆ 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

## ◆ hasEmbedIR()

bool hasEmbedIR | ( |  | ) | 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"

## ◆ setDependencies()

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

Deprecated
  "Use the FunctionBuilder to construct Functions"

## ◆ setEmbedIR()

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

Enable or disable the embedding of IR. Embedded IR is currently required for function which use parent function parameters.

## ◆ 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 IRFunction< SignatureT >.

## ◆ types() [2/2]

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

Note
  Bring in deprecated type methods

Reimplemented from IRFunction< SignatureT >.

## ◆ verifyResultType()

void verifyResultType | ( | const llvm::Type * | result,
|  | const llvm::Type * | expected ) const
| inline protected inherited

## Member Data Documentation

## ◆ mEmbedIR

bool mEmbedIR
| protected inherited

## ◆ mGen

const GeneratorArgumentsCb mGen
| protected inherited