Lib.Statement module
The base class for RISCV ASM statements is Statement.
It is inherited by Comment, Label
and Instruction. In turn, Instruction
is inherited by Instru3A
(for regular non-branching 3-address instructions),
AbsoluteJump and ConditionalJump.
-
Lib.Statement.regset_to_string(registerset) → str[source]
Utility function: pretty-prints a set of locations.
-
class Lib.Statement.Statement[source]
Bases: object
A Statement, which is an instruction, a comment or a label.
-
defined() → List[Operand][source]
Operands defined (written) in this instruction
-
used() → List[Operand][source]
Operands used (read) in this instruction
-
substitute(subst: Dict[Operand, Operand]) → TStatement[source]
Return a new instruction, cloned from this one, replacing operands
that appear as key in subst by their value.
-
with_args(new_args: List[Operand]) → TStatement[source]
Return a new instruction, cloned from this one, where operands have
been replaced by new_args.
-
printIns(stream)[source]
Print the statement on the given output.
Should never be called on the base class.
Bases: Statement
A comment.
Print the statement on the given output.
Should never be called on the base class.
-
class Lib.Statement.Label(name: str)[source]
Bases: Statement, Operand
A label is both a Statement and an Operand.
-
name: str
-
printIns(stream)[source]
Print the statement on the given output.
Should never be called on the base class.
-
class Lib.Statement.Instruction[source]
Bases: Statement
-
ins: str
-
is_read_only()[source]
True if the instruction only reads from its operands.
Otherwise, the first operand is considered as the destination
and others are source.
-
rename(renamer: Renamer) → None[source]
-
args() → List[Operand][source]
List of operands the instruction takes
-
defined()[source]
Operands defined (written) in this instruction
-
used() → List[Operand][source]
Operands used (read) in this instruction
-
printIns(stream)[source]
Print the instruction on the given output.
-
class Lib.Statement.Instru3A(ins, *args: Lib.Operands.Operand)[source]
Bases: Instruction
-
args()[source]
List of operands the instruction takes
-
rename(renamer: Renamer)[source]
-
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.
-
with_args(new_args: List[Operand])[source]
Return a new instruction, cloned from this one, where operands have
been replaced by new_args.
-
class Lib.Statement.AbsoluteJump(label: Label)[source]
Bases: Instruction
An Absolute Jump is a specific kind of instruction
-
ins: str = 'j'
-
label: Label
-
args() → List[Operand][source]
List of operands the instruction takes
-
rename(renamer: Renamer)[source]
-
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.
-
with_args(new_args: List[Operand])[source]
Return a new instruction, cloned from this one, where operands have
been replaced by new_args.
-
targets() → List[Label][source]
Return the labels targetted by the AbsoluteJump.
-
class Lib.Statement.ConditionalJump(cond: Condition, op1: RegisterLike, op2: RegisterLike, label: Label)[source]
Bases: Instruction
A Conditional Jump is a specific kind of instruction
-
cond: Condition
-
label: Label
-
op1: RegisterLike
-
op2: RegisterLike
-
args()[source]
List of operands the instruction takes
-
rename(renamer: Renamer)[source]
-
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.
-
with_args(new_args: List[Operand])[source]
Return a new instruction, cloned from this one, where operands have
been replaced by new_args.