1 | |
---|
2 | (** This module is the central part of the translation of [ERTL] |
---|
3 | programs into [LTL] programs. *) |
---|
4 | |
---|
5 | (* Pasted from Pottier's PP compiler *) |
---|
6 | |
---|
7 | (* This module translates [ERTL] statements into [LTL] statements. It is |
---|
8 | parameterized over a module [Env], whose signature appears below, which |
---|
9 | provides support for mapping pseudo-registers to stack slots or hardware |
---|
10 | registers and for generating instructions (which requires allocating fresh |
---|
11 | control flow graph labels). *) |
---|
12 | |
---|
13 | type decision = |
---|
14 | | Spill of AST.immediate |
---|
15 | | Color of I8051.register |
---|
16 | |
---|
17 | module Make (Env : sig |
---|
18 | |
---|
19 | val lookup: Register.t -> decision |
---|
20 | |
---|
21 | (* [generate instruction] returns a fresh instruction label, which |
---|
22 | it associates with [instruction] in the control flow graph. *) |
---|
23 | |
---|
24 | val generate: LTL.statement -> Label.t |
---|
25 | |
---|
26 | val fresh_label: unit -> Label.t |
---|
27 | |
---|
28 | val add_graph: Label.t -> LTL.statement -> unit |
---|
29 | |
---|
30 | val locals: int |
---|
31 | |
---|
32 | val stacksize: int |
---|
33 | |
---|
34 | end) : sig |
---|
35 | |
---|
36 | (* [translate_statement] turns a [ERTL] statement into a [LTL] statement, or |
---|
37 | sequence of statements, that transfers control to the same label(s). |
---|
38 | |
---|
39 | Existing statement labels are preserved, that is, the labels in |
---|
40 | the new control flow graph form a superset of the labels in the |
---|
41 | existing control flow graph. *) |
---|
42 | |
---|
43 | val translate_statement: ERTL.statement -> LTL.statement |
---|
44 | |
---|
45 | end |
---|
46 | |
---|