Commit 1bc1acfe by Chris Forbes

Add support for OpCompositeInsert

Most of the subtlety here comes from needing to deal with either the old parts or the new being possibly a constant object. Uses WalkLiteralAccessChain combined with the size of the "new part" to determine the range within the object which should be replaced. Bug: b/126475423 Change-Id: I81f58d0de5dcacc74ffbd155708996c23dbe388e Reviewed-on: https://swiftshader-review.googlesource.com/c/25214Tested-by: 's avatarChris Forbes <chrisforbes@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarBen Clayton <bclayton@google.com> Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
parent 9638b948
......@@ -260,6 +260,7 @@ namespace sw
case spv::OpLoad:
case spv::OpAccessChain:
case spv::OpCompositeConstruct:
case spv::OpCompositeInsert:
// Instructions that yield an ssavalue.
{
TypeID typeId = insn.word(1);
......@@ -987,6 +988,29 @@ namespace sw
}
break;
}
case spv::OpCompositeInsert:
{
TypeID resultTypeId = insn.word(1);
auto &type = getType(resultTypeId);
auto &dst = routine->createIntermediate(insn.word(2), type.sizeInComponents);
auto &newPartObject = getObject(insn.word(3));
auto &newPartObjectTy = getType(newPartObject.type);
auto firstNewComponent = WalkLiteralAccessChain(resultTypeId, insn.wordCount() - 5, insn.wordPointer(5));
GenericValue srcObjectAccess(this, routine, insn.word(4));
GenericValue newPartObjectAccess(this, routine, insn.word(3));
// old components before
for (auto i = 0u; i < firstNewComponent; i++)
dst.emplace(i, srcObjectAccess[i]);
// new part
for (auto i = 0u; i < newPartObjectTy.sizeInComponents; i++)
dst.emplace(firstNewComponent + i, newPartObjectAccess[i]);
// old components after
for (auto i = firstNewComponent + newPartObjectTy.sizeInComponents; i < type.sizeInComponents; i++)
dst.emplace(i, srcObjectAccess[i]);
break;
}
default:
printf("emit: ignoring opcode %d\n", insn.opcode());
break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment