microprobe.code.bbl.Bbl¶
-
class
Bbl
(size, instructions=None)[source]¶ Bases:
object
Class to represent a basic block.
Methods
__init__
(size[, instructions])param size: get_instruction_index
(instr)Returns the index of the given instruction within the basic block. insert_instr
(instrs[, before, after])Inserts a list of instruction in the basic block. remove_instructions_from
(instr)Removes the given instruction from the basic block. replicate
([displacement])Replicates current basic block. reset_instruction
(instr, new_instr)Resets the instruction within a basic block by another instruction. set_address
(address)Set the basic block address. set_displacement
(displacement)Set the displacement of the basic block. Attributes
address
Basic block address ( Address
)displacement
Displacement of the basic block (: int
)instrs
List of instructions in the basic block size
Size of the basic block, number of instructions (: int
)
-
instrs
¶ List of instructions in the basic block (
list
ofInstruction
)
-
set_address
(address)[source]¶ Set the basic block address.
Parameters: address ( Address
) – Address for the basic block
-
set_displacement
(displacement)[source]¶ Set the displacement of the basic block.
Parameters: displacement ( int
) – Displacement for the basic block
-
get_instruction_index
(instr)[source]¶ Returns the index of the given instruction within the basic block.
Returns the index of the given instruction within the basic block. If the instruction is not found, return a negative number.
Parameters: instr ( Instruction
) – Instruction instance
-
reset_instruction
(instr, new_instr)[source]¶ Resets the instruction within a basic block by another instruction.
Resets the instruction within a basic block by another instruction. If the instruction is not found, an exception is raised.
Parameters: - instr (
Instruction
) – Instruction to replace - new_instr (
Instruction
) – New instruction
Raises: microprobe.exceptions.MicroprobeCodeGenerationError – if the instruction is not found in the basic block
- instr (
-
remove_instructions_from
(instr)[source]¶ Removes the given instruction from the basic block.
Removes the given instruction from the basic block. If the instruction is not found, the basic block is not changed.
Parameters: instr ( Instruction
) – Instruction to remove
-
insert_instr
(instrs, before=None, after=None)[source]¶ Inserts a list of instruction in the basic block.
Inserts a list of instruction in the basic block. Before/After parameters specify the instructions before/after which the new instruction should be added.
Parameters: - instrs (
list
ofInstruction
) – Instruction to insert - before (
list
ofInstruction
) – Instructions will be inserted before this instruction (Default value = None) - after (
list
ofInstruction
) – Instructions will be inserted after this instruction (Default value = None)
- instrs (
-