2025-01-28 23:53:48 +01:00
|
|
|
|
LIB_DIR=$(shell pwd)/lib
|
2025-02-16 17:25:23 +01:00
|
|
|
|
TARGETS=posint-dec-to-hex-generated.c posint-dec-to-hex-generated-gcc posint-dec-to-hex-generated-clang posint-dec-to-hex-optimal-gcc posint-dec-to-hex-optimal-clang
|
2025-01-28 22:33:08 +01:00
|
|
|
|
|
|
|
|
|
all: $(TARGETS)
|
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
target:
|
|
|
|
|
mkdir -p target
|
|
|
|
|
|
2025-01-28 23:53:48 +01:00
|
|
|
|
lib/libmorph_%.so: src/%.c
|
2025-03-15 18:38:48 +01:00
|
|
|
|
$(CC) -O3 -shared -o target/$@ -fPIC -I../morphisms/runtime/include target/$<
|
|
|
|
|
|
|
|
|
|
ldmc:
|
|
|
|
|
cargo install --path ..
|
2025-01-28 23:53:48 +01:00
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
posint-dec-to-hex-generated.c: ldmc target
|
|
|
|
|
ldmc \
|
2025-03-20 16:28:16 +01:00
|
|
|
|
"ℕ~<PosInt 10 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 10>~Char~Ascii~native.UInt8>" \
|
|
|
|
|
"ℕ~<PosInt 16 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 16>~Char~Ascii~native.UInt8>" \
|
2025-03-15 18:38:48 +01:00
|
|
|
|
../morphisms/*.morphism-base >| target/$@
|
2025-02-16 17:25:23 +01:00
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
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
|
2025-02-03 17:05:19 +01:00
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
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
|
2025-02-03 17:05:19 +01:00
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
posint-dec-to-hex-optimal-gcc: posint-dec-to-hex-optimal.c target
|
|
|
|
|
gcc -g -Os -flto -o target/$@ $<
|
2025-02-03 17:05:19 +01:00
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
posint-dec-to-hex-optimal-clang: posint-dec-to-hex-optimal.c target
|
|
|
|
|
clang -g -Os -flto -o target/$@ $<
|
2025-02-03 17:05:19 +01:00
|
|
|
|
|
|
|
|
|
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
|
2025-03-15 18:38:48 +01:00
|
|
|
|
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)
|
2025-01-28 22:33:08 +01:00
|
|
|
|
|
|
|
|
|
clean:
|
2025-03-15 18:38:48 +01:00
|
|
|
|
rm target/*
|
|
|
|
|
rmdir target
|
2025-01-28 22:33:08 +01:00
|
|
|
|
|
2025-03-15 18:38:48 +01:00
|
|
|
|
.PHONY: all target clean
|