| 49 | } |
| 50 | |
| 51 | std::unique_ptr<opt::Instruction> InstructionFromMessage( |
| 52 | opt::IRContext* ir_context, |
| 53 | const protobufs::Instruction& instruction_message) { |
| 54 | // First, update the module's id bound with respect to the new instruction, |
| 55 | // if it has a result id. |
| 56 | if (instruction_message.result_id()) { |
| 57 | fuzzerutil::UpdateModuleIdBound(ir_context, |
| 58 | instruction_message.result_id()); |
| 59 | } |
| 60 | // Now create a sequence of input operands from the input operand data in the |
| 61 | // protobuf message. |
| 62 | opt::Instruction::OperandList in_operands; |
| 63 | for (auto& operand_message : instruction_message.input_operand()) { |
| 64 | opt::Operand::OperandData operand_data; |
| 65 | for (auto& word : operand_message.operand_data()) { |
| 66 | operand_data.push_back(word); |
| 67 | } |
| 68 | in_operands.push_back( |
| 69 | {static_cast<spv_operand_type_t>(operand_message.operand_type()), |
| 70 | operand_data}); |
| 71 | } |
| 72 | // Create and return the instruction. |
| 73 | return MakeUnique<opt::Instruction>( |
| 74 | ir_context, static_cast<spv::Op>(instruction_message.opcode()), |
| 75 | instruction_message.result_type_id(), instruction_message.result_id(), |
| 76 | in_operands); |
| 77 | } |
| 78 | |
| 79 | } // namespace fuzz |
| 80 | } // namespace spvtools |
no test coverage detected