Go to the documentation of this file.
66 #ifndef OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
67 #define OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
75 #include <llvm/IR/Constants.h>
76 #include <llvm/IR/IRBuilder.h>
77 #include <llvm/IR/Module.h>
83 #include <type_traits>
84 #include <unordered_map>
101 template <
typename T,
size_t _SIZE = 1>
104 static const size_t SIZE = _SIZE;
109 template <
typename T,
size_t S>
132 template <
typename T>
struct TypeToSymbol {
static inline std::string
s() {
return "?"; } };
133 template <>
struct TypeToSymbol<void> {
static inline std::string
s() {
return "v"; } };
134 template <>
struct TypeToSymbol<char> {
static inline std::string
s() {
return "c"; } };
135 template <>
struct TypeToSymbol<int16_t> {
static inline std::string
s() {
return "s"; } };
136 template <>
struct TypeToSymbol<int32_t> {
static inline std::string
s() {
return "i"; } };
137 template <>
struct TypeToSymbol<int64_t> {
static inline std::string
s() {
return "l"; } };
138 template <>
struct TypeToSymbol<float> {
static inline std::string
s() {
return "f"; } };
139 template <>
struct TypeToSymbol<double> {
static inline std::string
s() {
return "d"; } };
142 template <
typename T>
147 template <
typename T,
size_t S>
167 template <typename SignatureT, size_t I = FunctionTraits<SignatureT>::N_ARGS>
173 template <
typename OpT>
174 static void apply(
const OpT& op,
const bool forwards) {
186 template <
typename SignatureT>
189 template <
typename OpT>
190 static void apply(
const OpT&,
const bool) {}
201 template <
typename SignatureT>
204 std::vector<llvm::Type*>* types =
nullptr)
207 using ArgumentIteratorT =
211 types->reserve(Traits::N_ARGS);
212 auto callback = [&types, &C](
auto type) {
213 using Type = decltype(type);
216 ArgumentIteratorT::apply(callback,
true);
225 template <
typename SignatureT>
226 inline llvm::FunctionType*
229 std::vector<llvm::Type*> types;
230 llvm::Type* returnType =
231 llvmTypesFromSignature<SignatureT>(C, &types);
232 return llvm::FunctionType::get(returnType,
233 llvm::ArrayRef<llvm::Type*>(types),
250 const std::vector<llvm::Type*>& types,
251 const llvm::Type* returnType,
252 const char* name =
nullptr,
253 const std::vector<const char*>& names = {},
254 const bool axTypes =
false);
263 using Ptr = std::shared_ptr<Function>;
265 Function(
const size_t size,
const std::string& symbol)
268 , mAttributes(nullptr)
272 assert(!symbol.empty());
280 virtual llvm::Type*
types(std::vector<llvm::Type*>&, llvm::LLVMContext&)
const = 0;
304 virtual llvm::Function*
305 create(llvm::LLVMContext& C, llvm::Module* M =
nullptr)
const;
310 llvm::Function*
create(llvm::Module& M)
const {
311 return this->create(M.getContext(), &M);
336 call(
const std::vector<llvm::Value*>& args,
337 llvm::IRBuilder<>& B,
338 const bool cast =
false)
const;
367 inline size_t size()
const {
return mSize; }
371 inline const char*
symbol()
const {
return mSymbol.c_str(); }
378 inline const char*
argName(
const size_t idx)
const {
379 return idx < mNames.size() ? mNames[idx] :
"";
393 virtual void print(llvm::LLVMContext& C,
395 const char* name =
nullptr,
396 const bool axTypes =
true)
const;
401 const llvm::Attribute::AttrKind& kind)
const
403 if (!mAttributes)
return false;
404 const auto iter = mAttributes->mParamAttrs.find(i);
405 if (iter == mAttributes->mParamAttrs.end())
return false;
406 const auto& vec = iter->second;
407 return std::find(vec.begin(), vec.end(), kind) != vec.end();
417 this->attrs().mFnAttrs = in;
421 this->attrs().mRetAttrs = in;
424 const std::vector<llvm::Attribute::AttrKind>& in)
426 this->attrs().mParamAttrs[i] = in;
438 static void cast(std::vector<llvm::Value*>& args,
439 const std::vector<llvm::Type*>& types,
440 llvm::IRBuilder<>& B);
445 std::vector<llvm::Attribute::AttrKind> mFnAttrs, mRetAttrs;
446 std::map<size_t, std::vector<llvm::Attribute::AttrKind>> mParamAttrs;
449 inline Attributes& attrs() {
450 if (!mAttributes) mAttributes.reset(
new Attributes());
454 llvm::AttributeList flattenAttrs(llvm::LLVMContext& C)
const;
457 const std::string mSymbol;
458 std::unique_ptr<Attributes> mAttributes;
459 std::vector<const char*> mNames;
460 std::vector<const char*> mDeps;
477 template <
typename SignatureT,
typename DerivedFunction>
480 using Ptr = std::shared_ptr<SRetFunction<SignatureT, DerivedFunction>>;
484 static_assert(Traits::N_ARGS > 0,
485 "SRET Function object has been setup with the first argument as the return "
486 "value, however the provided signature is empty.");
489 static_assert(std::is_same<typename Traits::ReturnType, void>::value,
490 "SRET Function object has been setup with the first argument as the return "
491 "value and a non void return type.");
495 using FirstArgument =
typename Traits::template Arg<0>::Type;
496 static_assert(std::is_pointer<FirstArgument>::value,
497 "SRET Function object has been setup with the first argument as the return "
498 "value, but this argument it is not a pointer type.");
499 using SRetType =
typename std::remove_pointer<FirstArgument>::type;
506 llvm::LLVMContext& C)
const override
509 std::vector<llvm::Type*> inputs(args);
511 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
512 return DerivedFunction::match(inputs, C);
522 call(
const std::vector<llvm::Value*>& args,
523 llvm::IRBuilder<>& B,
524 const bool cast)
const override
527 std::vector<llvm::Value*> inputs(args);
530 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
531 DerivedFunction::call(inputs, B, cast);
532 return inputs.front();
538 const char* name =
nullptr,
539 const bool axTypes =
true)
const override
541 std::vector<llvm::Type*> current;
542 llvm::Type* ret = this->types(current, C);
544 std::rotate(current.begin(), current.begin() + 1, current.end());
545 ret = current.back();
548 std::vector<const char*> names;
549 names.reserve(this->size());
550 for (
size_t i = 0; i < this->size()-1; ++i) {
551 names.emplace_back(this->argName(i));
558 template <
typename ...Args>
565 using Ptr = std::shared_ptr<CFunctionBase>;
576 inline virtual llvm::Value*
fold(
const std::vector<llvm::Value*>&,
577 llvm::LLVMContext&)
const {
583 const std::string& symbol)
585 , mConstantFold(false) {}
596 template <
typename SignatureT>
600 using Ptr = std::shared_ptr<CFunctionT>;
605 static_assert(!std::is_pointer<typename Traits::ReturnType>::value,
606 "CFunction object has been setup with a pointer return argument. C bindings "
607 "cannot return memory locations to LLVM - Consider using a CFunctionSRet.");
609 CFunction(
const std::string& symbol,
const SignatureT
function)
611 , mFunction(function) {}
615 inline llvm::Type*
types(std::vector<llvm::Type*>& types, llvm::LLVMContext& C)
const override
617 return llvmTypesFromSignature<SignatureT>(C, &types);
620 inline uint64_t
address() const override final {
621 return reinterpret_cast<uint64_t
>(mFunction);
625 call(
const std::vector<llvm::Value*>& args,
626 llvm::IRBuilder<>& B,
627 const bool cast)
const override
629 llvm::Value* result = this->fold(args, B.getContext());
630 if (result)
return result;
631 return Function::call(args, B, cast);
634 llvm::Value*
fold(
const std::vector<llvm::Value*>& args, llvm::LLVMContext& C)
const override final
637 [](
const std::vector<llvm::Value*>& vals) ->
bool {
638 for (
auto& value : vals) {
639 if (!llvm::isa<llvm::Constant>(value))
return false;
644 if (!this->hasConstantFold())
return nullptr;
645 if (!allconst(args))
return nullptr;
646 std::vector<llvm::Constant*> constants;
647 constants.reserve(args.size());
648 for (
auto& value : args) {
649 constants.emplace_back(llvm::cast<llvm::Constant>(value));
657 const SignatureT* mFunction;
663 using Ptr = std::shared_ptr<IRFunctionBase>;
675 (
const std::vector<llvm::Value*>&, llvm::IRBuilder<>&)>;
677 llvm::Type*
types(std::vector<llvm::Type*>& types,
678 llvm::LLVMContext& C)
const override = 0;
698 create(llvm::LLVMContext& C, llvm::Module* M)
const override;
705 call(
const std::vector<llvm::Value*>& args,
706 llvm::IRBuilder<>& B,
707 const bool cast)
const override;
716 if (result == expected)
return;
717 std::string source, target;
721 "\" has been invoked with a mismatching return type. Expected: \"" +
722 target +
"\", got \"" + source +
"\".");
738 template <
typename SignatureT>
742 using Ptr = std::shared_ptr<IRFunction>;
748 types(std::vector<llvm::Type*>& types, llvm::LLVMContext& C)
const override
750 return llvmTypesFromSignature<SignatureT>(C, &types);
756 template <
typename SignatureT>
761 :
BaseT(symbol, function) {}
767 template <
typename SignatureT>
773 :
BaseT(symbol, gen) {}
780 using Ptr = std::shared_ptr<FunctionGroup>;
789 , mFunctionList(list) {}
807 match(
const std::vector<llvm::Type*>& types,
808 llvm::LLVMContext& C,
823 execute(
const std::vector<llvm::Value*>& args,
824 llvm::IRBuilder<>& B)
const;
829 const char*
name()
const {
return mName; }
830 const char*
doc()
const {
return mDoc; }
835 const FunctionList mFunctionList;
855 using Ptr = std::shared_ptr<Settings>;
858 if (mNames)
return false;
859 if (!mDeps.empty())
return false;
860 if (mConstantFold || mEmbedIR)
return false;
861 if (!mFnAttrs.empty())
return false;
862 if (!mRetAttrs.empty())
return false;
863 if (!mParamAttrs.empty())
return false;
867 std::shared_ptr<std::vector<const char*>> mNames =
nullptr;
868 std::vector<const char*> mDeps = {};
869 bool mConstantFold =
false;
870 bool mEmbedIR =
false;
871 std::vector<llvm::Attribute::AttrKind> mFnAttrs = {};
872 std::vector<llvm::Attribute::AttrKind> mRetAttrs = {};
873 std::map<size_t, std::vector<llvm::Attribute::AttrKind>> mParamAttrs = {};
878 , mCurrentSettings(new
Settings()) {}
881 template <
typename Signature,
bool SRet = false>
884 const char* symbol =
nullptr)
886 using IRFType =
typename std::conditional
888 using IRPtr =
typename IRFType::Ptr;
891 if (!mCurrentSettings->isDefault()) {
896 if (symbol) s = std::string(symbol);
897 else s = this->genSymbol<Signature>();
899 auto ir = IRPtr(
new IRFType(s, cb));
900 mIRFunctions.emplace_back(ir);
901 mSettings[ir.get()] = settings;
902 mCurrentSettings = settings;
906 template <
typename Signature,
bool SRet = false>
909 const char* symbol =
nullptr)
911 using CFType =
typename std::conditional
913 using CPtr =
typename CFType::Ptr;
916 if (!mCurrentSettings->isDefault()) {
921 if (symbol) s = std::string(symbol);
922 else s = this->genSymbol<Signature>();
924 auto c = CPtr(
new CFType(s, ptr));
925 mCFunctions.emplace_back(c);
926 mSettings[c.get()] = settings;
927 mCurrentSettings = settings;
931 template <
typename Signature,
bool SRet = false>
935 this->addSignature<Signature, SRet>(cb, symbol);
936 this->addSignature<Signature, SRet>(ptr, symbol);
941 mCurrentSettings->mDeps.emplace_back(name);
return *
this;
947 mCurrentSettings->mNames.reset(
new std::vector<const char*>(names));
1016 mCurrentSettings->mParamAttrs[idx].emplace_back(attr);
1022 mCurrentSettings->mRetAttrs.emplace_back(attr);
1028 mCurrentSettings->mFnAttrs.emplace_back(attr);
1037 for (
auto& decl : mCFunctions) {
1038 const auto& s = mSettings.at(decl.get());
1039 decl->setDependencies(s->mDeps);
1040 decl->setConstantFold(s->mConstantFold);
1041 if (!s->mFnAttrs.empty()) decl->setFnAttributes(s->mFnAttrs);
1042 if (!s->mRetAttrs.empty()) decl->setRetAttributes(s->mRetAttrs);
1043 if (!s->mParamAttrs.empty()) {
1044 for (
auto& idxAttrs : s->mParamAttrs) {
1045 if (idxAttrs.first > decl->size())
continue;
1046 decl->setParamAttributes(idxAttrs.first, idxAttrs.second);
1049 if (s->mNames) decl->setArgumentNames(*s->mNames);
1052 for (
auto& decl : mIRFunctions) {
1053 const auto& s = mSettings.at(decl.get());
1054 decl->setDependencies(s->mDeps);
1055 decl->setEmbedIR(s->mEmbedIR);
1056 if (!s->mFnAttrs.empty()) decl->setFnAttributes(s->mFnAttrs);
1057 if (!s->mRetAttrs.empty()) decl->setRetAttributes(s->mRetAttrs);
1058 if (!s->mParamAttrs.empty()) {
1059 for (
auto& idxAttrs : s->mParamAttrs) {
1060 if (idxAttrs.first > decl->size())
continue;
1061 decl->setParamAttributes(idxAttrs.first, idxAttrs.second);
1064 if (s->mNames) decl->setArgumentNames(*s->mNames);
1067 std::vector<Function::Ptr> functions;
1069 if (mDeclPref == DeclPreferrence::IR) {
1070 functions.insert(functions.end(), mIRFunctions.begin(), mIRFunctions.end());
1072 if (mDeclPref == DeclPreferrence::C) {
1073 functions.insert(functions.end(), mCFunctions.begin(), mCFunctions.end());
1075 if (functions.empty()) {
1076 functions.insert(functions.end(), mIRFunctions.begin(), mIRFunctions.end());
1077 functions.insert(functions.end(), mCFunctions.begin(), mCFunctions.end());
1086 template <
typename Signature>
1087 std::string genSymbol()
const
1092 auto callback = [&args](
auto type) {
1093 using Type = decltype(type);
1097 ArgumentIterator<Signature>::apply(callback,
true);
1103 return "ax." + std::string(this->mName) +
"." +
1104 TypeToSymbol<typename Traits::ReturnType>::s() + args;
1107 const char* mName =
"";
1108 const char* mDoc =
"";
1109 DeclPreferrence mDeclPref = IR;
1110 std::vector<CFunctionBase::Ptr> mCFunctions = {};
1111 std::vector<IRFunctionBase::Ptr> mIRFunctions = {};
1112 std::map<const Function*, Settings::Ptr> mSettings = {};
1113 Settings::Ptr mCurrentSettings =
nullptr;
1121 #endif // OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
void setFnAttributes(const std::vector< llvm::Attribute::AttrKind > &in)
Definition: FunctionTypes.h:415
std::function< llvm::Value *(const std::vector< llvm::Value * > &, llvm::IRBuilder<> &)> GeneratorCb
The IR callback function which will write the LLVM IR for this function's body.
Definition: FunctionTypes.h:675
Represents a concrete IR function with the first argument as its return type.
Definition: FunctionTypes.h:769
bool hasEmbedIR() const
Definition: FunctionTypes.h:683
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 Funct...
Definition: FunctionTypes.h:748
Consolidated llvm types for most supported types.
ArrayType mData
Definition: FunctionTypes.h:106
The base/abstract representation of an AX function. Derived classes must implement the Function::type...
Definition: FunctionTypes.h:262
The base/abstract definition for an IR function.
Definition: FunctionTypes.h:662
FunctionBuilder & setConstantFold(bool on)
Definition: FunctionTypes.h:945
std::shared_ptr< Settings > Ptr
Definition: FunctionTypes.h:855
bool hasConstantFold() const
Definition: FunctionTypes.h:574
Templated function traits which provides compile-time index access to the types of the function signa...
Definition: ax/openvdb_ax/codegen/Types.h:279
Templated interface class for SRET functions. This struct provides the interface for functions that w...
Definition: FunctionTypes.h:479
static void apply(const OpT &, const bool)
Definition: FunctionTypes.h:190
virtual ~Function()=default
static std::string s()
Definition: FunctionTypes.h:135
virtual llvm::Function * create(llvm::LLVMContext &C, llvm::Module *M=nullptr) const
Converts and creates this AX function into a llvm Function.
Represents a concrete C function binding with the first argument as its return type.
Definition: FunctionTypes.h:758
T Type
Definition: FunctionTypes.h:103
llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const override
Uses the IRBuilder to create a call to this function with the given arguments, creating the function ...
Definition: FunctionTypes.h:625
size_t size() const
The number of arguments that this function has.
Definition: FunctionTypes.h:367
llvm::Value * execute(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B) const
Given a vector of llvm values provided by the user, find the best possible function signature,...
llvm::Type * types(std::vector< llvm::Type * > &types, llvm::LLVMContext &C) const override=0
Populate a vector of llvm::Types which describe this function signature. This method is used by Funct...
IRFunction(const std::string &symbol, const GeneratorCb &gen)
Definition: FunctionTypes.h:744
SRetFunction(Args &&... ts)
Forward all arguments to the derived class.
Definition: FunctionTypes.h:559
FunctionBuilder & setPreferredImpl(DeclPreferrence pref)
Definition: FunctionTypes.h:1033
FunctionBuilder & addReturnAttribute(const llvm::Attribute::AttrKind attr)
Definition: FunctionTypes.h:1021
void verifyResultType(const llvm::Type *result, const llvm::Type *expected) const
Definition: FunctionTypes.h:714
The backend representation of strings in AX. This is also how strings are passed from the AX code gen...
Definition: CustomData.h:31
static std::string s()
Definition: FunctionTypes.h:137
DeclPreferrence
Definition: FunctionTypes.h:849
llvm::Function * create(llvm::Module &M) const
Convenience method which always uses the provided module to find the function or insert it if necessa...
Definition: FunctionTypes.h:310
const GeneratorCb mGen
Definition: FunctionTypes.h:733
Constant folding for C++ bindings.
virtual SignatureMatch match(const std::vector< llvm::Type * > &inputs, llvm::LLVMContext &C) const
The base implementation for determining how a vector of llvm arguments translates to this functions s...
4x4 -matrix class.
Definition: Mat4.h:24
static std::string s()
Definition: FunctionTypes.h:139
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 Funct...
Definition: FunctionTypes.h:615
Library and file format version numbers.
std::shared_ptr< FunctionGroup > Ptr
Definition: FunctionTypes.h:780
virtual void print(llvm::LLVMContext &C, std::ostream &os, const char *name=nullptr, const bool axTypes=true) const
Print this function's signature to the provided ostream.
llvm::Value * fold(const std::vector< llvm::Value * > &args, llvm::LLVMContext &C) const override final
Definition: FunctionTypes.h:634
static std::string s()
Definition: FunctionTypes.h:149
Type to symbol conversions - these characters are used to build each functions unique signature....
Definition: FunctionTypes.h:132
virtual llvm::Value * fold(const std::vector< llvm::Value * > &, llvm::LLVMContext &) const
Definition: FunctionTypes.h:576
The base class for all C bindings.
Definition: FunctionTypes.h:564
FunctionBuilder(const char *name)
Definition: FunctionTypes.h:876
std::vector< Function::Ptr > FunctionList
Definition: FunctionTypes.h:782
bool isDefault() const
Definition: FunctionTypes.h:857
virtual llvm::Type * types(std::vector< llvm::Type * > &, llvm::LLVMContext &) const =0
Populate a vector of llvm::Types which describe this function signature. This method is used by Funct...
#define OPENVDB_THROW(exception, message)
Definition: openvdb/Exceptions.h:82
Definition: FunctionTypes.h:143
void setConstantFold(bool on)
Definition: FunctionTypes.h:573
~CFunction() override=default
FunctionBuilder & setDocumentation(const char *doc)
Definition: FunctionTypes.h:1032
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.
Definition: FunctionTypes.h:505
llvm::Value * insertStaticAlloca(llvm::IRBuilder<> &B, llvm::Type *type, llvm::Value *size=nullptr)
Insert a stack allocation at the beginning of the current function of the provided type and size....
Definition: openvdb_ax/openvdb_ax/codegen/Utils.h:123
Definition: ax/openvdb_ax/Exceptions.h:36
virtual uint64_t address() const =0
Returns the global address of this function.
Function::Ptr match(const std::vector< llvm::Type * > &types, llvm::LLVMContext &C, Function::SignatureMatch *type=nullptr) const
Given a vector of llvm types, automatically returns the best possible function declaration from the s...
FunctionBuilder & addDependency(const char *name)
Definition: FunctionTypes.h:940
void printSignature(std::ostream &os, const std::vector< llvm::Type * > &types, const llvm::Type *returnType, const char *name=nullptr, const std::vector< const char * > &names={}, const bool axTypes=false)
Print a function signature to the provided ostream.
static std::string s()
Definition: FunctionTypes.h:138
typename FunctionTraits< SignatureT >::template Arg< I-1 > ArgT
Definition: FunctionTypes.h:170
const FunctionList & list() const
Accessor to the underlying function signature list.
Definition: FunctionTypes.h:828
3x3 matrix class.
Definition: Mat3.h:29
Represents a concrete IR function.
Definition: FunctionTypes.h:740
CFunction(const std::string &symbol, const SignatureT function)
Definition: FunctionTypes.h:609
static std::string s()
Definition: FunctionTypes.h:140
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...
bool hasParamAttribute(const size_t i, const llvm::Attribute::AttrKind &kind) const
Builder methods.
Definition: FunctionTypes.h:400
Object to array conversion methods to allow functions to return vector types. These containers provid...
Definition: FunctionTypes.h:102
The FunctionBuilder class provides a builder pattern framework to allow easy and valid construction o...
Definition: FunctionTypes.h:848
@ IR
Definition: FunctionTypes.h:850
@ Size
Definition: FunctionTypes.h:341
void setDependencies(std::vector< const char * > deps)
Definition: FunctionTypes.h:413
const std::vector< const char * > & dependencies() const
Definition: FunctionTypes.h:412
llvm::Type * llvmTypesFromSignature(llvm::LLVMContext &C, std::vector< llvm::Type * > *types=nullptr)
Populate a vector of llvm types from a function signature declaration.
Definition: FunctionTypes.h:203
Function(const size_t size, const std::string &symbol)
Definition: FunctionTypes.h:265
Utility code generation methods for performing various llvm operations.
Represents a concrete C function binding.
Definition: FunctionTypes.h:598
CFunctionBase(const size_t size, const std::string &symbol)
Definition: FunctionTypes.h:582
static std::string s()
Definition: FunctionTypes.h:132
std::unique_ptr< FunctionGroup > UniquePtr
Definition: FunctionTypes.h:781
FunctionGroup(const char *name, const char *doc, const FunctionList &list)
Definition: FunctionTypes.h:784
void setRetAttributes(const std::vector< llvm::Attribute::AttrKind > &in)
Definition: FunctionTypes.h:419
#define OPENVDB_USE_VERSION_NAMESPACE
Definition: version.h:147
void llvmTypeToString(const llvm::Type *const type, std::string &str)
Prints an llvm type to a std string.
Definition: openvdb_ax/openvdb_ax/codegen/Utils.h:70
llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const override
Override for call, which is only necessary if mEmbedIR is true, as the IR generation for embedded fun...
FunctionBuilder & addFunctionAttribute(const llvm::Attribute::AttrKind attr)
Definition: FunctionTypes.h:1027
~CFunctionSRet() override=default
FunctionBuilder & addSignature(const Signature *ptr, const char *symbol=nullptr)
Definition: FunctionTypes.h:908
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorCb &cb, const Signature *ptr, const char *symbol=nullptr)
Definition: FunctionTypes.h:933
bool mEmbedIR
Definition: FunctionTypes.h:734
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.
Definition: FunctionTypes.h:522
~IRFunctionSRet() override=default
Constant folding support structure.
Definition: ConstantFolding.h:35
IRFunctionSRet(const std::string &symbol, const IRFunctionBase::GeneratorCb &gen)
Definition: FunctionTypes.h:771
const char * argName(const size_t idx) const
Returns the descriptive name of the given argument index.
Definition: FunctionTypes.h:378
void setArgumentNames(std::vector< const char * > names)
Definition: FunctionTypes.h:410
FunctionBuilder & setEmbedIR(bool on)
Definition: FunctionTypes.h:944
FunctionBuilder & addParameterAttribute(const size_t idx, const llvm::Attribute::AttrKind attr)
Definition: FunctionTypes.h:1015
Alias mapping between two types, a frontend type T1 and a backend type T2. This class is the intended...
Definition: ax/openvdb_ax/codegen/Types.h:239
const char * name() const
Definition: FunctionTypes.h:829
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorCb &cb, const char *symbol=nullptr)
Definition: FunctionTypes.h:883
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition: version.h:95
std::shared_ptr< Function > Ptr
Definition: FunctionTypes.h:263
static std::string s()
Definition: FunctionTypes.h:133
SignatureMatch
The result type from calls to Function::match.
Definition: FunctionTypes.h:341
void setParamAttributes(const size_t i, const std::vector< llvm::Attribute::AttrKind > &in)
Definition: FunctionTypes.h:423
~CFunctionBase() override=default
static std::string s()
Definition: FunctionTypes.h:136
typename ArgT::Type ArgumentValueType
Definition: FunctionTypes.h:171
FunctionBuilder & setArgumentNames(const std::vector< const char * > &names)
Definition: FunctionTypes.h:946
Definition: FunctionTypes.h:854
static std::string s()
Definition: FunctionTypes.h:134
void setEmbedIR(bool on)
Enable or disable the embedding of IR. Embedded IR is currently required for function which use paren...
Definition: FunctionTypes.h:682
uint64_t address() const override final
Returns the global address of this function.
Definition: FunctionTypes.h:620
Templated argument iterator which implements various small functions per argument type,...
Definition: FunctionTypes.h:169
Definition: openvdb/Exceptions.h:13
const char * symbol() const
The function symbol name.
Definition: FunctionTypes.h:371
CFunctionSRet(const std::string &symbol, const SignatureT function)
Definition: FunctionTypes.h:760
LLVM type mapping from pod types.
Definition: ax/openvdb_ax/codegen/Types.h:55
Type[SIZE] ArrayType
Definition: FunctionTypes.h:105
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.
Definition: FunctionTypes.h:536
FunctionGroup::UniquePtr get() const
Definition: FunctionTypes.h:1035
virtual llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast=false) const
Uses the IRBuilder to create a call to this function with the given arguments, creating the function ...
static std::string s()
Definition: FunctionTypes.h:144
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....
IRFunctionBase(const std::string &symbol, const GeneratorCb &gen, const size_t size)
Definition: FunctionTypes.h:725
static void apply(const OpT &op, const bool forwards)
Definition: FunctionTypes.h:174
todo
Definition: FunctionTypes.h:779
const char * doc() const
Definition: FunctionTypes.h:830
llvm::FunctionType * llvmFunctionTypeFromSignature(llvm::LLVMContext &C)
Generate an LLVM FunctionType from a function signature.
Definition: FunctionTypes.h:227
~IRFunctionBase() override=default