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

Method ReplaceInterfaceVarInEntryPoint

source/opt/interface_var_sroa.cpp:585–620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

583}
584
585bool InterfaceVariableScalarReplacement::ReplaceInterfaceVarInEntryPoint(
586 Instruction* interface_var, Instruction* entry_point,
587 uint32_t scalar_var_id) {
588 analysis::DefUseManager* def_use_mgr = context()->get_def_use_mgr();
589 uint32_t interface_var_id = interface_var->result_id();
590 if (interface_vars_removed_from_entry_point_operands_.find(
591 interface_var_id) !=
592 interface_vars_removed_from_entry_point_operands_.end()) {
593 entry_point->AddOperand({SPV_OPERAND_TYPE_ID, {scalar_var_id}});
594 def_use_mgr->AnalyzeInstUse(entry_point);
595 return true;
596 }
597
598 bool success = !entry_point->WhileEachInId(
599 [&interface_var_id, &scalar_var_id](uint32_t* id) {
600 if (*id == interface_var_id) {
601 *id = scalar_var_id;
602 return false;
603 }
604 return true;
605 });
606 if (!success) {
607 std::string message(
608 "interface variable is not an operand of the entry point");
609 message += "\n " + interface_var->PrettyPrint(
610 SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
611 message += "\n " + entry_point->PrettyPrint(
612 SPV_BINARY_TO_TEXT_OPTION_FRIENDLY_NAMES);
613 context()->consumer()(SPV_MSG_ERROR, "", {0, 0, 0}, message.c_str());
614 return false;
615 }
616
617 def_use_mgr->AnalyzeInstUse(entry_point);
618 interface_vars_removed_from_entry_point_operands_.insert(interface_var_id);
619 return true;
620}
621
622uint32_t InterfaceVariableScalarReplacement::GetPointeeTypeIdOfVar(
623 Instruction* var) {

Callers

nothing calls this directly

Calls 10

AddOperandMethod · 0.80
AnalyzeInstUseMethod · 0.80
WhileEachInIdMethod · 0.80
consumerMethod · 0.80
c_strMethod · 0.80
get_def_use_mgrMethod · 0.45
result_idMethod · 0.45
endMethod · 0.45
PrettyPrintMethod · 0.45
insertMethod · 0.45

Tested by

no test coverage detected