| 509 | } |
| 510 | |
| 511 | Instruction* 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 | |
| 533 | void InterfaceVariableScalarReplacement::ReplaceAccessChainWith( |
| 534 | Instruction* access_chain, |
nothing calls this directly
no test coverage detected