66#ifndef OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
67#define OPENVDB_AX_CODEGEN_FUNCTION_TYPES_HAS_BEEN_INCLUDED
74#include <openvdb/version.h>
77#include <llvm/ADT/SmallVector.h>
78#include <llvm/IR/Constants.h>
79#include <llvm/IR/IRBuilder.h>
80#include <llvm/IR/Module.h>
116template <
typename T,
size_t _SIZE = 1>
119 static const size_t SIZE = _SIZE;
124template <
typename T,
size_t S>
147template <
typename T>
struct TypeToSymbol {
static inline std::string
s() {
return "?"; } };
148template <>
struct TypeToSymbol<void> {
static inline std::string
s() {
return "v"; } };
149template <>
struct TypeToSymbol<char> {
static inline std::string
s() {
return "c"; } };
150template <>
struct TypeToSymbol<uint8_t> {
static inline std::string
s() {
return "u8"; } };
151template <>
struct TypeToSymbol<uint16_t> {
static inline std::string
s() {
return "us"; } };
152template <>
struct TypeToSymbol<uint32_t> {
static inline std::string
s() {
return "ui"; } };
153template <>
struct TypeToSymbol<uint64_t> {
static inline std::string
s() {
return "ul"; } };
154template <>
struct TypeToSymbol<int8_t> {
static inline std::string
s() {
return "8"; } };
155template <>
struct TypeToSymbol<int16_t> {
static inline std::string
s() {
return "s"; } };
156template <>
struct TypeToSymbol<int32_t> {
static inline std::string
s() {
return "i"; } };
157template <>
struct TypeToSymbol<int64_t> {
static inline std::string
s() {
return "l"; } };
158template <>
struct TypeToSymbol<float> {
static inline std::string
s() {
return "f"; } };
159template <>
struct TypeToSymbol<double> {
static inline std::string
s() {
return "d"; } };
167template <
typename T,
size_t S>
187template <typename SignatureT, size_t I = FunctionTraits<SignatureT>::N_ARGS>
199 template <
typename OpT>
200 static void apply(
const OpT& op,
const bool forwards) {
212template <
typename SignatureT>
216 template <
typename OpT>
217 static void apply(
const OpT&,
const bool) {}
229 ArgInfo(llvm::Type* utype, uint8_t ptrs,
bool ret =
false)
230 : mUType(utype), mPtrs(ptrs), mReturn(ret) {
243 mUType == other.mUType &&
244 mPtrs == other.mPtrs &&
245 mReturn == other.mReturn;
251 mUType == other.mUType &&
252 mPtrs == other.mPtrs;
254 bool IsPtr()
const {
return mPtrs > 0; }
257 bool IsVoid()
const {
return mUType->isVoidTy(); }
262 llvm::Type* type = mUType;
263 for (uint8_t i = 0; i < mPtrs; ++i) {
264 type = llvm::PointerType::get(type, 0);
295 auto begin() {
return mInfoVec.begin(); }
296 auto end() {
return mInfoVec.end(); }
297 auto begin()
const {
return mInfoVec.begin(); }
298 auto end()
const {
return mInfoVec.end(); }
299 auto rbegin() {
return mInfoVec.rbegin(); }
300 auto rend() {
return mInfoVec.rend(); }
301 auto rbegin()
const {
return mInfoVec.rbegin(); }
302 auto rend()
const {
return mInfoVec.rend(); }
303 auto&
front() {
return mInfoVec.front(); }
304 auto&
front()
const {
return mInfoVec.front(); }
305 auto&
back() {
return mInfoVec.back(); }
306 auto&
back()
const {
return mInfoVec.back(); }
308 auto clear() {
return mInfoVec.clear(); }
309 auto size()
const {
return mInfoVec.size(); }
310 auto empty()
const {
return mInfoVec.empty(); }
311 auto erase(ContainerT::const_iterator iter) {
return mInfoVec.erase(iter); }
313 void reserve(
size_t i) { mInfoVec.reserve(i); }
314 template <
typename ...Args>
315 void emplace_back(Args&& ...args) { mInfoVec.emplace_back(std::move(args)...); }
319 return mInfoVec[pos];
324 return mInfoVec[pos];
330 types.reserve(mInfoVec.size());
331 for (
auto& info : mInfoVec) {
332 types.emplace_back(info.GetType());
354 : mArgs(args.begin(), args.end()) {}
359 size_t size()
const {
return mArgs.size(); }
388 mArgs.reserve(args.
size());
389 mTypes.reserve(args.
size());
390 for (
size_t i = 0; i < args.
size(); ++i) {
400 size_t size()
const {
return mArgs.size(); }
404 for (
const auto& types : mTypes) {
405 if (!types.IsNative())
return false;
413 return Value(mArgs[i], mTypes[i].GetUnderlyingType());
420 for (
size_t i = 0; i < mArgs.size(); ++i) {
426 const llvm::ArrayRef<llvm::Value*>
AsLLVMValues()
const {
return mArgs; }
438#if LLVM_VERSION_MAJOR <= 15
439 [[maybe_unused]] llvm::Type* base = val->getType();
440 while (base->isPointerTy()) base = base->getContainedType(0);
442 "Base type of val does not match stored underlying type");
444 mArgs.emplace_back(val);
445 mTypes.emplace_back(type);
451 mTypes.emplace_back(val);
457 std::rotate(mArgs.rbegin(), mArgs.rbegin() + 1, mArgs.rend());
458 std::rotate(mTypes.rbegin(), mTypes.rbegin() + 1, mTypes.rend());
477template <
typename SignatureT>
480 std::vector<llvm::Type*>* types =
nullptr)
483 using ArgumentIteratorT =
487 types->reserve(Traits::N_ARGS);
488 auto callback = [&types, &C](
auto type) {
489 using Type =
decltype(type);
492 ArgumentIteratorT::apply(callback,
true);
494 using Type =
typename Traits::ReturnType;
504template <
typename SignatureT>
510 using ArgumentIteratorT =
515 types->reserve(Traits::N_ARGS);
516 auto callback = [&types, &C](
auto type)
518 using UnderlyingType = std::remove_cv_t<
typename RemoveAllPtrTypes<
decltype(type)>::Type>;
519 static constexpr auto NPtrs =
CountNPtrs<
decltype(type)>::value;
520 static constexpr bool IsVoid = std::is_same_v<UnderlyingType, void>;
522 static_assert(!IsVoid || NPtrs > 0);
524 using Type = std::conditional_t<IsVoid, int8_t, UnderlyingType>;
527 ArgumentIteratorT::apply(callback,
true);
530 using UnderlyingType = std::remove_cv_t<typename RemoveAllPtrTypes<typename Traits::ReturnType>::Type>;
533 if constexpr (std::is_same_v<UnderlyingType, void> && NPtrs > 0)
552template <
typename SignatureT>
553inline llvm::FunctionType*
559 return llvm::FunctionType::get(returnType.
GetType(),
578 const char* name =
nullptr,
579 const llvm::ArrayRef<const char*>& names = {},
580 const bool axTypes =
false);
583#if LLVM_VERSION_MAJOR <= 15
587 const
std::vector<llvm::Type*>& types,
588 const llvm::Type* returnType,
589 const
char* name =
nullptr,
590 const
std::vector<const
char*>& names = {},
591 const bool axTypes =
false);
598struct FunctionBuilder;
604 using Ptr = std::shared_ptr<Function>;
609 , mAttributes(nullptr)
624#if LLVM_VERSION_MAJOR <= 15
628 std::string(
"New AX API for function arguments has been called but has not "
629 "been implemented by function: ") + this->
symbol());
632 virtual llvm::Type*
types(
std::vector<llvm::Type*>&, llvm::LLVMContext&) const = 0;
661 virtual llvm::Function*
662 create(llvm::LLVMContext& C, llvm::Module* M =
nullptr)
const;
667 llvm::Function*
create(llvm::Module& M)
const {
668 return this->
create(M.getContext(), &M);
675 llvm::Function*
get(
const llvm::Module& M)
const;
700#if LLVM_VERSION_MAJOR <= 15
702 "supports casting is incompatible with LLVM 16+ and will be removed.")
705 llvm::IRBuilder<>& B,
706 const
bool cast) const;
711 call(
const std::vector<llvm::Value*>& args,
712 llvm::IRBuilder<>& B)
const;
756#if LLVM_VERSION_MAJOR <= 15
762 inline size_t size()
const {
return mSize; }
766 inline const char*
symbol()
const {
return mSymbol.c_str(); }
773 inline const char*
argName(
const size_t idx)
const
775 return idx < mNames.size() ? mNames[idx] :
"";
789 virtual void print(llvm::LLVMContext& C,
791 const char* name =
nullptr,
792 const bool axTypes =
true)
const;
799 "of the function set by the FunctionBuilder, not by the codegen. To "
800 "inspect function attributes, retrieve the created function from the "
803 const llvm::Attribute::AttrKind& kind)
const
805 if (!mAttributes)
return false;
806 const auto iter = mAttributes->mParamAttrs.find(i);
807 if (iter == mAttributes->mParamAttrs.end())
return false;
808 const auto& vec = iter->second;
809 return std::find(vec.begin(), vec.end(), kind) != vec.end();
815 mNames.assign(names.begin(), names.end());
821 mDeps.assign(deps.begin(), deps.end());
827 this->attrs().mFnAttrs.assign(in.begin(), in.end());
833 this->attrs().mRetAttrs.assign(in.begin(), in.end());
838 const
std::vector<llvm::Attribute::AttrKind>& in)
840 this->attrs().mParamAttrs[i].assign(in.begin(), in.end());
845#if LLVM_VERSION_MAJOR <= 15
853 static void cast(std::vector<llvm::Value*>& args,
854 const std::vector<llvm::Type*>&
types,
855 llvm::IRBuilder<>& B);
859 friend FunctionBuilder;
870 std::map<size_t, SmallArgumentVector<llvm::Attribute::AttrKind>> mParamAttrs;
871 bool mReadOnly {
false};
872 Type mType {Type::kNormal};
875 inline Attributes& attrs()
877 if (!mAttributes) mAttributes.reset(
new Attributes());
882 bool IsParamReadOnly(
const size_t idx)
const
884 if (!mAttributes)
return false;
885 if (mAttributes->mReadOnly)
return true;
887 const auto iter = mAttributes->mParamAttrs.find(idx);
888 if (iter == mAttributes->mParamAttrs.end())
return false;
889 const auto& vec = iter->second;
890 return std::find(vec.begin(), vec.end(),
891 llvm::Attribute::AttrKind::ReadOnly) != vec.end();
894 llvm::AttributeList flattenAttrs(llvm::Function* F)
const;
898 const std::string mSymbol;
899 std::unique_ptr<Attributes> mAttributes;
900 SmallArgumentVector<const char*> mNames;
901 SmallArgumentVector<const char*> mDeps;
918template <
typename SignatureT,
typename DerivedFunction>
921 using Ptr = std::shared_ptr<SRetFunction<SignatureT, DerivedFunction>>;
925 static_assert(Traits::N_ARGS > 0,
926 "SRET Function object has been setup with the first argument as the return "
927 "value, however the provided signature is empty.");
930 static_assert(std::is_same<typename Traits::ReturnType, void>::value,
931 "SRET Function object has been setup with the first argument as the return "
932 "value and a non void return type.");
936 using FirstArgument =
typename Traits::template Arg<0>::Type;
937 static_assert(std::is_pointer<FirstArgument>::value,
938 "SRET Function object has been setup with the first argument as the return "
939 "value, but this argument it is not a pointer type.");
940 static_assert(!std::is_const_v<FirstArgument>,
941 "SRET Function object has been setup with the first argument as the return "
942 "value, but this argument is const.");
943 using SRetType =
typename std::remove_pointer<FirstArgument>::type;
952 ArgInfo ret = DerivedFunction::types(args, C);
957 args[0].SetIsReturn();
965 llvm::LLVMContext& C)
const override
973 inputs.
back().SetIsReturn();
975 return DerivedFunction::match(inputs, C);
985 call(
const std::vector<llvm::Value*>& args,
986 llvm::IRBuilder<>& B)
const override
989 std::vector<llvm::Value*> inputs(args);
992 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
993 DerivedFunction::call(inputs, B);
994 return inputs.front();
1003 DerivedFunction::call(inputs, B);
1010 const char* name =
nullptr,
1011 const bool axTypes =
true)
const override
1014 ArgInfo ret = this->types(current, C);
1016 std::rotate(current.
begin(), current.
begin() + 1, current.
end());
1017 ret = current.
back();
1021 names.reserve(this->
size());
1022 for (
size_t i = 0; i < this->
size()-1; ++i) {
1023 names.emplace_back(this->
argName(i));
1028#if LLVM_VERSION_MAJOR <= 15
1036 llvm::LLVMContext& C)
const override
1039 std::vector<llvm::Type*> inputs(args);
1041 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
1042 return DerivedFunction::match(inputs, C);
1049 call(
const std::vector<llvm::Value*>& args,
1050 llvm::IRBuilder<>& B,
1051 const bool cast)
const override
1054 std::vector<llvm::Value*> inputs(args);
1057 std::rotate(inputs.rbegin(), inputs.rbegin() + 1, inputs.rend());
1058 DerivedFunction::call(inputs, B,
cast);
1059 return inputs.front();
1065 template <
typename ...Args>
1072 using Ptr = std::shared_ptr<CFunctionBase>;
1083#if LLVM_VERSION_MAJOR <= 15
1086 const std::vector<llvm::Value*>&,
1087 llvm::LLVMContext&)
const
1092 inline virtual llvm::Value* fold(
1093 const llvm::ArrayRef<llvm::Value*>&,
1094 llvm::LLVMContext&)
const
1102 const std::string&
symbol)
1104 , mConstantFold(false) {}
1115template <
typename SignatureT>
1119 using Ptr = std::shared_ptr<CFunctionT>;
1125 static_assert(std::is_same<typename Traits::ReturnType, void*>::value ||
1126 !std::is_pointer<typename Traits::ReturnType>::value,
1127 "CFunction object has been setup with a pointer return argument. C bindings "
1128 "cannot return memory locations to LLVM - Consider using a CFunctionSRet.");
1132 , mFunction(function) {}
1143 return reinterpret_cast<uint64_t
>(mFunction);
1147 call(
const std::vector<llvm::Value*>& args,
1148 llvm::IRBuilder<>& B)
const override
1150 llvm::Value* result = this->
fold(args, B.getContext());
1151 if (result)
return result;
1158 if (result)
return Value(result);
1162#if LLVM_VERSION_MAJOR <= 15
1163 llvm::Constant*
fold(
const std::vector<llvm::Value*>& args, llvm::LLVMContext& C)
const override final
1165 llvm::Constant*
fold(
const llvm::ArrayRef<llvm::Value*>& args, llvm::LLVMContext& C)
const override final
1170 for (
auto& value : args) {
1171 if (!llvm::isa<llvm::Constant>(value))
return nullptr;
1172 constants.emplace_back(llvm::cast<llvm::Constant>(value));
1178#if LLVM_VERSION_MAJOR <= 15
1179 inline llvm::Type*
types(std::vector<llvm::Type*>&
types, llvm::LLVMContext& C)
const override
1188 call(
const std::vector<llvm::Value*>& args,
1189 llvm::IRBuilder<>& B,
1190 const bool cast)
const override
1192 llvm::Value* result = this->
fold(args, B.getContext());
1193 if (result)
return result;
1199 SignatureT* mFunction;
1205 using Ptr = std::shared_ptr<IRFunctionBase>;
1221 (
const Arguments&, llvm::IRBuilder<>&)>;
1226 (
const std::vector<llvm::Value*>&,
1227 llvm::IRBuilder<>&)>;
1247 create(llvm::LLVMContext& C, llvm::Module* M)
const override;
1254 call(
const std::vector<llvm::Value*>& args,
1255 llvm::IRBuilder<>& B)
const override;
1259#if LLVM_VERSION_MAJOR <= 15
1263 call(
const std::vector<llvm::Value*>& args,
1264 llvm::IRBuilder<>& B,
1265 const bool cast)
const override;
1275 if (result == expected)
return;
1276 std::string source, target;
1280 "\" has been invoked with a mismatching return type. Expected: \"" +
1281 target +
"\", got \"" + source +
"\".");
1287 ,
mGen([this, gen](const
Arguments& args, llvm::IRBuilder<>& B) {
1288 llvm::Value* result = gen(args.AsLLVMValues(), B);
1293 if (result->getType()->isPointerTy())
1295#if LLVM_VERSION_MAJOR <= 15
1296 return Value(result, result->getType()->getPointerElementType());
1299 ArgInfo r = this->types(unused, result->getContext());
1305 return Value(result, result->getType());
1308 , mEmbedIR(
false) {}
1315 return gen(args.AsNativeValues(), B);
1317 , mEmbedIR(
false) {}
1331template <
typename SignatureT>
1335 using Ptr = std::shared_ptr<IRFunction>;
1349#if LLVM_VERSION_MAJOR <= 15
1351 types(std::vector<llvm::Type*>&
types, llvm::LLVMContext& C)
const override
1360template <
typename SignatureT>
1371template <
typename SignatureT>
1397 using Ptr = std::shared_ptr<FunctionGroup>;
1406 , mFunctionList(
list) {}
1430 std::pair<const Function*, Function::SignatureMatch>
1458 const char*
name()
const {
return mName; }
1459 const char*
doc()
const {
return mDoc; }
1461#if LLVM_VERSION_MAJOR <= 15
1467 llvm::LLVMContext& C,
1468 Function::SignatureMatch* type =
nullptr) const;
1471 "supports argument matching/casting is incompatible with LLVM 16+ and will be "
1475 llvm::IRBuilder<>& B) const;
1491 "supports argument matching/casting is incompatible with LLVM 16+ and will be "
1495 llvm::IRBuilder<>& B,
1496 llvm::
Value*& result) const;
1522 using Ptr = std::shared_ptr<Settings>;
1526 if (
mNames)
return false;
1527 if (
mType != Function::Type::kNormal)
return false;
1528 if (!
mDeps.empty())
return false;
1530 if (!
mFnAttrs.empty())
return false;
1536 std::unique_ptr<SmallArgumentVector<const char*>>
mNames =
nullptr;
1541 Function::Type
mType = Function::Type::kNormal;
1544 std::map<size_t, SmallArgumentVector<llvm::Attribute::AttrKind>>
mParamAttrs = {};
1549 , mCurrentSettings(
std::make_shared<
Settings>()) {}
1552 template <
typename Signature,
bool SRet = false>
1556 using CFType =
typename std::conditional
1558 const std::string s = symbol ? symbol : this->genSymbol<Signature>();
1559 this->addSignatureImpl<CFType>(s, ptr);
1564 template <
typename Signature,
bool SRet = false>
1567 const char* symbol =
nullptr)
1569 using IRFType =
typename std::conditional
1572 const std::string s = symbol ? symbol : this->genSymbol<Signature>();
1573 this->addSignatureImpl<IRFType>(s, cb);
1578 template <
typename Signature,
bool SRet = false>
1588 template <
typename Signature,
bool SRet = false>
1593 using IRFType =
typename std::conditional
1596 const std::string s = symbol ? symbol : this->genSymbol<Signature>();
1597 this->addSignatureImpl<IRFType>(s, cb);
1602 template <
typename Signature,
bool SRet = false>
1613 template <
typename Signature,
bool SRet = false>
1616 const char* symbol =
nullptr)
1618 using IRFType =
typename std::conditional
1621 const std::string s = symbol ? symbol : this->genSymbol<Signature>();
1622 this->addSignatureImpl<IRFType>(s, cb);
1627 template <
typename Signature,
bool SRet = false>
1638 mCurrentSettings->mDeps.emplace_back(name);
return *
this;
1645 mCurrentSettings->mNames = std::make_unique<SmallArgumentVector<const char*>>();
1646 mCurrentSettings->mNames->assign(names.begin(), names.end());
1661 mCurrentSettings->mParamAttrs[idx].emplace_back(attr);
1668 mCurrentSettings->mRetAttrs.emplace_back(attr);
1675 mCurrentSettings->mFnAttrs.emplace_back(attr);
1689 mCurrentSettings->mReadOnly = on;
1721 mCurrentSettings->mType = Function::Type::kBuiltin;
1731 mCurrentSettings->mType = Function::Type::kKernel;
1749 for (
auto& decl : mCFunctions)
1751 const auto& s = mSettings.at(decl.get());
1752 if (s->mNames) decl->mNames = *s->mNames;
1753 decl->mDeps = s->mDeps;
1754 decl->setConstantFold(s->mConstantFold);
1755 if (!s->mFnAttrs.empty()) decl->attrs().mFnAttrs = s->mFnAttrs;
1756 if (!s->mRetAttrs.empty()) decl->attrs().mRetAttrs = s->mRetAttrs;
1757 if (!s->mParamAttrs.empty()) {
1758 for (
auto& idxAttrs : s->mParamAttrs) {
1759 if (idxAttrs.first > decl->size())
continue;
1760 decl->attrs().mParamAttrs[idxAttrs.first] = idxAttrs.second;
1763 if (s->mReadOnly) decl->attrs().mReadOnly =
true;
1764 if (s->mType != Function::Type::kNormal) {
1765 decl->attrs().mType = s->mType;
1769 for (
auto& decl : mIRFunctions)
1771 const auto& s = mSettings.at(decl.get());
1772 if (s->mNames) decl->mNames = *s->mNames;
1773 decl->mDeps = s->mDeps;
1774 decl->setEmbedIR(s->mEmbedIR);
1775 if (!s->mFnAttrs.empty()) decl->attrs().mFnAttrs = s->mFnAttrs;
1776 if (!s->mRetAttrs.empty()) decl->attrs().mRetAttrs = s->mRetAttrs;
1777 if (!s->mParamAttrs.empty()) {
1778 for (
auto& idxAttrs : s->mParamAttrs) {
1779 if (idxAttrs.first > decl->size())
continue;
1780 decl->attrs().mParamAttrs[idxAttrs.first] = idxAttrs.second;
1783 if (s->mReadOnly) decl->attrs().mReadOnly =
true;
1784 if (s->mType != Function::Type::kNormal) {
1785 decl->attrs().mType = s->mType;
1792 functions.insert(functions.end(), mIRFunctions.begin(), mIRFunctions.end());
1795 functions.insert(functions.end(), mCFunctions.begin(), mCFunctions.end());
1797 if (functions.empty()) {
1798 functions.insert(functions.end(), mIRFunctions.begin(), mIRFunctions.end());
1799 functions.insert(functions.end(), mCFunctions.begin(), mCFunctions.end());
1802 return std::make_unique<FunctionGroup>(mName, mDoc, std::move(functions));
1806 template <
typename FunctionT,
typename...Args>
1809 Settings::Ptr settings = mCurrentSettings;
1810 if (!mCurrentSettings->isDefault()) {
1811 settings = std::make_shared<Settings>();
1813 auto ptr = std::make_shared<FunctionT>(std::move(args)...);
1814 if constexpr (std::is_base_of_v<IRFunctionBase, FunctionT>) {
1815 mIRFunctions.emplace_back(ptr);
1818 static_assert(std::is_base_of_v<CFunctionBase, FunctionT>);
1819 mCFunctions.emplace_back(ptr);
1821 mSettings[ptr.get()] = settings;
1822 mCurrentSettings = settings;
1826 template <
typename Signature>
1827 std::string genSymbol()
const
1829 using Traits = FunctionTraits<Signature>;
1832 auto callback = [&args](
auto type) {
1833 using Type =
decltype(type);
1834 args += TypeToSymbol<Type>::s();
1837 ArgumentIterator<Signature>::apply(callback,
true);
1843 return "ax." + std::string(this->mName) +
"." +
1844 TypeToSymbol<typename Traits::ReturnType>::s() + args;
1848 const char* mName =
"";
1849 const char* mDoc =
"";
1850 DeclPreferrence mDeclPref = IR;
1851 std::vector<CFunctionBase::Ptr> mCFunctions = {};
1852 std::vector<IRFunctionBase::Ptr> mIRFunctions = {};
1853 std::map<const Function*, Settings::Ptr> mSettings = {};
1854 Settings::Ptr mCurrentSettings =
nullptr;
#define OPENVDB_ASSERT_MESSAGE(X, MSG)
Definition Assert.h:42
#define OPENVDB_ASSERT(X)
Definition Assert.h:41
Constant folding for C++ bindings.
Intermediate representation of supported AX values.
Consolidated llvm types for most supported types.
Definition Exceptions.h:38
Intermediate representation wrapper for supported value types in AX as immutable instances.
Definition Value.h:63
static Value Alloc(llvm::IRBuilder<> &B, llvm::Type *type, llvm::Value *size=nullptr)
Emit IR inserting an allocation at the front of the BasicBlock pointed to by the provided IRBuilder....
Definition Value.h:124
llvm::Value * GetValue() const
Access the underlying llvm Value.
Definition Value.h:673
static Value Invalid()
Return an invalid Value. This is used to represent various fail cases. Note that the operator bool(Va...
Definition Value.h:88
static bool Supports(llvm::Type *utype)
Return true if the underlying type held by utype is supported via the interface of this Value class.
Definition Value.h:109
ArgType< float, 16 > M4F
Definition FunctionTypes.h:139
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:479
ArgType< double, 2 > V2D
Definition FunctionTypes.h:127
ArgType< int32_t, 4 > V4I
Definition FunctionTypes.h:135
ArgInfo llvmArgTypesFromSignature(llvm::LLVMContext &C, ArgInfoVector *types=nullptr)
Populate a vector of ArgInfos from a function signature declaration.
Definition FunctionTypes.h:506
ArgType< float, 3 > V3F
Definition FunctionTypes.h:131
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 Utils.h:117
void llvmTypeToString(const llvm::Type *const type, std::string &str)
Prints an llvm type to a std string.
Definition Utils.h:80
ArgType< double, 9 > M3D
Definition FunctionTypes.h:136
ArgType< double, 16 > M4D
Definition FunctionTypes.h:138
ArgType< float, 4 > V4F
Definition FunctionTypes.h:134
ArgType< int32_t, 3 > V3I
Definition FunctionTypes.h:132
llvm::FunctionType * llvmFunctionTypeFromSignature(llvm::LLVMContext &C)
Generate an LLVM FunctionType from a function signature.
Definition FunctionTypes.h:554
ArgType< double, 4 > V4D
Definition FunctionTypes.h:133
OPENVDB_AX_API void printSignature(std::ostream &os, const ArgInfoVector &types, const ArgInfo &returnType, const char *name=nullptr, const llvm::ArrayRef< const char * > &names={}, const bool axTypes=false)
Print a function signature to the provided ostream.
ArgType< float, 9 > M3F
Definition FunctionTypes.h:137
ArgType< int32_t, 2 > V2I
Definition FunctionTypes.h:129
llvm::SmallVector< T, 3 > SmallArgumentVector
Typedef a stack allocated array with malloc grow support for anything which is relatively small and b...
Definition FunctionTypes.h:110
ArgType< float, 2 > V2F
Definition FunctionTypes.h:128
ArgType< double, 3 > V3D
Definition FunctionTypes.h:130
Definition OpenSimplexNoise.h:31
Definition Exceptions.h:13
#define OPENVDB_THROW(exception, message)
Definition Exceptions.h:74
Utility code generation methods for performing various llvm operations.
Alias mapping between two types, a frontend type T1 and a backend type T2. This class is the intended...
Definition Types.h:269
Container of ArgInfos. This class makes up part of the Function API for querying signature informatio...
Definition FunctionTypes.h:280
auto size() const
Definition FunctionTypes.h:309
bool operator!=(const ArgInfoVector &other) const
Definition FunctionTypes.h:293
SmallArgumentVector< llvm::Type * > AsLLVMTypes() const
Definition FunctionTypes.h:327
ArgInfoVector & operator=(const ArgInfoVector &)=default
ArgInfoVector(const ArgInfoVector &)=default
auto clear()
Definition FunctionTypes.h:308
auto rend() const
Definition FunctionTypes.h:302
void reserve(size_t i)
Definition FunctionTypes.h:313
auto rend()
Definition FunctionTypes.h:300
auto erase(ContainerT::const_iterator iter)
Definition FunctionTypes.h:311
auto & back()
Definition FunctionTypes.h:305
SmallArgumentVector< ArgInfo > ContainerT
Definition FunctionTypes.h:282
auto & front()
Definition FunctionTypes.h:303
auto end()
Definition FunctionTypes.h:296
ArgInfo & operator[](size_t pos)
Definition FunctionTypes.h:316
const ArgInfo & operator[](size_t pos) const
Definition FunctionTypes.h:321
auto empty() const
Definition FunctionTypes.h:310
auto pop_back()
Definition FunctionTypes.h:307
auto & front() const
Definition FunctionTypes.h:304
void emplace_back(Args &&...args)
Definition FunctionTypes.h:315
auto rbegin()
Definition FunctionTypes.h:299
ArgInfoVector(ArgInfoVector &&)=default
auto & back() const
Definition FunctionTypes.h:306
ArgInfoVector & operator=(ArgInfoVector &&)=default
auto rbegin() const
Definition FunctionTypes.h:301
auto begin() const
Definition FunctionTypes.h:297
auto begin()
Definition FunctionTypes.h:295
auto end() const
Definition FunctionTypes.h:298
ArgInfoVector(const std::initializer_list< ArgInfo > &info)
Definition FunctionTypes.h:285
bool operator==(const ArgInfoVector &other) const
Definition FunctionTypes.h:292
Metadata associated with a function argument or return value.
Definition FunctionTypes.h:225
ArgInfo & operator=(ArgInfo &&)=default
bool IsPtr() const
Definition FunctionTypes.h:254
ArgInfo(llvm::Type *utype)
Definition FunctionTypes.h:228
bool IsVoid() const
Definition FunctionTypes.h:257
ArgInfo(const Value &val)
Definition FunctionTypes.h:226
bool IsNative() const
Definition FunctionTypes.h:256
ArgInfo(const ArgInfo &)=default
bool operator!=(const ArgInfo &other) const
Definition FunctionTypes.h:247
uint8_t NumPtrs() const
Definition FunctionTypes.h:255
bool IsReturn() const
Definition FunctionTypes.h:258
ArgInfo & operator=(const ArgInfo &)=default
bool operator==(const ArgInfo &other) const
Definition FunctionTypes.h:240
bool IsMatchingType(const ArgInfo &other) const
Definition FunctionTypes.h:248
llvm::Type * GetUnderlyingType() const
Definition FunctionTypes.h:259
ArgInfo(llvm::Type *utype, uint8_t ptrs, bool ret=false)
Definition FunctionTypes.h:229
ArgInfo(ArgInfo &&)=default
void SetIsReturn()
Definition FunctionTypes.h:268
llvm::Type * GetType() const
Definition FunctionTypes.h:260
Object to array conversion methods to allow functions to return vector types. These containers provid...
Definition FunctionTypes.h:117
T Type
Definition FunctionTypes.h:118
static const size_t SIZE
Definition FunctionTypes.h:119
ArrayType mmArgs
Definition FunctionTypes.h:121
Type[SIZE] ArrayType
Definition FunctionTypes.h:120
static const bool IsNativeSignature
Definition FunctionTypes.h:215
static void apply(const OpT &, const bool)
Definition FunctionTypes.h:217
Templated argument iterator which implements various small functions per argument type,...
Definition FunctionTypes.h:189
static const bool IsNativeSignature
Whether this signature contains types that are representable in AX's Value type.
Definition FunctionTypes.h:195
static void apply(const OpT &op, const bool forwards)
Definition FunctionTypes.h:200
typename FunctionTraits< SignatureT >::template Arg< I-1 > ArgT
Definition FunctionTypes.h:190
typename ArgT::Type ArgumentValueType
Definition FunctionTypes.h:191
Arbitrary, potentially "non-native" arguments. This wrapper struct can be used when generating functi...
Definition FunctionTypes.h:382
const ArgInfo & GetArgInfo(size_t pos) const
Definition FunctionTypes.h:427
Value AsNativeValue(const size_t i) const
Definition FunctionTypes.h:410
const llvm::ArrayRef< llvm::Value * > AsLLVMValues() const
Definition FunctionTypes.h:426
size_t size() const
Definition FunctionTypes.h:400
void AddArg(const Value &val)
Definition FunctionTypes.h:448
NativeArguments AsNativeValues() const
Definition FunctionTypes.h:416
Arguments(const Arguments &)=default
Arguments(Arguments &&)=default
Arguments & operator=(const Arguments &)=default
Arguments(const NativeArguments &args)
Create a set of arguments from native arguments. The function framework typically works on generic ar...
Definition FunctionTypes.h:387
void AddArg(llvm::Value *val, const ArgInfo &type)
Definition FunctionTypes.h:436
Arguments & operator=(Arguments &&)=default
bool AreNativeValues() const
Definition FunctionTypes.h:402
void PrependArg(const Value &val)
Definition FunctionTypes.h:454
llvm::Value * operator[](size_t pos) const
Definition FunctionTypes.h:430
const ArgInfoVector & GetArgInfo() const
Definition FunctionTypes.h:428
bool hasConstantFold() const
Definition FunctionTypes.h:1081
void setConstantFold(bool on)
Definition FunctionTypes.h:1080
virtual llvm::Value * fold(const std::vector< llvm::Value * > &, llvm::LLVMContext &) const
Definition FunctionTypes.h:1085
virtual uint64_t address() const =0
Returns the global address of this function.
CFunctionBase(const size_t size, const std::string &symbol)
Definition FunctionTypes.h:1101
~CFunctionBase() override=default
std::shared_ptr< CFunctionBase > Ptr
Definition FunctionTypes.h:1072
Represents a concrete C function binding with the first argument as its return type.
Definition FunctionTypes.h:1362
CFunctionSRet(const std::string &symbol, const SignatureT function)
Definition FunctionTypes.h:1364
SRetFunction< SignatureT, CFunction< SignatureT > > BaseT
Definition FunctionTypes.h:1363
~CFunctionSRet() override=default
Represents a concrete C function binding.
Definition FunctionTypes.h:1117
std::shared_ptr< CFunctionT > Ptr
Definition FunctionTypes.h:1119
Value call(const Arguments &args, llvm::IRBuilder<> &B) const override
Definition FunctionTypes.h:1155
uint64_t address() const override final
Returns the global address of this function.
Definition FunctionTypes.h:1141
FunctionTraits< SignatureT > Traits
Definition FunctionTypes.h:1120
llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const override
Definition FunctionTypes.h:1188
llvm::Type * types(std::vector< llvm::Type * > &types, llvm::LLVMContext &C) const override
Definition FunctionTypes.h:1179
ArgInfo types(ArgInfoVector &types, llvm::LLVMContext &C) const override
Populate a vector of ArgInfos which describe this function signature. This method is used by Function...
Definition FunctionTypes.h:1136
~CFunction() override=default
llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B) const override
Definition FunctionTypes.h:1147
llvm::Constant * fold(const std::vector< llvm::Value * > &args, llvm::LLVMContext &C) const override final
Definition FunctionTypes.h:1163
CFunction(const std::string &symbol, SignatureT *function)
Definition FunctionTypes.h:1130
CFunction< SignatureT > CFunctionT
Definition FunctionTypes.h:1118
static llvm::Constant * fold(const llvm::ArrayRef< llvm::Constant * > &args, const SignatureT &function, llvm::LLVMContext &C, Tys &&... ts)
Definition ConstantFolding.h:56
static constexpr uint8_t value
Definition Types.h:50
Definition FunctionTypes.h:1521
std::unique_ptr< SmallArgumentVector< const char * > > mNames
Definition FunctionTypes.h:1536
bool mReadOnly
Definition FunctionTypes.h:1540
std::shared_ptr< Settings > Ptr
Definition FunctionTypes.h:1522
SmallArgumentVector< const char * > mDeps
Definition FunctionTypes.h:1537
bool isDefault() const
Definition FunctionTypes.h:1524
Function::Type mType
Definition FunctionTypes.h:1541
bool mEmbedIR
Definition FunctionTypes.h:1539
SmallArgumentVector< llvm::Attribute::AttrKind > mFnAttrs
Definition FunctionTypes.h:1542
std::map< size_t, SmallArgumentVector< llvm::Attribute::AttrKind > > mParamAttrs
Definition FunctionTypes.h:1544
bool mConstantFold
Definition FunctionTypes.h:1538
SmallArgumentVector< llvm::Attribute::AttrKind > mRetAttrs
Definition FunctionTypes.h:1543
The FunctionBuilder class provides a builder pattern framework to allow easy and valid construction o...
Definition FunctionTypes.h:1515
FunctionGroup::UniquePtr get() const
Definition FunctionTypes.h:1747
FunctionBuilder & addFunctionAttribute(const llvm::Attribute::AttrKind attr)
Definition FunctionTypes.h:1673
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorCb &cb, const Signature *ptr, const char *symbol=nullptr)
Definition FunctionTypes.h:1580
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorCb &cb, const char *symbol=nullptr)
Definition FunctionTypes.h:1566
FunctionBuilder & addParameterAttribute(const size_t idx, const llvm::Attribute::AttrKind attr)
Parameter and Function Attributes. When designing a C binding, llvm will be unable to assign paramete...
Definition FunctionTypes.h:1659
FunctionBuilder & setPreferredImpl(DeclPreferrence pref)
Definition FunctionTypes.h:1741
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorArgumentsCb &cb, const Signature *ptr, const char *symbol=nullptr)
Definition FunctionTypes.h:1629
DeclPreferrence
Definition FunctionTypes.h:1516
@ IR
Definition FunctionTypes.h:1517
@ C
Definition FunctionTypes.h:1517
@ Any
Definition FunctionTypes.h:1517
FunctionBuilder & addDependency(const char *name)
Definition FunctionTypes.h:1636
FunctionBuilder & setConstantFold(bool on)
Definition FunctionTypes.h:1642
FunctionBuilder & addSignature(const Signature *ptr, const char *symbol=nullptr)
Definition FunctionTypes.h:1554
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorNativeCb &cb, const Signature *ptr, const char *symbol=nullptr)
Definition FunctionTypes.h:1604
FunctionBuilder(const char *name)
Definition FunctionTypes.h:1547
FunctionBuilder & addReturnAttribute(const llvm::Attribute::AttrKind attr)
Definition FunctionTypes.h:1666
FunctionBuilder & setArgumentNames(const std::vector< const char * > &names)
Definition FunctionTypes.h:1643
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorNativeCb &cb, const char *symbol=nullptr)
Definition FunctionTypes.h:1590
FunctionBuilder & setReadOnly(const bool on)
Mark functions currently sharing settings with as "readonly". This enables the strictest possible mem...
Definition FunctionTypes.h:1687
FunctionBuilder & setExternalKernel()
Mark this function as an external kernel entry point. Should only be used by the ComputeGenerators....
Definition FunctionTypes.h:1729
FunctionBuilder & setDocumentation(const char *doc)
Definition FunctionTypes.h:1735
FunctionBuilder & setBuiltin()
Mark functions currently sharing settings as builtin AX methods. At compile time, this causes the IR ...
Definition FunctionTypes.h:1716
FunctionBuilder & addSignature(const IRFunctionBase::GeneratorArgumentsCb &cb, const char *symbol=nullptr)
Definition FunctionTypes.h:1615
FunctionBuilder & setEmbedIR(bool on)
Definition FunctionTypes.h:1641
bool HasUniqueTypeSignatures(llvm::LLVMContext &C) const
Verify the function signatures in this group.
Value execute(const NativeArguments &args, llvm::IRBuilder<> &B) const
Given a set of NativeArguments, find the best possible function signature, generate and execute the f...
std::vector< Function::Ptr > FunctionList
Definition FunctionTypes.h:1399
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....
std::pair< const Function *, Function::SignatureMatch > match(const ArgInfoVector &args, llvm::LLVMContext &C) const
Given a vector of args, automatically returns the best possible function declaration from the stored ...
std::shared_ptr< FunctionGroup > Ptr
Definition FunctionTypes.h:1397
std::unique_ptr< FunctionGroup > UniquePtr
Definition FunctionTypes.h:1398
const char * name() const
Definition FunctionTypes.h:1458
const char * doc() const
Definition FunctionTypes.h:1459
const FunctionList & list() const
Accessor to the underlying function signature list.
Definition FunctionTypes.h:1457
FunctionGroup(const char *name, const char *doc, const FunctionList &list)
Definition FunctionTypes.h:1401
Templated function traits which provides compile-time index access to the types of the function signa...
Definition Types.h:311
The base/abstract representation of an AX function. Derived classes must implement the Function::type...
Definition FunctionTypes.h:603
virtual SignatureMatch match(const ArgInfoVector &inputs, llvm::LLVMContext &C) const
The base implementation for determining how a vector of llvm arguments translates to this functions s...
Value call(const NativeArguments &args, llvm::IRBuilder<> &B) const
Definition FunctionTypes.h:716
const char * argName(const size_t idx) const
Returns the descriptive name of the given argument index.
Definition FunctionTypes.h:773
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.
void setDependencies(std::vector< const char * > deps)
Definition FunctionTypes.h:819
size_t size() const
The number of arguments that this function has.
Definition FunctionTypes.h:762
virtual llvm::Function * create(llvm::LLVMContext &C, llvm::Module *M=nullptr) const
Converts and creates this AX function into a llvm Function.
void setParamAttributes(const size_t i, const std::vector< llvm::Attribute::AttrKind > &in)
Definition FunctionTypes.h:837
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....
virtual llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B) const
Function(const size_t size, const std::string &symbol)
Definition FunctionTypes.h:606
void setRetAttributes(const std::vector< llvm::Attribute::AttrKind > &in)
Definition FunctionTypes.h:831
const SmallArgumentVector< const char * > & dependencies() const
Definition FunctionTypes.h:794
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:667
void setFnAttributes(const std::vector< llvm::Attribute::AttrKind > &in)
Definition FunctionTypes.h:825
std::shared_ptr< Function > Ptr
Definition FunctionTypes.h:604
virtual llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const
Uses the IRBuilder to create a call to this function with the given arguments, creating the function ...
bool hasParamAttribute(const size_t i, const llvm::Attribute::AttrKind &kind) const
Deprecated builder methods, no longer public.
Definition FunctionTypes.h:802
const char * symbol() const
The function symbol name.
Definition FunctionTypes.h:766
virtual ArgInfo types(ArgInfoVector &, llvm::LLVMContext &) const
Populate a vector of ArgInfos which describe this function signature. This method is used by Function...
Definition FunctionTypes.h:625
virtual ~Function()=default
llvm::Function * get(const llvm::Module &M) const
Convenience method for calling M.getFunction(symbol). Returns a nullptr if the function has not yet b...
SignatureMatch
The result type from calls to Function::match.
Definition FunctionTypes.h:725
@ Implicit
Definition FunctionTypes.h:728
@ Ambiguous
Definition FunctionTypes.h:729
@ None
Definition FunctionTypes.h:726
@ Explicit
Definition FunctionTypes.h:730
@ Size
Definition FunctionTypes.h:727
void setArgumentNames(std::vector< const char * > names)
Definition FunctionTypes.h:813
virtual Value call(const Arguments &args, llvm::IRBuilder<> &B) const
IRFunctionBase(const std::string &symbol, const GeneratorNativeCb &gen, const size_t size)
Definition FunctionTypes.h:1309
bool hasEmbedIR() const
Definition FunctionTypes.h:1232
void setEmbedIR(bool on)
Enable or disable the embedding of IR. Embedded IR is currently required for function which use paren...
Definition FunctionTypes.h:1231
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 ...
std::shared_ptr< IRFunctionBase > Ptr
Definition FunctionTypes.h:1205
const GeneratorArgumentsCb mGen
Definition FunctionTypes.h:1326
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...
std::function< llvm::Value *(const std::vector< llvm::Value * > &, llvm::IRBuilder<> &)> GeneratorCb
Legacy callback, will eventually be deprecated in favour of using the GeneratorArgumentsCb.
Definition FunctionTypes.h:1225
Value call(const Arguments &args, llvm::IRBuilder<> &) const override
bool mEmbedIR
Definition FunctionTypes.h:1327
llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B) const override
Override for call, which is only necessary if mEmbedIR is true, as the IR generation for embedded fun...
IRFunctionBase(const std::string &symbol, const GeneratorCb &gen, const size_t size)
Definition FunctionTypes.h:1283
void verifyResultType(const llvm::Type *result, const llvm::Type *expected) const
Definition FunctionTypes.h:1273
std::function< Value(const NativeArguments &, llvm::IRBuilder<> &)> GeneratorNativeCb
The IR callback function which will write the LLVM IR for this function's body.
Definition FunctionTypes.h:1217
std::function< Value(const Arguments &, llvm::IRBuilder<> &)> GeneratorArgumentsCb
Definition FunctionTypes.h:1220
IRFunctionBase(const std::string &symbol, const GeneratorArgumentsCb &gen, const size_t size)
Definition FunctionTypes.h:1318
~IRFunctionBase() override=default
Represents a concrete IR function with the first argument as its return type.
Definition FunctionTypes.h:1373
IRFunctionSRet(const std::string &symbol, const IRFunctionBase::GeneratorCb &gen)
Definition FunctionTypes.h:1375
IRFunctionSRet(const std::string &symbol, const IRFunctionBase::GeneratorArgumentsCb &gen)
Definition FunctionTypes.h:1381
IRFunctionSRet(const std::string &symbol, const IRFunctionBase::GeneratorNativeCb &gen)
Definition FunctionTypes.h:1378
SRetFunction< SignatureT, IRFunction< SignatureT > > BaseT
Definition FunctionTypes.h:1374
~IRFunctionSRet() override=default
Represents a concrete IR function.
Definition FunctionTypes.h:1333
IRFunction(const std::string &symbol, const GeneratorArgumentsCb &gen)
Definition FunctionTypes.h:1341
FunctionTraits< SignatureT > Traits
Definition FunctionTypes.h:1334
llvm::Type * types(std::vector< llvm::Type * > &types, llvm::LLVMContext &C) const override
Definition FunctionTypes.h:1351
ArgInfo types(ArgInfoVector &types, llvm::LLVMContext &C) const override
Populate a vector of ArgInfos which describe this function signature. This method is used by Function...
Definition FunctionTypes.h:1344
IRFunction(const std::string &symbol, const GeneratorCb &gen)
Definition FunctionTypes.h:1337
IRFunction(const std::string &symbol, const GeneratorNativeCb &gen)
Definition FunctionTypes.h:1339
std::shared_ptr< IRFunction > Ptr
Definition FunctionTypes.h:1335
LLVM type mapping from pod types.
Definition Types.h:68
static const bool CXXUTypeIsNativeType
Definition Types.h:76
static llvm::Type * get(llvm::LLVMContext &C)
Return an LLVM type which represents T.
Definition Types.h:81
Wrapper struct to represent "native" function arguments; that is, the set of Value type that the AX g...
Definition FunctionTypes.h:349
size_t size() const
Definition FunctionTypes.h:359
NativeArguments & operator=(const NativeArguments &)=default
void AddArg(const Value &val)
Definition FunctionTypes.h:370
NativeArguments()=default
NativeArguments(const std::initializer_list< Value > &args)
Definition FunctionTypes.h:351
OPENVDB_AX_API NativeArguments Cast(const Function &F, llvm::IRBuilder<> &B) const
Cast these arguments to match the given function's signature.
NativeArguments(const std::vector< Value > &args)
Definition FunctionTypes.h:353
Value & operator[](size_t pos)
Definition FunctionTypes.h:360
NativeArguments & operator=(NativeArguments &&)=default
const Value & operator[](size_t pos) const
Definition FunctionTypes.h:365
NativeArguments(NativeArguments &&)=default
NativeArguments(const NativeArguments &)=default
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:1008
Value call(const Arguments &args, llvm::IRBuilder<> &B) const override
Definition FunctionTypes.h:997
std::shared_ptr< SRetFunction< SignatureT, DerivedFunction > > Ptr
Definition FunctionTypes.h:921
FunctionTraits< SignatureT > Traits
Definition FunctionTypes.h:922
llvm::Value * call(const std::vector< llvm::Value * > &args, llvm::IRBuilder<> &B, const bool cast) const override
Definition FunctionTypes.h:1049
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.
Definition FunctionTypes.h:963
SRetFunction(Args &&... ts)
Forward all arguments to the derived class.
Definition FunctionTypes.h:1066
Function::SignatureMatch match(const std::vector< llvm::Type * > &args, llvm::LLVMContext &C) const override
Definition FunctionTypes.h:1035
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.
Definition FunctionTypes.h:985
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 argume...
Definition FunctionTypes.h:950
An extremely basic but native representation of a string class with SSO support. This exists to provi...
Definition String.h:34
static std::string s()
Definition FunctionTypes.h:164
static std::string s()
Definition FunctionTypes.h:169
static std::string s()
Definition FunctionTypes.h:149
static std::string s()
Definition FunctionTypes.h:160
static std::string s()
Definition FunctionTypes.h:159
static std::string s()
Definition FunctionTypes.h:158
static std::string s()
Definition FunctionTypes.h:155
static std::string s()
Definition FunctionTypes.h:156
static std::string s()
Definition FunctionTypes.h:157
static std::string s()
Definition FunctionTypes.h:154
static std::string s()
Definition FunctionTypes.h:151
static std::string s()
Definition FunctionTypes.h:152
static std::string s()
Definition FunctionTypes.h:153
static std::string s()
Definition FunctionTypes.h:150
static std::string s()
Definition FunctionTypes.h:148
Type to symbol conversions - these characters are used to build each functions unique signature....
Definition FunctionTypes.h:147
static std::string s()
Definition FunctionTypes.h:147
#define OPENVDB_VERSION_NAME
The version namespace name for this library version.
Definition version.h.in:121
#define OPENVDB_USE_VERSION_NAMESPACE
Definition version.h.in:218