mirror of https://github.com/Nonannet/copapy.git
code style fixed
This commit is contained in:
parent
52f5b28017
commit
79f1fc80a9
5
.flake8
5
.flake8
|
|
@ -13,8 +13,7 @@ exclude =
|
||||||
build,
|
build,
|
||||||
dist,
|
dist,
|
||||||
.conda,
|
.conda,
|
||||||
.venv,
|
.venv
|
||||||
tests/autogenerated_*
|
|
||||||
|
|
||||||
# Enable specific plugins or options
|
# Enable specific plugins or options
|
||||||
# Example: Enabling flake8-docstrings
|
# Example: Enabling flake8-docstrings
|
||||||
|
|
@ -22,4 +21,4 @@ select = C,E,F,W,D
|
||||||
|
|
||||||
# Specify custom error codes to ignore or enable
|
# Specify custom error codes to ignore or enable
|
||||||
per-file-ignores =
|
per-file-ignores =
|
||||||
tests/*: D
|
tests/*: D, E712
|
||||||
|
|
@ -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}.'
|
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
|
return reloc.fields['r_offset'] - func.fields['st_value'] - reloc.fields['r_addend'] - LENGTH_CALL_INSTRUCTION
|
||||||
|
|
||||||
|
|
||||||
def symbol_is_stencil(sym: elf_symbol) -> bool:
|
def symbol_is_stencil(sym: elf_symbol) -> bool:
|
||||||
return (sym.info == 'STT_FUNC' and len(sym.relocations) > 0 and
|
return (sym.info == 'STT_FUNC' and len(sym.relocations) > 0 and
|
||||||
sym.relocations[-1].symbol.info == 'STT_NOTYPE')
|
sym.relocations[-1].symbol.info == 'STT_NOTYPE')
|
||||||
|
|
||||||
|
|
||||||
class stencil_database():
|
class stencil_database():
|
||||||
"""A class for loading and querying a stencil database from an ELF object file
|
"""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)
|
self.stencil_definitions = {s.name: get_return_function_type(s)
|
||||||
for s in self.elf.symbols
|
for s in self.elf.symbols
|
||||||
if s.info == 'STT_FUNC'}
|
if s.info == 'STT_FUNC'}
|
||||||
|
|
||||||
#self.data = {s.name: strip_function(s)
|
#self.data = {s.name: strip_function(s)
|
||||||
# for s in self.elf.symbols
|
# for s in self.elf.symbols
|
||||||
# if s.info == 'STT_FUNC'}
|
# if s.info == 'STT_FUNC'}
|
||||||
|
|
@ -136,7 +138,7 @@ class stencil_database():
|
||||||
|
|
||||||
def get_stencil_code(self, name: str) -> bytes:
|
def get_stencil_code(self, name: str) -> bytes:
|
||||||
"""Return the striped function code for a provided function name
|
"""Return the striped function code for a provided function name
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
name: function name
|
name: function name
|
||||||
|
|
||||||
|
|
@ -144,7 +146,7 @@ class stencil_database():
|
||||||
Striped function code
|
Striped function code
|
||||||
"""
|
"""
|
||||||
return strip_function(self.elf.symbols[name])
|
return strip_function(self.elf.symbols[name])
|
||||||
|
|
||||||
def get_sub_functions(self, names: Iterable[str]) -> set[str]:
|
def get_sub_functions(self, names: Iterable[str]) -> set[str]:
|
||||||
name_set: set[str] = set()
|
name_set: set[str] = set()
|
||||||
for name in names:
|
for name in names:
|
||||||
|
|
@ -172,4 +174,4 @@ class stencil_database():
|
||||||
index = get_last_call_in_function(func)
|
index = get_last_call_in_function(func)
|
||||||
return func.data[index + LENGTH_CALL_INSTRUCTION:]
|
return func.data[index + LENGTH_CALL_INSTRUCTION:]
|
||||||
else:
|
else:
|
||||||
return func.data
|
return func.data
|
||||||
|
|
|
||||||
|
|
@ -59,7 +59,7 @@ if __name__ == "__main__":
|
||||||
rel_entr_point = dr.read_int()
|
rel_entr_point = dr.read_int()
|
||||||
print(f"ENTRY_POINT rel_entr_point={rel_entr_point}")
|
print(f"ENTRY_POINT rel_entr_point={rel_entr_point}")
|
||||||
elif com == Command.RUN_PROG:
|
elif com == Command.RUN_PROG:
|
||||||
print(f"RUN_PROG")
|
print("RUN_PROG")
|
||||||
elif com == Command.READ_DATA:
|
elif com == Command.READ_DATA:
|
||||||
offs = dr.read_int()
|
offs = dr.read_int()
|
||||||
size = dr.read_int()
|
size = dr.read_int()
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ stencil_func_prefix = '__attribute__((naked)) ' # Remove callee prolog
|
||||||
|
|
||||||
stack_size = 64
|
stack_size = 64
|
||||||
|
|
||||||
|
|
||||||
def get_aux_funcs() -> str:
|
def get_aux_funcs() -> str:
|
||||||
return f"""
|
return f"""
|
||||||
{entry_func_prefix}int entry_function_shell(){{
|
{entry_func_prefix}int entry_function_shell(){{
|
||||||
|
|
@ -17,8 +18,8 @@ def get_aux_funcs() -> str:
|
||||||
result_int(0);
|
result_int(0);
|
||||||
return 1;
|
return 1;
|
||||||
}}
|
}}
|
||||||
""" + \
|
|
||||||
"""
|
""" + """
|
||||||
__attribute__((noinline)) int floor_div(float arg1, float arg2) {
|
__attribute__((noinline)) int floor_div(float arg1, float arg2) {
|
||||||
float x = arg1 / arg2;
|
float x = arg1 / arg2;
|
||||||
int i = (int)x;
|
int i = (int)x;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue