X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=source%2Fopt%2Fir_builder.h;h=9c153deb684f8151c83a8570d57f58c30d1427f0;hb=bc1ec9418b89c996de85d68d28d070e6b2991a48;hp=b376f6d257ddf0ed611f9a68312f59285ad0d48f;hpb=1c0056c339227ca9e337ce3d2f5b83b1f8ccb1e5;p=platform%2Fupstream%2FSPIRV-Tools.git diff --git a/source/opt/ir_builder.h b/source/opt/ir_builder.h index b376f6d..9c153de 100644 --- a/source/opt/ir_builder.h +++ b/source/opt/ir_builder.h @@ -152,6 +152,22 @@ class InstructionBuilder { return AddInstruction(std::move(construct)); } + ir::Instruction* AddCompositeExtract( + uint32_t type, uint32_t id_of_composite, + const std::vector& index_list) { + std::vector operands; + operands.push_back({SPV_OPERAND_TYPE_ID, {id_of_composite}}); + + for (uint32_t index : index_list) { + operands.push_back({SPV_OPERAND_TYPE_LITERAL_INTEGER, {index}}); + } + + std::unique_ptr new_inst( + new ir::Instruction(GetContext(), SpvOpCompositeExtract, type, + GetContext()->TakeNextId(), operands)); + return AddInstruction(std::move(new_inst)); + } + // Inserts the new instruction before the insertion point. ir::Instruction* AddInstruction(std::unique_ptr&& insn) { ir::Instruction* insn_ptr = &*insert_before_.InsertBefore(std::move(insn));