Skip to content

Commit dfe4d14

Browse files
Added example programs to retrofit semantics
1 parent 3248ced commit dfe4d14

File tree

6 files changed

+13250
-0
lines changed

6 files changed

+13250
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# includes
2+
# ----------------------------------
3+
4+
CAKEMLDIR = ../../../cakeml
5+
6+
DEPENDENCIES = .. \
7+
$(CAKEMLDIR)/misc \
8+
$(CAKEMLDIR)/semantics \
9+
$(CAKEMLDIR)/semantics/proofs \
10+
$(CAKEMLDIR)/basis/pure \
11+
$(CAKEMLDIR)/basis \
12+
$(CAKEMLDIR)/translator \
13+
$(CAKEMLDIR)/characteristic \
14+
$(CAKEMLDIR)/compiler/parsing \
15+
$(CAKEMLDIR)/unverified/sexpr-bootstrap
16+
17+
# configuration
18+
# ----------------------------------
19+
HOLHEAP = ../retrofit_sem-heap
20+
#NEWHOLHEAP =
21+
22+
HEAPINC_EXTRA = wordsLib
23+
24+
25+
# included lines follow
26+
# ----------------------------------
27+
28+
# automatic Holmake targets (all theories and non-"Script.sml" .sml files)
29+
# automatic heap inclusion by name pattern
30+
# ----------------------------------
31+
SMLFILES = $(subst *.sml,, $(patsubst %Script.sml,%Theory.sml,$(wildcard *.sml)))
32+
TARGETS = $(patsubst %.sml,%.uo,$(SMLFILES))
33+
34+
HEAPINC = $(subst *Theory,,$(patsubst %Script.sml,%Theory ,$(wildcard *Script.sml))) \
35+
$(subst *Syntax,,$(patsubst %.sml,% ,$(wildcard *Syntax.sml))) \
36+
$(subst *Simps,, $(patsubst %.sml,% ,$(wildcard *Simps.sml ))) \
37+
$(subst *Lib,, $(patsubst %.sml,% ,$(wildcard *Lib.sml ))) \
38+
$(HEAPINC_EXTRA)
39+
40+
41+
# general configs
42+
# ----------------------------------
43+
all: $(TARGETS) $(if $(NEWHOLHEAP),$(NEWHOLHEAP),)
44+
45+
INCLUDES = $(DEPENDENCIES) $(if $(HOLHEAP),$(shell dirname $(HOLHEAP)),)
46+
47+
EXTRA_CLEANS = $(if $(NEWHOLHEAP),$(NEWHOLHEAP) $(NEWHOLHEAP).o,) $(wildcard *.exe)
48+
49+
OPTIONS = QUIT_ON_FAILURE
50+
51+
default: all
52+
53+
.PHONY: all default
54+
55+
56+
# holheap part
57+
# ----------------------------------
58+
ifdef POLY
59+
60+
$(NEWHOLHEAP): $(TARGETS) $(HOLHEAP)
61+
$(protect $(HOLDIR)/bin/buildheap) $(if $(HOLHEAP),-b $(HOLHEAP),) -o $@ $(HEAPINC)
62+
63+
endif
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
3+
if [ $# -ne 1 ]; then
4+
echo "Usage: $0 <program_name>"
5+
echo "Example: $0 port_swap"
6+
exit 1
7+
fi
8+
9+
PROGRAM_NAME=$1
10+
11+
Holmake ${PROGRAM_NAME}Theory
12+
13+
cp ${PROGRAM_NAME}.sexp compilation/
14+
15+
cd compilation
16+
17+
./compile_cake.sh ${PROGRAM_NAME}
18+
19+
cd ..
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
progname=$1
4+
5+
if [ -z $1 ]; then
6+
echo "Usage: supply the name of the CakeML sexp file without the .sexp suffix as a command-line argument"
7+
exit 0
8+
fi
9+
10+
# NOTE: Always set skip_type_inference to false if you don't know what you're doing when in-lining CakeML code.
11+
CML_STACK_SIZE=1000 CML_HEAP_SIZE=6000 ./cake --sexp=true --exclude_prelude=true --gc=gen50000 --skip_type_inference=false --emit_empty_ffi=true --reg_alg=0 < $progname.sexp > $progname.cake.S
12+
#Old version:
13+
#CML_STACK_SIZE=1000 CML_HEAP_SIZE=6000 ./cake --sexp=true --exclude_prelude=true --skip_type_inference=false --emit_empty_ffi=true --reg_alg=0 < $progname.sexp > $progname.cake.S
14+
15+
cc ${progname}.cake.S basis_ffi.c -lm -o ${progname}.cake

0 commit comments

Comments
 (0)