no-op fcode optimization pass

This commit is contained in:
Ulf Norell 2019-04-29 12:40:19 +02:00
parent 081a4d28b6
commit 4c2288274d

View File

@ -116,7 +116,7 @@
%% and produces Fate intermediate code. %% and produces Fate intermediate code.
-spec ast_to_fcode(aeso_syntax:ast(), [option()]) -> fcode(). -spec ast_to_fcode(aeso_syntax:ast(), [option()]) -> fcode().
ast_to_fcode(Code, Options) -> ast_to_fcode(Code, Options) ->
to_fcode(init_env(Options), Code). optimize_fcode(to_fcode(init_env(Options), Code)).
%% -- Environment ------------------------------------------------------------ %% -- Environment ------------------------------------------------------------
@ -657,10 +657,18 @@ stmts_to_fcode(Env, [Expr]) ->
%% - Translate && and || to ifte %% - Translate && and || to ifte
%% - Deadcode elimination %% - Deadcode elimination
%% - Unused variable analysis (replace by _) %% - Unused variable analysis (replace by _)
%% - Simplified case trees (FATE has special instructions for shallow matching)
%% - Case specialization %% - Case specialization
%% - Constant propagation %% - Constant propagation
-spec optimize_fcode(fcode()) -> fcode().
optimize_fcode(Code = #{ functions := Funs }) ->
Code#{ functions := maps:map(fun(Name, Def) -> optimize_fun(Code, Name, Def) end, Funs) }.
-spec optimize_fun(fcode(), fun_name(), fun_def()) -> fun_def().
optimize_fun(_Fcode, _Fun, Def = #{ body := _Body }) ->
%% io:format("Optimizing ~p =\n~s\n", [Fun, prettypr:format(pp_fexpr(Body))]),
Def.
%% -- Helper functions ------------------------------------------------------- %% -- Helper functions -------------------------------------------------------
%% -- Types -- %% -- Types --