| 472 | } |
| 473 | |
| 474 | spv_result_t ValidateGraphEnd(ValidationState_t& _, const Instruction* inst) { |
| 475 | size_t end_inst_num = inst->LineNum() - 1; |
| 476 | |
| 477 | // Gather OpGraphInputARM and OpGraphSetOutputARM instructions |
| 478 | std::deque<const Instruction*> graph_inputs, graph_outputs; |
| 479 | size_t in_inst_num = end_inst_num; |
| 480 | auto graph_inst = &_.ordered_instructions()[in_inst_num]; |
| 481 | while (--in_inst_num) { |
| 482 | graph_inst = &_.ordered_instructions()[in_inst_num]; |
| 483 | if (graph_inst->opcode() == spv::Op::OpGraphInputARM) { |
| 484 | graph_inputs.push_front(graph_inst); |
| 485 | continue; |
| 486 | } |
| 487 | if (graph_inst->opcode() == spv::Op::OpGraphSetOutputARM) { |
| 488 | graph_outputs.push_front(graph_inst); |
| 489 | continue; |
| 490 | } |
| 491 | if (graph_inst->opcode() == spv::Op::OpGraphARM) { |
| 492 | break; |
| 493 | } |
| 494 | } |
| 495 | |
| 496 | const Instruction* first_dup; |
| 497 | |
| 498 | // Check that there are no duplicate InputIndex and ElementIndex values |
| 499 | if (InputOutputInstructionsHaveDuplicateIndices(_, graph_inputs, |
| 500 | &first_dup)) { |
| 501 | return _.diag(SPV_ERROR_INVALID_DATA, first_dup) |
| 502 | << "Two OpGraphInputARM instructions with the same InputIndex " |
| 503 | "must not be part of the same " |
| 504 | << "graph definition unless ElementIndex is present in both with " |
| 505 | "different values."; |
| 506 | } |
| 507 | |
| 508 | // Check that there are no duplicate OutputIndex and ElementIndex values |
| 509 | if (InputOutputInstructionsHaveDuplicateIndices(_, graph_outputs, |
| 510 | &first_dup)) { |
| 511 | return _.diag(SPV_ERROR_INVALID_DATA, first_dup) |
| 512 | << "Two OpGraphSetOutputARM instructions with the same " |
| 513 | "OutputIndex must not be part of the same " |
| 514 | << "graph definition unless ElementIndex is present in both with " |
| 515 | "different values."; |
| 516 | } |
| 517 | |
| 518 | return SPV_SUCCESS; |
| 519 | } |
| 520 | |
| 521 | } // namespace |
| 522 |
no test coverage detected