Skip to content

Commit 5c1bae6

Browse files
authored
Merge pull request #965 from CakeML/explorer
2 parents e6db84d + 409796d commit 5c1bae6

21 files changed

+2013
-685
lines changed

compiler/backend/README.md

+10
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ to the front-end, i.e. parsing and type inference.
2525
[backend_commonScript.sml](backend_commonScript.sml):
2626
Definitions that are common for many parts of the compiler backend.
2727

28+
[backend_passesScript.sml](backend_passesScript.sml):
29+
Reformulates compile definition to expose the result of each internal
30+
compiler pass
31+
2832
[bviScript.sml](bviScript.sml):
2933
The BVI intermediate language. This language is very similar to BVL.
3034
One of the more notable differences is that exception handling is
@@ -234,6 +238,9 @@ This directory contains the mips-specific part of the compiler backend.
234238
[pattern_matching](pattern_matching):
235239
The CakeML pattern matching expressions compiler
236240

241+
[presLangLib.sml](presLangLib.sml):
242+
Library that helps pretty print code
243+
237244
[presLangScript.sml](presLangScript.sml):
238245
Functions for converting various intermediate languages
239246
into displayLang representations.
@@ -303,6 +310,9 @@ This compiler phase maps stackLang programs, which has structure
303310
such as If, While, Return etc, to labLang programs that are a soup
304311
of goto-like jumps.
305312

313+
[str_treeScript.sml](str_treeScript.sml):
314+
A Lisp inspired tree of mlstrings and a pretty printing function
315+
306316
[wordLangScript.sml](wordLangScript.sml):
307317
The wordLang intermediate language consists of structured programs
308318
that overate over machine words, a list-like stack and a flat memory.

compiler/backend/backendScript.sml

+7-15
Original file line numberDiff line numberDiff line change
@@ -44,16 +44,14 @@ val attach_bitmaps_def = Define `
4444
|>) /\
4545
attach_bitmaps names c bm NONE = NONE`
4646

47-
val compile_tap_def = Define`
48-
compile_tap c p =
47+
Definition compile_def:
48+
compile c p =
4949
let p = source_to_source$compile p in
5050
let _ = empty_ffi (strlit "finished: source_to_source") in
5151
let (c',p) = source_to_flat$compile c.source_conf p in
52-
let td = tap_flat c.tap_conf p [] in
5352
let _ = empty_ffi (strlit "finished: source_to_flat") in
5453
let c = c with source_conf := c' in
5554
let p = flat_to_clos$compile_prog p in
56-
let td = tap_clos c.tap_conf p td in
5755
let _ = empty_ffi (strlit "finished: flat_to_clos") in
5856
let (c',p,names) = clos_to_bvl$compile c.clos_conf p in
5957
let c = c with clos_conf := c' in
@@ -63,32 +61,26 @@ val compile_tap_def = Define`
6361
let c = c with bvl_conf updated_by (λc. c with <| inlines := l; next_name1 := n1; next_name2 := n2 |>) in
6462
let _ = empty_ffi (strlit "finished: bvl_to_bvi") in
6563
let p = bvi_to_data$compile_prog p in
66-
let td = tap_data_lang c.tap_conf (p,names) td in
6764
let _ = empty_ffi (strlit "finished: bvi_to_data") in
6865
let (col,p) = data_to_word$compile c.data_conf c.word_to_word_conf c.lab_conf.asm_conf p in
6966
let c = c with word_to_word_conf updated_by (λc. c with col_oracle := col) in
7067
let names = sptree$union (sptree$fromAList $ (data_to_word$stub_names () ++
7168
word_to_stack$stub_names () ++ stack_alloc$stub_names () ++
7269
stack_remove$stub_names ())) names in
73-
let td = tap_word c.tap_conf (p,names) td in
7470
let _ = empty_ffi (strlit "finished: data_to_word") in
7571
let (bm,c',fs,p) = word_to_stack$compile c.lab_conf.asm_conf p in
76-
let td = tap_stack c.tap_conf (p,names) td in
7772
let c = c with word_conf := c' in
7873
let _ = empty_ffi (strlit "finished: word_to_stack") in
7974
let p = stack_to_lab$compile
8075
c.stack_conf c.data_conf (2 * max_heap_limit (:'a) c.data_conf - 1)
8176
(c.lab_conf.asm_conf.reg_count - (LENGTH c.lab_conf.asm_conf.avoid_regs +3))
8277
(c.lab_conf.asm_conf.addr_offset) p in
83-
let td = tap_lab c.tap_conf (p,names) td in
8478
let _ = empty_ffi (strlit "finished: stack_to_lab") in
8579
let res = attach_bitmaps names c bm
8680
(lab_to_target$compile c.lab_conf (p:'a prog)) in
8781
let _ = empty_ffi (strlit "finished: lab_to_target") in
88-
(res, td)`;
89-
90-
val compile_def = Define`
91-
compile c p = FST (compile_tap c p)`;
82+
res
83+
End
9284

9385
val to_flat_def = Define`
9486
to_flat c p =
@@ -175,7 +167,7 @@ val to_target_def = Define`
175167
Theorem compile_eq_to_target:
176168
compile = to_target
177169
Proof
178-
srw_tac[][FUN_EQ_THM,compile_def,compile_tap_def,
170+
srw_tac[][FUN_EQ_THM,compile_def,
179171
to_target_def,
180172
to_lab_def,
181173
to_stack_def,
@@ -280,7 +272,7 @@ val from_source_def = Define`
280272
Theorem compile_eq_from_source:
281273
compile = from_source
282274
Proof
283-
srw_tac[][FUN_EQ_THM,compile_def,compile_tap_def,
275+
srw_tac[][FUN_EQ_THM,compile_def,
284276
from_source_def,
285277
from_lab_def,
286278
from_stack_def,
@@ -430,7 +422,7 @@ Proof
430422
to_bvl_def,
431423
to_clos_def,
432424
to_flat_def,to_livesets_def] >>
433-
fs[compile_def,compile_tap_def]>>
425+
fs[compile_def]>>
434426
pairarg_tac>>
435427
fs[data_to_wordTheory.compile_def,word_to_wordTheory.compile_def]>>
436428
fs[from_livesets_def,from_word_def,from_stack_def,from_lab_def]>>

0 commit comments

Comments
 (0)