Black formatting

This commit is contained in:
JanLJL
2024-05-02 17:04:56 +02:00
parent c9e38631d1
commit aca5511d6a
6 changed files with 28 additions and 23 deletions

View File

@@ -1,4 +1,5 @@
"""Open Source Architecture Code Analyzer""" """Open Source Architecture Code Analyzer"""
name = "osaca" name = "osaca"
__version__ = "0.5.3" __version__ = "0.5.3"

View File

@@ -85,9 +85,11 @@ class Frontend(object):
self._get_port_pressure( self._get_port_pressure(
instruction_form.port_pressure, port_len, separator=sep_list instruction_form.port_pressure, port_len, separator=sep_list
), ),
(
self._get_flag_symbols(instruction_form.flags) self._get_flag_symbols(instruction_form.flags)
if instruction_form.mnemonic is not None if instruction_form.mnemonic is not None
else " ", else " "
),
instruction_form.line.strip().replace("\t", " "), instruction_form.line.strip().replace("\t", " "),
) )
line = line if show_lineno else col_sep + col_sep.join(line.split(col_sep)[1:]) line = line if show_lineno else col_sep + col_sep.join(line.split(col_sep)[1:])
@@ -366,9 +368,11 @@ class Frontend(object):
cp_kernel if line_number in cp_lines else None, cp_kernel if line_number in cp_lines else None,
lcd_lines.get(line_number), lcd_lines.get(line_number),
), ),
(
self._get_flag_symbols(instruction_form.flags) self._get_flag_symbols(instruction_form.flags)
if instruction_form.mnemonic is not None if instruction_form.mnemonic is not None
else " ", else " "
),
instruction_form.line.strip().replace("\t", " "), instruction_form.line.strip().replace("\t", " "),
) )
s += "\n" s += "\n"

View File

@@ -3,6 +3,7 @@ Collection of parsers supported by OSACA.
Only the parser below will be exported, so please add new parsers to __all__. Only the parser below will be exported, so please add new parsers to __all__.
""" """
from .base_parser import BaseParser from .base_parser import BaseParser
from .parser_x86att import ParserX86ATT from .parser_x86att import ParserX86ATT
from .parser_AArch64 import ParserAArch64 from .parser_AArch64 import ParserAArch64

View File

@@ -3,6 +3,7 @@ Tools for semantic analysis of parser result.
Only the classes below will be exported, so please add new semantic tools to __all__. Only the classes below will be exported, so please add new semantic tools to __all__.
""" """
from .isa_semantics import ISASemantics, INSTR_FLAGS from .isa_semantics import ISASemantics, INSTR_FLAGS
from .arch_semantics import ArchSemantics from .arch_semantics import ArchSemantics
from .hw_model import MachineModel from .hw_model import MachineModel

View File

@@ -124,9 +124,9 @@ class MachineModel(object):
new_iform = InstructionForm( new_iform = InstructionForm(
mnemonic=iform["name"].upper() if "name" in iform else None, mnemonic=iform["name"].upper() if "name" in iform else None,
operands=iform["operands"] if "operands" in iform else [], operands=iform["operands"] if "operands" in iform else [],
hidden_operands=iform["hidden_operands"] hidden_operands=(
if "hidden_operands" in iform iform["hidden_operands"] if "hidden_operands" in iform else []
else [], ),
directive_id=iform["directive"] if "directive" in iform else None, directive_id=iform["directive"] if "directive" in iform else None,
comment_id=iform["comment"] if "comment" in iform else None, comment_id=iform["comment"] if "comment" in iform else None,
line=iform["line"] if "line" in iform else None, line=iform["line"] if "line" in iform else None,
@@ -136,14 +136,16 @@ class MachineModel(object):
uops=iform["uops"] if "uops" in iform else None, uops=iform["uops"] if "uops" in iform else None,
port_pressure=iform["port_pressure"] if "port_pressure" in iform else None, port_pressure=iform["port_pressure"] if "port_pressure" in iform else None,
operation=iform["operation"] if "operation" in iform else None, operation=iform["operation"] if "operation" in iform else None,
breaks_dependency_on_equal_operands=iform[ breaks_dependency_on_equal_operands=(
"breaks_dependency_on_equal_operands" iform["breaks_dependency_on_equal_operands"]
]
if "breaks_dependency_on_equal_operands" in iform if "breaks_dependency_on_equal_operands" in iform
else False, else False
semantic_operands=iform["semantic_operands"] ),
semantic_operands=(
iform["semantic_operands"]
if "semantic_operands" in iform if "semantic_operands" in iform
else {"source": [], "destination": [], "src_dst": []}, else {"source": [], "destination": [], "src_dst": []}
),
) )
# List containing classes with same name/instruction # List containing classes with same name/instruction
self._data["instruction_forms_dict"][iform["name"]].append(new_iform) self._data["instruction_forms_dict"][iform["name"]].append(new_iform)

View File

@@ -287,17 +287,13 @@ class ISASemantics(object):
dict_key = ( dict_key = (
"src_dst" "src_dst"
if op.source and op.destination if op.source and op.destination
else "source" else "source" if op.source else "destination"
if op.source
else "destination"
) )
else: else:
dict_key = ( dict_key = (
"src_dst" "src_dst"
if op["source"] and op["destination"] if op["source"] and op["destination"]
else "source" else "source" if op["source"] else "destination"
if op["source"]
else "destination"
) )
op_dict[dict_key].append(op) op_dict[dict_key].append(op)