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

Method CreateAccessChainWithIndex

source/opt/interface_var_sroa.cpp:511–531  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

509}
510
511Instruction* InterfaceVariableScalarReplacement::CreateAccessChainWithIndex(
512 uint32_t component_type_id, Instruction* var, uint32_t index,
513 Instruction* insert_before) {
514 uint32_t ptr_type_id =
515 GetPointerType(component_type_id, GetStorageClass(var));
516 uint32_t index_id = context()->get_constant_mgr()->GetUIntConstId(index);
517 uint32_t new_id = TakeNextId();
518 if (new_id == 0) {
519 return nullptr;
520 }
521 std::unique_ptr<Instruction> new_access_chain(
522 new Instruction(context(), spv::Op::OpAccessChain, ptr_type_id, new_id,
523 std::initializer_list<Operand>{
524 {SPV_OPERAND_TYPE_ID, {var->result_id()}},
525 {SPV_OPERAND_TYPE_ID, {index_id}},
526 }));
527 Instruction* inst = new_access_chain.get();
528 context()->get_def_use_mgr()->AnalyzeInstDefUse(inst);
529 insert_before->InsertBefore(std::move(new_access_chain));
530 return inst;
531}
532
533void InterfaceVariableScalarReplacement::ReplaceAccessChainWith(
534 Instruction* access_chain,

Callers

nothing calls this directly

Calls 8

GetUIntConstIdMethod · 0.80
get_constant_mgrMethod · 0.80
getMethod · 0.80
AnalyzeInstDefUseMethod · 0.80
GetStorageClassFunction · 0.70
result_idMethod · 0.45
get_def_use_mgrMethod · 0.45
InsertBeforeMethod · 0.45

Tested by

no test coverage detected