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.

class Lib.Statement.AbsoluteJump(label: Label)[source]

Bases: Instruction

An Absolute Jump is a specific kind of instruction

args()[source]
ins: str = 'j'
label: Label
rename(renamer: Renamer)[source]
substitute(subst: Dict[Operand, Operand])[source]
targets() List[Label][source]
class Lib.Statement.Comment(comment: str)[source]

Bases: Statement

A comment.

comment: str
printIns(stream)[source]

Print the statement on the output. Should never be called on the base class.

class Lib.Statement.ConditionalJump(cond: Condition, op1: Operand, op2: Operand, label: Label)[source]

Bases: Instruction

A Conditional Jump is a specific kind of instruction

args()[source]
cond: Condition
label: Label
op1: Operand
op2: Operand
rename(renamer: Renamer)[source]
substitute(subst: Dict[Operand, Operand])[source]
class Lib.Statement.Instru3A(ins, *args: Lib.Operands.Operand)[source]

Bases: Instruction

args()[source]
rename(renamer: Renamer)[source]
substitute(subst: Dict[Operand, Operand])[source]
class Lib.Statement.Instruction[source]

Bases: Statement

args() List[Operand][source]
defined()[source]
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.

printIns(stream)[source]

Print the instruction on the output.

rename(renamer: Renamer) None[source]
used()[source]
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 output. Should never be called on the base class.

class Lib.Statement.Statement[source]

Bases: object

A Statement, which is an instruction, a comment or a label.

defined() List[Operand][source]
printIns(stream)[source]

Print the statement on the output. Should never be called on the base class.

substitute(subst: Dict[Operand, Operand]) TStatement[source]
used() List[Operand][source]
Lib.Statement.regset_to_string(registerset)[source]

Utility function: pretty-prints a set of locations.