diff --git a/cpclib-basm/pgo.sh b/cpclib-basm/pgo.sh new file mode 100755 index 00000000..80213103 --- /dev/null +++ b/cpclib-basm/pgo.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +set -e + + +PROGRAM="basm" + +# STEP 0: Make sure there is no left-over profiling data from previous runs +rm -rf /tmp/pgo-data || true + +# STEP 1: Build the instrumented binaries +RUSTFLAGS="-Cprofile-generate=/tmp/pgo-data" \ + cargo build --release + +# STEP 2: Run the instrumented binaries with some typical data +../target/release/$PROGRAM ../../z80_assemblers_benchmark/z80/include_files.asm > /dev/null +../target/release/$PROGRAM ./tests/asm/roudoudou/rasm_sprites.asm > /dev/null + +# STEP 3: Merge the `.profraw` files into a `.profdata` file +llvm-profdata merge -o /tmp/pgo-data/merged.profdata /tmp/pgo-data + +# STEP 4: Use the `.profdata` file for guiding optimizations +RUSTFLAGS="-Cprofile-use=/tmp/pgo-data/merged.profdata" \ + cargo build --release \ No newline at end of file diff --git a/cpclib-basm/tests/asm/disc/save_hfe.asm b/cpclib-basm/tests/asm/disc/save_hfe.asm new file mode 100644 index 00000000..222100ba --- /dev/null +++ b/cpclib-basm/tests/asm/disc/save_hfe.asm @@ -0,0 +1,8 @@ + org 0x4000 +BINARY_START + run $ + ld a, 'A' : call 0xbb5a + jp $ +BINARY_STOP + + save "test", BINARY_START, BINARY_STOP-BINARY_START, HFE, "saved.hfe" \ No newline at end of file diff --git a/cpclib-basm/tests/asm/disc/saved.hfe b/cpclib-basm/tests/asm/disc/saved.hfe new file mode 100644 index 00000000..e6186f7e Binary files /dev/null and b/cpclib-basm/tests/asm/disc/saved.hfe differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/basm.sna b/cpclib-basm/tests/asm/rasm_comparison/basm.sna new file mode 100644 index 00000000..c4a24835 Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/basm.sna differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/basm_withbrks.sna b/cpclib-basm/tests/asm/rasm_comparison/basm_withbrks.sna new file mode 100644 index 00000000..38e159be Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/basm_withbrks.sna differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/basm_withoutbrks.sna b/cpclib-basm/tests/asm/rasm_comparison/basm_withoutbrks.sna new file mode 100644 index 00000000..b0612fca Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/basm_withoutbrks.sna differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/rasm.dsk b/cpclib-basm/tests/asm/rasm_comparison/rasm.dsk new file mode 100644 index 00000000..117b8e09 Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/rasm.dsk differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/rasm.sna b/cpclib-basm/tests/asm/rasm_comparison/rasm.sna new file mode 100644 index 00000000..07e5a7c5 Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/rasm.sna differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/rasm_master.sna b/cpclib-basm/tests/asm/rasm_comparison/rasm_master.sna new file mode 100644 index 00000000..07e5a7c5 Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/rasm_master.sna differ diff --git a/cpclib-basm/tests/asm/rasm_comparison/save_dsk.asm b/cpclib-basm/tests/asm/rasm_comparison/save_dsk.asm new file mode 100644 index 00000000..8137d0ee --- /dev/null +++ b/cpclib-basm/tests/asm/rasm_comparison/save_dsk.asm @@ -0,0 +1,8 @@ + + org 0x4000 +BINARY_START + run $ + jp $ +BINARY_STOP + + save "test", BINARY_START, BINARY_STOP-BINARY_START, DSK, "saved.dsk" \ No newline at end of file diff --git a/cpclib-basm/tests/asm/rasm_comparison/save_sna.asm b/cpclib-basm/tests/asm/rasm_comparison/save_sna.asm new file mode 100644 index 00000000..ab1a4805 --- /dev/null +++ b/cpclib-basm/tests/asm/rasm_comparison/save_sna.asm @@ -0,0 +1,16 @@ + ; cargo run -- save_sna.asm --nochunk BRKS --sna -o basm.sna + ; to be compared with + ; rasm -sb -ss save_sna.asm -o rasm + + + BUILDSNA + BANKSET 0 + + org 0x1234 +BINARY_START + run $ +START + BREAKPOINT + jp $ + BREAKPOINT +BINARY_STOP \ No newline at end of file diff --git a/cpclib-basm/tests/asm/rasm_comparison/saved.hfe b/cpclib-basm/tests/asm/rasm_comparison/saved.hfe new file mode 100644 index 00000000..25ff6fca Binary files /dev/null and b/cpclib-basm/tests/asm/rasm_comparison/saved.hfe differ