diff --git a/include/sirit/sirit.h b/include/sirit/sirit.h index b2509f2..996b8db 100644 --- a/include/sirit/sirit.h +++ b/include/sirit/sirit.h @@ -237,6 +237,10 @@ class Module { Id OpCompositeExtract(Id result_type, Id composite, const std::vector& indexes = {}); + /// Construct a new composite object from a set of constituent objects that + /// will fully form it. + Id OpCompositeConstruct(Id result_type, const std::vector& ids); + // Annotation /// Add a decoration to target. diff --git a/src/insts/memory.cpp b/src/insts/memory.cpp index 7306cd8..4e9d2d3 100644 --- a/src/insts/memory.cpp +++ b/src/insts/memory.cpp @@ -69,4 +69,12 @@ Id Module::OpCompositeExtract(Id result_type, Id composite, return AddCode(std::move(op)); } +Id Module::OpCompositeConstruct(Id result_type, const std::vector& ids) { + assert(ids.size() >= 1); + auto op{std::make_unique(spv::Op::OpCompositeConstruct, bound++, + result_type)}; + op->Add(ids); + return AddCode(std::move(op)); +} + } // namespace Sirit