| 480 | } |
| 481 | |
| 482 | Instruction* 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 | |
| 511 | Instruction* InterfaceVariableScalarReplacement::CreateAccessChainWithIndex( |
| 512 | uint32_t component_type_id, Instruction* var, uint32_t index, |
nothing calls this directly
no test coverage detected