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

Function InstructionFromMessage

source/fuzz/instruction_message.cpp:51–77  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

49}
50
51std::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

Callers 1

TryToAddFunctionMethod · 0.85

Calls 4

UpdateModuleIdBoundFunction · 0.85
result_idMethod · 0.45
push_backMethod · 0.45
opcodeMethod · 0.45

Tested by

no test coverage detected