|
21 | 21 | # Built-in modules |
22 | 22 | import copy |
23 | 23 | from itertools import product |
24 | | -from typing import TYPE_CHECKING, Callable |
| 24 | +from typing import TYPE_CHECKING, Callable, List |
25 | 25 |
|
26 | 26 | # Third party modules |
27 | 27 | import six |
@@ -114,11 +114,11 @@ def instruction_from_definition(definition: MicroprobeInstructionDefinition, |
114 | 114 |
|
115 | 115 |
|
116 | 116 | def instruction_set_def_properties(instr, |
117 | | - definition: MicroprobeInstructionDefinition, |
| 117 | + definition, |
118 | 118 | building_block=None, |
119 | | - target: Target | None = None, |
| 119 | + target=None, |
120 | 120 | allowed_registers=None, |
121 | | - fix_relative: bool = True, |
| 121 | + fix_relative=True, |
122 | 122 | label_displ=None): |
123 | 123 | """ |
124 | 124 | Set instruction properties from an intruction definition. |
@@ -168,7 +168,7 @@ def instruction_set_def_properties(instr, |
168 | 168 | LOG.debug("Operands, not fixed: %s", operands) |
169 | 169 | if len(operands) > 0: |
170 | 170 |
|
171 | | - fixed_operands = [] |
| 171 | + fixed_operands: List[Address | InstructionAddress] = [] |
172 | 172 | relocation_mode = False |
173 | 173 | LOG.debug("Fixed operands: %s", fixed_operands) |
174 | 174 |
|
@@ -298,13 +298,14 @@ def instruction_set_def_properties(instr, |
298 | 298 | instr.add_decorator(decorator_key, decorator_value) |
299 | 299 |
|
300 | 300 | for register_name in allowed_registers: |
301 | | - if register_name not in list(target.registers.keys()): |
| 301 | + assert target is not None |
| 302 | + if register_name not in list(target.isa.registers.keys()): |
302 | 303 | raise MicroprobeCodeGenerationError( |
303 | 304 | "Unknown register '%s'. Known registers: %s" % |
304 | | - (register_name, list(target.registers.keys()))) |
| 305 | + (register_name, list(target.isa.registers.keys()))) |
305 | 306 |
|
306 | | - if target.registers[register_name] in instr.sets() + instr.uses(): |
307 | | - instr.add_allow_register(target.registers[register_name]) |
| 307 | + if target.isa.registers[register_name] in instr.sets() + instr.uses(): |
| 308 | + instr.add_allow_register(target.isa.registers[register_name]) |
308 | 309 |
|
309 | 310 | # TODO : NO NEED TO CHECK ANYTHING JUST REPRODUCING! |
310 | 311 | # reserve implicit operands (if they are not already |
@@ -373,7 +374,7 @@ def __init__(self, operand_descriptor: OperandDescriptor): |
373 | 374 | self._operand_descriptor = operand_descriptor |
374 | 375 | self._value = None |
375 | 376 | self._set_function = None |
376 | | - self._unset_function = None |
| 377 | + self._unset_function: Callable[[], None] | None = None |
377 | 378 |
|
378 | 379 | @property |
379 | 380 | def value(self): |
@@ -613,7 +614,7 @@ def _compute_length(self): |
613 | 614 |
|
614 | 615 | return length |
615 | 616 |
|
616 | | - def _compute_possible_lengths(self, context: Context): |
| 617 | + def _compute_possible_lengths(self, context): |
617 | 618 | """Compute the possible lengths that can be generated. |
618 | 619 |
|
619 | 620 | Compute the possible lengths that can be generated from the context |
@@ -1596,7 +1597,7 @@ def __init__(self): |
1596 | 1597 | self._mem_operands = [] |
1597 | 1598 | self._operands = RejectingOrderedDict() |
1598 | 1599 |
|
1599 | | - def set_arch_type(self, instrtype: InstructionType): |
| 1600 | + def set_arch_type(self, instrtype): |
1600 | 1601 | """ |
1601 | 1602 |
|
1602 | 1603 | :param instrtype: |
@@ -1956,7 +1957,7 @@ def allowed_regs(self): |
1956 | 1957 | """List of allowed registers of the instructon. """ |
1957 | 1958 | return self._allowed_regs |
1958 | 1959 |
|
1959 | | - def set_label(self, label: str): |
| 1960 | + def set_label(self, label: str | None): |
1960 | 1961 | """ |
1961 | 1962 |
|
1962 | 1963 | :param label: |
|
0 commit comments