Commit | Line | Data |
---|---|---|
7f918cf1 CE |
1 | (* Copyright (C) 2009 Matthew Fluet. |
2 | * Copyright (C) 1999-2007 Henry Cejtin, Matthew Fluet, Suresh | |
3 | * Jagannathan, and Stephen Weeks. | |
4 | * Copyright (C) 1997-2000 NEC Research Institute. | |
5 | * | |
6 | * MLton is released under a BSD-style license. | |
7 | * See the file MLton-LICENSE for details. | |
8 | *) | |
9 | ||
10 | signature PEEPHOLE_TYPES = | |
11 | sig | |
12 | type entry_type | |
13 | type profileLabel_type | |
14 | type statement_type | |
15 | type transfer_type | |
16 | datatype block = T of {entry: entry_type, | |
17 | profileLabel: profileLabel_type, | |
18 | statements: statement_type list, | |
19 | transfer: transfer_type} | |
20 | end | |
21 | ||
22 | signature PEEPHOLE = | |
23 | sig | |
24 | include PEEPHOLE_TYPES | |
25 | ||
26 | datatype statement_border = Empty | |
27 | | EmptyOrNonEmpty | |
28 | type statement_element = (int * int option) * (statement_type -> bool) | |
29 | type transfer_element = transfer_type -> bool | |
30 | ||
31 | val One : (statement_type -> bool) -> statement_element | |
32 | val All : (statement_type -> bool) -> statement_element | |
33 | ||
34 | type template = {start: statement_border, | |
35 | statements: statement_element list, | |
36 | finish: statement_border, | |
37 | transfer: transfer_element} | |
38 | ||
39 | type match = {entry: entry_type, | |
40 | profileLabel: profileLabel_type, | |
41 | start: statement_type list, | |
42 | statements: statement_type list list, | |
43 | finish: statement_type list, | |
44 | transfer: transfer_type} | |
45 | ||
46 | type rewriter = match -> block option | |
47 | ||
48 | type callback = bool -> unit | |
49 | ||
50 | type optimization = {template: template, | |
51 | rewriter: rewriter, | |
52 | callback: callback} | |
53 | ||
54 | val peepholeBlock : {block: block, | |
55 | optimizations: optimization list} -> | |
56 | {block: block, | |
57 | changed: bool} | |
58 | val peepholeBlocks : {blocks: block list, | |
59 | optimizations: optimization list} -> | |
60 | {blocks: block list, | |
61 | changed: bool} | |
62 | end |