89 using Ts::operator()...;
98 os <<
"InsertSimpleInstructionBlock " << arg.instruction_block_idx;
100 [&](
JumpToNewBlock arg) { os <<
"JumpToNewBlock " << arg.target_program_block_instruction_block_idx; },
102 os <<
"JumpIfToNewBlock " << arg.then_program_block_instruction_block_idx <<
" "
103 << arg.else_program_block_instruction_block_idx <<
" " << arg.condition_offset_index;
105 [&](
JumpToBlock arg) { os <<
"JumpToBlock " << arg.target_block_idx; },
107 os <<
"JumpIToBlock " << arg.target_then_block_idx <<
" " << arg.target_else_block_idx <<
" "
108 << arg.condition_offset_index;
111 os <<
"FinalizeWithReturn " << arg.return_options.return_size <<
" "
112 << arg.return_options.return_value_tag <<
" " << arg.return_options.return_value_offset_index;
115 os <<
"SwitchToNonTerminatedBlock " << arg.non_terminated_block_idx;
118 os <<
"InsertInternalCall " << arg.target_program_block_instruction_block_idx;
void process_jump_to_block(JumpToBlock instruction)
terminates the current block with a jump to the block, which does not create a loop in the graph (def...
ProgramBlock * current_block
std::vector< std::vector< FuzzInstruction > > * instruction_blocks
std::vector< ProgramBlock * > get_reachable_blocks(ProgramBlock *block)
get the list of blocks which are can be reached from the given block without creating a loop in the g...
ControlFlow(std::vector< std::vector< FuzzInstruction > > &instruction_blocks)
ProgramBlock * start_block
the entry block of the program
void process_cfg_instruction(CFGInstruction instruction)
void process_insert_simple_instruction_block(InsertSimpleInstructionBlock instruction)
add instructions to the current block from the instruction block at the given index taken modulo leng...
void process_insert_internal_call(InsertInternalCall instruction)
inserts INTERNALCALL instruction to the current block creates a new block and sets it as the current ...
void process_switch_to_non_terminated_block(SwitchToNonTerminatedBlock instruction)
switches to the non-terminated block with the chosen index
std::vector< ProgramBlock * > get_non_terminated_blocks()
get the list of non-terminated blocks
void process_finalize_with_return(FinalizeWithReturn instruction)
terminates the current block with Return and switches to the first non-terminated block
void process_jump_to_new_block(JumpToNewBlock instruction)
terminates the current block with a jump and creates a new block
std::vector< uint8_t > build_bytecode(const ReturnOptions &return_options)
build the bytecode, finalizing the current block with return
void process_jump_if_to_new_block(JumpIfToNewBlock instruction)
terminates the current block with a jump if and creates two new blocks, sets the first as the then bl...
void process_jump_if_to_block(JumpIfToBlock instruction)
terminates the current block with a jumpi and jump instructions to the blocks, which does not create ...
static std::vector< ProgramBlock * > dfs_traverse(ProgramBlock *start_block, bool reverse=false)
traverse the control flow graph using DFS
std::variant< InsertSimpleInstructionBlock, JumpToNewBlock, JumpIfToNewBlock, JumpToBlock, JumpIfToBlock, FinalizeWithReturn, SwitchToNonTerminatedBlock, InsertInternalCall > CFGInstruction
std::ostream & operator<<(std::ostream &os, const CFGInstruction &instruction)
constexpr decltype(auto) get(::tuplet::tuple< T... > &&t) noexcept
finalizes the current block with Return and switches to the first non-terminated block
MSGPACK_FIELDS(return_options)
ReturnOptions return_options
inserts INTERNALCALL instruction to the current block creates a new block and sets it as the current ...
MSGPACK_FIELDS(target_program_block_instruction_block_idx)
uint16_t target_program_block_instruction_block_idx
insert instruction block to the current block
MSGPACK_FIELDS(instruction_block_idx)
uint16_t instruction_block_idx
finalizes the current block with a JumpI and Jump instructions to the block, which does not create a ...
uint16_t condition_offset_index
uint16_t target_then_block_idx
MSGPACK_FIELDS(target_then_block_idx, target_else_block_idx, condition_offset_index)
uint16_t target_else_block_idx
finalizes the current block with jump if, creates two new blocks, sets the first as the then block an...
uint16_t condition_offset_index
uint16_t else_program_block_instruction_block_idx
uint16_t then_program_block_instruction_block_idx
MSGPACK_FIELDS(then_program_block_instruction_block_idx, else_program_block_instruction_block_idx, condition_offset_index)
finalizes the current block with a jump to the block, which does not create a loop in the graph (defi...
MSGPACK_FIELDS(target_block_idx)
uint16_t target_block_idx
finalizes the current block with jump, creates a new block and sets it as the current block
MSGPACK_FIELDS(target_program_block_instruction_block_idx)
uint16_t target_program_block_instruction_block_idx
Wrapper for MemoryTag to allow for msgpack packing and unpacking.
MemoryTagWrapper return_value_tag
MSGPACK_FIELDS(return_size, return_value_tag, return_value_offset_index)
uint16_t return_value_offset_index
switches to the non-terminated block with the chosen index
MSGPACK_FIELDS(non_terminated_block_idx)
uint16_t non_terminated_block_idx