From d0b76b588fd6966d839763437a5ef55c65676c37 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 15 Oct 2025 22:56:59 +0200 Subject: [PATCH 1/5] readme updated --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 016a826..de02c42 100644 --- a/README.md +++ b/README.md @@ -5,20 +5,22 @@ Development is in a very early stage. Only very few components are in a working # Introduction -Copapy is a copy and patch based compiler. It compiles a python based language to machine code. The language can be considered as an embedded language. It uses the python interpreter for generating a directed graph of variables and operations. The compiler generates machine code by composing pre-compiled stencils derived from C code with gcc -O3. +Copapy is a python based embedded domain specific language (eDSL) with a copy & patch compiler. It compiles to machine code. It uses the python interpreter for compilation. It generates a directed graph of variables and operations. The compiler generates machine code by composing pre-compiled stencils derived from C code with gcc -O3. -For code execution a runner executable receives the composed machine code, data and patch instructions. The patch instructions are used to correct memory address offsets. +For code execution a executable or library receives the composed machine code, data and patch instructions. The patch instructions are used to correct memory address offsets. -The Project targets applications that profit from fast implementation (e.g. prototyping) and require realtime with low latency as well as minimizing risk of implementation errors reaching runtime. This applies primarily for applications interfacing hardware, where runtime errors might lead to physical damage. +The Project targets applications that profit from fast implementation (e.g. prototyping) and require realtime with low latency as well as minimizing risk of implementation errors not cached during compile time. This applies primarily for applications interfacing hardware, where runtime errors might lead to physical damage. For example robotics, embedded systems and control systems. -The project aims to be: -- Type save -- Having turing completeness only during compile time -- Predictable runtime -- No software runtime errors +The language aims to be: +- Fast to write +- Easy to read +- Type safe +- Having a predictable runtime +- Turing-complete only during compile time +- No runtime errors - Immutable types -# Structure +# How it works ## Compilation The Compilation step starts with the directed graph of variables and operations generated by the python interpreter. From fcc54801269467045ddb7e802e0c74b82e767d39 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 15 Oct 2025 22:59:22 +0200 Subject: [PATCH 2/5] asm html formatter added --- .github/workflows/ci.yml | 12 +++++------- tools/clean_asm.py | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 7 deletions(-) create mode 100644 tools/clean_asm.py diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e382280..8da376f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -58,13 +58,11 @@ jobs: python tools/make_example.py python tools/extract_code.py "bin/test.copapy" "bin/test.copapy.bin" objdump -D -b binary -m i386:x86-64 --adjust-vma=0x1000 bin/test.copapy.bin > bin/test.copapy.asm - echo '

test.copapy.asm

' >> $GITHUB_STEP_SUMMARY
-        cat bin/test.copapy.asm >> $GITHUB_STEP_SUMMARY
-        echo '
' >> $GITHUB_STEP_SUMMARY - objdump -d -j .text src/copapy/obj/stencils_x86_64_O3.o > bin/stencils_x86_64_O3.asm - echo '

stencils_x86_64_O3.asm

' >> $GITHUB_STEP_SUMMARY
-        cat bin/stencils_x86_64_O3.asm >> $GITHUB_STEP_SUMMARY
-        echo '
' >> $GITHUB_STEP_SUMMARY + echo '

test.copapy.asm

' >> $GITHUB_STEP_SUMMARY + python tools/clean_asm.py bin/test.copapy.asm >> $GITHUB_STEP_SUMMARY + objdump -d -x src/copapy/obj/stencils_x86_64_O3.o > bin/stencils_x86_64_O3.asm + echo '

stencils_x86_64_O3.asm

' >> $GITHUB_STEP_SUMMARY + python tools/clean_asm.py bin/stencils_x86_64_O3.asm >> $GITHUB_STEP_SUMMARY - name: Run tests with pytest run: pytest diff --git a/tools/clean_asm.py b/tools/clean_asm.py new file mode 100644 index 0000000..24aadd3 --- /dev/null +++ b/tools/clean_asm.py @@ -0,0 +1,34 @@ +import argparse +import re + +def main(): + parser = argparse.ArgumentParser() + parser.add_argument("path", type=str, help="Input file path") + #parser.add_argument("--abi", type=str, default="", help="Optionaler String (Standard: '')") + args = parser.parse_args() + + regex = r"(\:\n)(.*?)(^[^\n]+\n[^\n]+result_.*?\n\n)" + subst = "\\g<1>\\g<2>\\g<3>" + + with open(args.path, 'rt') as f: + text = f.read() + + outp_flag = "Disassembly of section .text" not in text + + text = text.replace('>', '>') + text = text.replace('<', '<') + + text = re.sub(regex, subst, text, 0, re.MULTILINE | re.DOTALL) + + print('') + for line in text.splitlines(): + if outp_flag: + print(line.replace(' ', ' ') + '
') + + if "Disassembly of section .text:" in line: + outp_flag = True + + print('
') + +if __name__ == "__main__": + main() \ No newline at end of file From 39b803c17daa6b6942d27147496f815c6d3e90ba Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 15 Oct 2025 23:15:47 +0200 Subject: [PATCH 3/5] ci: coloring fixed --- tools/clean_asm.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tools/clean_asm.py b/tools/clean_asm.py index 24aadd3..03d0286 100644 --- a/tools/clean_asm.py +++ b/tools/clean_asm.py @@ -1,29 +1,31 @@ import argparse import re -def main(): +def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("path", type=str, help="Input file path") - #parser.add_argument("--abi", type=str, default="", help="Optionaler String (Standard: '')") args = parser.parse_args() regex = r"(\:\n)(.*?)(^[^\n]+\n[^\n]+result_.*?\n\n)" - subst = "\\g<1>\\g<2>\\g<3>" + subst = "\\g<1>\\g<2>\\g<3>" with open(args.path, 'rt') as f: text = f.read() outp_flag = "Disassembly of section .text" not in text + text = text.replace('\t', ' ' * 4) text = text.replace('>', '>') text = text.replace('<', '<') text = re.sub(regex, subst, text, 0, re.MULTILINE | re.DOTALL) + text = re.sub(r" +", " ", text, 0, re.MULTILINE | re.DOTALL) + print('') for line in text.splitlines(): if outp_flag: - print(line.replace(' ', ' ') + '
') + print(line + '
') if "Disassembly of section .text:" in line: outp_flag = True @@ -31,4 +33,4 @@ def main(): print('
') if __name__ == "__main__": - main() \ No newline at end of file + main() From efd56e1a7a11d6139b796a98aaab5ae5ea6e0504 Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 15 Oct 2025 23:15:18 +0200 Subject: [PATCH 4/5] ci: changed style --- tools/clean_asm.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/clean_asm.py b/tools/clean_asm.py index 03d0286..e7bdccd 100644 --- a/tools/clean_asm.py +++ b/tools/clean_asm.py @@ -7,7 +7,7 @@ def main() -> None: args = parser.parse_args() regex = r"(\:\n)(.*?)(^[^\n]+\n[^\n]+result_.*?\n\n)" - subst = "\\g<1>\\g<2>\\g<3>" + subst = "\\g<1>\\g<2>\\g<3>" with open(args.path, 'rt') as f: text = f.read() From 1384bcddd07a93fcae85a6ac94e7130f8c54ac0b Mon Sep 17 00:00:00 2001 From: Nicolas Date: Wed, 15 Oct 2025 23:15:43 +0200 Subject: [PATCH 5/5] ci: fixed --- tools/clean_asm.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/clean_asm.py b/tools/clean_asm.py index e7bdccd..9ade8b6 100644 --- a/tools/clean_asm.py +++ b/tools/clean_asm.py @@ -7,7 +7,7 @@ def main() -> None: args = parser.parse_args() regex = r"(\:\n)(.*?)(^[^\n]+\n[^\n]+result_.*?\n\n)" - subst = "\\g<1>\\g<2>\\g<3>" + subst = "\\g<1>\\g<2>\\g<3>" with open(args.path, 'rt') as f: text = f.read() @@ -20,7 +20,7 @@ def main() -> None: text = re.sub(regex, subst, text, 0, re.MULTILINE | re.DOTALL) - text = re.sub(r" +", " ", text, 0, re.MULTILINE | re.DOTALL) + text = re.sub(r"(?<= ) ", " ", text, 0, re.MULTILINE | re.DOTALL) print('') for line in text.splitlines():