| # Copyright lowRISC contributors. |
| # Licensed under the Apache License, Version 2.0, see LICENSE for details. |
| # SPDX-License-Identifier: Apache-2.0 |
| from shared.decode import OTBNProgram |
| from shared.insn_yaml import Insn |
| '''A continuous part of a program's code (represented as a PC range). |
| The code section is considered to include both the start and end PC. |
| def __init__(self, start: int, end: int): |
| def get_insn_sequence(self, program: OTBNProgram) -> List[Insn]: |
| program.get_insn(pc) for pc in range(self.start, self.end + 4, 4) |
| return '0x{:x}-0x{:x}'.format(self.start, self.end) |
| def __contains__(self, pc: int) -> bool: |
| return self.start <= pc and pc <= self.end |