From 44043bca568b2305df00b42b0d32eaa12380d44c Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Sun, 4 Nov 2018 02:38:13 -0300 Subject: [PATCH] Add OpCompositeConstruct --- include/sirit/sirit.h | 4 ++++ src/insts/memory.cpp | 8 ++++++++ 2 files changed, 12 insertions(+) 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