microprobe.target.isa.comparator.Comparator

class Comparator(arch)[source]

Bases: object

Abstract class to perform comparisons. Comparator objects are in charge of performing comparisons between values while providing an architecture independent and modular interface. They are registered in an ISA object using the register_value_comparator(). Once registered, whenever a comparison is needed to perform a given operation, it is possible to check (check()) if the Comparator can perform the requested comparison, and if so, it can generate (generate()) the required list of Instruction to perform it.

Parameters:

isa – Architecture to operate on.

__init__(arch)[source]
Parameters:

arch

Methods

__init__(arch)

param arch:

check(reg, value)

Checks whether the Register reg instance can be compared with the value, which can be a :int or another Register.

generate(reg, value, helper_instr)

Generate the Instruction to perform the comparison.

Attributes

arch

Architecture on this Comparator will work on (ISA).

instr_name

Value comparator name, usually the opcode of the instruction it uses (str).




check(reg, value)[source]

Checks whether the Register reg instance can be compared with the value, which can be a :int or another Register. If is not possible to perform the comparison, a None value is returned. Otherwise, the Register instance where the result of the comparison would be placed is returned.

Parameters:
  • reg (Register) – 1st operand of the comparison.

  • value (Register or :int) – 2nd operand of the comparison.

generate(reg, value, helper_instr)[source]

Generate the Instruction to perform the comparison. If the required instruction is found within the list of Instruction helper_instr, no new instruction is generated and the matching instruction operands are set accordingly.

Parameters:
  • reg (Register) – 1st operand of the comparison.

  • value (Register or :int) – 2nd operand of the comparison.

  • helper_instr (list of :class`~.Instruction` instances.) – List of helper instructions.

property instr_name

Value comparator name, usually the opcode of the instruction it uses (str).

property arch

Architecture on this Comparator will work on (ISA).