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

Method CreateAccessChainToVar

source/opt/interface_var_sroa.cpp:482–509  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480}
481
482Instruction* InterfaceVariableScalarReplacement::CreateAccessChainToVar(
483 uint32_t var_type_id, Instruction* var,
484 const std::vector<uint32_t>& index_ids, Instruction* insert_before,
485 uint32_t* component_type_id) {
486 analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr();
487 *component_type_id = GetComponentTypeOfArrayMatrix(
488 def_use_mgr, var_type_id, static_cast<uint32_t>(index_ids.size()));
489
490 uint32_t ptr_type_id =
491 GetPointerType(*component_type_id, GetStorageClass(var));
492
493 uint32_t new_id = TakeNextId();
494 if (new_id == 0) {
495 return nullptr;
496 }
497 std::unique_ptr<Instruction> new_access_chain(
498 new Instruction(context(), spv::Op::OpAccessChain, ptr_type_id, new_id,
499 std::initializer_list<Operand>{
500 {SPV_OPERAND_TYPE_ID, {var->result_id()}}}));
501 for (uint32_t index_id : index_ids) {
502 new_access_chain->AddOperand({SPV_OPERAND_TYPE_ID, {index_id}});
503 }
504
505 Instruction* inst = new_access_chain.get();
506 def_use_mgr->AnalyzeInstDefUse(inst);
507 insert_before->InsertBefore(std::move(new_access_chain));
508 return inst;
509}
510
511Instruction* InterfaceVariableScalarReplacement::CreateAccessChainWithIndex(
512 uint32_t component_type_id, Instruction* var, uint32_t index,

Callers

nothing calls this directly

Calls 9

AddOperandMethod · 0.80
getMethod · 0.80
AnalyzeInstDefUseMethod · 0.80
GetStorageClassFunction · 0.70
get_def_use_mgrMethod · 0.45
sizeMethod · 0.45
result_idMethod · 0.45
InsertBeforeMethod · 0.45

Tested by

no test coverage detected