PreviousUpNext

15.4.327  src/lib/compiler/back/low/mcg/machcode-peephole-phase-g.pkg

# machcode-peephole-phase-g.pkg
#
# Run peephole improvers on a cluster

# Compiled by:
#     src/lib/compiler/back/low/lib/peephole.lib



###              "The human race has one really effective
###               weapon, and that is laughter."
###
###                                  -- Mark Twain


stipulate
    package odg =  oop_digraph;                                         # oop_digraph                           is from   src/lib/graph/oop-digraph.pkg
herein


    # This generic is nowhere invoked:
    #
    generic package   machcode_peephole_phase_g   (
        #             ========================
        #
        package mcg: Machcode_Controlflow_Graph;                        # Machcode_Controlflow_Graph            is from   src/lib/compiler/back/low/mcg/machcode-controlflow-graph.api

        package pee: Peephole;                                          # Peephole                              is from   src/lib/compiler/back/low/code/peephole.api

        sharing mcg::mcf == pee::mcf;                                   # "mcf" == "machcode_form" (abstract machine code).
    )
    : (weak) Machcode_Controlflow_Graph_Improver                        # Machcode_Controlflow_Graph_Improver   is from   src/lib/compiler/back/low/mcg/machcode-controlflow-graph-improver.api
    {
        # Export to client packages:
        #
        package mcg = mcg;                                              # "mcg" == "machcode_controlflow_graph".

        improvement_name = "Peephole improvers";

        fun run (mcg as odg::DIGRAPH graph)
            =
            {   fun opt (_, mcg::BBLOCK { ops, ... } )                  # "opt" is probably "optimize" or such.
                    =
                    ops :=  pee::peephole (reverse *ops);

                graph.forall_nodes  opt;

                mcg;
            };
    };
end;


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext