Revision 8df40160
Added by Pierre-Loïc Garoche about 5 years ago
src/compiler_stages.ml | ||
---|---|---|
81 | 81 |
let prog = SortProg.sort prog in |
82 | 82 |
Log.report ~level:3 (fun fmt -> |
83 | 83 |
Format.fprintf fmt "@[<v 0>Contracts resolved:@ %a@ @]@ " Printers.pp_prog prog); |
84 |
|
|
85 |
(* Consolidating main node *) |
|
86 |
let _ = |
|
87 |
match !Options.main_node with |
|
88 |
| "" -> () |
|
89 |
| main_node -> ( |
|
90 |
Global.main_node := main_node; |
|
91 |
try |
|
92 |
ignore (Corelang.node_from_name main_node) |
|
93 |
with Not_found -> ( |
|
94 |
Format.eprintf "Code generation error: %a@." Error.pp_error_msg Error.Main_not_found; |
|
95 |
raise (Corelang.Error (Location.dummy_loc, Error.Main_not_found)) |
|
96 |
)) |
|
97 |
in |
|
84 | 98 |
|
85 | 99 |
(* Perform inlining before any analysis *) |
86 | 100 |
let orig, prog = |
87 |
if !Options.global_inline && !Options.main_node <> "" then
|
|
101 |
if !Options.global_inline && !Global.main_node <> "" then
|
|
88 | 102 |
(if !Options.witnesses then prog else []), |
89 | 103 |
Inliner.global_inline basename prog |
90 | 104 |
else (* if !Option.has_local_inline *) |
... | ... | |
117 | 131 |
(* Optimization of prog: |
118 | 132 |
- Unfold consts |
119 | 133 |
- eliminate trivial expressions |
120 |
*) |
|
121 |
(* |
|
122 |
let prog =
|
|
134 |
*)
|
|
135 |
|
|
136 |
let prog = |
|
123 | 137 |
if !Options.const_unfold || !Options.optimization >= 5 then |
124 |
begin |
|
125 |
Log.report ~level:1 (fun fmt -> fprintf fmt ".. eliminating constants and aliases@,"); |
|
126 |
Optimize_prog.prog_unfold_consts prog |
|
127 |
end |
|
138 |
begin
|
|
139 |
Log.report ~level:1 (fun fmt -> fprintf fmt ".. eliminating constants and aliases@,");
|
|
140 |
Optimize_prog.prog_unfold_consts prog
|
|
141 |
end
|
|
128 | 142 |
else |
129 |
prog |
|
130 |
in
|
|
131 |
*) |
|
143 |
prog
|
|
144 |
in |
|
145 |
|
|
132 | 146 |
(* Delay calculus *) |
133 | 147 |
(* TO BE DONE LATER (Xavier) |
134 | 148 |
if(!Options.delay_calculus) |
... | ... | |
143 | 157 |
Utils.track_exception (); |
144 | 158 |
raise exc |
145 | 159 |
end; |
146 |
*) |
|
160 |
*)
|
|
147 | 161 |
|
148 | 162 |
(* Creating destination directory if needed *) |
149 | 163 |
create_dest_dir (); |
150 |
|
|
164 |
|
|
151 | 165 |
Typing.uneval_prog_generics prog; |
152 | 166 |
Clock_calculus.uneval_prog_generics prog; |
153 | 167 |
|
154 | 168 |
|
155 |
(* Disabling witness option. Could but reactivated later |
|
169 |
(* Disabling witness option. Could but reactivated later
|
|
156 | 170 |
if !Options.global_inline && !Options.main_node <> "" && !Options.witnesses then |
157 | 171 |
begin |
158 | 172 |
let orig = Corelang.copy_prog orig in |
... | ... | |
167 | 181 |
!Options.main_node |
168 | 182 |
orig prog type_env clock_env |
169 | 183 |
end; |
170 |
*) |
|
184 |
*)
|
|
171 | 185 |
|
172 | 186 |
(* Computes and stores generic calls for each node, |
173 | 187 |
only useful for ANSI C90 compliant generic node compilation *) |
... | ... | |
228 | 242 |
|
229 | 243 |
|
230 | 244 |
(* from source to machine code, with optimization *) |
231 |
let stage2 prog = |
|
245 |
let stage2 params prog =
|
|
232 | 246 |
(* Computation of node equation scheduling. It also breaks dependency cycles |
233 | 247 |
and warns about unused input or memory variables *) |
234 | 248 |
Log.report ~level:1 (fun fmt -> fprintf fmt ".. @[<v 2>scheduling@ "); |
... | ... | |
258 | 272 |
Log.report ~level:3 (fun fmt -> fprintf fmt ".. generated machines (unoptimized):@ %a@ " Machine_code_common.pp_machines machine_code); |
259 | 273 |
|
260 | 274 |
(* Optimize machine code *) |
261 |
Optimize_machine.optimize prog node_schs machine_code |
|
275 |
Optimize_machine.optimize params prog node_schs machine_code
|
|
262 | 276 |
|
263 | 277 |
|
264 | 278 |
(* printing code *) |
Also available in: Unified diff
Reactivated Unfold constant