diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index d24ce2c..ee3a024 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -160,6 +160,10 @@ class Module { /// Ends a function. Id OpFunctionEnd(); + /// Call a function. + Id OpFunctionCall(Id result_type, Id function, + const std::vector& arguments = {}); + // Flow /// Declare a structured loop. diff --git a/src/insts/function.cpp b/src/insts/function.cpp index dcd803a..f9f74df 100644 --- a/src/insts/function.cpp +++ b/src/insts/function.cpp @@ -20,4 +20,13 @@ Id Module::OpFunction(Id result_type, spv::FunctionControlMask function_control, Id Module::OpFunctionEnd() { return AddCode(spv::Op::OpFunctionEnd); } +Id Module::OpFunctionCall(Id result_type, Id function, + const std::vector& arguments) { + auto op{ + std::make_unique(spv::Op::OpFunctionCall, bound++, result_type)}; + op->Add(function); + op->Add(arguments); + return AddCode(std::move(op)); +} + } // namespace Sirit