From 630948139bbb2ca17e02d3184fe740c1141d4efb Mon Sep 17 00:00:00 2001 From: Michael Sippel <micha@fragmental.art> Date: Sat, 15 Mar 2025 18:38:48 +0100 Subject: [PATCH] move header & library for morphism data structures to 'runtime' diretcory - adapt Makefile for code size benchmark - write build files to 'target' directory --- code-size-benchmark/Makefile | 45 +++++++++++-------- .../include/array/length-prefix.h | 0 morphisms/{ => runtime}/src/length-prefix.c | 0 3 files changed, 26 insertions(+), 19 deletions(-) rename morphisms/{ => runtime}/include/array/length-prefix.h (100%) rename morphisms/{ => runtime}/src/length-prefix.c (100%) diff --git a/code-size-benchmark/Makefile b/code-size-benchmark/Makefile index 02dc461..c9d5abe 100644 --- a/code-size-benchmark/Makefile +++ b/code-size-benchmark/Makefile @@ -3,37 +3,44 @@ TARGETS=posint-dec-to-hex-generated.c posint-dec-to-hex-generated-gcc posint-dec all: $(TARGETS) -lib/libmorph_%.so: src/%.c - $(CC) -O3 -shared -o $@ -fPIC -Iinclude $< +target: + mkdir -p target -posint-dec-to-hex-generated.c: - cargo run -- \ +lib/libmorph_%.so: src/%.c + $(CC) -O3 -shared -o target/$@ -fPIC -I../morphisms/runtime/include target/$< + +ldmc: + cargo install --path .. + +posint-dec-to-hex-generated.c: ldmc target + ldmc \ "ℕ~<PosInt 10 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 10>~Char~Ascii~x86.UInt8>" \ "ℕ~<PosInt 16 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 16>~Char~Ascii~x86.UInt8>" \ - ../morphisms/*.morphism-base >| $@ + ../morphisms/*.morphism-base >| target/$@ -posint-dec-to-hex-generated-gcc: posint-dec-to-hex-generated.c - gcc -g -Os -flto -o $@ -I../morphisms/include $< ../morphisms/src/length-prefix.c +posint-dec-to-hex-generated-gcc: posint-dec-to-hex-generated.c target + gcc -g -Os -flto -o target/$@ -I../morphisms/runtime/include target/$< ../morphisms/runtime/src/*.c -posint-dec-to-hex-generated-clang: posint-dec-to-hex-generated.c - clang -g -Os -flto -o $@ -I../morphisms/include $< ../morphisms/src/length-prefix.c +posint-dec-to-hex-generated-clang: posint-dec-to-hex-generated.c target + clang -g -Os -flto -o target/$@ -I../morphisms/runtime/include target/$< ../morphisms/runtime/src/*.c -posint-dec-to-hex-optimal-gcc: posint-dec-to-hex-optimal.c - gcc -g -Os -flto -o $@ $< +posint-dec-to-hex-optimal-gcc: posint-dec-to-hex-optimal.c target + gcc -g -Os -flto -o target/$@ $< -posint-dec-to-hex-optimal-clang: posint-dec-to-hex-optimal.c - clang -g -Os -flto -o $@ $< +posint-dec-to-hex-optimal-clang: posint-dec-to-hex-optimal.c target + clang -g -Os -flto -o target/$@ $< code-size-benchmark: posint-dec-to-hex-generated-gcc \ posint-dec-to-hex-generated-clang \ posint-dec-to-hex-optimal-gcc \ posint-dec-to-hex-optimal-clang - INST_COUNT_GEN_GCC=$(shell gdb --batch -ex "file posint-dec-to-hex-generated-gcc" -ex "disassemble main" | wc -l) - INST_COUNT_GEN_CLANG=$(shell gdb --batch -ex "file posint-dec-to-hex-generated-clang" -ex "disassemble main" | wc -l) - INST_COUNT_OPT_GCC=$(shell gdb --batch -ex "file posint-dec-to-hex-optimal-gcc" -ex "disassemble main" | wc -l) - INST_COUNT_OPT_CLANG=$(shell gdb --batch -ex "file posint-dec-to-hex-optimal-clang" -ex "disassemble main" | wc -l) + INST_COUNT_GEN_GCC=$(shell gdb --batch -ex "file target/posint-dec-to-hex-generated-gcc" -ex "disassemble main" | wc -l) + INST_COUNT_GEN_CLANG=$(shell gdb --batch -ex "file target/posint-dec-to-hex-generated-clang" -ex "disassemble main" | wc -l) + INST_COUNT_OPT_GCC=$(shell gdb --batch -ex "file target/posint-dec-to-hex-optimal-gcc" -ex "disassemble main" | wc -l) + INST_COUNT_OPT_CLANG=$(shell gdb --batch -ex "file target/posint-dec-to-hex-optimal-clang" -ex "disassemble main" | wc -l) clean: - rm $(TARGETS) + rm target/* + rmdir target -.PHONY: all clean +.PHONY: all target clean diff --git a/morphisms/include/array/length-prefix.h b/morphisms/runtime/include/array/length-prefix.h similarity index 100% rename from morphisms/include/array/length-prefix.h rename to morphisms/runtime/include/array/length-prefix.h diff --git a/morphisms/src/length-prefix.c b/morphisms/runtime/src/length-prefix.c similarity index 100% rename from morphisms/src/length-prefix.c rename to morphisms/runtime/src/length-prefix.c