MCPcopy Create free account
hub / github.com/KhronosGroup/SPIRV-Tools / InsertConstructedObject

Function InsertConstructedObject

source/opt/folding_rules.cpp:2785–2793  ·  view source on GitHub ↗

Replaces the OpCompositeInsert |inst| that inserts |construct| into the same object as |inst| with final index removed. If the resulting OpCompositeInsert instruction would have no remaining indexes, the instruction is replaced with an OpCopyObject instead.

Source from the content-addressed store, hash-verified

2783// OpCompositeInsert instruction would have no remaining indexes, the
2784// instruction is replaced with an OpCopyObject instead.
2785void InsertConstructedObject(Instruction* inst, const Instruction* construct) {
2786 if (inst->NumInOperands() == 3) {
2787 inst->SetOpcode(spv::Op::OpCopyObject);
2788 inst->SetInOperands({{SPV_OPERAND_TYPE_ID, {construct->result_id()}}});
2789 } else {
2790 inst->SetInOperand(kInsertObjectIdInIdx, {construct->result_id()});
2791 inst->RemoveOperand(inst->NumOperands() - 1);
2792 }
2793}
2794
2795// Replaces a series of |OpCompositeInsert| instruction that cover the entire
2796// object with an |OpCompositeConstruct|.

Callers 1

Calls 7

NumInOperandsMethod · 0.80
SetOpcodeMethod · 0.80
SetInOperandsMethod · 0.80
SetInOperandMethod · 0.80
RemoveOperandMethod · 0.80
NumOperandsMethod · 0.80
result_idMethod · 0.45

Tested by

no test coverage detected