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 anISA
object using theregister_value_comparator()
. Once registered, whenever a comparison is needed to perform a given operation, it is possible to check (check()
) if theComparator
can perform the requested comparison, and if so, it can generate (generate()
) the requiredlist
ofInstruction
to perform it.- Parameters
isa – Architecture to operate on.
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 anotherRegister
.generate
(reg, value, helper_instr)Generate the
Instruction
to perform the comparison.Attributes
Architecture on this
Comparator
will work on (ISA
).Value comparator name, usually the opcode of the instruction it uses (
str
).
- abstract check(reg, value)[source]¶
Checks whether the
Register
reg instance can be compared with the value, which can be a :int
or anotherRegister
. If is not possible to perform the comparison, a None value is returned. Otherwise, theRegister
instance where the result of the comparison would be placed is returned.
- abstract generate(reg, value, helper_instr)[source]¶
Generate the
Instruction
to perform the comparison. If the required instruction is found within thelist
ofInstruction
helper_instr, no new instruction is generated and the matching instruction operands are set accordingly.
- abstract 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
).