summary refs log tree commit diff
path: root/source/xi_lib/iface.ml
blob: b67a78764388a160c30fd0fe9ae886a92283f9c3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
type node2type = (Ast.node_tag, Types.normal_type) Hashtbl.t

type schedule = (Ir.procedure, Ir.label list) Hashtbl.t

type register_mapping = (Ir.reg, Ir.reg) Hashtbl.t


module type LEXER = sig

  type token

  val token: Lexing.lexbuf -> token

end

module type PARSER = sig

  type token

  exception Error

  val file: (Lexing.lexbuf -> token) -> Lexing.lexbuf -> Ast.module_definition

end

module type LEXER_AND_PARSER = sig

  type token

  module Lexer: LEXER with type token = token

  module Parser: PARSER with type token = token

end

module type TYPECHECKER = sig

  val check_module: Ast.module_definition -> (node2type, Typechecker_errors.type_checking_error list) result

end

module type TRANSLATOR = sig

  val translate_module: Ast.module_definition -> node2type -> Ir.program

end

module type HI_LOWER = sig

  val lower: Ir.procedure -> unit

end

module type MIPS_LOWER = sig

  val lower: Ir.procedure -> unit

end

module type CALLCONV = sig

  val callconv: Ir.procedure -> unit

end

module type REGISTER_ALLOCATOR = sig

  val regalloc: Ir.procedure -> register_mapping

end

module type CODEGEN = sig

  val codegen: schedule -> Ir.program -> Mips32.program

end

module type LIVE_VARIABLES_ANALYSIS = sig

  val analyse: Ir.ControlFlowGraph.t -> Analysis_domain.LiveVariables.table
end

module type REACHABILITY_ANALYSIS = sig

  val analyse: Ir.ControlFlowGraph.t -> Analysis_domain.ReachabilityAnalysis.table

end

module type CONSTANT_FOLDING_ANALYSIS = sig

  val analyse: Ir.procedure -> Analysis_domain.ConstantFolding.table

end

module type JUMP_THREADING = sig

  val jump_threading: Ir.procedure -> unit

end

module type CONSTANT_FOLDING = sig

  val fold_constants: Ir.procedure -> unit

end

module type DEAD_CODE_ELIMINATION = sig

  val eliminate_dead_code: Ir.procedure -> unit

end

module type DOMINATORS_ANALYSIS = sig

  val analyse: Ir.ControlFlowGraph.t -> Analysis_domain.DominatorsAnalysis.table

end

module type NATURAL_LOOPS_ANALYSIS = sig

  val analyse: Ir.ControlFlowGraph.t -> Analysis_domain.DominatorsAnalysis.table -> Analysis_domain.NaturalLoops.table

end

module type SCHEDULER = sig

  val schedule: Ir.program -> schedule

end

module type SPILL_COSTS_ANALYSIS = sig

  val analyse: Ir.ControlFlowGraph.t -> Analysis_domain.NaturalLoops.table -> (Ir.reg, int) Hashtbl.t

end

module type INTERFERENCE_GRAPH_ANALYSIS = sig

  val analyse: Ir.ControlFlowGraph.t ->  Analysis_domain.LiveVariables.table -> Ir.RegGraph.t

end

module type SPILLING = sig

  val spill: Ir.procedure -> Ir.reg list -> unit

end

module type COMPILER_TOOLBOX = sig

  module LiveVariablesAnalysis : LIVE_VARIABLES_ANALYSIS

  module DominatorsAnalysis : DOMINATORS_ANALYSIS

  module NaturalLoopsAnalysis : NATURAL_LOOPS_ANALYSIS

  module SpillCostsAnalysis : SPILL_COSTS_ANALYSIS

  module Scheduler: SCHEDULER

  module RegistersDescription : Ir_arch.REGISTERS_DESCRIPTION

  module ConstantFoldingAnalysis : CONSTANT_FOLDING_ANALYSIS

  module InterferenceGraphAnalysis : INTERFERENCE_GRAPH_ANALYSIS

  module Spilling : SPILLING

  module ReachabilityAnalysis : REACHABILITY_ANALYSIS
end


module type COMPILER_STEPS = sig

  module Toolbox: COMPILER_TOOLBOX

  module LexerAndParser: LEXER_AND_PARSER

  module Typechecker: TYPECHECKER

  module Translator: TRANSLATOR

  module JumpThreading: JUMP_THREADING

  module ConstantFolding: CONSTANT_FOLDING

  module HiLower: HI_LOWER

  module CallConv: CALLCONV

  module MipsLower: MIPS_LOWER

  module RegisterAllocator: REGISTER_ALLOCATOR

  module Codegen: CODEGEN

  module DeadCodeElimination: DEAD_CODE_ELIMINATION
end