Add OpCompositeExtract

This commit is contained in:
ReinUsesLisp 2018-11-03 20:41:03 -03:00
parent 65ccda50c7
commit ad963b6520
2 changed files with 20 additions and 6 deletions

View file

@ -229,6 +229,10 @@ class Module {
Id OpCompositeInsert(Id result_type, Id object, Id composite, Id OpCompositeInsert(Id result_type, Id object, Id composite,
const std::vector<Literal>& indexes = {}); const std::vector<Literal>& indexes = {});
/// Extract a part of a composite object.
Id OpCompositeExtract(Id result_type, Id composite,
const std::vector<Literal>& indexes = {});
// Annotation // Annotation
/// Add a decoration to target. /// Add a decoration to target.

View file

@ -52,11 +52,21 @@ Id Module::OpAccessChain(Id result_type, Id base,
Id Module::OpCompositeInsert(Id result_type, Id object, Id composite, Id Module::OpCompositeInsert(Id result_type, Id object, Id composite,
const std::vector<Literal>& indexes) { const std::vector<Literal>& indexes) {
auto op{std::make_unique<Op>(spv::Op::OpCompositeInsert, bound++, result_type)}; auto op{
std::make_unique<Op>(spv::Op::OpCompositeInsert, bound++, result_type)};
op->Add(object); op->Add(object);
op->Add(composite); op->Add(composite);
op->Add(indexes); op->Add(indexes);
return AddCode(std::move(op)); return AddCode(std::move(op));
} }
Id Module::OpCompositeExtract(Id result_type, Id composite,
const std::vector<Literal>& indexes) {
auto op{std::make_unique<Op>(spv::Op::OpCompositeExtract, bound++,
result_type)};
op->Add(composite);
op->Add(indexes);
return AddCode(std::move(op));
}
} // namespace Sirit } // namespace Sirit