Linters update

This commit is contained in:
stefandesouza
2023-12-10 18:25:00 +01:00
parent 8a6ae8c701
commit 339b06bd7f
7 changed files with 39 additions and 16 deletions

View File

@@ -68,7 +68,7 @@ def sanity_check(arch: str, verbose=False, internet_check=False, output_file=sys
colors=True if output_file == sys.stdout else False,
)
print(report, file=output_file)
return not any([missing_port_pressure, bad_operand])
@@ -148,8 +148,13 @@ def _get_asmbench_output(input_data, isa):
mnemonic = i_form.split("-")[0]
operands = i_form.split("-")[1].split("_")
operands = [_create_db_operand(op, isa) for op in operands]
entry = instructionForm(instruction_id=mnemonic,operands_id=operands,throughput=_validate_measurement(float(input_data[i + 2].split()[1]), "tp"),
latency=_validate_measurement(float(input_data[i + 1].split()[1]), "lt"),port_pressure=None)
entry = instructionForm(
instruction_id=mnemonic,
operands_id=operands,
throughput=_validate_measurement(float(input_data[i + 2].split()[1]), "tp"),
latency=_validate_measurement(float(input_data[i + 1].split()[1]), "lt"),
port_pressure=None,
)
if not entry.throughput or not entry.latency:
warnings.warn(
"Your measurement for {} looks suspicious".format(i_form)
@@ -174,7 +179,13 @@ def _get_ibench_output(input_data, isa):
mnemonic = instruction.split("-")[0]
operands = instruction.split("-")[1].split("_")
operands = [_create_db_operand(op, isa) for op in operands]
entry = instructionForm(instruction_id=mnemonic,operands_id=operands,throughput=None,latency=None,port_pressure=None)
entry = instructionForm(
instruction_id=mnemonic,
operands_id=operands,
throughput=None,
latency=None,
port_pressure=None,
)
if "TP" in instruction:
entry.throughput = _validate_measurement(float(line.split()[1]), "tp")
if not entry.throughput:

View File

@@ -427,7 +427,9 @@ class ParserAArch64(BaseParser):
if memory_address["index"]["shift_op"].lower() in valid_shift_ops:
scale = 2 ** int(memory_address["index"]["shift"][0]["value"])
if index is not None:
index = RegisterOperand(name=index["name"], prefix_id=index["prefix"] if "prefix" in index else None)
index = RegisterOperand(
name=index["name"], prefix_id=index["prefix"] if "prefix" in index else None
)
new_dict = MemoryOperand(
offset_ID=offset,
base_id=RegisterOperand(name=base["name"], prefix_id=base["prefix"]),
@@ -631,7 +633,7 @@ class ParserAArch64(BaseParser):
def is_reg_dependend_of(self, reg_a, reg_b):
"""Check if ``reg_a`` is dependent on ``reg_b``"""
#if not isinstance(reg_b, Operand):
# if not isinstance(reg_b, Operand):
# print(reg_b)
if not isinstance(reg_a, Operand):
reg_a = RegisterOperand(name=reg_a["name"])

View File

@@ -374,7 +374,7 @@ class ParserX86ATT(BaseParser):
# immediate["value"] = int(immediate["value"], 0)
new_immediate = ImmediateOperand(value_id=int(immediate["value"], 0))
return new_immediate
def process_identifier(self, identifier):
return IdentifierOperand(name=identifier["name"])

View File

@@ -6,14 +6,12 @@ import pickle
import re
import string
from collections import defaultdict
from copy import deepcopy
from itertools import product
from pathlib import Path
import ruamel.yaml
from osaca import __version__, utils
from osaca.parser import ParserX86ATT
from ruamel.yaml.compat import StringIO
from osaca.parser.instruction_form import instructionForm
from osaca.parser.operand import Operand
from osaca.parser.memory import MemoryOperand
@@ -203,7 +201,10 @@ class MachineModel(object):
if isinstance(o["base"], dict):
o["base"] = RegisterOperand(name=o["base"]["name"])
if isinstance(o["index"], dict):
o["index"] = RegisterOperand(name=o["index"]["name"],prefix_id=o["index"]["prefix"] if "prefix" in o["index"] else None)
o["index"] = RegisterOperand(
name=o["index"]["name"],
prefix_id=o["index"]["prefix"] if "prefix" in o["index"] else None,
)
new_operands.append(
MemoryOperand(
base_id=o["base"],
@@ -494,6 +495,7 @@ class MachineModel(object):
if isinstance(stream, StringIO):
return stream.getvalue()
'''
def operand_to_dict(self, mem):
return {
"base": mem.base,

View File

@@ -200,7 +200,8 @@ class ISASemantics(object):
base_name = (o.base.prefix if o.base.prefix is not None else "") + o.base.name
return {
base_name: {
"name": (o.base.prefix if o.base.prefix is not None else "") + o.base.name,
"name": (o.base.prefix if o.base.prefix is not None else "")
+ o.base.name,
"value": o.post_indexed["value"],
}
}
@@ -225,7 +226,7 @@ class ISASemantics(object):
if isa_data is not None and isa_data.operation is not None:
for i, o in enumerate(instruction_form.operands):
operand_name = "op{}".format(i + 1)
if isinstance(o, RegisterOperand):
o_reg_name = (o.prefix if o.prefix is not None else "") + o.name
reg_operand_names[o_reg_name] = operand_name

View File

@@ -299,7 +299,11 @@ class KernelDG(nx.DiGraph):
# write to register -> abort
if self.is_written(dst, instr_form):
break
if not isinstance(dst, Operand) and ("flag" in dst or dst["class"] == "flag" if "class" in dst else False) and flag_dependencies:
if (
not isinstance(dst, Operand)
and ("flag" in dst or dst["class"] == "flag" if "class" in dst else False)
and flag_dependencies
):
# read of flag
if self.is_read(dst, instr_form):
yield instr_form, []
@@ -377,7 +381,9 @@ class KernelDG(nx.DiGraph):
):
if isinstance(src, RegisterOperand):
is_read = self.parser.is_reg_dependend_of(register, src) or is_read
if not isinstance(src, Operand) and ("flag" in src or src["class"] == "flag" if "class" in src else False):
if not isinstance(src, Operand) and (
"flag" in src or src["class"] == "flag" if "class" in src else False
):
is_read = self.parser.is_flag_dependend_of(register, src) or is_read
if isinstance(src, MemoryOperand):
if src.base is not None:
@@ -480,7 +486,9 @@ class KernelDG(nx.DiGraph):
):
if isinstance(dst, RegisterOperand):
is_written = self.parser.is_reg_dependend_of(register, dst) or is_written
if not isinstance(dst, Operand) and ("flag" in dst or dst["class"] == "flag" if "class" in dst else False):
if not isinstance(dst, Operand) and (
"flag" in dst or dst["class"] == "flag" if "class" in dst else False
):
is_written = self.parser.is_flag_dependend_of(register, dst) or is_written
if isinstance(dst, MemoryOperand):
if dst.pre_indexed or dst.post_indexed: