code style fixed

This commit is contained in:
Nicolas Kruse 2025-10-18 23:20:27 +02:00
parent 52f5b28017
commit 79f1fc80a9
4 changed files with 12 additions and 10 deletions

View File

@ -13,8 +13,7 @@ exclude =
build,
dist,
.conda,
.venv,
tests/autogenerated_*
.venv
# Enable specific plugins or options
# Example: Enabling flake8-docstrings
@ -22,4 +21,4 @@ select = C,E,F,W,D
# Specify custom error codes to ignore or enable
per-file-ignores =
tests/*: D
tests/*: D, E712

View File

@ -62,10 +62,12 @@ def get_last_call_in_function(func: elf_symbol) -> int:
assert reloc, f'No call function in stencil function {func.name}.'
return reloc.fields['r_offset'] - func.fields['st_value'] - reloc.fields['r_addend'] - LENGTH_CALL_INSTRUCTION
def symbol_is_stencil(sym: elf_symbol) -> bool:
return (sym.info == 'STT_FUNC' and len(sym.relocations) > 0 and
sym.relocations[-1].symbol.info == 'STT_NOTYPE')
class stencil_database():
"""A class for loading and querying a stencil database from an ELF object file
@ -90,7 +92,7 @@ class stencil_database():
self.stencil_definitions = {s.name: get_return_function_type(s)
for s in self.elf.symbols
if s.info == 'STT_FUNC'}
#self.data = {s.name: strip_function(s)
# for s in self.elf.symbols
# if s.info == 'STT_FUNC'}
@ -136,7 +138,7 @@ class stencil_database():
def get_stencil_code(self, name: str) -> bytes:
"""Return the striped function code for a provided function name
Args:
name: function name
@ -144,7 +146,7 @@ class stencil_database():
Striped function code
"""
return strip_function(self.elf.symbols[name])
def get_sub_functions(self, names: Iterable[str]) -> set[str]:
name_set: set[str] = set()
for name in names:
@ -172,4 +174,4 @@ class stencil_database():
index = get_last_call_in_function(func)
return func.data[index + LENGTH_CALL_INSTRUCTION:]
else:
return func.data
return func.data

View File

@ -59,7 +59,7 @@ if __name__ == "__main__":
rel_entr_point = dr.read_int()
print(f"ENTRY_POINT rel_entr_point={rel_entr_point}")
elif com == Command.RUN_PROG:
print(f"RUN_PROG")
print("RUN_PROG")
elif com == Command.READ_DATA:
offs = dr.read_int()
size = dr.read_int()

View File

@ -9,6 +9,7 @@ stencil_func_prefix = '__attribute__((naked)) ' # Remove callee prolog
stack_size = 64
def get_aux_funcs() -> str:
return f"""
{entry_func_prefix}int entry_function_shell(){{
@ -17,8 +18,8 @@ def get_aux_funcs() -> str:
result_int(0);
return 1;
}}
""" + \
"""
""" + """
__attribute__((noinline)) int floor_div(float arg1, float arg2) {
float x = arg1 / arg2;
int i = (int)x;