Lib.Terminator module¶
MIF08, CAP, CFG library - Terminators.
Each block of a CFG
ends with a branching instruction called a terminator.
There are three kinds of terminators:
Lib.Statement.AbsoluteJumpis a non-conditional jump to another block of the CFGBranchingTerminatoris a conditional branching instruction with two successor blocks. Unlike the classConditionalJumpthat was used inLinearCode, both successor labels have to be specified.Returnmarks the end of the function
During the construction of the CFG, jump2terminator() builds
a terminator for each extracted chunk of instructions.
- class Lib.Terminator.Return[source]¶
Bases:
StatementA terminator that marks the end of the function.
- printIns(stream)[source]¶
Print the statement on the given output. Should never be called on the base class.
- substitute(subst: Dict[Operand, Operand])[source]¶
Return a new instruction, cloned from this one, replacing operands that appear as key in subst by their value.
- class Lib.Terminator.BranchingTerminator(cond: Condition, op1: RegisterLike, op2: RegisterLike, label_then: Label, label_else: Label)[source]¶
Bases:
InstructionA terminating statement with a condition.
- op1: RegisterLike¶
The first operand of the condition
- op2: RegisterLike¶
The second operand of the condition
- Lib.Terminator.Terminator = Lib.Terminator.Return | Lib.Statement.AbsoluteJump | Lib.Terminator.BranchingTerminator¶
Type alias for terminators
- Lib.Terminator.jump2terminator(j: ConditionalJump | AbsoluteJump | None, next_label: Label | None) Return | AbsoluteJump | BranchingTerminator[source]¶
Construct the Terminator associated to the potential jump j to the potential label next_label.