ldmc/code-size-benchmark/Makefile

46 lines
1.9 KiB
Makefile
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

LIB_DIR=$(shell pwd)/lib
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
all: $(TARGETS)
target:
mkdir -p target
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~native.UInt8>" \
"~<PosInt 16 BigEndian>~<Seq~<ValueTerminated '\\0'> <Digit 16>~Char~Ascii~native.UInt8>" \
../morphisms/*.morphism-base >| target/$@
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 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 target
gcc -g -Os -flto -o target/$@ $<
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 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 target/*
rmdir target
.PHONY: all target clean